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; }