[opencms-dev] How to steal lock using Opencms API

Mohan Reddy Mohan at Indosoft.stph.net
Mon Apr 12 08:58:01 CEST 2004


Hi All, 
I am trying to call steal lock functionality using Opencms API. I have to
steal lock before publish a page created by some other user. can someone
please help to do this. 
here is the code : 
ArrayList SitemapTree= null;
SitemapTree = cms.getNavigation().getNavigationForFolder(resPath);
Iterator iter = SitemapTree.iterator(); 
while (iter.hasNext()) {
com.opencms.flex.jsp.CmsJspNavElement ne
=(com.opencms.flex.jsp.CmsJspNavElement)iter.next();
CmsResource res = cmsObject.readFileHeader(ne.getResourceName());
Class cdClass = getContentDefinitionClass();
Object o = null;
String id=new Integer(res.getResourceId()).toString();
o = getContentDefinition(cms, cdClass, id); 
if(res.isLocked()){
int actUserId = cms.getRequestContext().currentUser().getId();
int lockedUserId=res.isLockedBy();
if(actUserId!=lockedUserId){
try {
((A_CmsContentDefinition)o).setLockstate(A_CmsBackoffice.C_NOT_LOCKED);
} catch (Exception e) {
A_OpenCms.log(A_OpenCms.C_OPENCMS_INFO, " Backoffice getContentLock: Method
setLockstate throwed an exception!");
} 
}

}
} 
Errors: 
C:\Program Files\Apache Group\Tomcat
4.1\work\Standalone\localhost\opencms\WEB-INF\jsp\offline\Cms_TOTDPublish_js
p_jsp.java:14: org.apache.jsp.Cms_TOTDPublish_jsp_jsp should be declared
abstract; it does not define getContentDefinitionClass() in
com.opencms.defaults.A_CmsBackoffice
public class Cms_TOTDPublish_jsp_jsp extends
com.opencms.defaults.A_CmsChannelBackoffice {
^
C:\Program Files\Apache Group\Tomcat
4.1\work\Standalone\localhost\opencms\WEB-INF\jsp\offline\Cms_TOTDPublish_js
p_jsp.java:39:
getPageContext(javax.servlet.Servlet,javax.servlet.ServletRequest,javax.serv
let.ServletResponse,java.lang.String,boolean,int,boolean) in
javax.servlet.jsp.JspFactory cannot be applied to
(org.apache.jsp.Cms_TOTDPublish_jsp_jsp,javax.servlet.http.HttpServletReques
t,javax.servlet.http.HttpServletResponse,<*>,boolean,int,boolean)
pageContext = _jspxFactory.getPageContext(this, request, response,
^
C:\Program Files\Apache Group\Tomcat
4.1\work\Standalone\localhost\opencms\WEB-INF\jsp\offline\Cms_TOTDPublish_js
p_jsp.java:88: cannot resolve symbol
symbol : method getContentDefinition
(com.opencms.flex.jsp.CmsJspActionElement,java.lang.Class,java.lang.String)
location: class org.apache.jsp.Cms_TOTDPublish_jsp_jsp
o = getContentDefinition(cms, cdClass, id);
^
3 errors
Awaiting for an early reply,
Thanks,
Mohan.




More information about the opencms-dev mailing list