/* Public Interfaces */
 public static URI newLink(DataObject resource) {
   if (resource == null) {
     throw new NullPointerException();
   }
   ResourceTypeEnum res = ResourceTypeMapping.getResourceType(resource);
   try {
     URI parentId;
     if (res == null) {
       return new URI("/");
     }
     switch (res) {
       case STORAGE_POOL:
         parentId = ((StoragePool) resource).getStorageDevice();
         return secondaryResourceLink(res.getService(), resource.getId(), parentId);
       case STORAGE_PORT:
         parentId = ((StoragePort) resource).getStorageDevice();
         return secondaryResourceLink(res.getService(), resource.getId(), parentId);
       case RDF_GROUP:
         parentId = ((RemoteDirectorGroup) resource).getSourceStorageSystemUri();
         return secondaryResourceLink(res.getService(), resource.getId(), parentId);
       case BLOCK_MIRROR:
         parentId = ((BlockMirror) resource).getSource().getURI();
         return secondaryResourceLink(res.getService(), resource.getId(), parentId);
       case VPLEX_MIRROR:
         parentId = ((VplexMirror) resource).getSource().getURI();
         return secondaryResourceLink(res.getService(), resource.getId(), parentId);
       case PROTECTION_SET:
         // any volume in the volume string set is valid
         StringSet volumeIDs = ((ProtectionSet) resource).getVolumes();
         if (volumeIDs != null && !volumeIDs.isEmpty()) {
           for (String volumeID : volumeIDs) {
             // No .get(), same as iterator.
             return secondaryResourceLink(res.getService(), resource.getId(), new URI(volumeID));
           }
         }
         // This will not produce a good URI, but it's impossible to get here with the dependent
         // data model.
         return simpleServiceLink(res.getService(), resource.getId());
       default:
         return simpleServiceLink(res, resource.getId());
     }
   } catch (URISyntaxException ex) {
     return null; // impossible;
   }
 }
  public static URI newLink(ResourceTypeEnum res, URI resourceId, URI parentId) {
    try {
      if (resourceId == null) {
        return new URI("/");
      }

      if (res == ResourceTypeEnum.STORAGE_POOL
          || res == ResourceTypeEnum.STORAGE_PORT
          || res == ResourceTypeEnum.RDF_GROUP
          || res == ResourceTypeEnum.BLOCK_MIRROR
          || res == ResourceTypeEnum.VPLEX_MIRROR
          || res == ResourceTypeEnum.PROTECTION_SET) {
        return secondaryResourceLink(res.getService(), resourceId, parentId);
      } else {
        return simpleServiceLink(res, resourceId);
      }
    } catch (URISyntaxException ex) {
      return null; // impossible;
    }
  }
 public static URI simpleServiceLink(ResourceTypeEnum res, URI resourceId)
     throws URISyntaxException {
   return simpleServiceLink(res.getService(), resourceId);
 }