cancel
Showing results for 
Search instead for 
Did you mean: 

Create Category without admin

fidel2003
Champ in-the-making
Champ in-the-making
Hello! I want to a create a category via webservices in Alfresco. My function is ok, but I must execute this with user ADMIN. My function is this:

      public static CategoryDTO createCategory(String name, String descripcion, String uuidParent)  {

      Store store = null; // almacen
      CategoryDTO cat = new CategoryDTO();
      String newCategoryUuid = null;
      String subcategory = "subcategories";
      String uuid2 = null;

      try {
         store = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
         loginWSAlfresco();

         NamedValue[] properties = new NamedValue[] { Utils.createNamedValue(Constants.PROP_NAME, name), Utils.createNamedValue(Constants.PROP_DESCRIPTION, descripcion) };

         if ((uuidParent != null) && (!uuidParent.equals("")))
            uuid2 = uuidParent;
         else {
            // get de root category reference

            Query q2 = new Query(Constants.QUERY_LANG_LUCENE, "PATH:\"" + "/cm:generalclassifiable/cm:SDK/cm:SDK_ST" + "\"");
            RepositoryServiceSoapBindingStub repoService2 = WebServiceFactory.getRepositoryService();
            QueryResult r2 = repoService2.query(store, q2, true);
            ResultSet result2 = r2.getResultSet();
            ResultSetRow[] rows2 = result2.getRows();
            uuid2 = rows2[0].getNode().getId();
         }

         Reference cateRootRef2 = new Reference(store, uuid2, null);

         ParentReference parentRef = new ParentReference(store, cateRootRef2.getUuid(), null, Constants.createQNameString(Constants.NAMESPACE_CONTENT_MODEL, subcategory), Constants.createQNameString(Constants.NAMESPACE_CONTENT_MODEL, name));


         CMLCreate cmlCreate = new CMLCreate("12", parentRef, null, null, null, "{http://www.alfresco.org/model/content/1.0}category", properties);
         CML cml = new CML();
         cml.setCreate(new CMLCreate[] { cmlCreate });
         UpdateResult[] result = WebServiceFactory.getRepositoryService().update(cml);
         
      } catch (Exception e) {
         e.printStackTrace();
      } finally {
         AuthenticationUtils.endSession();
      }

   
   }

What can I do to create this with other user? Where I do permissions of create categories to this user ?
Thanks for yor help!
1 REPLY 1

andy
Champ on-the-rise
Champ on-the-rise
Hi

You can change the permissions required for the appropriate service by over-ridding the bean definition in public-services-security-context.xml

Andy