private List<String> getRepresentationPIDsFromBrowser(String type, List<String> subTypes) throws RODAException { Filter filter = new Filter(); if (!StringUtils.isBlank(type)) { filter.add(new SimpleFilterParameter("type", type)); // No sense to use subType without type if (subTypes != null && subTypes.size() > 0) { String[] subTypesArray = subTypes.toArray(new String[subTypes.size()]); filter.add(new OneOfManyFilterParameter("subtype", subTypesArray)); } } Sorter sorter = new Sorter(); sorter.add(new SortParameter("pid", false)); try { SimpleRepresentationObject[] simpleROs = this.browserService.getSimpleRepresentationObjects( new ContentAdapter(filter, sorter, null)); List<String> pids = new ArrayList<String>(); if (simpleROs != null) { for (SimpleRepresentationObject simpleRO : simpleROs) { pids.add(simpleRO.getPid()); } } return pids; } catch (BrowserException e) { logger.debug( "Error getting representations with specified type and subType - " + e.getMessage(), e); throw new BrowserException( "Error getting representations with specified type and subType - " + e.getMessage(), e); } catch (RemoteException e) { RODAException rodaException = RODAClient.parseRemoteException(e); logger.debug( "Error getting representations with specified type and subType - " + rodaException.getMessage(), rodaException); throw rodaException; } }
/** @param args */ public static void main(String[] args) { try { RODAClient rodaClient = null; if (args.length == 3) { // http://localhost:8180/ String hostUrl = args[0]; String username = args[1]; String password = args[2]; rodaClient = new RODAClient(new URL(hostUrl), username, password); } else { System.err.println( BrowserSimpleROTest.class.getSimpleName() + " protocol://hostname:port/core-service [username password]"); System.exit(1); } Browser browserService = rodaClient.getBrowserService(); System.out.println("\n**************************************"); System.out.println("Number of Event Preservation Objects"); System.out.println("**************************************"); int count = browserService.getSimpleEventPreservationObjectCount(null); System.out.println(count + " event preservation objects in the repository"); System.out.println("\n**************************************"); System.out.println("Number of Event Preservation Objects (Inactive)"); System.out.println("**************************************"); Filter filterInactive = new Filter(); filterInactive.add(new SimpleFilterParameter("state", RODAObject.STATE_INACTIVE)); count = browserService.getSimpleEventPreservationObjectCount(filterInactive); System.out.println(count + " inactive event preservation objects in the repository"); SimpleEventPreservationObject[] simpleEPOs = browserService.getSimpleEventPreservationObjects(null); System.out.println("\n**************************************"); System.out.println("List of Event Preservation Objects"); System.out.println("**************************************"); for (int i = 0; simpleEPOs != null && i < simpleEPOs.length; i++) { System.out.println(simpleEPOs[i]); } if (simpleEPOs != null && simpleEPOs.length > 0) { System.out.println("\n*********************************************"); System.out.println( "Getting EventPreservationObject of the first representation (" + simpleEPOs[0].getPid() + ")"); System.out.println("*********************************************"); EventPreservationObject rObject = browserService.getEventPreservationObject(simpleEPOs[0].getPid()); System.out.println(rObject); } } catch (Throwable e) { e.printStackTrace(); if (e.getCause() != null) { System.err.println("Cause exception:"); e.getCause().printStackTrace(); } } }