private ContentData sanitizeMimetype(ContentData contentData) { String mimetype = contentData.getMimetype(); if (mimetype != null) { mimetype = mimetype.toLowerCase(); contentData = ContentData.setMimetype(contentData, mimetype); } return contentData; }
private ContentData sanitizeMimetype(ContentData contentData) { String mimetype = contentData.getMimetype(); if (mimetype != null) { mimetype = mimetype.toLowerCase(); contentData = ContentData.setMimetype(contentData, mimetype); } return contentData; }
public void setMimetype(String mimetype) { mimetype = mimetype.toLowerCase(); this.contentData = ContentData.setMimetype(this.contentData, mimetype); services.getNodeService().setProperty(nodeRef, this.property, this.contentData); updateContentData(false); }
/** * Persists the given field data as the mimetype property * * @param nodeRef The NodeRef to update the mimetype for * @param fieldData The data representing the new mimetype value * @param propsToPersist Map of properties to be persisted */ protected void processMimetypePropertyPersist(NodeRef nodeRef, FieldData fieldData, Map<QName, Serializable> propsToPersist) { ContentData contentData = (ContentData) propsToPersist.get(ContentModel.PROP_CONTENT); if (contentData == null) { // content data has not been persisted yet so get it from the node contentData = (ContentData) this.nodeService.getProperty(nodeRef, ContentModel.PROP_CONTENT); } if (contentData != null) { // update content data if we found the property contentData = ContentData.setMimetype(contentData, (String) fieldData.getValue()); propsToPersist.put(ContentModel.PROP_CONTENT, contentData); } }
/** * Persists the given field data as the mimetype property * * @param nodeRef The NodeRef to update the mimetype for * @param fieldData The data representing the new mimetype value * @param propsToPersist Map of properties to be persisted */ protected void processMimetypePropertyPersist(NodeRef nodeRef, FieldData fieldData, Map<QName, Serializable> propsToPersist) { ContentData contentData = (ContentData) propsToPersist.get(ContentModel.PROP_CONTENT); if (contentData == null) { // content data has not been persisted yet so get it from the node contentData = (ContentData) this.nodeService.getProperty(nodeRef, ContentModel.PROP_CONTENT); } if (contentData != null) { // update content data if we found the property contentData = ContentData.setMimetype(contentData, (String) fieldData.getValue()); propsToPersist.put(ContentModel.PROP_CONTENT, contentData); } }
public void setMimetype(String mimetype) { mimetype = mimetype.toLowerCase(); this.contentData = ContentData.setMimetype(this.contentData, mimetype); services.getNodeService().setProperty(nodeRef, this.property, this.contentData); updateContentData(false); }
/** * Copy content data from file to file * * @param sess SrvSession * @param tree TreeConnection * @param fromNode NodeRef * @param toNode NodeRef * @param newName String */ private void copyContentData( SrvSession sess, TreeConnection tree, NodeRef fromNode, NodeRef toNode, String newName) { ContentData content = (ContentData) nodeService.getProperty(fromNode, ContentModel.PROP_CONTENT); if ( newName != null) content = ContentData.setMimetype( content, mimetypeService.guessMimetype( newName)); nodeService.setProperty(toNode, ContentModel.PROP_CONTENT, content); }
/** * Copy content data from file to file * * @param sess SrvSession * @param tree TreeConnection * @param fromNode NodeRef * @param toNode NodeRef * @param newName String */ private void copyContentData( SrvSession sess, TreeConnection tree, NodeRef fromNode, NodeRef toNode, String newName) { ContentData content = (ContentData) nodeService.getProperty(fromNode, ContentModel.PROP_CONTENT); if ( newName != null) content = ContentData.setMimetype( content, mimetypeService.guessMimetype( newName)); nodeService.setProperty(toNode, ContentModel.PROP_CONTENT, content); }
prop = ContentData.setMimetype(data, targetData.getMimetype());
prop = ContentData.setMimetype(data, targetData.getMimetype());
private void putContent(NodeRef zipFileNodeRef, String resource) { URL url = AbstractContentTransformerTest.class.getClassLoader().getResource(resource); final File file = new File(url.getFile()); contentService.getWriter(zipFileNodeRef, ContentModel.PROP_CONTENT, true).putContent(file); ContentData contentData = (ContentData) nodeService.getProperty(zipFileNodeRef, ContentModel.PROP_CONTENT); ContentData newContentData = ContentData.setMimetype(contentData, MimetypeMap.MIMETYPE_ZIP); nodeService.setProperty(zipFileNodeRef, ContentModel.PROP_CONTENT, newContentData); }
if (mimetype == null) contentData = ContentData.setMimetype(contentData, determineDefaultMimetype(data)); if (contentData != null) contentData = ContentData.setMimetype(contentData, determineDefaultMimetype(data)); contentData = ContentData.setMimetype(contentData, mimetypeEncoding.getMimetype()); contentData = ContentData.setEncoding(contentData, mimetypeEncoding.getEncoding());
if (mimetype == null) contentData = ContentData.setMimetype(contentData, determineDefaultMimetype(data)); if (contentData != null) contentData = ContentData.setMimetype(contentData, determineDefaultMimetype(data)); contentData = ContentData.setMimetype(contentData, mimetypeEncoding.getMimetype()); contentData = ContentData.setEncoding(contentData, mimetypeEncoding.getEncoding());
oldContentData = ContentData.setMimetype(null, mimetype); newContentData = ContentData.setMimetype(newContentData, mimetype);
oldContentData = ContentData.setMimetype(null, mimetype); newContentData = ContentData.setMimetype(newContentData, mimetype);
/** * the caveat to {@link #testEnsureCaseSensitiveStorage()} is that mimetypes * must be normalized to lowercase. * * @throws Exception */ public void testEnsureCaseInsensitiveMimetypeStorage() throws Exception { ContentData contentData = getContentData(); ContentData cdWithUpperMimetype = ContentData.setMimetype(contentData, "TEXT/MYFORMAT"); ContentData cdWithLowerMimetype = ContentData.setMimetype(contentData, "text/myformat"); // In both instances, the created entry should have a lowercase mimetype Pair<Long, ContentData> result = create(cdWithUpperMimetype); // Ensure the ContentData's mimetype was stored in lowercase assertEquals("text/myformat", result.getSecond().getMimetype()); result = create(cdWithLowerMimetype); assertEquals("text/myformat", result.getSecond().getMimetype()); }
ContentData replacement = ContentData.setMimetype(content, mimetype); nodeService.setProperty(toNode, ContentModel.PROP_CONTENT, replacement);
ContentData replacement = ContentData.setMimetype(content, mimetype); nodeService.setProperty(toNode, ContentModel.PROP_CONTENT, replacement);
if (mimetype == null) contentData = ContentData.setMimetype(contentData, determineDefaultMimetype(data)); .setMimetype(contentData, mimetypeService.getMimetype(fileName.substring(fileName .lastIndexOf(".") + 1))); contentData = ContentData.setMimetype(contentData, mimetypeEncoding.getMimetype()); contentData = ContentData.setEncoding(contentData,
public void testUpdate() throws Exception { ContentData contentData = getContentData(); Pair<Long, ContentData> resultPair = create(contentData); Long id = resultPair.getFirst(); // Update contentData = ContentData.setMimetype(contentData, "TEXT/HTML"); // Note the upper case mimetype contentData = ContentData.setEncoding(contentData, "UTF-16"); // Don't update the content itself update(id, contentData); // Check Pair<Long, ContentData> result = getAndCheck(id, contentData); // Check the mimetype has been lowercased assertEquals("text/html", result.getSecond().getMimetype()); }