private static void testAdvancedSearch() { final ContentService contentService = new ContentService(BASE_URL, AUTH_TICKET); // EVERYTHING EXCEPT FOR PROPCO CONTENT MODEL SearchRequest searchReuqest = new SearchRequest("@cm\\:author:\"SavedbyWindowsInternetExplorer8\""); // FOR PROPCO CONTENT MODEL // SearchRequest searchReuqest = new SearchRequest("cm:lastName=\"Jain\""); // final SearchRequest searchReuqest = new SearchRequest("+PATH:\"//cm:QA//*\" // +@cm\\:lastName:\"Jain\""); // final SearchRequest searchReuqest = new // SearchRequest("@techblue\\:application-id:44284"); // final PagingConfig pagingConfig = new PagingConfig(); // pagingConfig.setMaxItems(2); // pagingConfig.setSkipCount(5); final QueryResponseSorter responseSorter = new QueryResponseSorter(); responseSorter.setColumnName("@cm:modified"); final List<QueryResponseSorter> responseSorters = new ArrayList<QueryResponseSorter>(); responseSorters.add(responseSorter); searchReuqest.setResponseSorters(responseSorters); // searchReuqest.setPagingConfig(pagingConfig); try { System.out.println("RESPONSE:" + contentService.search(searchReuqest)); } catch (final SearchException e) { e.printStackTrace(); } }
private static void testGetContent() { final ContentService contentService = new ContentService(BASE_URL, AUTH_TICKET); try { // ba90e398-dc4f-4de8-a97d-e30669ebee6c DOCX // 27eb6ac6-abb3-4e31-be96-a97140ff641a DOC System.out.println(contentService.getNodeContent("baf47bf6-0fa2-458e-b557-b38e3c2683fb")); } catch (final ContentException e) { e.printStackTrace(); } }
private static void testStoreMetadata() { final ContentService contentService = new ContentService(BASE_URL, AUTH_TICKET); final ContentMetadata contentMetadata = new ContentMetadata(); final Map<String, String> properties = new HashMap<String, String>(); properties.put("author", "SavedbyWindowsInternetExplorer8"); properties.put("originator", "SavedbyWindowsInternetExplorer8"); properties.put("application-id", "44284"); contentMetadata.setProperties(properties); ; try { contentService.storeNodeMetadata("7b08f922-d84b-4aeb-a44c-8743c4a9d0d0", contentMetadata); } catch (final ContentException e) { e.printStackTrace(); } }
private static void testUploadContent() { final ContentService contentService = new ContentService(BASE_URL, AUTH_TICKET); final ContentUploadForm uploadMetadata = new ContentUploadForm(); final FileDataSource fileDataSource = new FileDataSource("C:\\Users\\Public\\Pictures\\Sample Pictures\\Desert.jpg"); // FileDataSource fileDataSource = new FileDataSource("C:\\Users\\Public\\Pictures\\Sample // Pictures\\Desert.jpg"); uploadMetadata.setFileData(fileDataSource); uploadMetadata.setDestination("workspace://SpacesStore/a31a1771-fd57-4d78-a6b8-65372e50fdbc"); // uploadMetadata.setContainerId("documentLibrary"); // uploadMetadata.setUploadDirectory("/Company Home"); // uploadMetadata.setSiteId("swsdp"); uploadMetadata.setFileName("demo123.pdf"); uploadMetadata.setDescription("Test REST upload"); try { System.out.println(contentService.uploadDocument(uploadMetadata)); } catch (final ContentException e) { e.printStackTrace(); } }