cancel
Showing results for 
Search instead for 
Did you mean: 

[SOLVED]invite users, groups to space with role?

targa2000
Champ in-the-making
Champ in-the-making
I can create spaces and groups via javascript, but how do I invite these groups to a space with a particular role?
2 REPLIES 2

targa2000
Champ in-the-making
Champ in-the-making
tried :

var aGroup = "AName";
var vGroup = "VName";

var vgroupAuth = people.getGroup(vGroup);
var agroupAuth = people.getGroup(aGroup);

var eFolder = companyhome.childByNamePath("Sites/testone/documentLibrary/Project/Draft");
eFolder.setInheritsPermissions(false);
eFolder.setPermission("Collaborator", vgroupAuth );
eFolder.setPermission("Coordinator", agroupAuth );

vgroupAuth and agroupAuth looks to be null even though both groups exist in the repository 

error message :

User:admin ERROR [ui.common.Utils] Failed to run Actions due to error: 02090058 Faile
d to execute script 'workspace://SpacesStore/cc7de8cd-9145-449a-9d05-6baf1adf70b7': Authority is a
mandatory parameter
org.alfresco.scripts.ScriptException: 02090058 Failed to execute script 'workspace://SpacesStore/c
c7de8cd-9145-449a-9d05-6baf1adf70b7': Authority is a mandatory parameter
        at org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:228)
        at org.alfresco.repo.processor.ScriptServiceImpl.executeScript(ScriptServiceImpl.java:187)

        at sun.reflect.GeneratedMethodAccessor932.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:3
04)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(Reflective
MethodInvocation.java:182)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodIn
vocation.java:149)
        at org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor.invoke(Alway
sProceedMethodInterceptor.java:40)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodIn
vocation.java:171)
        at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke
(ExceptionTranslatorMethodInterceptor.java:49)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodIn
vocation.java:171)
        at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:148)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodIn
vocation.java:171)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionIn
terceptor.java:106)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodIn
vocation.java:171)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204
)
        at $Proxy172.executeScript(Unknown Source)
        at org.alfresco.repo.action.executer.ScriptActionExecuter.executeImpl(ScriptActionExecuter
.java:170)
        at org.alfresco.repo.action.executer.ActionExecuterAbstractBase.execute(ActionExecuterAbst
ractBase.java:127)
        at org.alfresco.repo.action.ActionServiceImpl.directActionExecution(ActionServiceImpl.java
:711)
        at org.alfresco.repo.action.ActionServiceImpl.executeActionImpl(ActionServiceImpl.java:648
)
        at org.alfresco.repo.action.ActionServiceImpl.executeAction(ActionServiceImpl.java:510)
        at org.alfresco.repo.action.ActionServiceImpl.executeAction(ActionServiceImpl.java:498)
        at org.alfresco.repo.action.ActionServiceImpl.executeAction(ActionServiceImpl.java:719)
        at sun.reflect.GeneratedMethodAccessor929.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:3
04)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(Reflective
MethodInvocation.java:182)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodIn
vocation.java:149)
        at org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor.invoke(Alway
sProceedMethodInterceptor.java:40)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodIn
vocation.java:171)
        at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke
(ExceptionTranslatorMethodInterceptor.java:49)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodIn
vocation.java:171)
        at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:148)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodIn
vocation.java:171)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionIn
terceptor.java:106)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodIn
vocation.java:171)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204
)
        at $Proxy25.executeAction(Unknown Source)
        at org.alfresco.web.bean.actions.RunActionWizard.finishImpl(RunActionWizard.java:101)
        at org.alfresco.web.bean.dialog.BaseDialogBean$1.execute(BaseDialogBean.java:124)
        at org.alfresco.web.bean.dialog.BaseDialogBean$1.execute(BaseDialogBean.java:121)
        at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransac
tionHelper.java:327)
        at org.alfresco.web.bean.dialog.BaseDialogBean.finish(BaseDialogBean.java:130)
        at org.alfresco.web.bean.wizard.WizardManager.finish(WizardManager.java:599)
        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)
        at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java
:61)
        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(InvokeApplicationExecuto
r.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:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:20
6)
        at org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:11
0)
        at sun.reflect.GeneratedMethodAccessor445.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(Chaining
SubsystemProxyFactory.java:122)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodIn
vocation.java:171)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204
)
        at $Proxy161.doFilter(Unknown Source)
        at org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:88)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain
.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:20
6)
        at org.alfresco.repo.web.filter.beans.NullFilter.doFilter(NullFilter.java:74)
        at sun.reflect.GeneratedMethodAccessor445.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(Chaining
SubsystemProxyFactory.java:122)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodIn
vocation.java:171)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204
)
        at $Proxy161.doFilter(Unknown Source)
        at org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:88)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain
.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:20
6)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.
java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.IllegalArgumentException: Authority is a mandatory parameter
        at org.alfresco.util.ParameterCheck.mandatoryString(ParameterCheck.java:64)
        at org.alfresco.repo.jscript.ScriptNode.setPermission(ScriptNode.java:1326)
        at sun.reflect.GeneratedMethodAccessor939.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:155)
        at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:243)
        at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3237)
        at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2394)
        at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162)
        at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)
        at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834)
        at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:173)
        at org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.j
ava:456)
        at org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:224)
        … 93 more

also tried adding "GROUP_" prefix, but a different error:

var vgroupAuth = people.getGroup("GROUP_"+vGroup);
var agroupAuth = people.getGroup("GROUP_"+aGroup);

org.mozilla.javascript.WrappedException: Wrapped org.springframework.dao.InvalidDataAccessResourceUsageException:
could not insert:
[org.alfresco.repo.domain.hibernate.DbAuthorityImpl];
nested exception is org.hibernate.exception.DataException:
could not insert:
[org.alfresco.repo.domain.hibernate.DbAuthorityImpl} (workspace://SpacesStore/a861577b-119e-…)

targa2000
Champ in-the-making
Champ in-the-making
need to use "GROUP_" + {group_name} in setPermission

correct form:

var someFolder = companyhome.childByNamePath("Sites/testone/documentLibrary/Project/SomeFolder");
someFolder.setInheritsPermissions(false);
someFolder.setPermission("Consumer", "GROUP_someGroup");