try {
lastInfo = "";
if (sourceFormat.getName() == null || "".equals(sourceFormat.getName())
|| sourceFormat.getVersion() == null || "".equals(sourceFormat.getVersion())) {
throw new PlatoServiceException("The sample object's format is missing name or version information," +
"both of which are needed for querying this registry. " +
"Please provide name and version or try one of the other registries, which work on PUIDS of formats.");
}
ArrayList<String> shortnames = new ArrayList<String>();
/*
* CRiB uses "<name>, version <version nr>", both from PRONOM, as ID
*/
String cribID = Utils.makeCRiBId(sourceFormat);
/*
* First get the available target formats
*/
String [] targetFormats = serviceRegistryService.findall_targetFormats(cribID);
ArrayList<PreservationActionDefinition> preservationActions = new ArrayList<PreservationActionDefinition>();
for (int i = targetFormats.length-1; i >= 0; i--) {
String targetFormat = targetFormats[i];
/*
* Then get all the possible migration paths for each target format
* - each migration path corresponds to one service
*/
PreservationActionDefinition action;
MigrationPath[] paths = serviceRegistryService.findall_migrationPaths(cribID, targetFormat);
for (int j = 0; j < paths.length; j++) {
MigrationPath path = paths[j];
action = new PreservationActionDefinition();
action.setShortname(getShortnameFromPath(path, shortnames));
String urls[] = path.getAccessPoints();
LinkedList<Parameter> params = new LinkedList<Parameter>();
for (int k = 0; k < urls.length; k++) {
Parameter param = new Parameter();
param.setName("crib::location"+k);
param.setValue(urls[k]);
params.add(param);
}
action.setParams(params);
action.setTargetFormat(targetFormats[i]);
if (urls.length > 0)
action.setUrl(urls[0].substring(0, urls[0].lastIndexOf("/")));
/*
* extract information about the conversions from urls
*/
StringBuilder b = new StringBuilder();
b.append(getSourceFormatFromPath(urls[0]));
for(int uIdx = 0; uIdx < urls.length; uIdx++) {
b.append(">");
b.append(getTargetFormatFromPath(urls[uIdx]));
}
action.setInfo(b.toString());
/*
* mark this as a CRiB action
*/
action.setActionIdentifier("CRiB-local");
/*
* no gif, bmp, text - conversions: they are of minor interest for dp
*/
/* String info = action.getInfo().toUpperCase();
if (!(info.contains("GIF") ||
info.contains("TEXT") ||
info.contains("BMP") ||
info.contains("PDF") ||
info.indexOf("JPG",4) > -1 ))
*/
preservationActions.add(action);
}
}
if (preservationActions.size() == 0)
lastInfo = "This registry does not contain a service that handles objects of type " + sourceFormat.getLongName();
return preservationActions;
} catch (UDDIException e) {
throw new PlatoServiceException("Access to registry failed.", e);
} catch (TransportException e) {
throw new PlatoServiceException("Access to registry failed.", e);
} catch (RemoteException e) {
throw new PlatoServiceException("Access to registry failed.", e);
}
}