Hello, I am fairly new with Alfresco so forgive me if I do not explain everything properly. I am just using a test installation to see if Alfresco will be what is right for what I need. I am running Alfresco 3.4B on glassfish 3.0 . I am just trying to create spaces and documents right now. I am running into issues with dashes in space names though.For example: I create a space named "Testing Space"Inside "Testing Space" I create "inside-test"I was looking at the examples located here:http://wiki.alfresco.com/wiki/IngresTutorial_Alfresco_Web_Service_API_for_JavaSo my understanding goes if I am creating a space with the "createSpace" methods provided it will try to get a reference to that space, if that fails it will then assume the space has not been created and create that space.All works well the first time around, I can create the spaces and the program exits fine. The second time the program is run it tries to create the "inside-test" space again, although you can browse the spaces on the web interface and see that they are there. Is there a different method available for handling dashes in space names? I am getting a duplicate child name not allowed errorHere is the code I am using.Actual space creation:
Reference baseFolder = createSpace("Testing Space");
Reference insideFolder = createSpace(baseFolder, "inside-test");
protected static Reference createSpace(String spacename) throws Exception
{
Reference space = null;
// Create the space if it is not already existent
try {
//Therefore a reference to the maybe not existent space is required
System.out.println("Entering space " + spacename);
space = new Reference(STORE, null, getCompanyHome().getPath() + "/cm:" + normilizeNodeName(spacename));
getRepositoryService().get(new Predicate(new Reference[]{space}, STORE, null));
}
catch (Exception e1)
{
System.out.println("The space named " + spacename + " does not exist. Creating it.");
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);
} catch (Exception e2) {
System.err.println("Can not create the space.");
throw e2;
}
}
return space;
}
protected static Reference createSpace(Reference parentref, String spacename) throws Exception
{
Reference space = null;
ParentReference parent = ReferenceToParent(parentref);
try {
System.out.println("Entering space " + spacename);
space = new Reference(STORE, null, parent.getPath() + "/cm:" + normilizeNodeName(spacename));
WebServiceFactory.getRepositoryService().get(new Predicate(new Reference[]{space}, STORE, null));
System.out.println("What the hell");
}
catch (Exception e1)
{
System.out.println("The space named " + spacename + " does not exist. Creating it.");
parent.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", parent, 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);
} catch (Exception e2) {
System.err.println("Can not create the space.");
throw e2;
}
}
return space;
}
protected static ParentReference ReferenceToParent(Reference spaceref)
{
ParentReference parent = new ParentReference();
parent.setStore(STORE);
parent.setPath(spaceref.getPath());
parent.setUuid(spaceref.getUuid());
parent.setAssociationType(Constants.ASSOC_CONTAINS);
return parent;
}
//Blanks are allowed in space names but not in paths. Because the path should depend on the name we need a version of the name which contains no blanks
protected static String normilizeNodeName(String name)
{
return name.replace(" ","_");
}
protected static RepositoryServiceSoapBindingStub getRepositoryService()
{
return WebServiceFactory.getRepositoryService();
}
protected static ContentServiceSoapBindingStub getContentService()
{
return WebServiceFactory.getContentService();
}
protected static ParentReference getCompanyHome()
{
ParentReference companyHomeParent = new ParentReference(STORE, null, "/app:company_home", Constants.ASSOC_CONTAINS, null);
return companyHomeParent;
}