As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
HashMap<QName, Serializable> properties = new HashMap<QName, Serializable>(); properties.put(ContentModel.PROP_USERNAME, "testUser"); properties.put(ContentModel.PROP_HOMEFOLDER, userNodeRef); properties.put(ContentModel.PROP_FIRSTNAME, "Test"); properties.put(ContentModel.PROP_LASTNAME, "User"); properties.put(ContentModel.PROP_EMAIL, "testUser@localhost.com"); personService.createPerson(properties);
authorityService.createAuthority(AuthorityType.GROUP, null, "myGroup");
authorityService.addAuthority(authorityService.getName(AuthorityType.GROUP,"myGroup"),"testUser");
javax.faces.FacesException: Error calling action method of component with id loginForm:submit at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72) at javax.faces.component.UICommand.broadcast(UICommand.java:109) at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97) at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:171) at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32) at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95) at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:139) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:94) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685) at java.lang.Thread.run(Thread.java:619) Caused by: javax.faces.el.EvaluationException: Exception while invoking expression #{LoginBean.login} at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:156) at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:61) … 24 more Caused by: org.alfresco.repo.security.permissions.AccessDeniedException: Access Denied. You do not have the appropriate permissions to perform this operation. at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:53) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176) at org.alfresco.repo.audit.AuditComponentImpl.auditImpl(AuditComponentImpl.java:256) at org.alfresco.repo.audit.AuditComponentImpl.audit(AuditComponentImpl.java:191) at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:69) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:210) at $Proxy2.createNode(Unknown Source) at org.alfresco.web.bean.repository.User.getUserPreferencesRef(User.java:216) at org.alfresco.web.bean.repository.User.getPreferences(User.java:168) at org.alfresco.web.bean.repository.PreferencesService.getPreferences(PreferencesService.java:69) at org.alfresco.web.bean.repository.PreferencesService.getPreferences(PreferencesService.java:60) at org.alfresco.web.bean.repository.PreferencesService.getPreferences(PreferencesService.java:50) at org.alfresco.web.bean.UserPreferencesBean.getStartLocation(UserPreferencesBean.java:283) at org.alfresco.web.bean.LoginBean.login(LoginBean.java:295) 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.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:132) … 25 more Caused by: net.sf.acegisecurity.AccessDeniedException: Access is denied. at net.sf.acegisecurity.vote.AffirmativeBased.decide(AffirmativeBased.java:86) at net.sf.acegisecurity.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:394) at net.sf.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:77) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176) at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:49) … 46 more
//create the node to represent the Person NodeRef newPerson = this.personService.createPerson(props); // ensure the user can access their own Person object permissionService.setPermission(newPerson,"testUser", permissionService.getAllPermission(), true); // create the ACEGI Authentication instance for the new user authenticationService.createAuthentication("testUser","testUser".toCharArray());
QName firstNameQName = QName.createQName("{http://www.alfresco.org/model/content/1.0}firstName"); QName lastNameQName = QName.createQName("{http://www.alfresco.org/model/content/1.0}lastName"); QName passwordQName = QName.createQName("{http://www.alfresco.org/model/content/1.0}password"); QName emailQName = QName.createQName("{http://www.alfresco.org/model/content/1.0}email"); QName homeFolderQName = QName.createQName("{http://www.alfresco.org/model/content/1.0}homeFolder"); Map<QName, Serializable> props = null; props = new HashMap<QName, Serializable>(4); props.put(firstNameQName, firstName); props.put(lastNameQName, lastName); props.put(passwordQName, passwd); props.put(emailQName, email); try{ configurationApplicationContext=WebApplicationContextUtils.getWebApplicationContext(this.getServlet().getServletContext()); authenticationService = (AuthenticationServiceImpl) configurationApplicationContext.getBean("authenticationService"); peopleService = (PeopleServiceImpl) configurationApplicationContext.getBean("peopleService"); nodeService = (NodeServiceImpl) configurationApplicationContext.getBean("nodeService"); ticket = authenticationService.authenticate(repositoryUri, userid, password.toCharArray()); [b]NodeRef homeFolder= nodeService.getRootNode(ticket, new StoreRef("workspace://SpacesStore"));[/b] props.put(homeFolderQName, homeFolder); NodeRef userRef = peopleService.createPerson(ticket, userName, passwd.toCharArray(), props);
Thanks for the clue.. I am able to create user by following your instructions..
//get the user data String userName; userName = user.getScreenName(); String passwd = user.getPassword(); String firstName = user.getFirstName(); String lastName = user.getLastName(); String email = user.getEmailAddress(); Map<QName, Serializable> props = null; props = new HashMap<QName, Serializable>(5); // homeFolder value must be a nodeRef props.put(ContentModel.PROP_USERNAME, userName); props.put(ContentModel.PROP_FIRSTNAME, firstName); props.put(ContentModel.PROP_LASTNAME, lastName); props.put(ContentModel.PROP_PASSWORD, passwd); props.put(ContentModel.PROP_EMAIL, email); try{ //WebApplicationContext configurationApplicationContext=WebApplicationContextUtils.getWebApplicationContext(this.getServlet().getServletContext()); //Alfresco connection peopleService = (PeopleServiceImpl) configurationApplicationContext.getBean("peopleService"); searchService = (SearchServiceImpl) configurationApplicationContext.getBean("searchService"); nodeService = (NodeServiceImpl) configurationApplicationContext.getBean("nodeService"); configurationApplicationContext=WebApplicationContextUtils.getWebApplicationContext(this.getServlet().getServletContext()); authenticationService = (AuthenticationServiceImpl) configurationApplicationContext.getBean("authenticationService"); ticket = authenticationService.authenticate(repositoryUri, userid, password.toCharArray()); //Create the user in Alfresco and add it to the convenient groups System.out.println("Creating the user called pruebaLray"); NodeRef userRef = peopleService.createPerson(ticket, userName, passwd.toCharArray(), props);
I want to set the folder "Company Home" as the user folder home, if anyone knows a better way to get the nodeRef of "Company Home" and how to set the property homeFolder as "Company Home" y will apreciate any help.
List<QName> properties = new Vector<QName>(); properties.add(ContentModel.PROP_NAME); String query = "PATH:\"/app:company_home\""; nodes = searchService.query(ticket, new StoreRef("workspace://SpacesStore"), SearchService.QueryLanguage.lucene, query, properties, false, false, false, false, null, 1, null); if (nodes != null) { for (Node node: nodes) { props.put(homeFolderQName, node.getNodeRef()); } }
authenticationService.createAuthentication("testUser","testUser".toCharArray());