org.gcube.portlets.user.collectionexplorer.server
Class MetadataConverter

java.lang.Object
  extended by org.gcube.portlets.user.collectionexplorer.server.MetadataConverter

public class MetadataConverter
extends Object

Author:
Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it

Field Summary
protected  Map<String,String> schemaNameId
          Schema name to XSLT generic resource id map.
protected  boolean setup
           
protected  Map<String,String> xsltCache
          Id to XSLT map cache.
 
Constructor Summary
MetadataConverter(CollectionServiceImpl myServlet)
          Create a new MetadataConverter.
 
Method Summary
 String convert(String schemaName, String xml, org.gcube.application.framework.core.session.ASLSession d4session)
          Convert the given metadata XML to HTML.
 String convertUsingDefault(String xml, org.gcube.application.framework.core.session.ASLSession d4session)
          Convert the given XML to HTML using the default XSLT.
protected  String getDefaultXSLT()
           
protected  String getXSL(String xsltId, org.gcube.application.framework.core.session.ASLSession d4session)
          Get a XSLT from is id.
 void isReady()
           
protected  String retrieveXSLT(String xslId, org.gcube.application.framework.core.session.ASLSession d4session)
          Retrieve a schema from his generic resource.
protected  void retrieveXSLTIds(org.gcube.application.framework.core.session.ASLSession session)
          Retrieve from user profile all transformation schemas id.
 void setup(org.gcube.application.framework.core.session.ASLSession d4session)
          Load user xslt.
protected  String transform(String xml, String xslt)
          Transform an XML string to HTML string using an XSLT processor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

schemaNameId

protected Map<String,String> schemaNameId
Schema name to XSLT generic resource id map.


xsltCache

protected Map<String,String> xsltCache
Id to XSLT map cache.


setup

protected boolean setup
Constructor Detail

MetadataConverter

public MetadataConverter(CollectionServiceImpl myServlet)
Create a new MetadataConverter.

Method Detail

setup

public void setup(org.gcube.application.framework.core.session.ASLSession d4session)
Load user xslt.

Parameters:
d4session -

isReady

public void isReady()

convert

public String convert(String schemaName,
                      String xml,
                      org.gcube.application.framework.core.session.ASLSession d4session)
               throws Exception
Convert the given metadata XML to HTML.

Parameters:
schemaName -
xml -
d4session -
Returns:
Throws:
Exception

convertUsingDefault

public String convertUsingDefault(String xml,
                                  org.gcube.application.framework.core.session.ASLSession d4session)
                           throws Exception
Convert the given XML to HTML using the default XSLT.

Parameters:
xml - the XML to convert.
d4session - the user session.
Returns:
the HTML.
Throws:
Exception

retrieveXSLTIds

protected void retrieveXSLTIds(org.gcube.application.framework.core.session.ASLSession session)
Retrieve from user profile all transformation schemas id.

Parameters:
d4session -

getXSL

protected String getXSL(String xsltId,
                        org.gcube.application.framework.core.session.ASLSession d4session)
                 throws RemoteException
Get a XSLT from is id. If the XSLT is not in the cache then is retrieved from IS.

Parameters:
xsltId - the XSLT id.
d4session -
Returns:
the XSLT.
Throws:
RemoteException

retrieveXSLT

protected String retrieveXSLT(String xslId,
                              org.gcube.application.framework.core.session.ASLSession d4session)
                       throws RemoteException
Retrieve a schema from his generic resource.

Parameters:
xslId - the schema id.
d4session -
Returns:
the schema.
Throws:
RemoteException

transform

protected String transform(String xml,
                           String xslt)
                    throws TransformerException
Transform an XML string to HTML string using an XSLT processor.

Parameters:
xml - the XML to convert.
xslt - the XML used for the conversion.
Returns:
the HTML.
Throws:
TransformerException - if an error occurs.

getDefaultXSLT

protected String getDefaultXSLT()
                         throws IOException
Returns:
Throws:
IOException


Copyright © 2014. All Rights Reserved.