/** * Creates a IdAddressBean based on a URA. * * @param address A URA which must use the ID scheme * @return A IdAddressBean or null * @throws URISyntaxException If the URA is ill formed */ public IdAddressBean createIdAddressBean(String address) throws URISyntaxException { IdAddressBean out = null; if ((address == null) || (address.isEmpty())) { throw new URISyntaxException("", "Null or Empty Address sent"); } URI u = new URI(address); String entity = u.getScheme(); String scheme = getScheme(u.getHost()); String path = u.getPath(); if (!path.isEmpty()) { path = path.substring(1); } EntityType et = EntityTypeHelper.getType(entity); if (scheme != null) { if (scheme.compareToIgnoreCase("id") == 0) { out = new IdAddressBean(et, path, getSubScheme(u.getHost())); } } return out; }
/** * Creates a UniversalResourceAddressBean based on a URA. * * @param address A URA to parse and turn into a UniversalResourceAddressBean * @return A UniversalResourceAddressBean or null * @throws URISyntaxException DOCUMENT ME! * @see https://socraticgrid.org/display/docs/Universal+Resource+Addresses */ public UniversalResourceAddressBean createUniversalResourceBean(String address) throws URISyntaxException { UniversalResourceAddressBean out = null; if ((address == null) || (address.isEmpty())) { throw new URISyntaxException("", "Null or Empty Address sent"); } URI u = new URI(address); String entity = u.getScheme(); String scheme = getScheme(u.getHost()); String path = u.getPath(); if (!path.isEmpty()) { path = path.substring(1); } EntityType et = EntityTypeHelper.getType(entity); if (scheme == null) { out = new GenericResourceAddressBean(et, entity, "unknown", u.getHost(), ""); } else if (scheme.compareToIgnoreCase("id") == 0) { out = new IdAddressBean(et, path, getSubScheme(u.getHost())); } else { out = new GenericResourceAddressBean(et, entity, scheme, getSubScheme(u.getHost()), path); } return out; }