private List<BroadcastMetadata> getBroadcastMetadata( List<String> fileObjectPids, InfrastructureContext context, TranscodeRequest request) throws ProcessorException { Map<String, BroadcastMetadata> pidMap = new HashMap<String, BroadcastMetadata>(); CentralWebservice doms = CentralWebserviceFactory.getServiceInstance(context); List<BroadcastMetadata> broadcastMetadataList = new ArrayList<BroadcastMetadata>(); for (String fileObjectPid : fileObjectPids) { BroadcastMetadata broadcastMetadata = null; try { String broadcastMetadataXml = doms.getDatastreamContents(fileObjectPid, "BROADCAST_METADATA"); logger.debug("Found file metadata '" + fileObjectPid + "' :\n" + broadcastMetadataXml); broadcastMetadata = JAXBContext.newInstance(BroadcastMetadata.class) .createUnmarshaller() .unmarshal( new StreamSource(new StringReader(broadcastMetadataXml)), BroadcastMetadata.class) .getValue(); } catch (Exception e) { throw new ProcessorException( "Failed to get Broadcast Metadata for " + request.getObjectPid(), e); } broadcastMetadataList.add(broadcastMetadata); pidMap.put(fileObjectPid, broadcastMetadata); } request.setPidMap(pidMap); return broadcastMetadataList; }
/** * Returns either a list of all the files connected to this program or the single file that * represents this program exactly, if such a file exists. * * @param request * @param context * @return * @throws InvalidCredentialsException * @throws InvalidResourceException * @throws MethodFailedException */ private List<String> findFileObjects(TranscodeRequest request, InfrastructureContext context) throws InvalidCredentialsException, InvalidResourceException, MethodFailedException { CentralWebservice doms = CentralWebserviceFactory.getServiceInstance(context); List<String> fileObjectPids = new ArrayList<String>(); List<Relation> relations = doms.getRelations(request.getObjectPid()); for (Relation relation : relations) { logger.debug( "Relation: " + request.getObjectPid() + " " + relation.getPredicate() + " " + relation.getObject()); if (relation.getPredicate().equals(HAS_EXACT_FILE_RELATION)) { fileObjectPids = new ArrayList<String>(); fileObjectPids.add(relation.getObject()); request.setHasExactFile(true); logger.debug( "Program " + request.getObjectPid() + " has an exact file " + relation.getObject()); return fileObjectPids; } else if (relation.getPredicate().equals(HAS_FILE_RELATION)) { fileObjectPids.add(relation.getObject()); } } return fileObjectPids; }
public void walk() throws InvalidCredentialsException, MethodFailedException, InvalidResourceException { List<Relation> relations = domsAPI.getInverseRelations("doms:ContentModel_Program"); for (Relation relation : relations) { String programPid = relation.getObject(); domsAPI.getDatastreamContents(programPid, "PBCORE"); } }
/** Test code :-) */ @org.junit.Test public void testExample() throws Exception { CentralWebservice webservice = new CentralWebserviceService( new URL("http://localhost:7880/centralWebservice-service/central/?wsdl"), new QName("http://central.doms.statsbiblioteket.dk/", "CentralWebserviceService")) .getCentralWebservicePort(); Map<String, Object> domsAPILogin = ((BindingProvider) webservice).getRequestContext(); domsAPILogin.put(BindingProvider.USERNAME_PROPERTY, "fedoraAdmin"); domsAPILogin.put(BindingProvider.PASSWORD_PROPERTY, "fedoraAdminPass"); for (dk.statsbiblioteket.doms.central.SearchResult result : webservice.findObjects("Valse", 0, 20)) { System.out.println(result.getPid() + ": " + result.getTitle()); } List<DatastreamProfile> datastreams = webservice.getObjectProfile("uuid:bd64c76a-67c5-4aa3-bc51-acfce17df791").getDatastreams(); for (DatastreamProfile datastream : datastreams) { System.out.println(datastream.getId() + "\t" + datastream.getFormatUri()); } System.out.println(); webservice.markInProgressObject( Arrays.asList(new String[] {"uuid:bd64c76a-67c5-4aa3-bc51-acfce17df791"}), "In progress"); webservice.addFileFromPermanentURL( "uuid:bd64c76a-67c5-4aa3-bc51-acfce17df791", "valse1.bwf", null, "http://stage01/doms/valse1.bwf", "info:pronom/fmt/2", "Added file"); webservice.markPublishedObject( Arrays.asList(new String[] {"uuid:bd64c76a-67c5-4aa3-bc51-acfce17df791"}), "Ready"); List<DatastreamProfile> datastreams2 = webservice.getObjectProfile("uuid:bd64c76a-67c5-4aa3-bc51-acfce17df791").getDatastreams(); for (DatastreamProfile datastream : datastreams2) { System.out.println(datastream.getId() + "\t" + datastream.getFormatUri()); } }