Metadata Manager

From Gcube Wiki
Revision as of 12:31, 22 June 2009 by Lucio.lelii (Talk | contribs) (Usage Examples)

Jump to: navigation, search

Introduction

The Metadata Manager service manages the modelling of arbitrary metadata relationships (IDB-relationships). The only assumption it does is that the metadata objects are serialized as well-formed XML documents. The service has a two-fold role:

  • to manage Metadata Objects and Metadata Collections
  • to establish secondary role-typed links. Such relationships can be in place between any type of Information Object and in the scope of a Collection or not

Clients interacts also with the Metadata Manager library for a higher level of abstraction which simplifies clients interaction with the service.

Metadata Object

A Metadata Object (MO) is a source Information Object for an IDB-relationship. An MO can be associated to one and only one target Information Object (even if in the context of different Metadata Collections) which is described by the MO. An MO here is always intended as an XML document wrapped in a well defined envelope. As to content, the Metadata Manager Service adopts an exchange model to add a number of system-level properties needed for the appropriate management of the Metadata Objects within the context of the Metadata Manager Service.

The Metadata Manager Components

The main functionality of the Metadata Manager components is the management of Metadata Objects, Metadata Collection and their relationships. To operate over Metadata Collections, the Metadata Catalog instantiates Collection Managers (or shortly, Managers) for each collection. A Collection Manager is the access point to all the possible operations over a specific Metadata Collection. From an architectural point of view, the Metadata Manager adopts the Factory pattern and Collection Managers are implemented as a stateful WS-Resource. Physically, the service is composed by:

  • the MetadataManagerFactory, a factory service that creates new Collection Managers and offers some cross-Collection operations
  • the MetadataManagerService, a service that operates over Metadata Collections (MCs) and on Metadata Objects as Elements, i.e. members of a specific Metadata Collection


MetadataManagerFactory

The MetadataManagerFactory Service creates new Collection Managers and offers some cross-Collection operations. Moreover, it operates on Metadata Objects as Information Objects related to other Information Objects and not as Members of Metadata Collections.

  • EndPointReferenceType createManager(CollectionID, params): This operation takes a set of creation parameters and creates a new Manager in order to manage a Metadata Collection bound to such a Collection. If a Metadata Collection with the specified Metadata characteristics does not exist, the Manager creates the Metadata Collection, binds it with the Document Collection with the given secondary role relationship and publishes its profile in the IS. The Creation parameters are a set of key-value; the following keys are defined in the MMLibrary and accepted by the operation:

These ones are mandatory:

    • COLLECTIONNAME -> name of the collection
    • METADATANAME -> metadata name (e.g. “dc”)
    • METADATALANG -> metadata language (e.g. “English”), as specified in the ISO 639-2
    • METADATAURI -> metadata URI: the XML Schema that defines the MO payloads
    • ROLE -> secondary role

The optional ones are:

    • DESCRIPTION -> description
    • INDEXABLE -> if the collection is indexable or not (“True”/”False”)
    • USER -> if the collection is a user collection or not (“True”/”False”)
    • RELATEDBY_COLLID -> the id of the source content collection
    • RELATEDBY_ROLE -> the source XML Schema from which the current one has been generated
    • GENERATEDBY_COLLID -> the source Metadata Collection from which the current one has been generated (by the Metadata Broker), if any
    • GENERATEDBY_URI -> the URI of the source schema of the collection from which it has been generated
    • Among the others, two parameters can modify the way in which the Metadata Collection is managed:
      • Indexable: if the new Metadata Collection is indexable, the Manager creates also a new MetadataXMLIndexer (see Section 4.2.2.3) for such a Collection using the XMLIndexer Service;
      • User: a user Collection is shown in the Portals and an end-user can operate on it; a non-user Collection is intended for internal puporses (like to collect parts of persisted Indexes).
  • ResultSetService
  • EndPointReferenceType createManagerFromCollection (MetadataCollectionID): This operation takes a Metadata Collection ID. It returns:
    • the related CollectionManager, if it already exists
    • creates a new CollectionManager and returns its EPR, if the Metadata Collection exists
    • an error, if the Collection ID is not valid
  • MOID addMetadata(ObjectID, MO, SecondaryRole): This operation takes a new non-collectable Metadata Object and
    • completes the metadata header information (e.g. the MOID, if it is not specified)
    • stores (or updates if the MOID is already included in the MO header) the object on the Storage Management Service as Information Object
    • creates a <is-described-by, <SecondaryRole>> binding in the Storage Management Service between the Metadata Object and the Information Object identified by the given Object ID
    • returns the assigned MOID
  • void deleteMetadata(MOID): This operation deletes from the Storage Management Service the Metadata Object identified by the given ID.
  • (ObjectID, (MO, SecondaryRole)[])[] getMetadata ((ObjectID, SecondaryRole, CollectionID, Rank)[]): For each given ObjectID, this operation returns the Metadata Objets. They are:
    • bound with the specified secondary role (the primary role is, of course, is-described-by) to the Information Object identified by that ObjectID
    • members of the specified Metadata Collection. The operation relies on the String[] retrieveReferred(String targetObjectID, String role, String secondaryrole) operation of the Storage Management Service.

The MMLibrary

The library offers a number of facilities for interacting with the creation and manipulation of Metadata Object.

First of all,the library operates at client-side by moving some of the logic on that side avoiding unnecessary interactions between clients and the Metadata Manager service.

The library offers a a set of method to easily wrap an XML documents in the model exchanged format as required by Metadata Manager service. In addition, the library offers support for wrap the Object with the appropriate metadata envelope, to create a valid Metadata Object that can be stored on the Metadata Manager Service.

In addition, the library permits to extract the basic MO information from a string representing a Metadata Object.

Dependencies

These are the dependencies of the Service :


  • MMLibrary
  • XMLIndexer
  • ResultSetService
  • ResultSetLibrary
  • ResultSetClientLibrary
  • ContentManagement
  • ContentManagementService
  • ContentManagementLibrary

Usage Examples

This example shows how to create a MetadataManager:


...

                String factoryURI ="http://node2.d.d4science.research-infrastructures.eu:8080/wsrf/services/gcube/metadatamanagement/metadatamanager/MetadataManagerFactory";
										
		String id = args[0]; // collection name
		
		MetadataManagerFactoryServiceAddressingLocator factoryLocator = new MetadataManagerFactoryServiceAddressingLocator();
		//MetadataManagerServiceAddressingLocator  instanceLocator = new MetadataManagerServiceAddressingLocator();
		MetadataManagerFactoryPortType mFactory;

		try {			
			EndpointReferenceType factoryEPR = new EndpointReferenceType();
			factoryEPR.setAddress(new Address(factoryURI));
			
			
			System.out.println("Creating the new Factory portType");

			mFactory= factoryLocator.getMetadataManagerFactoryPortTypePort(factoryEPR);

			System.out.println("Created instance.\n");
			
			CreateManagerRequest request = new CreateManagerRequest();
			request.setCollectionID(id);			
			CollectionParameter [] ss = new CollectionParameter[6];
			CreateCollectionParameters ccp = new CreateCollectionParameters();			
			
			for ( int i =0; i<ss.length; i++ )
				ss[i] = new CollectionParameter();
			
			ss[0].setName(CreationParameters.COLLECTIONNAME.toString());
			ss[0].setValue(id);	
			
			
			// metadatalang, metadataname, metadataformat are all used for MetadataFormat 
			// they are mandatory
			ss[1].setName(CreationParameters.METADATALANG.toString());
			ss[1].setValue("en");
			
			ss[2].setName(CreationParameters.METADATANAME.toString());
			ss[2].setValue("dc");
			
			ss[3].setName(CreationParameters.METADATAURI.toString());
			ss[3].setValue("http://mail.google.com/mail");
			
			ss[4].setName(CreationParameters.ROLE.toString());
			ss[4].setValue(SecondaryRoleDescription.ROLE_GENERATION);
			
	String factoryURI = //"http://dlib31.isti.cnr.it:8080/wsrf/services/gcube/metadatamanagement/metadatamanager/MetadataManagerFactory";
				"http://node2.d.d4science.research-infrastructures.eu:8080/wsrf/services/gcube/metadatamanagement/metadatamanager/MetadataManagerFactory";
										
		String id = "CMProve";     
		if (args.length ==1) 
        	id = args[0];
		
		MetadataManagerFactoryServiceAddressingLocator factoryLocator = new MetadataManagerFactoryServiceAddressingLocator();
		//MetadataManagerServiceAddressingLocator  instanceLocator = new MetadataManagerServiceAddressingLocator();
		MetadataManagerFactoryPortType mFactory;

		try {			
			EndpointReferenceType factoryEPR = new EndpointReferenceType();
			factoryEPR.setAddress(new Address(factoryURI));
			
			
			System.out.println("Creating the new Factory portType");

			mFactory= factoryLocator.getMetadataManagerFactoryPortTypePort(factoryEPR);

			System.out.println("Created instance.\n");
			
			CreateManagerRequest request = new CreateManagerRequest();
			request.setCollectionID(id);			
			CollectionParameter [] ss = new CollectionParameter[8];
			CreateCollectionParameters ccp = new CreateCollectionParameters();			
			
			for ( int i =0; i<ss.length; i++ )
				ss[i] = new CollectionParameter();
			
			ss[0].setName(CreationParameters.COLLECTIONNAME.toString());
			ss[0].setValue(id);
			System.out.println("COLLECTIONNAME:"+id);			
			/*ss[1].setName(CreationParameters.DESCRIPTION.toString());
			ss[1].setValue("Description Metadata Collection");			
			String editable = "True";
			ss[2].setName(CreationParameters.EDITABLE.toString());
			ss[2].setValue(editable);*/
			
			/*System.out.println(CreationParameters.DESCRIPTION.toString()+": Description Metadata Collection");
			System.out.println(CreationParameters.EDITABLE.toString()+ ": "+editable);
			
			// Indexable mandatory
			String indexable = "True";
			
			ss[3].setName(CreationParameters.INDEXABLE.toString());
			ss[3].setValue(indexable);
			
			System.out.println(CreationParameters.INDEXABLE.toString() +": "+indexable);		
			
			String user = "True";
			ss[4].setName(CreationParameters.USER.toString());
			ss[4].setValue(user);
			System.out.println(CreationParameters.USER.toString()+": " +user);*/
			
			// metadatalang, metadataname, metadataformat are all used for MetadataFormat 
			// they are mandatory
			ss[1].setName(CreationParameters.METADATALANG.toString());
			ss[1].setValue("en");
			
			ss[2].setName(CreationParameters.METADATANAME.toString());
			ss[2].setValue("dc");
			
			ss[3].setName(CreationParameters.METADATAURI.toString());
			ss[3].setValue("http://mail.google.com/mail");
			
			ss[4].setName(CreationParameters.ROLE.toString());
			ss[4].setValue(SecondaryRoleDescription.ROLE_GENERATION);
			
			ss[5].setName(CreationParameters.INDEXABLE.toString());
			ss[5].setValue("true");
			//String relatedbyCollID = "3971d1a0-4771-11dd-8639-ae5f2f1f5aef";
		
			
			String generatedbyCollID = "1222d1a0-4771-11dd-8639-ae5f2f1f5ae";
			ss[6].setName(CreationParameters.GENERATEDBY_COLLID.toString());
			ss[6].setValue(generatedbyCollID);
			System.out.println(CreationParameters.GENERATEDBY_COLLID.toString() + ": GeneratedID");			
			ss[7].setName(CreationParameters.GENERATEDBY_URI.toString());
			ss[7].setValue("http://mail.google.com/mail");
						
			ccp.setParams(ss);
			request.setCollectionParameters(ccp);
			CreateManagerResponse response  = new CreateManagerResponse();
			try{
				 mFactory = GCUBERemotePortTypeContext.getProxy(mFactory,GCUBEScope.getScope("/gcube/devsec"));	 	               
				response = mFactory.createManager(request);
			}catch(Exception e ){
				e.printStackTrace();
				return;
			}
			
			System.out.println("Created MC:"+response.getEndpointReference().toString());
		} catch (Exception e) {
			e.getMessage();
			e.printStackTrace();	
		}
	}		
....