AnsweredAssumed Answered

como usar los roles creados?

Question asked by ijr87 on Oct 8, 2010
Latest reply on Oct 20, 2010 by cristinamr
buenas, he creado una serie de roles nuevos, pero cuando quiero llamarlos para asignarlos a un usuario no me deja… os pongo las partes del código que he creado a ver si alguien tiene alguna solución.

codigo java:

   public void createGroup(String grup) throws Exception {
      // conexion y autentificacion con alfresco
      DMSConnectionAlfresco dms = new DMSConnectionAlfresco();
      ProfileTO profileUser = new ProfileTO();
      profileUser.setUserName("admin");
      profileUser.setPassword("admin");

      dms.establishConnection(profileUser);

      AccessControlServiceSoapBindingStub accessControlService = WebServiceFactory
            .getAccessControlService();
      NewAuthority authority = new NewAuthority("GROUP", grup);

      try {
         NewAuthority[] newAuthorities = { authority };
         String[] result = accessControlService.createAuthorities(null,
               newAuthorities);

      } catch (RemoteException e) {
         e.printStackTrace();
      }
      dms.closeConnection();
      System.out.println("creado el grupo:" + grup);
   }

   public void addUsersToGroup(String user, String grup) throws Exception {
      String[] Users = { user };
      String parentAuthority = "GROUP" + "_" + grup;

      // conexion y autentificacion con alfresco
      DMSConnectionAlfresco dms = new DMSConnectionAlfresco();
      ProfileTO profileUser = new ProfileTO();
      profileUser.setUserName("admin");
      profileUser.setPassword("admin");

      dms.establishConnection(profileUser);
      AccessControlServiceSoapBindingStub accessControlService = WebServiceFactory
            .getAccessControlService();

      String[] result = accessControlService.addChildAuthorities(
            parentAuthority, Users);
      dms.closeConnection();
      System.out.println("añadido usuario:" + user + "al grupo:" + grup);
   }

   public void asignarPermisos(String user, String id) throws Exception // user
                                                         // o
                                                         // GROUP
   {
      DMSConnectionAlfresco dms = new DMSConnectionAlfresco();
      ProfileTO profileUser = new ProfileTO();
      profileUser.setUserName("admin");
      profileUser.setPassword("admin");

      dms.establishConnection(profileUser);

      AccessControlServiceSoapBindingStub accessControlService = WebServiceFactory
            .getAccessControlService();

      Predicate predicate = new Predicate();
      predicate.setStore(dms.getStore());

      Reference ref = new Reference();
      ref.setStore(dms.getStore());
      ref.setUuid(id);
      predicate.setNodes(new Reference[] { ref });

      ACL[] acl = accessControlService.getACLs(predicate, null);
      ACE[] ace = acl[0].getAces();
      AccessStatus accessStatus = ace[0].getAccessStatus();

      // Añadir permisos
       ACE[] aces1 = new ACE[]{new ACE(user,
       evPermissionModel.RESPONSABLESERIE, AccessStatus.acepted)};

      ACL[] acls1 = accessControlService.addACEs(predicate, aces1);
      System.out.println("Grupo:" + aces1[0].getAuthority());
      System.out.println("Permiso:" + aces1[0].getPermission());

      dms.closeConnection();
   }

public class evPermissionModel {
   public static final String NAMESPACE_CONTENT_MODEL = "http://www.....com/model/content/1.0";

   
   public static final String ADMIN="Admin";
   public static final String EQUIPACTUACIO="EquipActuacio";
   public static final String PROPIETARI="Propietari";
   public static final String SUPERIORJERARQUIC="SuperiorJerarquic";
   public static final String RESPONSABLESERIE="ResponsableSerie";
   public static final String CONSULTA="Consulta";
   public static final String ARXIVER="Arxiver";
   public static final String INTERESSAT="Interessat";
   public static final String CIUTADA="Ciutada";
   public static final String SYSTEM="System";
}

ficheros xml:
context-model

<beans>
<!– Registre de nous models –>

<bean id="extension.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">

<property name="models">

<list>
<value>alfresco/extension/evModel.xml</value>
</list>
</property>
</bean>

<bean id="permissionModelDAO" class="org.alfresco.repo.security.permissions.impl.model.PermissionModel">

<property name="model">
<value>alfresco/extension/evPermissionDefinitions.xml</value>
</property>

<property name="nodeService">
<ref bean="nodeService"/>
</property>

<property name="dictionaryService">
<ref bean="dictionaryService"/>
</property>
</bfi

permissionDefinition

<!– Admin –>
<permissionsGroup name="Admin" allowFullControl="true" expose="true"/>
<!– Equip Actuacio –>
<permissionsGroup name="EquipActuacio" allowFullControl="true" expose="true"/>
<!– Propietari –>
<permissionsGroup name="Propietari" allowFullControl="true" expose="true"/>
<!– Superior Jerarquic –>

<permissionsGroup name="SuperiorJerarquic" allowFullControl="false" expose="true">
<includePermissionGroup permissionGroup="ReadProperties" type="sys:base"/>
<includePermissionGroup permissionGroup="ReadContent" type="sys:base"/>
</permissionsGroup>
<!– Responsable Serie –>

<permissionsGroup name="ResponsableSerie" allowFullControl="false" expose="true">
<includePermissionGroup permissionGroup="ReadProperties" type="sys:base"/>
<includePermissionGroup permissionGroup="WriteProperties" type="sys:base"/>
<includePermissionGroup permissionGroup="WriteContent" type="sys:base"/>
<includePermissionGroup permissionGroup="CheckOut" type="cm:lockable"/>
<includePermissionGroup permissionGroup="CancelCheckOut" type="cm:lockable"/>
<includePermissionGroup permissionGroup="CheckIn" type="cm:lockable"/>
<includePermissionGroup permissionGroup="CreateChildren" type="sys:base"/>
<includePermissionGroup permissionGroup="DeleteNode" type="sys:base"/>
<includePermissionGroup permissionGroup="DeleteChildren" type="sys:base"/>
</permissionsGroup>
<!– Consulta –>

<permissionsGroup name="Consulta" allowFullControl="false" expose="true">
<includePermissionGroup permissionGroup="ReadProperties" type="sys:base"/>
</permissionsGroup>
<!– Arxiver –>

<permissionsGroup name="Arxiver" allowFullControl="false" expose="true">
<includePermissionGroup permissionGroup="ReadProperties" type="sys:base"/>
</permissionsGroup>
<!– Interessat –>

<permissionsGroup name="Interessat" allowFullControl="false" expose="true">
<includePermissionGroup permissionGroup="ReadProperties" type="sys:base"/>
</permissionsGroup>
<!– Ciutada –>
<permissionsGroup name="Ciutada" allowFullControl="false" expose="true"/>
<!– System –>
<permissionsGroup name="System" allowFullControl="true" expose

He mirado ya en todos los manuales y no encuentro nada, este es el error que me da cuando lo ejecuto

Exception in thread "main" AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
faultSubcode:
faultString:
faultActor:
faultNode:
faultDetail:
   {}faultData:<ns1:errorCode xmlns:ns1="http://www.alfresco.org/ws/service/action/1.0">0</ns1:errorCode><ns2:message xmlns:ns2="http://www.alfresco.org/ws/service/action/1.0">Can not find {http://www.alfresco.com/model/content/1.0}ResponsableSerie</ns2:message>
   {http://xml.apache.org/axis/}exceptionName:org.alfresco.repo.webservice.action.ActionFault
   {http://xml.apache.org/axis/}stackTrace:
   at org.alfresco.repo.webservice.accesscontrol.AccessControlWebService.addACEs(AccessControlWebService.java:204)
   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.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:397)
   at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:186)
   at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
   at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
   at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
   at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
   at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:454)
   at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)
   at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
   at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   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)

   {http://xml.apache.org/axis/}hostname:gd-alfresco-vm


   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:494)
   at java.lang.Class.newInstance0(Class.java:350)
   at java.lang.Class.newInstance(Class.java:303)
   at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:182)
   at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
   at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
   at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:633)
   at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanEndElement(XMLNSDocumentScannerImpl.java:719)
   at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1685)
   at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
   at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
   at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
   at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
   at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
   at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
   at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
   at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
   at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
   at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
   at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
   at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
   at org.apache.axis.client.Call.invoke(Call.java:2767)
   at org.apache.axis.client.Call.invoke(Call.java:2443)
   at org.apache.axis.client.Call.invoke(Call.java:2366)
   at org.apache.axis.client.Call.invoke(Call.java:1812)
   at org.alfresco.webservice.accesscontrol.AccessControlServiceSoapBindingStub.addACEs(AccessControlServiceSoapBindingStub.java:772)
   at com.ad10.data.utilsAlfresco.utilsUsersAlfresco.asignarPermisos(utilsUsersAlfresco.java:166)
   at demoAltaUser.main(demoAltaUser.java:43)

haber si alguien me puede echar un cable…

Outcomes