Class DocumentViewCodecService
- java.lang.Object
-
- org.nuxeo.runtime.model.DefaultComponent
-
- org.nuxeo.ecm.platform.url.service.DocumentViewCodecService
-
- All Implemented Interfaces:
Serializable
,DocumentViewCodecManager
,Adaptable
,Component
,Extensible
,TimestampedService
public class DocumentViewCodecService extends DefaultComponent implements DocumentViewCodecManager
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,DocumentViewCodec>
codecs
static String
CODECS_EXTENSION_POINT
protected String
defaultCodecName
protected Map<String,DocumentViewCodecDescriptor>
descriptors
static String
NAME
-
Fields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name
-
-
Constructor Summary
Constructors Constructor Description DocumentViewCodecService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
deactivate(ComponentContext context)
Deactivates the component.<T> T
getAdapter(Class<T> adapter)
Returns an object which is an instance of the given class associated with this object.DocumentViewCodec
getCodec()
DocumentViewCodec
getCodec(String codecName)
Returns theDocumentViewCodec
with the given name ornull
if ot doesn't exist.String
getDefaultCodecName()
Returns the default codec name.List<String>
getDocumentViewCodecDescriptorNames()
DocumentView
getDocumentViewFromUrl(String url, boolean hasBaseUrl, String baseUrl)
Returns a DocumentView applying for given url, or null.DocumentView
getDocumentViewFromUrl(String codecName, String url, boolean hasBaseUrl, String baseUrl)
Returns a DocumentView callingDocumentViewCodec.getDocumentViewFromUrl(String)
on codec with given name.protected DocumentView
getDocumentViewFromUrl(DocumentViewCodec codec, String finalUrl)
String
getUrlFromDocumentView(String codecName, DocumentView docView, boolean needBaseUrl, String baseUrl)
Returns an URL callingDocumentViewCodec.getUrlFromDocumentView(DocumentView)
on codec with given name.String
getUrlFromDocumentView(DocumentView docView, boolean needBaseUrl, String baseUrl)
Returns an URL applying for given document view, or null.protected String
getUrlFromDocumentView(DocumentViewCodec codec, DocumentView docView, boolean needBaseUrl, String baseUrl)
protected String
getUrlWithoutBase(String url, boolean hasBaseUrl, String baseUrl)
void
registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
void
unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
-
Methods inherited from class org.nuxeo.runtime.model.DefaultComponent
activate, addRuntimeMessage, addRuntimeMessage, getDescriptor, getDescriptors, getLastModified, getRegistry, register, registerExtension, setLastModified, setModifiedNow, setName, start, stop, unregister, unregisterExtension
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuxeo.runtime.model.Component
applicationStarted, getApplicationStartedOrder
-
-
-
-
Field Detail
-
NAME
public static final String NAME
-
CODECS_EXTENSION_POINT
public static final String CODECS_EXTENSION_POINT
- See Also:
- Constant Field Values
-
defaultCodecName
protected String defaultCodecName
-
descriptors
protected final Map<String,DocumentViewCodecDescriptor> descriptors
-
codecs
protected final Map<String,DocumentViewCodec> codecs
-
-
Method Detail
-
deactivate
public void deactivate(ComponentContext context)
Description copied from interface:Component
Deactivates the component.This method is called by the runtime when a component is deactivated.
- Specified by:
deactivate
in interfaceComponent
- Overrides:
deactivate
in classDefaultComponent
- Parameters:
context
- the runtime context
-
getAdapter
public <T> T getAdapter(Class<T> adapter)
Description copied from interface:Adaptable
Returns an object which is an instance of the given class associated with this object. Returnsnull
if no such object can be found.- Specified by:
getAdapter
in interfaceAdaptable
- Overrides:
getAdapter
in classDefaultComponent
- Parameters:
adapter
- the adapter class to look up- Returns:
- a object castable to the given class, or
null
if this object does not have an adapter for the given class
-
registerContribution
public void registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
- Overrides:
registerContribution
in classDefaultComponent
-
unregisterContribution
public void unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
- Overrides:
unregisterContribution
in classDefaultComponent
-
getDefaultCodecName
public String getDefaultCodecName()
Description copied from interface:DocumentViewCodecManager
Returns the default codec name.This information is set on codec descriptors.
- Specified by:
getDefaultCodecName
in interfaceDocumentViewCodecManager
-
getCodec
public DocumentViewCodec getCodec()
-
getCodec
public DocumentViewCodec getCodec(String codecName)
Description copied from interface:DocumentViewCodecManager
Returns theDocumentViewCodec
with the given name ornull
if ot doesn't exist.- Specified by:
getCodec
in interfaceDocumentViewCodecManager
-
getUrlFromDocumentView
public String getUrlFromDocumentView(DocumentView docView, boolean needBaseUrl, String baseUrl)
Description copied from interface:DocumentViewCodecManager
Returns an URL applying for given document view, or null.Iterates over registered codecs, starting from the default codec, and if
DocumentViewCodec.handleDocumentView(DocumentView)
returns true, callsDocumentViewCodec.getUrlFromDocumentView(DocumentView)
. Stops iterating when a codec returns a non-null value. am docView the original document view from request- Specified by:
getUrlFromDocumentView
in interfaceDocumentViewCodecManager
- Parameters:
docView
- the original document view from requestneedBaseUrl
- boolean indicating if base url should be added to the url returned by the codec.baseUrl
- value of the base url.
-
getUrlFromDocumentView
public String getUrlFromDocumentView(String codecName, DocumentView docView, boolean needBaseUrl, String baseUrl)
Description copied from interface:DocumentViewCodecManager
Returns an URL callingDocumentViewCodec.getUrlFromDocumentView(DocumentView)
on codec with given name.- Specified by:
getUrlFromDocumentView
in interfaceDocumentViewCodecManager
- Parameters:
codecName
- the codec name to usedocView
- the original document view from requestneedBaseUrl
- boolean indicating if base url should be added to the url returned by the codec.baseUrl
- value of the base url.
-
getUrlFromDocumentView
protected String getUrlFromDocumentView(DocumentViewCodec codec, DocumentView docView, boolean needBaseUrl, String baseUrl)
-
getDocumentViewFromUrl
public DocumentView getDocumentViewFromUrl(String url, boolean hasBaseUrl, String baseUrl)
Description copied from interface:DocumentViewCodecManager
Returns a DocumentView applying for given url, or null.Iterates over registered codecs, starting from the default codec, and if
DocumentViewCodec.handleUrl(String)
returns true, callsDocumentViewCodec.getDocumentViewFromUrl(String)
. Stops iterating when a codec returns a non-null value.- Specified by:
getDocumentViewFromUrl
in interfaceDocumentViewCodecManager
- Parameters:
url
- the original url from request, including request parameters if any.hasBaseUrl
- boolean indicating if base url should be removed from given url.baseUrl
- value of the base url.
-
getDocumentViewFromUrl
public DocumentView getDocumentViewFromUrl(String codecName, String url, boolean hasBaseUrl, String baseUrl)
Description copied from interface:DocumentViewCodecManager
Returns a DocumentView callingDocumentViewCodec.getDocumentViewFromUrl(String)
on codec with given name.- Specified by:
getDocumentViewFromUrl
in interfaceDocumentViewCodecManager
url
- the original url from request, including request parameters if any.hasBaseUrl
- boolean indicating if base url should be removed from given url.baseUrl
- value of the base url.
-
getUrlWithoutBase
protected String getUrlWithoutBase(String url, boolean hasBaseUrl, String baseUrl)
-
getDocumentViewFromUrl
protected DocumentView getDocumentViewFromUrl(DocumentViewCodec codec, String finalUrl)
-
-