01-21-2010 03:51 AM
public StringBuilder createGroup(String alfrescoAxisUrl,
String parentGroupName, String groupName)
throws AccessControlFault, RemoteException {
StringBuilder stringBuilder = new StringBuilder();
AccessControlServiceSoapBindingStub accessControlService = WebServiceFactory
.getAccessControlService(alfrescoAxisUrl);
// test if exist group name
AuthorityFilter authorityFilter = new AuthorityFilter();
authorityFilter.setAuthorityType(GROUP);
String[] allAuthorities = accessControlService
.getAllAuthorities(authorityFilter);
Boolean existGroup = ArrayUtils.contains(allAuthorities,
Constants.GROUP_PREFIX + groupName);
if (!existGroup) {
NewAuthority newAuthorityGroup = new NewAuthority(GROUP, groupName);
NewAuthority[] newAuthorities = { newAuthorityGroup };
if (parentGroupName != null) {
parentGroupName = Constants.GROUP_PREFIX + parentGroupName;
}
accessControlService.createAuthorities(parentGroupName,
newAuthorities);
stringBuilder.append("parentGroupName = ");
stringBuilder.append(parentGroupName);
stringBuilder.append(", groupName = ");
stringBuilder.append(groupName);
logger.info(stringBuilder.toString());
} else {
stringBuilder.append("group = ");
stringBuilder.append(groupName);
stringBuilder.append(" already exists");
logger.info(stringBuilder.toString());
}
stringBuilder.append("\n");
return stringBuilder;
}
01-21-2010 04:16 AM
01-21-2010 05:14 AM
01-26-2010 06:48 AM
Update the details of a group
PUT /alfresco/wcservice/api/groups/{shortName}
01-31-2010 12:43 AM
package org.my.self.test;
import java.rmi.RemoteException;
import org.alfresco.webservice.accesscontrol.AccessControlServiceSoapBindingStub;
import org.alfresco.webservice.authentication.AuthenticationFault;
import org.alfresco.webservice.repository.RepositoryFault;
import org.alfresco.webservice.repository.RepositoryServiceSoapBindingStub;
import org.alfresco.webservice.repository.UpdateResult;
import org.alfresco.webservice.types.CML;
import org.alfresco.webservice.types.CMLUpdate;
import org.alfresco.webservice.types.NamedValue;
import org.alfresco.webservice.types.Node;
import org.alfresco.webservice.types.Predicate;
import org.alfresco.webservice.types.Query;
import org.alfresco.webservice.types.Reference;
import org.alfresco.webservice.types.Store;
import org.alfresco.webservice.util.AuthenticationUtils;
import org.alfresco.webservice.util.Constants;
import org.alfresco.webservice.util.Utils;
import org.alfresco.webservice.util.WebServiceFactory;
public class TestRenameGroup {
public static void renameGroup(String groupName, String newName) {
String query = "+PATH:\"/sys:system/sys:authorities//*\" + @usr\\:authorityName:\""
+ groupName + "\"";
RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory
.getRepositoryService();
try {
Node[] nodes = repositoryService.get(new Predicate(null, new Store(
"user", "alfrescoUserStore"), new Query(
Constants.QUERY_LANG_LUCENE, query)));
CMLUpdate update = new CMLUpdate(new NamedValue[] {Utils.createNamedValue("{http://www.alfresco.org/model/user/1.0}authorityName", newName)},
new Predicate(new Reference[] { nodes[0].getReference() },
null, null), null);
CML cml = new CML();
cml.setUpdate(new CMLUpdate[]{update});
UpdateResult[] updateResults = repositoryService.update(cml);
for (UpdateResult updateResult : updateResults) {
System.out.println(updateResult.getStatement());
}
} catch (RepositoryFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void main(String[] args) {
try {
WebServiceFactory
.setEndpointAddress("http://10.7.16.199:8080/alfresco/api");
AuthenticationUtils.startSession("admin", "admin");
renameGroup("GROUP_NODE_READER_ONLY", "GROUP_NODE_READER_ONLY1");
} catch (AuthenticationFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
02-10-2010 07:05 AM
public static void main(String[] args) {
try {
WebServiceFactory
.setEndpointAddress("http://192.168.11.235:8080/alfresco/api");
AuthenticationUtils.startSession("admin", "admin");
renameGroup1("test", "test12345");
AuthenticationUtils.endSession();
} catch (AuthenticationFault e) {
e.printStackTrace();
}
}
but I have a java.lang.NullPointerExceptionException in thread "main" java.lang.NullPointerException
at it.eng.alfresco.webservice.space.creation.test.TestRenameGroup.renameGroup1(TestRenameGroup.java:73)
at it.eng.alfresco.webservice.space.creation.test.TestRenameGroup.main(TestRenameGroup.java:97)
02-12-2010 06:34 AM
Properties
Reference: workspace://SpacesStore/1fe88e02-6e91-4c6d-8c88-f4d3114c1112
Name: {http://www.alfresco.org/model/content/1.0}authorityName
Value: GROUP_test
Name: {http://www.alfresco.org/model/system/1.0}store-identifier
Value: SpacesStore
Name: {http://www.alfresco.org/model/content/1.0}authorityDisplayName
Value: test
Name: {http://www.alfresco.org/model/system/1.0}store-protocol
Value: workspace
4. I start the web service java main for rename authorityDisplayName propertypublic class TestRenameGroup {
public static void renameGroup5(String uuid, String authorityDisplayName) {
RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory
.getRepositoryService();
try {
Store store = new Store("workspace", "SpacesStore");
Reference reference = new Reference(store, uuid, null);
Reference[] references = { reference };
NamedValue[] namedValues = new NamedValue[] { Utils.createNamedValue("{http://www.alfresco.org/model/content/1.0}authorityDisplayName", authorityDisplayName) };
Predicate predicate = new Predicate(references, store, null);
CMLUpdate update = new CMLUpdate(namedValues, predicate, null);
CML cml = new CML();
cml.setUpdate(new CMLUpdate[] { update });
UpdateResult[] updateResults = repositoryService.update(cml);
for (UpdateResult updateResult : updateResults) {
System.out.println(updateResult.getStatement());
}
} catch (RepositoryFault e) {
e.printStackTrace();
} catch (RemoteException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
try {
WebServiceFactory
.setEndpointAddress("http://192.168.11.235:8080/alfresco/api");
AuthenticationUtils.startSession("admin", "admin");
renameGroup5("1fe88e02-6e91-4c6d-8c88-f4d3114c1112", "Test2_A");
AuthenticationUtils.endSession();
} catch (AuthenticationFault e) {
e.printStackTrace();
}
}
}
5. This is the principal properties that I see in Alfresco Node Browser for group test now!Properties
Reference: workspace://SpacesStore/1fe88e02-6e91-4c6d-8c88-f4d3114c1112
Name: {http://www.alfresco.org/model/content/1.0}authorityName
Value: GROUP_test
Name: {http://www.alfresco.org/model/system/1.0}store-identifier
Value: SpacesStore
Name: {http://www.alfresco.org/model/content/1.0}authorityDisplayName
Value: Test2_A
Name: {http://www.alfresco.org/model/system/1.0}store-protocol
Value: workspace
6. Logout Alfresco02-16-2010 01:36 PM
03-01-2010 12:17 PM
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
faultSubcode:
faultString:
faultActor:
faultNode:
faultDetail:
{http://www.alfresco.org/ws/service/repository/1.0}RepositoryFault:<ns1:errorCode>0</ns1:errorCode><ns1:message>java.lang.UnsupportedOperationException: The name of an authority can not be changed</ns1:message>
{http://xml.apache.org/axis/}exceptionName:org.alfresco.repo.webservice.repository.RepositoryFault
{http://xml.apache.org/axis/}stackTrace:
at org.alfresco.repo.webservice.repository.RepositoryWebService.update(RepositoryWebService.java:341)
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:ubuntu-desktop
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:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at org.apache.axis.encoding.ser.BeanDeserializer.<init>(BeanDeserializer.java:104)
at org.apache.axis.encoding.ser.BeanDeserializer.<init>(BeanDeserializer.java:90)
at org.alfresco.webservice.repository.RepositoryFault.getDeserializer(RepositoryFault.java:146)
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.encoding.ser.BaseDeserializerFactory.getSpecialized(BaseDeserializerFactory.java:154)
at org.apache.axis.encoding.ser.BaseDeserializerFactory.getDeserializerAs(BaseDeserializerFactory.java:84)
at org.apache.axis.encoding.DeserializationContext.getDeserializer(DeserializationContext.java:464)
at org.apache.axis.encoding.DeserializationContext.getDeserializerForType(DeserializationContext.java:547)
at org.apache.axis.message.SOAPFaultDetailsBuilder.onStartChild(SOAPFaultDetailsBuilder.java:157)
at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
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.repository.RepositoryServiceSoapBindingStub.update(RepositoryServiceSoapBindingStub.java:986)
at it.eng.alfresco.webservice.space.creation.test.TestRenameGroup.renameGroup5(TestRenameGroup.java:57)
at it.eng.alfresco.webservice.space.creation.test.TestRenameGroup.main(TestRenameGroup.java:37)
03-01-2010 01:08 PM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.