Search in sources :

Example 1 with MCRViewerConfigurationStrategy

use of org.mycore.viewer.configuration.MCRViewerConfigurationStrategy in project mycore by MyCoRe-Org.

the class MCRViewerResource method getContent.

protected MCRContent getContent(final HttpServletRequest req) throws Exception {
    // get derivate id from request object
    String derivate = MCRViewerConfiguration.getDerivate(req);
    if (derivate == null) {
        MCRJerseyUtil.throwException(Status.BAD_REQUEST, "Could not locate derivate identifer in path.");
    }
    // get mycore object id
    final MCRObjectID derivateID = MCRObjectID.getInstance(derivate);
    if (!MCRMetadataManager.exists(derivateID)) {
        String errorMessage = MCRTranslation.translate("component.viewer.MCRIViewClientServlet.object.not.found", derivateID);
        MCRJerseyUtil.throwException(Status.NOT_FOUND, errorMessage);
    }
    // check permission
    if (IVIEW_ACL_PROVDER != null && !IVIEW_ACL_PROVDER.checkAccess(req.getSession(), derivateID)) {
        String errorMessage = MCRTranslation.translate("component.viewer.MCRIViewClientServlet.noRights", derivateID);
        MCRJerseyUtil.throwException(Status.UNAUTHORIZED, errorMessage);
    }
    // build configuration object
    MCRViewerConfigurationStrategy configurationStrategy = MCRConfiguration.instance().getInstanceOf("MCR.Viewer.configuration.strategy", new MCRViewerDefaultConfigurationStrategy());
    MCRJDOMContent source = new MCRJDOMContent(buildResponseDocument(configurationStrategy.get(req)));
    MCRParameterCollector parameter = new MCRParameterCollector(req);
    MCRContentTransformer transformer = getContentTransformer(source.getDocType(), parameter);
    return transformer.transform(source);
}
Also used : MCRParameterCollector(org.mycore.common.xsl.MCRParameterCollector) MCRViewerConfigurationStrategy(org.mycore.viewer.configuration.MCRViewerConfigurationStrategy) MCRJDOMContent(org.mycore.common.content.MCRJDOMContent) MCRViewerDefaultConfigurationStrategy(org.mycore.viewer.configuration.MCRViewerDefaultConfigurationStrategy) MCRContentTransformer(org.mycore.common.content.transformer.MCRContentTransformer) MCRObjectID(org.mycore.datamodel.metadata.MCRObjectID)

Aggregations

MCRJDOMContent (org.mycore.common.content.MCRJDOMContent)1 MCRContentTransformer (org.mycore.common.content.transformer.MCRContentTransformer)1 MCRParameterCollector (org.mycore.common.xsl.MCRParameterCollector)1 MCRObjectID (org.mycore.datamodel.metadata.MCRObjectID)1 MCRViewerConfigurationStrategy (org.mycore.viewer.configuration.MCRViewerConfigurationStrategy)1 MCRViewerDefaultConfigurationStrategy (org.mycore.viewer.configuration.MCRViewerDefaultConfigurationStrategy)1