@Override public PersistentIdentifier createIdentifier(VirtualCollection vc) throws VirtualCollectionRegistryException { if (vc == null) { throw new NullPointerException("vc == null"); } logger.debug("creating handle for virtual collection \"{}\"", vc.getId()); try { String target = makeCollectionURI(vc); URI serviceURI = URI.create(SERVICE_URI_BASE + "write/create"); List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("url", target)); Map<Attribute, String> props = invokeWebService(serviceURI, params); String pid = props.get(Attribute.PID); if (pid == null) { throw new VirtualCollectionRegistryException("no handle returned"); } logger.info("created handle \"{}\" for virtual collection \"{}\"", pid, vc.getId()); return new PersistentIdentifier(vc, PersistentIdentifier.Type.HANDLE, pid); } catch (VirtualCollectionRegistryException e) { throw new RuntimeException("failed to create handle", e); } }
private String makeCollectionURI(VirtualCollection vc) { return base_uri + "service/clarin-virtualcollection/" + vc.getId(); }