You are attempting to access items in the DM repository using AVM-like paths. If you do not understand the difference between the two then I would suggest doing some background reading such as the Professional Alfresco book.
You could try something like the following code, but I have not tested this myself.
String siteName = "blah", newFile = "My New File";
String path = "app:company_home/st:sites/cm:" + siteName + "/cm:documentLibrary";
List<String> pathElements = Arrays.asList(str.split("/"));
NodeRef rootNode = nodeService.getRootNode(new StoreRef("workspace", "SpacesStore"));
NodeRef dlNode = fileFolderService.resolveNamePath(rootNode, pathElements);
NodeRef newNode = fileFolderService.create(dlNode, newFile, ContentModel.TYPE_CONTENT).getNodeRef();
You will want to set some properties and content for the node, but that will at least create it for you. You can find more examples in the Alfresco FirstFoundationClient SDK project.
Exactly how you inject the objects nodeService
and fileFolderService
depends on what container your code is running in, but in the case of a Java-backed web script then you can inject in the dependencies via Spring config by referencing the NodeService
and FileFolderService
beans. Try to avoid using the serviceRegistry
if you can.