Getting error while creating space in alfresco using java api

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2014 01:57 AM
Hi,
I am trying to create sapce in company home, I am able to start a session but not able to create a space.
Getting following error :
{http://schemas.xmlsoap.org/soap/envelope/}Server.userException
Can anybody help me to solve this error.
I am using 5.0.a community version.
I am trying to create sapce in company home, I am able to start a session but not able to create a space.
Getting following error :
{http://schemas.xmlsoap.org/soap/envelope/}Server.userException
Can anybody help me to solve this error.
I am using 5.0.a community version.
Labels:
- Labels:
-
Archive
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2014 03:55 AM
More detailed information is needed, please paste you code here.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-17-2014 03:43 AM
//this is the code to create the space.
public Reference createSpace(String spacename) throws Exception {
Reference space = null;
Predicate predicate = null;
// Create the space if it is not already existent
createSession();
try {
// Therefore a reference to the maybe not existent space is required
space = new Reference(STORE, null, getCompanyHome().getPath()
+ "/cm:" + normilizeNodeName(spacename));
predicate = new Predicate(new Reference[] { space }, STORE, null);
getRepositoryService().get(predicate);
} catch (Exception e1) {
ParentReference companyHome = getCompanyHome();
// Set Company Home as the parent space
companyHome.setChildName(Constants.createQNameString(
Constants.NAMESPACE_CONTENT_MODEL,
normilizeNodeName(spacename)));
// Set the space's property name
NamedValue[] properties = new NamedValue[] { Utils
.createNamedValue(Constants.PROP_NAME, spacename) };
// Create the space using CML (Content Manipulation Language)
CMLCreate create = new CMLCreate("1", companyHome, null, null,
null, Constants.TYPE_FOLDER, properties);
CML cml = new CML();
cml.setCreate(new CMLCreate[] { create });
// Execute the CML create statement
try {
getRepositoryService().update(cml);
// To limit the access
getAccessControlService()
.setInheritPermission(predicate, false);
}
catch (AxisFault af) {
System.out.println(af.getFaultCode());
} catch (Exception e2) {
System.err.println("Can not create the space.");
// throw e2;
}
}
return space;
}
//this is code to create session
public void createSession() {
server_host = "127.0.0.1";
server_port = "8080";
server_username = "admin";
server_password = "admin";
try {
System.out.println("Starting Session");
if (AuthenticationUtils.getAuthenticationDetails() == null) {
// setSessionProperties();
System.out.println("Connecting to: " + "http://" + server_host
+ ":" + server_port + "/alfresco in AlfrescoUtil");
System.out.println("User: " + server_username + "
assword"
+ server_password);
WebServiceFactory.setEndpointAddress("http://" + server_host
+ ":" + server_port + "/alfresco/api");
AuthenticationUtils.startSession(server_username,
server_password);
System.out.println("Session Created");
}
} catch (Exception e) {
System.err
.println("Can not initiate session with Alfresco server.");
e.printStackTrace();
}
}
I am able to start session, but not able to create space.
public Reference createSpace(String spacename) throws Exception {
Reference space = null;
Predicate predicate = null;
// Create the space if it is not already existent
createSession();
try {
// Therefore a reference to the maybe not existent space is required
space = new Reference(STORE, null, getCompanyHome().getPath()
+ "/cm:" + normilizeNodeName(spacename));
predicate = new Predicate(new Reference[] { space }, STORE, null);
getRepositoryService().get(predicate);
} catch (Exception e1) {
ParentReference companyHome = getCompanyHome();
// Set Company Home as the parent space
companyHome.setChildName(Constants.createQNameString(
Constants.NAMESPACE_CONTENT_MODEL,
normilizeNodeName(spacename)));
// Set the space's property name
NamedValue[] properties = new NamedValue[] { Utils
.createNamedValue(Constants.PROP_NAME, spacename) };
// Create the space using CML (Content Manipulation Language)
CMLCreate create = new CMLCreate("1", companyHome, null, null,
null, Constants.TYPE_FOLDER, properties);
CML cml = new CML();
cml.setCreate(new CMLCreate[] { create });
// Execute the CML create statement
try {
getRepositoryService().update(cml);
// To limit the access
getAccessControlService()
.setInheritPermission(predicate, false);
}
catch (AxisFault af) {
System.out.println(af.getFaultCode());
} catch (Exception e2) {
System.err.println("Can not create the space.");
// throw e2;
}
}
return space;
}
//this is code to create session
public void createSession() {
server_host = "127.0.0.1";
server_port = "8080";
server_username = "admin";
server_password = "admin";
try {
System.out.println("Starting Session");
if (AuthenticationUtils.getAuthenticationDetails() == null) {
// setSessionProperties();
System.out.println("Connecting to: " + "http://" + server_host
+ ":" + server_port + "/alfresco in AlfrescoUtil");
System.out.println("User: " + server_username + "

+ server_password);
WebServiceFactory.setEndpointAddress("http://" + server_host
+ ":" + server_port + "/alfresco/api");
AuthenticationUtils.startSession(server_username,
server_password);
System.out.println("Session Created");
}
} catch (Exception e) {
System.err
.println("Can not initiate session with Alfresco server.");
e.printStackTrace();
}
}
I am able to start session, but not able to create space.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-17-2014 04:30 AM
Why are you still using native webservice?,it is deprecated in 5.0.Please use opencmis api instead.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-18-2014 02:23 AM
Thank you very very much kaynezhang.
Now I am using opencmis api.
They are working fine.
Really thank you very very much.
Now I am using opencmis api.
They are working fine.
Really thank you very very much.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-18-2014 03:13 AM
You are welcome ,good luck.
