MiniReefServiceRegistry implements IPreservationActionRegistry { public List<IServiceInfo> getAvailableActions(FormatInfo sourceFormat) throws PlatoException { if ((sourceFormat == null) || (StringUtils.isEmpty(sourceFormat.getPuid()))) { throw new PlatoException("No source format defined."); } String puid = sourceFormat.getPuid(); if (!puidPattern.matcher(puid).matches()) { throw new PlatoException("Invalid Pronom Unique ID"); } String statement = "SELECT distinct ?swname ?swversion ?formatname ?formatversion ?released ?vendorname " + "WHERE { ?sw ?link1 ?format . " + " ?format pronom:FileFormatIdentifier ?ident . " + " ?ident pronom:Identifier \"$PUID$\" ." + " ?ident pronom:IdentifierType \"PUID\" ." + " ?sw ?link2 ?format2 . " + " ?sw pronom:SoftwareName ?swname . " + " ?sw pronom:Version ?swversion . " + " ?format2 pronom:FormatName ?formatname . " + " ?format2 pronom:FormatVersion ?formatversion . " + " ?sw pronom:Vendor ?vendor . " + " ?vendor pronom:VendorName ?vendorname . " + " ?link2 rdf:type <http: Map<String, String> params = new HashMap<String, String>(); params.put("PUID", puid); ResultSet resultSet = MiniREEFResolver.getInstance().resolve(statement, params); ArrayList<IServiceInfo> result = new ArrayList<IServiceInfo>(); if (resultSet == null) { log.error("querying miniREEF/P2 knowledge base failed for statement: " + statement); return result; } for (int i = 0; i < resultSet.size(); i++) { ActionInfo def = new ActionInfo(); def.setShortname("Convert using " + resultSet.getRow(i).get(0) + " " + resultSet.getRow(i).get(1)); def.setTargetFormat(resultSet.getRow(i).get(2) + " " + resultSet.getRow(i).get(3)); def.setInfo("by " + resultSet.getRow(i).get(4)); def.setActionIdentifier("P2"); def.setExecutable(false); result.add(def); } return result; }  void connect(String URL); String getToolIdentifier(String url); String getToolParameters(String url); List<IServiceInfo> getAvailableActions(FormatInfo sourceFormat); String getLastInfo();  }
@Test(expected=PlatoException.class) public void testRetrieveWithNullFormatInfo() throws PlatoException{ registry.getAvailableActions(null); }
@Test public void testRetrieveAction() throws PlatoException{ FormatInfo formatInfo = new FormatInfo(); formatInfo.setPuid("fmt/16"); List<IServiceInfo> services = registry.getAvailableActions(formatInfo); assertNotNull(services); assertTrue(services.size() > 0); }
@Test public void testRetrieveActionForTemporalPuid() throws PlatoException{ FormatInfo formatInfo = new FormatInfo(); formatInfo.setPuid("x-fmt/35"); List<IServiceInfo> services = registry.getAvailableActions(formatInfo); assertNotNull(services); assertTrue(services.size() > 0); }
@Test(expected=PlatoException.class) public void testMalformedPuid() throws PlatoException{ FormatInfo formatInfo = new FormatInfo(); formatInfo.setPuid("G:\\tmp\\DSC_3161.NEF"); registry.getAvailableActions(formatInfo); }