Hi,I am using Alfresco 3.2r with Tomcat 6.I have written a workflow in which i am tyring to move a document from one space to another using ActionHandler.I am calling my ActionHandler from WF as<node name="approved">
<event type="node-leave">
<script>
<variable name="wfFlag" access="write"/>
<expression>
wfFlag = "Approved";
</expression>
</script>
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<runas>admin</runas>
<script>
logger.log("!!In Approval Workflow….!!!!@!@@@@");
executionContext.setVariable("wfFlag", wfFlag);
logger.log("wfFlag in WF "+wfFlag);
</script>
</action>
<action class="com.xxxx.alfresco.km.bpm.KMReviewProcessAction" name="test1234"/>
</event>
<transition name="" to="end" />
</node>Now i am able to get KMReviewProcessAction instance but when i am trying to get AuthenticationServiceImpl aspackage com.xxxx.alfresco.km.bpm;
import java.util.List;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.security.authentication.AuthenticationServiceImpl;
import org.alfresco.repo.workflow.WorkflowServiceImpl;
import org.alfresco.repo.workflow.jbpm.JBPMSpringActionHandler;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.AuthorityService;
import org.alfresco.service.cmr.workflow.WorkflowService;
import org.apache.log4j.Logger;
import org.jbpm.context.exe.ContextInstance;
import org.jbpm.graph.exe.ExecutionContext;
import org.springframework.beans.factory.BeanFactory;
public class KMReviewProcessAction extends JBPMSpringActionHandler {
private static final long serialVersionUID = 1L;
private static Logger logger = Logger
.getLogger(KMReviewProcessAction.class);
private static NodeService nodeservice = null;
private static AuthorityService authorityService = null;
private static SearchService searchService = null;
private ServiceRegistry services;
private ContentService contentService;
private WorkflowService workflowService;
private AVMService avmServ;
private AuthenticationService authenticationService;
WorkflowServiceImpl wserv = new WorkflowServiceImpl();
private AuthenticationServiceImpl authenticationServiceImpl;
// SearchServiceImpl searchServiceImpl = null;
@Override
protected void initialiseHandler(BeanFactory factory) {
System.out.println("Inside initialiseHandler of KMReviewProcessAction!!!!");
services = (ServiceRegistry) factory
.getBean(ServiceRegistry.SERVICE_REGISTRY);
contentService = (ContentService) factory.getBean("contentService");
workflowService = services.getWorkflowService();
avmServ = services.getAVMService();
authenticationServiceImpl = (AuthenticationServiceImpl) services.getAuthenticationService();
System.out.println("authenticationService "+authenticationService);
nodeservice = services.getNodeService();
searchService = services.getSearchService();
}
@Override
public void execute(ExecutionContext context) throws Exception {
logger.debug("Inside execute of KMReviewProcessAction logger@@@");
System.out.println("Inside execute of KMReviewProcessActionsyso");
// authserv.authenticate("admin", "admin".toCharArray());
ContextInstance contextInstance = context.getContextInstance();
String wfFlag = (String) contextInstance.getVariable("wfFlag");
logger.debug("wfFlag in KMReviewProcessAction logger @!@!" + wfFlag);
System.out.println("wfFlag in KMReviewProcessAction syso" + wfFlag);
if (wfFlag.equalsIgnoreCase("Approved")) {
// to do for approval!!
String password = "km@jindal!";
authenticationServiceImpl.authenticate("jindaladmin", password.toCharArray());
StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE,
"SpacesStore");
System.out.println("searchService " + searchService);
ResultSet rs = searchService.query(storeRef,
SearchService.LANGUAGE_XPATH, "/app:company_home");
NodeRef companyHomeNodeRef = null;
try {
if (rs.length() == 0) {
throw new AlfrescoRuntimeException(
"Didn't find Company Home");
}
companyHomeNodeRef = rs.getNodeRef(0);
} catch (Exception e) {
logger.error("Error while getting company home "
+ e.getMessage());
}
List<ChildAssociationRef> children = nodeservice
.getChildAssocs(companyHomeNodeRef);
for (ChildAssociationRef childAssoc : children) {
NodeRef childNodeRef = childAssoc.getChildRef();
System.out.println("childNodeRef inside execute " + " " + childNodeRef.getId()
+ childNodeRef.getStoreRef());
}
}
}
}
I am gettinig this errornside initialiseHandler of KMReviewProcessAction!!!!
17:00:55,140 User:shishir ERROR [ui.common.Utils] A system error happened during the operation: org.alfresco.service.Ser
viceRegistry.getAuthenticationService()Lorg/alfresco/service/cmr/security/AuthenticationService;
java.lang.NoSuchMethodError: org.alfresco.service.ServiceRegistry.getAuthenticationService()Lorg/alfresco/service/cmr/se
curity/AuthenticationService;
at com.xxxx.alfresco.km.bpm.KMReviewProcessAction.initialiseHandler(KMReviewProcessAction.java:52)
at org.alfresco.repo.workflow.jbpm.JBPMSpringActionHandler.<init>(JBPMSpringActionHandler.java:53)
at com.xxxx.alfresco.km.bpm.KMReviewProcessAction.<init>(KMReviewProcessAction.java:26)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at org.jbpm.instantiation.FieldInstantiator.newInstance(FieldInstantiator.java:107)
at org.jbpm.instantiation.FieldInstantiator.instantiate(FieldInstantiator.java:52)
at org.jbpm.instantiation.Delegation.instantiate(Delegation.java:168)
at org.jbpm.instantiation.Delegation.getInstance(Delegation.java:126)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:157)
Line no 52 isauthenticationServiceImpl = (AuthenticationServiceImpl) services.getAuthenticationService();
I checked with org.alfresco.service.ServiceRegistry class, i can see this…
static final QName AUTHENTICATION_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "AuthenticationService");
…
/**
* @return the authentication service (or null, if one is not provided)
*/
@NotAuditable
AuthenticationService getAuthenticationService();
…
Seriously i am struggling with getting authenticationServiceImpl object as in 3.2 , i am not able to do so?This way i am not able to search also. :x Sometime back also i was stuck in same then i had to change approach. :arrow: .Any idea or workaround?