http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/rest/server/OMRSRepositoryRESTServices.java
----------------------------------------------------------------------
diff --git 
a/omrs/src/main/java/org/apache/atlas/omrs/rest/server/OMRSRepositoryRESTServices.java
 
b/omrs/src/main/java/org/apache/atlas/omrs/rest/server/OMRSRepositoryRESTServices.java
index d53c795..237a2b0 100644
--- 
a/omrs/src/main/java/org/apache/atlas/omrs/rest/server/OMRSRepositoryRESTServices.java
+++ 
b/omrs/src/main/java/org/apache/atlas/omrs/rest/server/OMRSRepositoryRESTServices.java
@@ -17,17 +17,80 @@
  */
 package org.apache.atlas.omrs.rest.server;
 
-import 
org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnector;
+import org.apache.atlas.omrs.ffdc.OMRSErrorCode;
+import org.apache.atlas.omrs.ffdc.exception.*;
+import 
org.apache.atlas.omrs.localrepository.repositoryconnector.LocalOMRSRepositoryConnector;
+import org.apache.atlas.omrs.metadatacollection.OMRSMetadataCollection;
+import org.apache.atlas.omrs.metadatacollection.properties.MatchCriteria;
+import org.apache.atlas.omrs.metadatacollection.properties.SequencingOrder;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.*;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.*;
+import org.apache.atlas.omrs.rest.properties.*;
+import org.springframework.web.bind.annotation.*;
+
+
+import java.text.MessageFormat;
+import java.util.Date;
+import java.util.List;
 
 /**
  * OMRSRepositoryRESTServices provides the server-side support for the OMRS 
Repository REST Services API.
  * It is a minimal wrapper around the OMRSRepositoryConnector for the local 
server's metadata collection.
- * If localRepositoryConnector is null when a REST calls is received, the 
request is rejected.
+ * If localRepositoryConnector is null when a REST call is received, the 
request is rejected.
+ *
+ * The REST services are based around the OMRSMetadataCollection interface.
+ * * <p>
+ *     OMRSMetadataCollection is the common interface for working with the 
contents of a metadata repository.
+ *     Within a metadata collection are the type definitions (TypeDefs) and 
metadata instances (Entities and
+ *     Relationships).  OMRSMetadataCollectionBase provides empty 
implementation of the the abstract methods of
+ *     OMRSMetadataCollection.
+ *
+ *     The methods on OMRSMetadataCollection are in the following major groups:
+ * </p>
+ * <ul>
+ *     <li><b>Methods to retrieve information about the metadata 
repository</b> -
+ *         Used to retrieve or confirm the identity of the metadata repository
+ *     </li>
+ *     <li><b>Methods for working with typedefs</b> -
+ *         Typedefs are used to define the type model for open metadata.
+ *         The open metadata support had a comprehensive set of typedefs 
implemented, and these can be augmented by
+ *         different vendors or applications.  The typedefs can be queried, 
created, updated and deleted though the
+ *         metadata collection.
+ *     </li>
+ *
+ *     <li><b>Methods for querying Entities and Relationships</b> -
+ *         The metadata repository stores instances of the typedefs as 
metadata instances.
+ *         Principally these are entities (nodes in the graph) and 
relationships (links between nodes).
+ *         Both the entities and relationships can have properties.
+ *         The entity may also have structured properties called structs and 
classifications attached.
+ *         This second group of methods supports a range of queries to 
retrieve these instances.
+ *     </li>
+ *
+ *     <li><b>Methods for maintaining the instances</b> -
+ *         The fourth group of methods supports the maintenance of the 
metadata instances.  Each instance as a status
+ *         (see InstanceStatus) that allows an instance to be proposed, 
drafted and approved before it becomes
+ *         active.  The instances can also be soft-deleted and restored or 
purged from the metadata
+ *         collection.
+ *     </li>
+ *     <li>
+ *         <b>Methods for repairing the metadata collections of the cohort</b> 
-
+ *         The fifth group of methods are for editing the control information 
of entities and relationships to
+ *         manage changes in the cohort.  These methods are advanced methods 
and are rarely used.
+ *     </li>
+ *     <li>
+ *         <b>Methods for local maintenance of a metadata collection</b>
+ *         The final group of methods are for removing reference copies of the 
metadata instances.  These updates
+ *         are not broadcast to the rest of the Cohort as events.
+ *     </li>
+ * </ul>
  */
+@RestController
+@RequestMapping("/omag/omrs/")
 public class OMRSRepositoryRESTServices
 {
-    //TODO remember to support getInstanceURL from TypeDefManager
-    public static OMRSRepositoryConnector localRepositoryConnector = null;
+    private static LocalOMRSRepositoryConnector localRepositoryConnector = 
null;
+    private static OMRSMetadataCollection       localMetadataCollection = null;
+    private static String                       localServerURL = null;
 
 
     /**
@@ -36,9 +99,5078 @@ public class OMRSRepositoryRESTServices
      * @param localRepositoryConnector - link to the local repository 
responsible for servicing the REST calls.
      *                                 If localRepositoryConnector is null 
when a REST calls is received, the request
      *                                 is rejected.
+     * @param localServerURL - URL of the local server
      */
-    public static void setLocalRepository(OMRSRepositoryConnector    
localRepositoryConnector)
+    public static void setLocalRepository(LocalOMRSRepositoryConnector    
localRepositoryConnector,
+                                          String                          
localServerURL)
     {
         OMRSRepositoryRESTServices.localRepositoryConnector = 
localRepositoryConnector;
+        OMRSRepositoryRESTServices.localMetadataCollection = 
localRepositoryConnector.getMetadataCollection();
+        OMRSRepositoryRESTServices.localServerURL = localServerURL;
+    }
+
+
+    /**
+     * Default constructor
+     */
+    public OMRSRepositoryRESTServices()
+    {
+    }
+
+
+    /* ======================================================================
+     * Group 1: Confirm the identity of the metadata repository being called.
+     */
+
+    /**
+     * Returns the identifier of the metadata repository.  This is the 
identifier used to register the
+     * metadata repository with the metadata repository cohort.  It is also 
the identifier used to
+     * identify the home repository of a metadata instance.
+     *
+     * @return String - metadata collection id.
+     * @throws RepositoryErrorException - there is a problem communicating 
with the metadata repository.
+     */
+    @RequestMapping(method = RequestMethod.GET, path = 
"/metadata-collection-id")
+
+    public String      getMetadataCollectionId() throws 
RepositoryErrorException
+    {
+        final  String   methodName = "getMetadataCollectionId";
+
+        validateLocalRepository(methodName);
+
+        return localMetadataCollection.getMetadataCollectionId();
+    }
+
+
+    /* ==============================
+     * Group 2: Working with typedefs
+     */
+
+
+    /**
+     * Returns the list of different types of metadata organized into two 
groups.  The first are the
+     * attribute type definitions (AttributeTypeDefs).  These provide types 
for properties in full
+     * type definitions.  Full type definitions (TypeDefs) describe types for 
entities, relationships
+     * and classifications.
+     *
+     * @param userId - unique identifier for requesting user.
+     * @return TypeDefGalleryResponse:
+     * List of different categories of type definitions or
+     * RepositoryErrorException - there is a problem communicating with the 
metadata repository or
+     * UserNotAuthorizedException - the userId is not permitted to perform 
this operation.
+     */
+    @RequestMapping(method = RequestMethod.GET, path = "/{userId}/types/all")
+
+    public TypeDefGalleryResponse getAllTypes(@PathVariable String   userId)
+    {
+        final  String   methodName = "getAllTypes";
+
+        TypeDefGalleryResponse  response = new TypeDefGalleryResponse();
+
+        try
+        {
+            validateLocalRepository(methodName);
+
+            TypeDefGallery typeDefGallery = 
localMetadataCollection.getAllTypes(userId);
+            if (typeDefGallery != null)
+            {
+                
response.setAttributeTypeDefs(typeDefGallery.getAttributeTypeDefs());
+                response.setTypeDefs(typeDefGallery.getTypeDefs());
+            }
+        }
+        catch (RepositoryErrorException  error)
+        {
+            captureRepositoryErrorException(response, error);
+        }
+        catch (UserNotAuthorizedException error)
+        {
+            captureUserNotAuthorizedException(response, error);
+        }
+
+        return response;
+    }
+
+
+    /**
+     * Returns a list of type definitions that have the specified name.  Type 
names should be unique.  This
+     * method allows wildcard character to be included in the name.  These are 
* (asterisk) for an
+     * arbitrary string of characters and ampersand for an arbitrary character.
+     *
+     * @param userId - unique identifier for requesting user.
+     * @param name - name of the TypeDefs to return (including wildcard 
characters).
+     * @return TypeDefGalleryResponse:
+     * List of different categories of type definitions or
+     * RepositoryErrorException - there is a problem communicating with the 
metadata repository or
+     * UserNotAuthorizedException - the userId is not permitted to perform 
this operation or
+     * InvalidParameterException - the name of the TypeDef is null.
+     */
+    @RequestMapping(method = RequestMethod.GET, path = 
"/{userId}/types/by-name")
+
+    public TypeDefGalleryResponse findTypesByName(@PathVariable String userId,
+                                                  @RequestParam String name)
+    {
+        final  String   methodName = "findTypesByName";
+
+        TypeDefGalleryResponse  response = new TypeDefGalleryResponse();
+
+        try
+        {
+            validateLocalRepository(methodName);
+
+            TypeDefGallery typeDefGallery = 
localMetadataCollection.findTypesByName(userId, name);
+            if (typeDefGallery != null)
+            {
+                
response.setAttributeTypeDefs(typeDefGallery.getAttributeTypeDefs());
+                response.setTypeDefs(typeDefGallery.getTypeDefs());
+            }
+
+        }
+        catch (RepositoryErrorException  error)
+        {
+            captureRepositoryErrorException(response, error);
+        }
+        catch (UserNotAuthorizedException error)
+        {
+            captureUserNotAuthorizedException(response, error);
+        }
+        catch (InvalidParameterException error)
+        {
+            captureInvalidParameterException(response, error);
+        }
+
+        return response;
+    }
+
+
+    /**
+     * Returns all of the TypeDefs for a specific category.
+     *
+     * @param userId - unique identifier for requesting user.
+     * @param category - enum value for the category of TypeDef to return.
+     * @return TypeDefListResponse:
+     * TypeDefs list or
+     * InvalidParameterException - the TypeDefCategory is null or
+     * RepositoryErrorException - there is a problem communicating with the 
metadata repository or
+     * UserNotAuthorizedException - the userId is not permitted to perform 
this operation.
+     */
+    @RequestMapping(method = RequestMethod.GET, path = 
"/{userId}/types/typedefs/by-category")
+
+    public TypeDefListResponse findTypeDefsByCategory(@PathVariable String     
     userId,
+                                                      @RequestParam 
TypeDefCategory category)
+    {
+        final  String   methodName = "findTypeDefsByCategory";
+
+        TypeDefListResponse response = new TypeDefListResponse();
+
+        try
+        {
+            validateLocalRepository(methodName);
+
+            
response.setTypeDefs(localMetadataCollection.findTypeDefsByCategory(userId, 
category));
+        }
+        catch (RepositoryErrorException  error)
+        {
+            captureRepositoryErrorException(response, error);
+        }
+        catch (UserNotAuthorizedException error)
+        {
+            captureUserNotAuthorizedException(response, error);
+        }
+        catch (InvalidParameterException error)
+        {
+            captureInvalidParameterException(response, error);
+        }
+
+        return response;
+    }
+
+
+    /**
+     * Returns all of the AttributeTypeDefs for a specific category.
+     *
+     * @param userId - unique identifier for requesting user.
+     * @param category - enum value for the category of an AttributeTypeDef to 
return.
+     * @return AttributeTypeDefListResponse:
+     * AttributeTypeDefs list or
+     * InvalidParameterException - the TypeDefCategory is null or
+     * RepositoryErrorException - there is a problem communicating with the 
metadata repository or
+     * UserNotAuthorizedException - the userId is not permitted to perform 
this operation.
+     */
+    @RequestMapping(method = RequestMethod.GET, path = 
"/{userId}/types/attribute-typedefs/by-category")
+
+    public AttributeTypeDefListResponse 
findAttributeTypeDefsByCategory(@PathVariable String                   userId,
+                                                                        
@RequestParam AttributeTypeDefCategory category)
+    {
+        final  String   methodName = "findAttributeTypeDefsByCategory";
+
+        AttributeTypeDefListResponse response = new 
AttributeTypeDefListResponse();
+
+        try
+        {
+            validateLocalRepository(methodName);
+
+            
response.setAttributeTypeDefs(localMetadataCollection.findAttributeTypeDefsByCategory(userId,
 category));
+        }
+        catch (RepositoryErrorException  error)
+        {
+            captureRepositoryErrorException(response, error);
+        }
+        catch (UserNotAuthorizedException error)
+        {
+            captureUserNotAuthorizedException(response, error);
+        }
+        catch (InvalidParameterException error)
+        {
+            captureInvalidParameterException(response, error);
+        }
+
+        return response;
+    }
+
+
+    /**
+     * Return the TypeDefs that have the properties matching the supplied 
match criteria.
+     *
+     * @param userId - unique identifier for requesting user.
+     * @param matchCriteria - TypeDefProperties - a list of property names and 
values.
+     * @return TypeDefListResponse:
+     * TypeDefs list or
+     * InvalidParameterException - the matchCriteria is null or
+     * RepositoryErrorException - there is a problem communicating with the 
metadata repository or
+     * UserNotAuthorizedException - the userId is not permitted to perform 
this operation.
+     */
+    @RequestMapping(method = RequestMethod.GET, path = 
"/{userId}/types/typedefs/by-property")
+
+    public TypeDefListResponse findTypeDefsByProperty(@PathVariable String     
       userId,
+                                                      @RequestParam 
TypeDefProperties matchCriteria)
+    {
+        final  String   methodName = "findTypeDefsByProperty";
+
+        TypeDefListResponse response = new TypeDefListResponse();
+
+        try
+        {
+            validateLocalRepository(methodName);
+
+            
response.setTypeDefs(localMetadataCollection.findTypeDefsByProperty(userId, 
matchCriteria));
+        }
+        catch (RepositoryErrorException  error)
+        {
+            captureRepositoryErrorException(response, error);
+        }
+        catch (UserNotAuthorizedException error)
+        {
+            captureUserNotAuthorizedException(response, error);
+        }
+        catch (InvalidParameterException error)
+        {
+            captureInvalidParameterException(response, error);
+        }
+
+        return response;
+    }
+
+
+    /**
+     * Return the types that are linked to the elements from the specified 
standard.
+     *
+     * @param userId - unique identifier for requesting user.
+     * @param standard - name of the standard - null means any.
+     * @param organization - name of the organization - null means any.
+     * @param identifier - identifier of the element in the standard - null 
means any.
+     * @return TypeDefsGalleryResponse:
+     * A list of types or
+     * InvalidParameterException - all attributes of the external id are null 
or
+     * RepositoryErrorException - there is a problem communicating with the 
metadata repository or
+     * UserNotAuthorizedException - the userId is not permitted to perform 
this operation.
+     */
+    @RequestMapping(method = RequestMethod.GET, path = 
"/{userId}/types/typedefs/by-external-id")
+
+    public TypeDefListResponse findTypesByExternalID(@PathVariable String    
userId,
+                                                     @RequestParam String    
standard,
+                                                     @RequestParam String    
organization,
+                                                     @RequestParam String    
identifier)
+    {
+        final  String   methodName = "findTypesByExternalID";
+
+        TypeDefListResponse  response = new TypeDefListResponse();
+
+        try
+        {
+            validateLocalRepository(methodName);
+
+            List<TypeDef> typeDefs = 
localMetadataCollection.findTypesByExternalID(userId,
+                                                                               
    standard,
+                                                                               
    organization,
+                                                                               
    identifier);
+            response.setTypeDefs(typeDefs);
+        }
+        catch (RepositoryErrorException  error)
+        {
+            captureRepositoryErrorException(response, error);
+        }
+        catch (UserNotAuthorizedException error)
+        {
+            captureUserNotAuthorizedException(response, error);
+        }
+        catch (InvalidParameterException error)
+        {
+            captureInvalidParameterException(response, error);
+        }
+
+        return response;
+    }
+
+
+    /**
+     * Return the TypeDefs that match the search criteria.
+     *
+     * @param userId - unique identifier for requesting user.
+     * @param searchCriteria - String - search criteria.
+     * @return TypeDefListResponse:
+     * TypeDefs list or
+     * InvalidParameterException - the searchCriteria is null or
+     * RepositoryErrorException - there is a problem communicating with the 
metadata repository or
+     * UserNotAuthorizedException - the userId is not permitted to perform 
this operation.
+     */
+    @RequestMapping(method = RequestMethod.GET, path = 
"/{userId}/types/typedefs/by-search-criteria")
+
+    public TypeDefListResponse searchForTypeDefs(@PathVariable String userId,
+                                                 @RequestParam String 
searchCriteria)
+    {
+        final  String   methodName = "searchForTypeDefs";
+
+        TypeDefListResponse response = new TypeDefListResponse();
+
+        try
+        {
+            validateLocalRepository(methodName);
+
+            
response.setTypeDefs(localMetadataCollection.searchForTypeDefs(userId, 
searchCriteria));
+        }
+        catch (RepositoryErrorException  error)
+        {
+            captureRepositoryErrorException(response, error);
+        }
+        catch (UserNotAuthorizedException error)
+        {
+            captureUserNotAuthorizedException(response, error);
+        }
+        catch (InvalidParameterException error)
+        {
+            captureInvalidParameterException(response, error);
+        }
+
+        return response;
+    }
+
+
+    /**
+     * Return the TypeDef identified by the GUID.
+     *
+     * @param userId - unique identifier for requesting user.
+     * @param guid - String unique id of the TypeDef.
+     * @return TypeDefResponse:
+     * TypeDef structure describing its category and properties or
+     * InvalidParameterException - the guid is null or
+     * RepositoryErrorException - there is a problem communicating with the 
metadata repository where
+     *                                  the metadata collection is stored or
+     * TypeDefNotKnownException - The requested TypeDef is not known in the 
metadata collection or
+     * UserNotAuthorizedException - the userId is not permitted to perform 
this operation.
+     */
+    @RequestMapping(method = RequestMethod.GET, path = 
"/{userId}/types/typedef/{guid}")
+
+    public TypeDefResponse getTypeDefByGUID(@PathVariable String    userId,
+                                            @PathVariable String    guid)
+    {
+        final  String   methodName = "getTypeDefByGUID";
+
+        TypeDefResponse response = new TypeDefResponse();
+
+        try
+        {
+            validateLocalRepository(methodName);
+
+            
response.setTypeDef(localMetadataCollection.getTypeDefByGUID(userId, guid));
+        }
+        catch (RepositoryErrorException  error)
+        {
+            captureRepositoryErrorException(response, error);
+        }
+        catch (UserNotAuthorizedException error)
+        {
+            captureUserNotAuthorizedException(response, error);
+        }
+        catch (InvalidParameterException error)
+        {
+            captureInvalidParameterException(response, error);
+        }
+        catch (TypeDefNotKnownException error)
+        {
+            captureTypeDefNotKnownException(response, error);
+        }
+
+        return response;
+    }
+
+
+    /**
+     * Return the AttributeTypeDef identified by the GUID.
+     *
+     * @param userId - unique identifier for requesting user.
+     * @param guid - String unique id of the TypeDef
+     * @return AttributeTypeDefResponse:
+     * TypeDef structure describing its category and properties or
+     * InvalidParameterException - the guid is null or
+     * RepositoryErrorException - there is a problem communicating with the 
metadata repository where
+     *                                  the metadata collection is stored or
+     * TypeDefNotKnownException - The requested TypeDef is not known in the 
metadata collection or
+     * UserNotAuthorizedException - the userId is not permitted to perform 
this operation.
+     */
+    @RequestMapping(method = RequestMethod.GET, path = 
"/{userId}/types/attribute-typedef/{guid}")
+
+    public AttributeTypeDefResponse getAttributeTypeDefByGUID(@PathVariable 
String    userId,
+                                                              @PathVariable 
String    guid)
+    {
+        final  String   methodName = "getAttributeTypeDefByGUID";
+
+        AttributeTypeDefResponse response = new AttributeTypeDefResponse();
+
+        try
+        {
+            validateLocalRepository(methodName);
+
+            
response.setAttributeTypeDef(localMetadataCollection.getAttributeTypeDefByGUID(userId,
 guid));
+        }
+        catch (RepositoryErrorException  error)
+        {
+            captureRepositoryErrorException(response, error);
+        }
+        catch (UserNotAuthorizedException error)
+        {
+            captureUserNotAuthorizedException(response, error);
+        }
+        catch (InvalidParameterException error)
+        {
+            captureInvalidParameterException(response, error);
+        }
+        catch (TypeDefNotKnownException error)
+        {
+            captureTypeDefNotKnown(response, error);
+        }
+
+        return response;
+    }
+
+
+
+    /**
+     * Return the TypeDef identified by the unique name.
+     *
+     * @param userId - unique identifier for requesting user.
+     * @param name - String name of the TypeDef.
+     * @return TypeDefResponse:
+     * TypeDef structure describing its category and properties or
+     * InvalidParameterException - the name is null or
+     * RepositoryErrorException - there is a problem communicating with the 
metadata repository where
+     *                                  the metadata collection is stored or
+     * TypeDefNotKnownException - the requested TypeDef is not found in the 
metadata collection or
+     * UserNotAuthorizedException - the userId is not permitted to perform 
this operation.
+     */
+    @RequestMapping(method = RequestMethod.GET, path = 
"/{userId}/types/typedef/name/{name}")
+
+    public TypeDefResponse getTypeDefByName(@PathVariable String    userId,
+                                            @PathVariable String    name)
+    {
+        final  String   methodName = "getTypeDefByName";
+
+        TypeDefResponse response = new TypeDefResponse();
+
+        try
+        {
+            validateLocalRepository(methodName);
+
+            
response.setTypeDef(localMetadataCollection.getTypeDefByName(userId, name));
+        }
+        catch (RepositoryErrorException  error)
+        {
+            captureRepositoryErrorException(response, error);
+        }
+        catch (UserNotAuthorizedException error)
+        {
+            captureUserNotAuthorizedException(response, error);
+        }
+        catch (InvalidParameterException error)
+        {
+            captureInvalidParameterException(response, error);
+        }
+        catch (TypeDefNotKnownException error)
+        {
+            captureTypeDefNotKnownException(response, error);
+        }
+
+        return response;
+    }
+
+
+    /**
+     * Return the AttributeTypeDef identified by the unique name.
+     *
+     * @param userId - unique identifier for requesting user.
+     * @param name - String name of the TypeDef.
+     * @return AttributeTypeDefResponse:
+     * AttributeTypeDef structure describing its category and properties or
+     * InvalidParameterException - the name is null or
+     * RepositoryErrorException - there is a problem communicating with the 
metadata repository where
+     *                                  the metadata collection is stored or
+     * TypeDefNotKnownException - the requested TypeDef is not found in the 
metadata collection or
+     * UserNotAuthorizedException - the userId is not permitted to perform 
this operation.
+     */
+    @RequestMapping(method = RequestMethod.GET, path = 
"/{userId}/types/attribute-typedef/name/{name}")
+
+    public  AttributeTypeDefResponse getAttributeTypeDefByName(@PathVariable 
String    userId,
+                                                               @PathVariable 
String    name)
+    {
+        final  String   methodName = "getAttributeTypeDefByName";
+
+        AttributeTypeDefResponse response = new AttributeTypeDefResponse();
+
+        try
+        {
+            validateLocalRepository(methodName);
+
+            
response.setAttributeTypeDef(localMetadataCollection.getAttributeTypeDefByName(userId,
 name));
+        }
+        catch (RepositoryErrorException  error)
+        {
+            captureRepositoryErrorException(response, error);
+        }
+        catch (UserNotAuthorizedException error)
+        {
+            captureUserNotAuthorizedException(response, error);
+        }
+        catch (InvalidParameterException error)
+        {
+            captureInvalidParameterException(response, error);
+        }
+        catch (TypeDefNotKnownException error)
+        {
+            captureTypeDefNotKnown(response, error);
+        }
+
+        return response;
+    }
+
+
+    /**
+     * Create a collection of related types.
+     *
+     * @param userId - unique identifier for requesting user.
+     * @param newTypes - TypeDefGalleryResponse structure describing the new 
AttributeTypeDefs and TypeDefs.
+     * @return VoidResponse:
+     * void or
+     * InvalidParameterException - the new TypeDef is null or
+     * RepositoryErrorException - there is a problem communicating with the 
metadata repository where
+     *                                  the metadata collection is stored or
+     * TypeDefNotSupportedException - the repository is not able to support 
this TypeDef or
+     * TypeDefKnownException - the TypeDef is already stored in the repository 
or
+     * TypeDefConflictException - the new TypeDef conflicts with an existing 
TypeDef or
+     * InvalidTypeDefException - the new TypeDef has invalid contents or
+     * FunctionNotSupportedException - the repository does not support this 
call or
+     * UserNotAuthorizedException - the userId is not permitted to perform 
this operation.
+     */
+    @RequestMapping(method = RequestMethod.POST, path = "/{userId}/types")
+
+    public  VoidResponse addTypeDefGallery(@PathVariable String          
userId,
+                                           @RequestParam TypeDefGallery  
newTypes)
+    {
+        final  String   methodName = "addTypeDefGallery";
+
+        VoidResponse response = new VoidResponse();
+
+        try
+        {
+            validateLocalRepository(methodName);
+
+            localMetadataCollection.addTypeDefGallery(userId, newTypes);
+        }
+        catch (FunctionNotSupportedException error)
+        {
+            captureFunctionNotSupportedException(response, error);
+        }
+        catch (RepositoryErrorException  error)
+        {
+            captureRepositoryErrorException(response, error);
+        }
+        catch (UserNotAuthorizedException error)
+        {
+            captureUserNotAuthorizedException(response, error);
+        }
+        catch (InvalidParameterException error)
+        {
+            captureInvalidParameterException(response, error);
+        }
+        catch (TypeDefNotSupportedException error)
+        {
+            captureTypeDefNotSupportedException(response, error);
+        }
+        catch (TypeDefKnownException error)
+        {
+            captureTypeDefKnownException(response, error);
+        }
+        catch (TypeDefConflictException error)
+        {
+            captureTypeDefConflictException(response, error);
+        }
+        catch (InvalidTypeDefException error)
+        {
+            captureInvalidTypeDefException(response, error);
+        }
+
+        return response;
+    }
+
+
+    /**
+     * Create a definition of a new TypeDef.
+     *
+     * @param userId - unique identifier for requesting user.
+     * @param newTypeDef - TypeDef structure describing the new TypeDef.
+     * @return VoidResponse:
+     * void or
+     * InvalidParameterException - the new TypeDef is null or
+     * RepositoryErrorException - there is a problem communicating with the 
metadata repository where
+     *                                  the metadata collection is stored or
+     * TypeDefNotSupportedException - the repository is not able to support 
this TypeDef or
+     * TypeDefKnownException - the TypeDef is already stored in the repository 
or
+     * TypeDefConflictException - the new TypeDef conflicts with an existing 
TypeDef or
+     * InvalidTypeDefException - the new TypeDef has invalid contents or
+     * FunctionNotSupportedException - the repository does not support this 
call or
+     * UserNotAuthorizedException - the userId is not permitted to perform 
this operation.
+     */
+    @RequestMapping(method = RequestMethod.POST, path = 
"/{userId}/types/typedef")
+
+    public VoidResponse addTypeDef(@PathVariable String       userId,
+                                   @RequestParam TypeDef      newTypeDef)
+    {
+        final  String   methodName = "addTypeDef";
+
+        VoidResponse response = new VoidResponse();
+
+        try
+        {
+            validateLocalRepository(methodName);
+
+            localMetadataCollection.addTypeDef(userId, newTypeDef);
+        }
+        catch (FunctionNotSupportedException error)
+        {
+            captureFunctionNotSupportedException(response, error);
+        }
+        catch (RepositoryErrorException  error)
+        {
+            captureRepositoryErrorException(response, error);
+        }
+        catch (UserNotAuthorizedException error)
+        {
+            captureUserNotAuthorizedException(response, error);
+        }
+        catch (InvalidParameterException error)
+        {
+            captureInvalidParameterException(response, error);
+        }
+        catch (TypeDefNotSupportedException error)
+        {
+            captureTypeDefNotSupportedException(response, error);
+        }
+        catch (TypeDefKnownException error)
+        {
+            captureTypeDefKnownException(response, error);
+        }
+        catch (TypeDefConflictException error)
+        {
+            captureTypeDefConflictException(response, error);
+        }
+        catch (InvalidTypeDefException error)
+        {
+            captureInvalidTypeDefException(response, error);
+        }
+
+        return response;
+    }
+
+
+    /**
+     * Create a definition of a new AttributeTypeDef.
+     *
+     * @param userId - unique identifier for requesting user.
+     * @param newAttributeTypeDef - TypeDef structure describing the new 
TypeDef.
+     * @return VoidResponse:
+     * void or
+     * InvalidParameterException - the new TypeDef is null or
+     * RepositoryErrorException - there is a problem communicating with the 
metadata repository where
+     *                                  the metadata collection is stored or
+     * TypeDefNotSupportedException - the repository is not able to support 
this TypeDef or
+     * TypeDefKnownException - the TypeDef is already stored in the repository 
or
+     * TypeDefConflictException - the new TypeDef conflicts with an existing 
TypeDef or
+     * InvalidTypeDefException - the new TypeDef has invalid contents or
+     * FunctionNotSupportedException - the repository does not support this 
call or
+     * UserNotAuthorizedException - the userId is not permitted to perform 
this operation.
+     */
+    @RequestMapping(method = RequestMethod.POST, path = 
"/{userId}/types/attribute-typedef")
+
+    public  VoidResponse addAttributeTypeDef(@PathVariable String             
userId,
+                                             @RequestParam AttributeTypeDef   
newAttributeTypeDef)
+    {
+        final  String   methodName = "addAttributeTypeDef";
+
+        VoidResponse response = new VoidResponse();
+
+        try
+        {
+            validateLocalRepository(methodName);
+
+            localMetadataCollection.addAttributeTypeDef(userId, 
newAttributeTypeDef);
+        }
+        catch (FunctionNotSupportedException error)
+        {
+            captureFunctionNotSupportedException(response, error);
+        }
+        catch (RepositoryErrorException  error)
+        {
+            captureRepositoryErrorException(response, error);
+        }
+        catch (UserNotAuthorizedException error)
+        {
+            captureUserNotAuthorizedException(response, error);
+        }
+        catch (InvalidParameterException error)
+        {
+            captureInvalidParameterException(response, error);
+        }
+        catch (TypeDefNotSupportedException error)
+        {
+            captureTypeDefNotSupportedException(response, error);
+        }
+        catch (TypeDefKnownException error)
+        {
+            captureTypeDefKnownException(response, error);
+        }
+        catch (TypeDefConflictException error)
+        {
+            captureTypeDefConflictException(response, error);
+        }
+        catch (InvalidTypeDefException error)
+        {
+            captureInvalidTypeDefException(response, error);
+        }
+
+        return response;
+    }
+
+
+
+
+    /**
+     * Verify that a definition of a TypeDef is either new - or matches the 
definition already stored.
+     *
+     * @param userId - unique identifier for requesting user.
+     * @param typeDef - TypeDef structure describing the TypeDef to test.
+     * @return BooleanResponse:
+     * boolean - true means the TypeDef matches the local definition - false 
means the TypeDef is not known or
+     * InvalidParameterException - the TypeDef is null.
+     * RepositoryErrorException - there is a problem communicating with the 
metadata repository where
+     *                                  the metadata collection is stored.
+     * TypeDefNotSupportedException - the repository is not able to support 
this TypeDef.
+     * TypeDefConflictException - the new TypeDef conflicts with an existing 
TypeDef.
+     * InvalidTypeDefException - the new TypeDef has invalid contents.
+     * UserNotAuthorizedException - the userId is not permitted to perform 
this operation.
+     */
+    @RequestMapping(method = RequestMethod.GET, path = 
"/{userId}/types/typedef/compatibility")
+
+    public BooleanResponse verifyTypeDef(@PathVariable String       userId,
+                                         @RequestParam TypeDef      typeDef)
+    {
+        final  String   methodName = "verifyTypeDef";
+
+        BooleanResponse response = new BooleanResponse();
+
+        try
+        {
+            validateLocalRepository(methodName);
+
+            response.setFlag(localMetadataCollection.verifyTypeDef(userId, 
typeDef));
+        }
+        catch (RepositoryErrorException  error)
+        {
+            captureRepositoryErrorException(response, error);
+        }
+        catch (UserNotAuthorizedException error)
+        {
+            captureUserNotAuthorizedException(response, error);
+        }
+        catch (InvalidParameterException error)
+        {
+            captureInvalidParameterException(response, error);
+        }
+        catch (TypeDefNotSupportedException error)
+        {
+            captureTypeDefNotSupportedException(response, error);
+        }
+        catch (TypeDefConflictException error)
+        {
+            captureTypeDefConflictException(response, error);
+        }
+        catch (InvalidTypeDefException error)
+        {
+            captureInvalidTypeDefException(response, error);
+        }
+
+        return response;
+    }
+
+
+
+    /**
+     * Verify that a definition of an AttributeTypeDef is either new - or 
matches the definition already stored.
+     *
+     * @param userId - unique identifier for requesting user.
+     * @param attributeTypeDef - TypeDef structure describing the TypeDef to 
test.
+     * @return BooleanResponse:
+     * boolean - true means the TypeDef matches the local definition - false 
means the TypeDef is not known or
+     * InvalidParameterException - the TypeDef is null or
+     * RepositoryErrorException - there is a problem communicating with the 
metadata repository where
+     *                                  the metadata collection is stored or
+     * TypeDefNotSupportedException - the repository is not able to support 
this TypeDef or
+     * TypeDefConflictException - the new TypeDef conflicts with an existing 
TypeDef or
+     * InvalidTypeDefException - the new TypeDef has invalid contents or
+     * UserNotAuthorizedException - the userId is not permitted to perform 
this operation.
+     */
+    @RequestMapping(method = RequestMethod.GET, path = 
"/{userId}/types/attribute-typedef/compatibility")
+
+    public  BooleanResponse verifyAttributeTypeDef(@PathVariable String        
    userId,
+                                                   @RequestParam 
AttributeTypeDef  attributeTypeDef)
+    {
+        final  String   methodName = "verifyAttributeTypeDef";
+
+        BooleanResponse response = new BooleanResponse();
+
+        try
+        {
+            validateLocalRepository(methodName);
+
+            
response.setFlag(localMetadataCollection.verifyAttributeTypeDef(userId, 
attributeTypeDef));
+        }
+        catch (RepositoryErrorException  error)
+        {
+            captureRepositoryErrorException(response, error);
+        }
+        catch (UserNotAuthorizedException error)
+        {
+            captureUserNotAuthorizedException(response, error);
+        }
+        catch (InvalidParameterException error)
+        {
+            captureInvalidParameterException(response, error);
+        }
+        catch (TypeDefNotSupportedException error)
+        {
+            captureTypeDefNotSupportedException(response, error);
+        }
+        catch (TypeDefConflictException error)
+        {
+            captureTypeDefConflictException(response, error);
+        }
+        catch (InvalidTypeDefException error)
+        {
+            captureInvalidTypeDefException(response, error);
+        }
+
+        return response;
+    }
+
+
+    /**
+     * Update one or more properties of the TypeDef.  The TypeDefPatch 
controls what types of updates
+     * are safe to make to the TypeDef.
+     *
+     * @param userId - unique identifier for requesting user.
+     * @param typeDefPatch - TypeDef patch describing change to TypeDef.
+     * @return TypeDefResponse:
+     * updated TypeDef or
+     * InvalidParameterException - the TypeDefPatch is null or
+     * RepositoryErrorException - there is a problem communicating with the 
metadata repository where
+     *                                    the metadata collection is stored or
+     * TypeDefNotKnownException - the requested TypeDef is not found in the 
metadata collection or
+     * PatchErrorException - the TypeDef can not be updated because the 
supplied patch is incompatible
+     *                               with the stored TypeDef or
+     * FunctionNotSupportedException - the repository does not support this 
call or
+     * UserNotAuthorizedException - the userId is not permitted to perform 
this operation.
+     */
+    @RequestMapping(method = RequestMethod.PATCH, path = 
"/{userId}/types/typedef")
+
+    public TypeDefResponse updateTypeDef(@PathVariable String       userId,
+                                         @RequestParam TypeDefPatch 
typeDefPatch)
+    {
+        final  String   methodName = "updateTypeDef";
+
+        TypeDefResponse response = new TypeDefResponse();
+
+        try
+        {
+            validateLocalRepository(methodName);
+
+            response.setTypeDef(localMetadataCollection.updateTypeDef(userId, 
typeDefPatch));
+        }
+        catch (FunctionNotSupportedException error)
+        {
+            captureFunctionNotSupportedException(response, error);
+        }
+        catch (RepositoryErrorException  error)
+        {
+            captureRepositoryErrorException(response, error);
+        }
+        catch (UserNotAuthorizedException error)
+        {
+            captureUserNotAuthorizedException(response, error);
+        }
+        catch (InvalidParameterException error)
+        {
+            captureInvalidParameterException(response, error);
+        }
+        catch (TypeDefNotKnownException error)
+        {
+            captureTypeDefNotKnownException(response, error);
+        }
+        catch (PatchErrorException error)
+        {
+            response.setRelatedHTTPCode(error.getReportedHTTPCode());
+            
response.setExceptionClassName(PatchErrorException.class.getName());
+            response.setExceptionErrorMessage(error.getErrorMessage());
+            response.setExceptionSystemAction(error.getReportedSystemAction());
+            response.setExceptionUserAction(error.getReportedUserAction());
+        }
+
+        return response;
+    }
+
+
+    /**
+     * Delete the TypeDef.  This is only possible if the TypeDef has never 
been used to create instances or any
+     * instances of this TypeDef have been purged from the metadata collection.
+     *
+     * @param userId - unique identifier for requesting user.
+     * @param obsoleteTypeDefGUID - String unique identifier for the TypeDef.
+     * @param obsoleteTypeDefName - String unique name for the TypeDef.
+     * @return VoidResponse:
+     * void or
+     * InvalidParameterException - the one of TypeDef identifiers is null or
+     * RepositoryErrorException - there is a problem communicating with the 
metadata repository where
+     *                                    the metadata collection is stored or
+     * TypeDefNotKnownException - the requested TypeDef is not found in the 
metadata collection or
+     * TypeDefInUseException - the TypeDef can not be deleted because there 
are instances of this type in the
+     *                                 the metadata collection.  These 
instances need to be purged before the
+     *                                 TypeDef can be deleted or
+     * FunctionNotSupportedException - the repository does not support this 
call or
+     * UserNotAuthorizedException - the userId is not permitted to perform 
this operation.
+     */
+    @RequestMapping(method = RequestMethod.PATCH, path = 
"/{userId}/types/typedef/{obsoleteTypeDefGUID}")
+
+    public VoidResponse deleteTypeDef(@PathVariable String    userId,
+                                      @PathVariable String    
obsoleteTypeDefGUID,
+                                      @RequestParam String    
obsoleteTypeDefName)
+    {
+        final  String   methodName = "deleteTypeDef";
+
+        VoidResponse response = new VoidResponse();
+
+        try
+        {
+            validateLocalRepository(methodName);
+
+            localMetadataCollection.deleteTypeDef(userId, obsoleteTypeDefGUID, 
obsoleteTypeDefName);
+        }
+        catch (FunctionNotSupportedException error)
+        {
+            captureFunctionNotSupportedException(response, error);
+        }
+        catch (RepositoryErrorException  error)
+        {
+            captureRepositoryErrorException(response, error);
+        }
+        catch (UserNotAuthorizedException error)
+        {
+            captureUserNotAuthorizedException(response, error);
+        }
+        catch (InvalidParameterException error)
+        {
+            captureInvalidParameterException(response, error);
+        }
+        catch (TypeDefNotKnownException error)
+        {
+            captureTypeDefNotKnownException(response, error);
+        }
+        catch (TypeDefInUseException error)
+        {
+            captureTypeDefInUseException(response, error);
+        }
+
+        return response;
+    }
+
+
+    /**
+     * Delete an AttributeTypeDef.  This is only possible if the 
AttributeTypeDef has never been used to create
+     * instances or any instances of this AttributeTypeDef have been purged 
from the metadata collection.
+     *
+     * @param userId - unique identifier for requesting user.
+     * @param obsoleteTypeDefGUID - String unique identifier for the 
AttributeTypeDef.
+     * @param obsoleteTypeDefName - String unique name for the 
AttributeTypeDef.
+     * @return VoidResponse:
+     * void or
+     * InvalidParameterException - the one of AttributeTypeDef identifiers is 
null or
+     * RepositoryErrorException - there is a problem communicating with the 
metadata repository where
+     *                                    the metadata collection is stored or
+     * TypeDefNotKnownException - the requested AttributeTypeDef is not found 
in the metadata collection.
+     * TypeDefInUseException - the AttributeTypeDef can not be deleted because 
there are instances of this type in the
+     *                                 the metadata collection.  These 
instances need to be purged before the
+     *                                 AttributeTypeDef can be deleted or
+     * FunctionNotSupportedException - the repository does not support this 
call or
+     * UserNotAuthorizedException - the userId is not permitted to perform 
this operation.
+     */
+    @RequestMapping(method = RequestMethod.PATCH, path = 
"/{userId}/types/attribute-typedef/{obsoleteTypeDefGUID}")
+
+    public VoidResponse deleteAttributeTypeDef(@PathVariable String    userId,
+                                               @PathVariable String    
obsoleteTypeDefGUID,
+                                               @RequestParam String    
obsoleteTypeDefName)
+    {
+        final  String   methodName = "deleteAttributeTypeDef";
+
+        VoidResponse response = new VoidResponse();
+
+        try
+        {
+            validateLocalRepository(methodName);
+
+            localMetadataCollection.deleteAttributeTypeDef(userId, 
obsoleteTypeDefGUID, obsoleteTypeDefName);
+        }
+        catch (FunctionNotSupportedException error)
+        {
+            captureFunctionNotSupportedException(response, error);
+        }
+        catch (RepositoryErrorException  error)
+        {
+            captureRepositoryErrorException(response, error);
+        }
+        catch (UserNotAuthorizedException error)
+        {
+            captureUserNotAuthorizedException(response, error);
+        }
+        catch (InvalidParameterException error)
+        {
+            captureInvalidParameterException(response, error);
+        }
+        catch (TypeDefNotKnownException error)
+        {
+            captureTypeDefNotKnownException(response, error);
+        }
+        catch (TypeDefInUseException error)
+        {
+            captureTypeDefInUseException(response, error);
+        }
+
+        return response;
+    }
+
+
+    /**
+     * Change the guid or name of an existing TypeDef to a new value.  This is 
used if two different
+     * TypeDefs are discovered to have the same guid.  This is extremely 
unlikely but not impossible so
+     * the open metadata protocol has provision for this.
+     *
+     * @param userId - unique identifier for requesting user.
+     * @param originalTypeDefGUID - the original guid of the TypeDef.
+     * @param originalTypeDefName - the original name of the TypeDef.
+     * @param newTypeDefGUID - the new identifier for the TypeDef.
+     * @param newTypeDefName - new name for this TypeDef.
+     * @return TypeDefResponse:
+     * typeDef - new values for this TypeDef, including the new guid/name or
+     * InvalidParameterException - one of the parameters is invalid or null or
+     * RepositoryErrorException - there is a problem communicating with the 
metadata repository where
+     *                                    the metadata collection is stored or
+     * TypeDefNotKnownException - the TypeDef identified by the original 
guid/name is not found
+     *                                    in the metadata collection or
+     * FunctionNotSupportedException - the repository does not support this 
call or
+     * UserNotAuthorizedException - the userId is not permitted to perform 
this operation.
+     */
+    @RequestMapping(method = RequestMethod.PATCH, path = 
"/{userId}/types/typedef/{originalTypeDefGUID}/identifier")
+
+    public  TypeDefResponse reIdentifyTypeDef(@PathVariable String     userId,
+                                              @PathVariable String     
originalTypeDefGUID,
+                                              @RequestParam String     
originalTypeDefName,
+                                              @RequestParam String     
newTypeDefGUID,
+                                              @RequestParam String     
newTypeDefName)
+    {
+        final  String   methodName = "reIdentifyTypeDef";
+
+        TypeDefResponse response = new TypeDefResponse();
+
+        try
+        {
+            validateLocalRepository(methodName);
+
+            
response.setTypeDef(localMetadataCollection.reIdentifyTypeDef(userId,
+                                                                          
originalTypeDefGUID,
+                                                                          
originalTypeDefName,
+                                                                          
newTypeDefGUID,
+                                                                          
newTypeDefName));
+        }
+        catch (FunctionNotSupportedException error)
+        {
+            captureFunctionNotSupportedException(response, error);
+        }
+        catch (RepositoryErrorException  error)
+        {
+            captureRepositoryErrorException(response, error);
+        }
+        catch (UserNotAuthorizedException error)
+        {
+            captureUserNotAuthorizedException(response, error);
+        }
+        catch (InvalidParameterException error)
+        {
+            captureInvalidParameterException(response, error);
+        }
+        catch (TypeDefNotKnownException error)
+        {
+            captureTypeDefNotKnownException(response, error);
+        }
+
+        return response;
+    }
+
+
+    /**
+     * Change the guid or name of an existing TypeDef to a new value.  This is 
used if two different
+     * TypeDefs are discovered to have the same guid.  This is extremely 
unlikely but not impossible so
+     * the open metadata protocol has provision for this.
+     *
+     * @param userId - unique identifier for requesting user.
+     * @param originalAttributeTypeDefGUID - the original guid of the 
AttributeTypeDef.
+     * @param originalAttributeTypeDefName - the original name of the 
AttributeTypeDef.
+     * @param newAttributeTypeDefGUID - the new identifier for the 
AttributeTypeDef.
+     * @param newAttributeTypeDefName - new name for this AttributeTypeDef.
+     * @return AttributeTypeDefResponse:
+     * attributeTypeDef - new values for this AttributeTypeDef, including the 
new guid/name or
+     * InvalidParameterException - one of the parameters is invalid or null or
+     * RepositoryErrorException - there is a problem communicating with the 
metadata repository where
+     *                                    the metadata collection is stored or
+     * TypeDefNotKnownException - the AttributeTypeDef identified by the 
original guid/name is not
+     *                                    found in the metadata collection or
+     * FunctionNotSupportedException - the repository does not support this 
call or
+     * UserNotAuthorizedException - the userId is not permitted to perform 
this operation.
+     */
+    @RequestMapping(method = RequestMethod.PATCH, path = 
"/{userId}/types/attribute-typedef/{originalAttributeTypeDefGUID}/identifier")
+
+    public  AttributeTypeDefResponse reIdentifyAttributeTypeDef(@PathVariable 
String     userId,
+                                                                @PathVariable 
String     originalAttributeTypeDefGUID,
+                                                                @RequestParam 
String     originalAttributeTypeDefName,
+                                                                @RequestParam 
String     newAttributeTypeDefGUID,
+                                                                @RequestParam 
String     newAttributeTypeDefName)
+    {
+        final  String   methodName = "reIdentifyAttributeTypeDef";
+
+        AttributeTypeDefResponse response = new AttributeTypeDefResponse();
+
+        try
+        {
+            validateLocalRepository(methodName);
+
+            
response.setAttributeTypeDef(localMetadataCollection.reIdentifyAttributeTypeDef(userId,
+                                                                               
             originalAttributeTypeDefGUID,
+                                                                               
             originalAttributeTypeDefName,
+                                                                               
             newAttributeTypeDefGUID,
+                                                                               
             newAttributeTypeDefName));
+        }
+        catch (FunctionNotSupportedException error)
+        {
+            captureFunctionNotSupportedException(response, error);
+        }
+        catch (RepositoryErrorException  error)
+        {
+            captureRepositoryErrorException(response, error);
+        }
+        catch (UserNotAuthorizedException error)
+        {
+            captureUserNotAuthorizedException(response, error);
+        }
+        catch (InvalidParameterException error)
+        {
+            captureInvalidParameterException(response, error);
+        }
+        catch (TypeDefNotKnownException error)
+        {
+            captureTypeDefNotKnown(response, error);
+        }
+
+        return response;
+    }
+
+
+    /* ===================================================
+     * Group 3: Locating entity and relationship instances
+     */
+
+
+    /**
+     * Returns a boolean indicating if the entity is stored in the metadata 
collection.
+     *
+     * @param userId - unique identifier for requesting user.
+     * @param guid - String unique identifier for the entity.
+     * @return EntityDetailResponse:
+     * entity details if the entity is found in the metadata collection; 
otherwise return null or
+     * InvalidParameterException - the guid is null or
+     * RepositoryErrorException - there is a problem communicating with the 
metadata repository where
+     *                                  the metadata collection is stored or
+     * UserNotAuthorizedException - the userId is not permitted to perform 
this operation.
+     */
+    @RequestMapping(method = RequestMethod.GET, path = 
"/{userId}/instances/entity/{guid}/existence")
+
+    public EntityDetailResponse isEntityKnown(@PathVariable String     userId,
+                                              @PathVariable String     guid)
+    {
+        final  String   methodName = "isEntityKnown";
+
+        EntityDetailResponse response = new EntityDetailResponse();
+
+        try
+        {
+            validateLocalRepository(methodName);
+
+            response.setEntity(localMetadataCollection.isEntityKnown(userId, 
guid));
+        }
+        catch (RepositoryErrorException  error)
+        {
+            captureRepositoryErrorException(response, error);
+        }
+        catch (UserNotAuthorizedException error)
+        {
+            captureUserNotAuthorizedException(response, error);
+        }
+        catch (InvalidParameterException error)
+        {
+            captureInvalidParameterException(response, error);
+        }
+
+        return response;
+    }
+
+
+    /**
+     * Return the header and classifications for a specific entity.
+     *
+     * @param userId - unique identifier for requesting user.
+     * @param guid - String unique identifier for the entity.
+     * @return EntitySummaryResponse:
+     * EntitySummary structure or
+     * InvalidParameterException - the guid is null or
+     * RepositoryErrorException - there is a problem communicating with the 
metadata repository where
+     *                                  the metadata collection is stored or
+     * EntityNotKnownException - the requested entity instance is not known in 
the metadata collection or
+     * UserNotAuthorizedException - the userId is not permitted to perform 
this operation.
+     */
+    @RequestMapping(method = RequestMethod.GET, path = 
"/{userId}/instances/entity/{guid}/summary")
+
+    public EntitySummaryResponse getEntitySummary(@PathVariable String     
userId,
+                                                  @PathVariable String     
guid)
+    {
+        final  String   methodName = "getEntitySummary";
+
+        EntitySummaryResponse response = new EntitySummaryResponse();
+
+        try
+        {
+            validateLocalRepository(methodName);
+
+            
response.setEntity(localMetadataCollection.getEntitySummary(userId, guid));
+        }
+        catch (RepositoryErrorException  error)
+        {
+            captureRepositoryErrorException(response, error);
+        }
+        catch (UserNotAuthorizedException error)
+        {
+            captureUserNotAuthorizedException(response, error);
+        }
+        catch (InvalidParameterException error)
+        {
+            captureInvalidParameterException(response, error);
+        }
+        catch (EntityNotKnownException error)
+        {
+            captureEntityNotKnownException(response, error);
+        }
+
+        return response;
+    }
+
+
+    /**
+     * Return the header, classifications and properties of a specific entity. 
 This method supports anonymous
+     * access to an instance.  The call may fail if the metadata is secured.
+     *
+     * @param guid - String unique identifier for the entity.
+     * @return EntityDetailResponse:
+     * EntityDetail structure or
+     * InvalidParameterException - the guid is null or
+     * RepositoryErrorException - there is a problem communicating with the 
metadata repository where
+     *                                 the metadata collection is stored or
+     * EntityNotKnownException - the requested entity instance is not known in 
the metadata collection or
+     * EntityProxyOnlyException - the requested entity instance is only a 
proxy in the metadata collection or
+     * UserNotAuthorizedException - the userId is not permitted to perform 
this operation.
+     */
+    @RequestMapping(method = RequestMethod.GET, path = 
"/instances/entity/{guid}")
+
+    public EntityDetailResponse getEntityDetail(@PathVariable String     guid)
+    {
+        return this.getEntityDetail(null, guid);
+    }
+
+
+    /**
+     * Return the header, classifications and properties of a specific entity.
+     *
+     * @param userId - unique identifier for requesting user.
+     * @param guid - String unique identifier for the entity.
+     * @return EntityDetailResponse:
+     * EntityDetail structure or
+     * InvalidParameterException - the guid is null or
+     * RepositoryErrorException - there is a problem communicating with the 
metadata repository where
+     *                                 the metadata collection is stored or
+     * EntityNotKnownException - the requested entity instance is not known in 
the metadata collection or
+     * EntityProxyOnlyException - the requested entity instance is only a 
proxy in the metadata collection or
+     * UserNotAuthorizedException - the userId is not permitted to perform 
this operation.
+     */
+    @RequestMapping(method = RequestMethod.GET, path = 
"/{userId}/instances/entity/{guid}")
+
+    public EntityDetailResponse getEntityDetail(@PathVariable String     
userId,
+                                                @PathVariable String     guid)
+    {
+        final  String   methodName = "getEntityDetail";
+
+        EntityDetailResponse response = new EntityDetailResponse();
+
+        try
+        {
+            validateLocalRepository(methodName);
+
+            response.setEntity(localMetadataCollection.getEntityDetail(userId, 
guid));
+        }
+        catch (RepositoryErrorException  error)
+        {
+            captureRepositoryErrorException(response, error);
+        }
+        catch (UserNotAuthorizedException error)
+        {
+            captureUserNotAuthorizedException(response, error);
+        }
+        catch (InvalidParameterException error)
+        {
+            captureInvalidParameterException(response, error);
+        }
+        catch (EntityNotKnownException error)
+        {
+            captureEntityNotKnownException(response, error);
+        }
+        catch (EntityProxyOnlyException error)
+        {
+            captureEntityProxyOnlyException(response, error);
+        }
+
+        return response;
+    }
+
+
+    /**
+     * Return a historical versionName of an entity - includes the header, 
classifications and properties of the entity.
+     *
+     * @param userId - unique identifier for requesting user.
+     * @param guid - String unique identifier for the entity.
+     * @param asOfTime - the time used to determine which versionName of the 
entity that is desired.
+     * @return EnityDetailResponse:
+     * EntityDetail structure or
+     * InvalidParameterException - the guid or date is null or the asOfTime 
property is for a future time or
+     * RepositoryErrorException - there is a problem communicating with the 
metadata repository where
+     *                                 the metadata collection is stored or
+     * EntityNotKnownException - the requested entity instance is not known in 
the metadata collection
+     *                                   at the time requested or
+     * EntityProxyOnlyException - the requested entity instance is only a 
proxy in the metadata collection or
+     * FunctionNotSupportedException - the repository does not support 
satOfTime parameter or
+     * UserNotAuthorizedException - the userId is not permitted to perform 
this operation.
+     */
+    @RequestMapping(method = RequestMethod.GET, path = 
"/{userId}/instances/entity/{guid}/history")
+
+    public  EntityDetailResponse getEntityDetail(@PathVariable String     
userId,
+                                                 @PathVariable String     guid,
+                                                 @RequestParam Date       
asOfTime)
+    {
+        final  String   methodName = "getEntityDetail";
+
+        EntityDetailResponse response = new EntityDetailResponse();
+
+        try
+        {
+            validateLocalRepository(methodName);
+
+            response.setEntity(localMetadataCollection.getEntityDetail(userId, 
guid, asOfTime));
+        }
+        catch (RepositoryErrorException  error)
+        {
+            captureRepositoryErrorException(response, error);
+        }
+        catch (FunctionNotSupportedException  error)
+        {
+            captureFunctionNotSupportedException(response, error);
+        }
+        catch (UserNotAuthorizedException error)
+        {
+            captureUserNotAuthorizedException(response, error);
+        }
+        catch (InvalidParameterException error)
+        {
+            captureInvalidParameterException(response, error);
+        }
+        catch (EntityNotKnownException error)
+        {
+            captureEntityNotKnownException(response, error);
+        }
+        catch (EntityProxyOnlyException error)
+        {
+            captureEntityProxyOnlyException(response, error);
+        }
+
+        return response;
+    }
+
+
+
+    /**
+     * Return the relationships for a specific entity.
+     *
+     * @param userId - unique identifier for requesting user.
+     * @param entityGUID - String unique identifier for the entity.
+     * @param relationshipTypeGUID - String GUID of the the type of 
relationship required (null for all).
+     * @param fromRelationshipElement - the starting element number of the 
relationships to return.
+     *                                This is used when retrieving elements
+     *                                beyond the first page of results. Zero 
means start from the first element.
+     * @param limitResultsByStatus - By default, relationships in all statuses 
are returned.  However, it is possible
+     *                             to specify a list of statuses (eg ACTIVE) 
to restrict the results to.  Null means all
+     *                             status values.
+     * @param asOfTime - Requests a historical query of the relationships for 
the entity.  Null means return the
+     *                 present values.
+     * @param sequencingProperty - String name of the property that is to be 
used to sequence the results.
+     *                           Null means do not sequence on a property name 
(see SequencingOrder).
+     * @param sequencingOrder - Enum defining how the results should be 
ordered.
+     * @param pageSize -- the maximum number of result classifications that 
can be returned on this request.  Zero means
+     *                 unrestricted return results size.
+     * @return RelationshipListResponse:
+     * Relationships list.  Null means no relationships associated with the 
entity or
+     * InvalidParameterException - a parameter is invalid or null or
+     * RepositoryErrorException - there is a problem communicating with the 
metadata repository where
+     *                                  the metadata collection is stored or
+     * EntityNotKnownException - the requested entity instance is not known in 
the metadata collection or
+     * PropertyErrorException - the sequencing property is not valid for the 
attached classifications or
+     * PagingErrorException - the paging/sequencing parameters are set up 
incorrectly or
+     * FunctionNotSupportedException - the repository does not support 
satOfTime parameter or
+     * UserNotAuthorizedException - the userId is not permitted to perform 
this operation or
+     */
+    @RequestMapping(method = RequestMethod.GET, path = 
"/{userId}/instances/entity/{entityGUID}/relationships")
+
+    public RelationshipListResponse getRelationshipsForEntity(@PathVariable    
               String                     userId,
+                                                              @PathVariable    
               String                     entityGUID,
+                                                              
@RequestParam(required = false) String                     relationshipTypeGUID,
+                                                              
@RequestParam(required = false) int                        
fromRelationshipElement,
+                                                              
@RequestParam(required = false) List<InstanceStatus>       limitResultsByStatus,
+                                                              
@RequestParam(required = false) Date                       asOfTime,
+                                                              
@RequestParam(required = false) String                     sequencingProperty,
+                                                              
@RequestParam(required = false) SequencingOrder            sequencingOrder,
+                                                              
@RequestParam(required = false) int                        pageSize)
+    {
+        final  String   methodName = "getRelationshipsForEntity";
+
+        RelationshipListResponse response = new RelationshipListResponse();
+
+        try
+        {
+            validateLocalRepository(methodName);
+
+            List<Relationship>  relationships = 
localMetadataCollection.getRelationshipsForEntity(userId,
+                                                                               
                   entityGUID,
+                                                                               
                   relationshipTypeGUID,
+                                                                               
                   fromRelationshipElement,
+                                                                               
                   limitResultsByStatus,
+                                                                               
                   asOfTime,
+                                                                               
                   sequencingProperty,
+                                                                               
                   sequencingOrder,
+                                                                               
                   pageSize);
+            response.setRelationships(relationships);
+            if (relationships != null)
+            {
+                response.setOffset(fromRelationshipElement);
+                response.setPageSize(pageSize);
+                if (response.getRelationships().size() == pageSize)
+                {
+                    final String urlTemplate = 
"{0}/instances/entity/{1}/relationships?relationshipTypeGUID={2}&fromRelationshipElement={3}&limitResultsByStatus={4}&asOfTime={5}&sequencingProperty={6}&sequencingOrder={7}&pageSize={8}";
+
+                    response.setNextPageURL(formatNextPageURL(localServerURL + 
urlTemplate,
+                                                              userId,
+                                                              entityGUID,
+                                                              
relationshipTypeGUID,
+                                                              
fromRelationshipElement + pageSize,
+                                                              
limitResultsByStatus,
+                                                              asOfTime,
+                                                              
sequencingProperty,
+                                                              sequencingOrder,
+                                                              pageSize));
+                }
+            }
+
+        }
+        catch (RepositoryErrorException  error)
+        {
+            captureRepositoryErrorException(response, error);
+        }
+        catch (FunctionNotSupportedException  error)
+        {
+            captureFunctionNotSupportedException(response, error);
+        }
+        catch (UserNotAuthorizedException error)
+        {
+            captureUserNotAuthorizedException(response, error);
+        }
+        catch (InvalidParameterException error)
+        {
+            captureInvalidParameterException(response, error);
+        }
+        catch (EntityNotKnownException error)
+        {
+            captureEntityNotKnownException(response, error);
+        }
+        catch (PropertyErrorException error)
+        {
+            capturePropertyErrorException(response, error);
+        }
+        catch (PagingErrorException error)
+        {
+            capturePagingErrorException(response, error);
+        }
+
+        return response;
+    }
+
+
+    /**
+     * Return a list of entities that match the supplied properties according 
to the match criteria.  The results
+     * can be returned over many pages.
+     *
+     * @param userId - unique identifier for requesting user.
+     * @param entityTypeGUID - String unique identifier for the entity type of 
interest (null means any entity type).
+     * @param matchProperties - List of entity properties to match to (null 
means match on entityTypeGUID only).
+     * @param matchCriteria - Enum defining how the properties should be 
matched to the entities in the repository.
+     * @param fromEntityElement - the starting element number of the entities 
to return.
+     *                                This is used when retrieving elements
+     *                                beyond the first page of results. Zero 
means start from the first element.
+     * @param limitResultsByStatus - By default, entities in all statuses are 
returned.  However, it is possible
+     *                             to specify a list of statuses (eg ACTIVE) 
to restrict the results to.  Null means all
+     *                             status values.
+     * @param limitResultsByClassification - List of classifications that must 
be present on all returned entities.
+     * @param asOfTime - Requests a historical query of the entity.  Null 
means return the present values.
+     * @param sequencingProperty - String name of the entity property that is 
to be used to sequence the results.
+     *                           Null means do not sequence on a property name 
(see SequencingOrder).
+     * @param sequencingOrder - Enum defining how the results should be 
ordered.
+     * @param pageSize - the maximum number of result entities that can be 
returned on this request.  Zero means
+     *                 unrestricted return results size.
+     * @return EntityListResponse:
+     * a list of entities matching the supplied criteria - null means no 
matching entities in the metadata
+     * collection or
+     * InvalidParameterException - a parameter is invalid or null or
+     * RepositoryErrorException - there is a problem communicating with the 
metadata repository where
+     *                                    the metadata collection is stored or
+     * TypeErrorException - the type guid passed on the request is not known 
by the
+     *                              metadata collection or
+     * PropertyErrorException - the properties specified are not valid for any 
of the requested types of
+     *                                  entity or
+     * PagingErrorException - the paging/sequencing parameters are set up 
incorrectly or
+     * FunctionNotSupportedException - the repository does not support 
satOfTime parameter or
+     * UserNotAuthorizedException - the userId is not permitted to perform 
this operation.
+     */
+    @RequestMapping(method = RequestMethod.GET, path = 
"/{userId}/instances/entities/by-property")
+
+    public  EntityListResponse findEntitiesByProperty(@PathVariable            
       String                    userId,
+                                                      @RequestParam(required = 
false) String                    entityTypeGUID,
+                                                      @RequestParam(required = 
false) InstanceProperties        matchProperties,
+                                                      @RequestParam(required = 
false) MatchCriteria             matchCriteria,
+                                                      @RequestParam(required = 
false) int                       fromEntityElement,
+                                                      @RequestParam(required = 
false) List<InstanceStatus>      limitResultsByStatus,
+                                                      @RequestParam(required = 
false) List<String>              limitResultsByClassification,
+                                                      @RequestParam(required = 
false) Date                      asOfTime,
+                                                      @RequestParam(required = 
false) String                    sequencingProperty,
+                                                      @RequestParam(required = 
false) SequencingOrder           sequencingOrder,
+                                                      @RequestParam(required = 
false) int                       pageSize)
+    {
+        final  String   methodName = "findEntitiesByProperty";
+
+        EntityListResponse response = new EntityListResponse();
+
+        try
+        {
+            validateLocalRepository(methodName);
+
+            List<EntityDetail>  entities = 
localMetadataCollection.findEntitiesByProperty(userId,
+                                                                               
           entityTypeGUID,
+                                                                               
           matchProperties,
+                                                                               
           matchCriteria,
+                                                                               
           fromEntityElement,
+                                                                               
           limitResultsByStatus,
+                                                                               
           limitResultsByClassification,
+                                                                               
           asOfTime,
+                                                                               
           sequencingProperty,
+                                                                               
           sequencingOrder,
+                                                                               
           pageSize);
+            response.setEntities(entities);
+            if (entities != null)
+            {
+                response.setOffset(fromEntityElement);
+                response.setPageSize(pageSize);
+                if (entities.size() == pageSize)
+                {
+                    final String urlTemplate = 
"{0}/instances/entities/by-property?entityTypeGUID={1}&matchProperties={2}&matchCriteria={3}&fromEntityElement={4}&limitResultsByStatus={5}&limitResultsByClassification={6}&asOfTime={7}&sequencingProperty={8}&sequencingOrder={9}&pageSize={10}";
+
+                    response.setNextPageURL(formatNextPageURL(localServerURL + 
urlTemplate,
+                                                              userId,
+                                                              entityTypeGUID,
+                                                              matchProperties,
+                                                              matchCriteria,
+                                                              
fromEntityElement + pageSize,
+                                                              
limitResultsByStatus,
+                                                              
limitResultsByClassification,
+                                                              asOfTime,
+                                                              
sequencingProperty,
+                                                              sequencingOrder,
+                                                              pageSize));
+                }
+            }
+
+        }
+        catch (RepositoryErrorException  error)
+        {
+            captureRepositoryErrorException(response, error);
+        }
+        catch (FunctionNotSupportedException  error)
+        {
+            captureFunctionNotSupportedException(response, error);
+        }
+        catch (UserNotAuthorizedException error)
+        {
+            captureUserNotAuthorizedException(response, error);
+        }
+        catch (InvalidParameterException error)
+        {
+            captureInvalidParameterException(response, error);
+        }
+        catch (TypeErrorException error)
+        {
+            captureTypeErrorException(response, error);
+        }
+        catch (PropertyErrorException error)
+        {
+            capturePropertyErrorException(response, error);
+        }
+        catch (PagingErrorException error)
+        {
+            capturePagingErrorException(response, error);
+        }
+
+        return response;
+    }
+
+
+    /**
+     * Return a list of entities that have the requested type of 
classification attached.
+     *
+     * @param userId - unique identifier for requesting user.
+     * @param entityTypeGUID - unique identifier for the type of entity 
requested.  Null mans any type of entity.
+     * @param classificationName - name of the classification - a null is not 
valid.
+     * @param matchClassificationProperties - list of classification 
properties used to narrow the search.
+     * @param matchCriteria - Enum defining how the properties should be 
matched to the classifications in the repository.
+     * @param fromEntityElement - the starting element number of the entities 
to return.
+     *                                This is used when retrieving elements
+     *                                beyond the first page of results. Zero 
means start from the first element.
+     * @param limitResultsByStatus - By default, entities in all statuses are 
returned.  However, it is possible
+     *                             to specify a list of statuses (eg ACTIVE) 
to restrict the results to.  Null means all
+     *                             status values.
+     * @param asOfTime - Requests a historical query of the entity.  Null 
means return the present values.
+     * @param sequencingProperty - String name of the entity property that is 
to be used to sequence the results.
+     *                           Null means do not sequence on a property name 
(see SequencingOrder).
+     * @param sequencingOrder - Enum defining how the results should be 
ordered.
+     * @param pageSize - the maximum number of result entities that can be 
returned on this request.  Zero means
+     *                 unrestricted return results size.
+     * @return EntityListResponse:
+     * a list of entities matching the supplied criteria - null means no 
matching entities in the metadata
+     * collection or
+     * InvalidParameterException - a parameter is invalid or null or
+     * RepositoryErrorException - there is a problem communicating with the 
metadata repository where
+     *                                    the metadata collection is stored or
+     * TypeErrorException - the type guid passed on the request is not known 
by the
+     *                              metadata collection or
+     * ClassificationErrorException - the classification request is not known 
to the metadata collection.
+     * PropertyErrorException - the properties specified are not valid for the 
requested type of
+     *                                  classification or
+     * PagingErrorException - the paging/sequencing parameters are set up 
incorrectly or
+     * FunctionNotSupportedException - the repository does not support 
satOfTime parameter or
+     * UserNotAuthorizedException - the userId is not permitted to perform 
this operation.
+     */
+    @RequestMapping(method = RequestMethod.GET, path = 
"/{userId}/instances/entities/by-classification/{classificationName}")
+
+    public  EntityListResponse findEntitiesByClassification(@PathVariable      
             String                    userId,
+                                                            
@RequestParam(required = false) String                    entityTypeGUID,
+                                                            @PathVariable      
             String                    classificationName,
+                                                            
@RequestParam(required = false) InstanceProperties        
matchClassificationProperties,
+                                                            
@RequestParam(required = false) MatchCriteria             matchCriteria,
+                                                            
@RequestParam(required = false) int                       fromEntityElement,
+                                                            
@RequestParam(required = false) List<InstanceStatus>      limitResultsByStatus,
+                                                            
@RequestParam(required = false) Date                      asOfTime,
+                                                            
@RequestParam(required = false) String                    sequencingProperty,
+                                                            
@RequestParam(required = false) SequencingOrder           sequencingOrder,
+                                                            
@RequestParam(required = false) int                       pageSize)
+    {
+        final  String   methodName = "findEntitiesByClassification";
+
+        EntityListResponse response = new EntityListResponse();
+
+        try
+        {
+            validateLocalRepository(methodName);
+
+            List<EntityDetail>  entities = 
localMetadataCollection.findEntitiesByClassification(userId,
+                                                                               
                 entityTypeGUID,
+                                                                               
                 classificationName,
+                                                                               
                 matchClassificationProperties,
+                                                                               
                 matchCriteria,
+                                                                               
                 fromEntityElement,
+                                                                               
                 limitResultsByStatus,
+                                                                               
                 asOfTime,
+                                                                               
                 sequencingProperty,
+                                                                               
                 sequencingOrder,
+                                                                               
                 pageSize);
+            response.setEntities(entities);
+            if (entities != null)
+            {
+                response.setOffset(fromEntityElement);
+                response.setPageSize(pageSize);
+                if (entities.size() == pageSize)
+                {
+                    final String urlTemplate = 
"{0}/instances/entities/by-classification/{1}?entityTypeGUID={2}&matchClassificationProperties={3}&matchCriteria={4}&fromEntityElement={5}&limitResultsByStatus={6}&asOfTime={7}&sequencingProperty={8}&sequencingOrder={9}&pageSize={10}";
+
+                    response.setNextPageURL(formatNextPageURL(localServerURL + 
urlTemplate,
+                                                              userId,
+                                                              entityTypeGUID,
+                                                              
classificationName,
+                                                              
matchClassificationProperties,
+                                                              matchCriteria,
+                                                              
fromEntityElement + pageSize,
+                                                              
limitResultsByStatus,
+                                                              asOfTime,
+                                                              
sequencingProperty,
+                                                              sequencingOrder,
+                                                              pageSize));
+                }
+            }
+        }
+        catch (RepositoryErrorException  error)
+        {
+            captureRepositoryErrorException(response, error);
+        }
+        catch (FunctionNotSupportedException  error)
+        {
+            captureFunctionNotSupported

<TRUNCATED>

Reply via email to