use of org.mycore.viewer.configuration.MCRViewerDefaultConfigurationStrategy 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);
}
Aggregations