cancel
Showing results for 
Search instead for 
Did you mean: 

How to delete a group?

spizzico7
Champ in-the-making
Champ in-the-making
I have used this code :
   public static boolean deleteGroups(String groupname) {
      boolean control=true;
      String[] delgroup = {groupname};
      try{
         AccessControlServiceSoapBindingStub accessControlService = WebServiceFactory.getAccessControlService();

         NewAuthority cpGrpAuth = new NewAuthority(GROUP_AUTHORITY_TYPE,groupname);
         
         NewAuthority[] newAuthorities = {cpGrpAuth};
         
         accessControlService.deleteAuthorities(delgroup);
      }

      catch(Exception e)
      {
         e.printStackTrace();
         control=false;
      }
      return control;
   }


but get this error: trying to modify a fixed authority.


How must i do?
5 REPLIES 5

rliu
Champ in-the-making
Champ in-the-making
You need to obtain the node reference to the user group and use the nodeService to delete the node.

spizzico7
Champ in-the-making
Champ in-the-making
You need to obtain the node reference to the user group and use the nodeService to delete the node.
can you give me a code please?

spizzico7
Champ in-the-making
Champ in-the-making
You need to obtain the node reference to the user group and use the nodeService to delete the node.
can you give me a code please?

or a simple example… Smiley Happy

rliu
Champ in-the-making
Champ in-the-making
Hi Spizzico,

I see that you're using Alfresco 2.9. I was not as "fortunate" to use that version. My experience has been in 3.0 and I don't know what the differences are. In 3.0, you can utilize the AuthorityService to delete the user group. There is an overloaded (one cascades, while the other does not) method AuthorityService.deleteAuthority(....) that you can use to delete the user group.

relax
Champ in-the-making
Champ in-the-making
Hello, for Alfresco 3.2r2 I delete User Groups

public StringBuilder deleteGroup(String alfrescoAxisUrl, String groupName)
         throws AccessControlFault, RemoteException {

      StringBuilder stringBuilder = new StringBuilder();

      AccessControlServiceSoapBindingStub accessControlService = WebServiceFactory
            .getAccessControlService(alfrescoAxisUrl);

      AuthorityFilter authorityFilter = new AuthorityFilter();
      authorityFilter.setAuthorityType(GROUP);   
      String[] deleteAuthorities = {Constants.GROUP_PREFIX + groupName};
      accessControlService.deleteAuthorities(deleteAuthorities);

      stringBuilder.append("Delete Group");
      stringBuilder.append("\n");
      return stringBuilder;
   }