public static String getClassCategLink(final NodeList sources) { if (sources.getLength() == 0) { LOGGER.warn("Cannot get first element of node list 'sources'."); return ""; } final Element source = (Element) sources.item(0); MCRCategoryID category = MCRClassMapper.getCategoryID(source); if (category == null) { return ""; } String id; try { id = MCRXMLFunctions.encodeURIPath(category.getID()); } catch (URISyntaxException e) { /* This should be impossible! */ throw new MCRException(e); } return MessageFormat.format("classification:metadata:0:children:{0}:{1}", category.getRootID(), id); }
public static MCRObject getMcrObjectForDerivateID(String requestDerivateID) { final MCRObjectID objectID = MCRObjectID.getInstance(MCRXMLFunctions.getMCRObjectID(requestDerivateID)); return (MCRObject) MCRMetadataManager.retrieve(objectID); }
private static boolean notAltoOrMets(Path file) { String mimeType = MCRXMLFunctions.getMimeType(file.getFileName().toString()); return !XML_MIME_TYPES.contains(mimeType) || !getLocalRootName(file).map(IGNORE_XML_ROOT_LOCAL_NAMES::contains).orElse(false); }
private void setSubmittedValues(MCRBinding binding, String[] values) throws JDOMException, JaxenException { List<Object> boundNodes = binding.getBoundNodes(); while (boundNodes.size() < values.length) { binding.cloneBoundElement(boundNodes.size() - 1); } for (int i = 0; i < values.length; i++) { String value = values[i] == null ? "" : values[i].trim(); value = MCRXMLFunctions.normalizeUnicode(value); value = MCRXMLHelper.removeIllegalChars(value); binding.setValue(i, value); } removeXPaths2CheckResubmission(binding); binding.detach(); }
MCRParameterCollector params = new MCRParameterCollector(request); if (!MCRXMLFunctions.isMobileDevice(request.getHeader("User-Agent"))) {
&& !MCRXMLFunctions.isDisplayedEnabledDerivate(derivateId.toString()) && !checkObjectPermission(derivateId, MCRAccessManager.PERMISSION_WRITE)) {
} else { LOGGER.warn("Password expired for user {} on {}", user.getUserID(), MCRXMLFunctions.getISODate(user.getValidUntil(), MCRISO8601Format.COMPLETE_HH_MM_SS.toString()));
public MCRJDOMContent transform(MCRContent source) throws IOException { try { Element root = source.asXML().getRootElement().clone(); for (Text text : root.getDescendants(Filters.text())) { text.setText(MCRXMLFunctions.normalizeUnicode(text.getText())); } return new MCRJDOMContent(root); } catch (JDOMException | SAXException ex) { throw new IOException(ex); } } }
public static String getClassCategParentLink(final NodeList sources) { if (sources.getLength() == 0) { LOGGER.warn("Cannot get first element of node list 'sources'."); return ""; } final Element source = (Element) sources.item(0); MCRCategoryID category = MCRClassMapper.getCategoryID(source); if (category == null) { return ""; } String id; try { id = MCRXMLFunctions.encodeURIPath(category.getID()); } catch (URISyntaxException e) { /* This should be impossible! */ throw new MCRException(e); } return MessageFormat .format("classification:metadata:0:parents:{0}:{1}", category.getRootID(), id); }
/** * Builds a list with with right content types and media urls assigned of a specific Object * * @param obj the object * @return a list of entrys Media-Type, URL */ public List<Map.Entry<String, URI>> getMediaList(MCRObject obj) { List<Map.Entry<String, URI>> entryList = new ArrayList<>(); Optional<MCRObjectID> derivateIdOptional = MCRMetadataManager.getDerivateIds(obj.getId(), 1, TimeUnit.MINUTES) .stream().findFirst(); derivateIdOptional.ifPresent(derivateId -> { MCRDerivate derivate = MCRMetadataManager.retrieveMCRDerivate(derivateId); String mainDoc = derivate.getDerivate().getInternals().getMainDoc(); MCRPath mainDocumentPath = MCRPath.getPath(derivateId.toString(), mainDoc); try { String contentType = Optional.ofNullable(MCRContentTypes.probeContentType(mainDocumentPath)) .orElse("application/octet-stream"); entryList.add(new AbstractMap.SimpleEntry<>(contentType, new URI(this.registerURL + MCRXMLFunctions .encodeURIPath("/servlets/MCRFileNodeServlet/" + derivateId + "/" + mainDoc)))); } catch (IOException | URISyntaxException e) { LOGGER.error("Error while detecting the file to register!", e); } }); return entryList; }