public static void main(String[] args) throws Exception { try { HttpAutomationClient client = new HttpAutomationClient("http://localhost:8080/nuxeo/site/automation"); Session session = client.getSession("Administrator", "Administrator"); DocumentService rs = session.getAdapter(DocumentService.class); Documents docs = rs.query("SELECT * from Workspace"); System.out.println(docs); for (Document d : docs) { System.out.println( d.getTitle() + " at " + d.getLastModified() + " facets :" + d.getFacets() + " token:" + d.getChangeToken()); } client.shutdown(); } catch (RemoteException e) { e.printStackTrace(); System.out.println(e.getRemoteStackTrace()); } }
@Test public void shouldFetchVersionLabelAndLockInfo() throws Exception { client.setResponse("application/json+nxentity", HttpResponses.DOC_LOCK_AND_VERSIONNED); Session session = client.getSession("Administrator", "Administrator"); Document file = (Document) session.newRequest("Document.Fetch").set("value", "/default-domain").execute(); assertEquals("8243123c-34d0-4e33-b4b3-290cef008db0", file.getId()); assertEquals(6, file.getFacets().size()); assertEquals("Downloadable", file.getFacets().getString(0)); assertEquals("Commentable", file.getFacets().getString(1)); assertEquals("Asset", file.getFacets().getString(2)); assertEquals("Versionable", file.getFacets().getString(3)); assertEquals("Publishable", file.getFacets().getString(4)); assertEquals("HasRelatedText", file.getFacets().getString(5)); assertEquals("Administrator:2013-05-16T17:58:26.618+02:00", file.getLock()); assertEquals("2013-05-16T17:58:26.618+02:00", file.getLockCreated().toString()); assertEquals(true, file.isLocked()); assertEquals("Administrator", file.getLockOwner()); assertEquals("/default-domain/UserWorkspaces/Administrator/My File", file.getPath()); assertEquals("1.1", file.getVersionLabel()); assertFalse(file.isCheckedOut()); assertEquals("File", file.getType()); assertEquals("My File", file.getTitle()); assertEquals("project", file.getState()); assertEquals("default", file.getRepository()); client.shutdown(); }
@Test public void shouldFetchDocumentProperties() throws Exception { client.setResponse("application/json+nxentity", HttpResponses.DOC_DEFAULT_DOMAIN); Session session = client.getSession("Administrator", "Administrator"); Document defaultDomain = (Document) session.newRequest("Document.Fetch").set("value", "/default-domain").execute(); assertEquals("6e4ee4b8-af3f-4fb4-ad31-1a0a88720dfb", defaultDomain.getId()); assertEquals(1368704100560L, defaultDomain.getLastModified().getTime()); assertEquals(2, defaultDomain.getFacets().size()); assertEquals("SuperSpace", defaultDomain.getFacets().getString(0)); assertEquals("Folderish", defaultDomain.getFacets().getString(1)); assertEquals(null, defaultDomain.getLock()); assertEquals(null, defaultDomain.getLockCreated()); assertEquals(false, defaultDomain.isLocked()); assertEquals(null, defaultDomain.getLockOwner()); assertEquals("/default-domain", defaultDomain.getPath()); assertEquals("", defaultDomain.getVersionLabel()); assertEquals("Domain", defaultDomain.getType()); assertEquals("Default Domain", defaultDomain.getTitle()); assertEquals("project", defaultDomain.getState()); assertEquals("default", defaultDomain.getRepository()); client.shutdown(); }