Access to document on alfresco

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Active Member

Access to document on alfresco

I created a project alfresco amp. To add a document, I run this Test class:

-------------------------------------------------------------------------------------------------------------------------------------------------------------

public class Test

{

      public static void main(String[] args) throws UnsupportedEncodingException

      {
            Map<String, String> sessionParameters = new HashMap<String, String>();
            sessionParameters.put(SessionParameter.USER, "admin");
            sessionParameters.put(SessionParameter.PASSWORD, "admin");
            sessionParameters.put(SessionParameter.ATOMPUB_URL, "http://localhost:8080/alfresco/api/-                      default-/public/cmis/versions/1.1/atom");
             sessionParameters.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
            SessionFactory sessionFactory = SessionFactoryImpl.newInstance();
            Session lSession = sessionFactory.getRepositories(sessionParameters).get(0).createSession();
            Folder root = lSession.getRootFolder();
            Map<String, Object> folderProperties = new HashMap<String, Object>();
            folderProperties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
            folderProperties.put(PropertyIds.NAME, "oo");
            Folder newFolder = root.createFolder(folderProperties);
            Map<String, Object> lProperties = new HashMap<String, Object>();
            String name = "lol.txt";
            lProperties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
            lProperties.put(PropertyIds.NAME, name);
            byte[] content = "CMIS Testdata One".getBytes();
            InputStream stream = new ByteArrayInputStream(content);
            ContentStream contentStream = new ContentStreamImpl(name, new BigInteger(content), "text/plain", stream);
            Document newContent1 = newFolder.createDocument(lProperties, contentStream, null);
            System.out.println("Document created: " + newContent1.getId());
       }
}

-------------------------------------------------------------------------------------------------------------------------------------------------------------

The document is created with success; I got: Document created: e3184105-e59e-4b8a-88e7-9442942433a4;1.0

My problem is how can I access to this document (With which url can I access to that document). Please help?.

1 Reply
Master

Re: Access to document on alfresco

The response to the document creation should typically contain the URL to the document you just created. Also, you can simply use the CMIS library you were using to create it in order to retrieve it later.

If you are talking about wanting a URL to view it inside the Alfresco Share web application, then you should be more specific with your question and say so. You could use http://yourHostSmiley Tongueort/share/page/document-details?nodeRef=workspace://SpacesStore/e3184105-e59e-4b8a-88e7-9442942433a4 for the document you created in the example.