use of org.alfresco.service.cmr.repository.ContentData in project alfresco-remote-api by Alfresco.
the class RenditionsImpl method toApiRendition.
protected Rendition toApiRendition(NodeRef renditionNodeRef) {
Rendition apiRendition = new Rendition();
String renditionName = (String) nodeService.getProperty(renditionNodeRef, ContentModel.PROP_NAME);
apiRendition.setId(renditionName);
ContentData contentData = getContentData(renditionNodeRef, false);
ContentInfo contentInfo = null;
if (contentData != null) {
contentInfo = new ContentInfo(contentData.getMimetype(), getMimeTypeDisplayName(contentData.getMimetype()), contentData.getSize(), contentData.getEncoding());
}
apiRendition.setContent(contentInfo);
apiRendition.setStatus(RenditionStatus.CREATED);
return apiRendition;
}
use of org.alfresco.service.cmr.repository.ContentData in project acs-community-packaging by Alfresco.
the class TemplateSupportBean method selectDictionaryNodes.
/**
* @param fc FacesContext
* @param xpath XPath to the nodes to select
* @param noSelectionLabel Label to add to the list if no items are found in the search
* @param mimetype Optional mimetype of items to add, will not add to list if mimetype does not match
*
* @return List of SelectItem wrapper objects for the nodes found at the XPath
*/
private List<SelectItem> selectDictionaryNodes(FacesContext fc, String xpath, String noSelectionLabel, String mimetype) {
List<SelectItem> wrappers = null;
try {
NodeRef rootNodeRef = this.getNodeService().getRootNode(Repository.getStoreRef());
NamespaceService resolver = Repository.getServiceRegistry(fc).getNamespaceService();
List<NodeRef> results = this.getSearchService().selectNodes(rootNodeRef, xpath, null, resolver, false);
wrappers = new ArrayList<SelectItem>(results.size() + 1);
if (results.size() != 0) {
DictionaryService dd = Repository.getServiceRegistry(fc).getDictionaryService();
for (NodeRef ref : results) {
if (this.getNodeService().exists(ref) == true) {
Node childNode = new Node(ref);
ContentData content = (ContentData) childNode.getProperties().get(ContentModel.PROP_CONTENT);
if (dd.isSubClass(childNode.getType(), ContentModel.TYPE_CONTENT) && (mimetype == null || mimetype.equals(content.getMimetype()))) {
wrappers.add(new SelectItem(childNode.getId(), childNode.getName()));
}
}
}
// make sure the list is sorted by the label
QuickSort sorter = new QuickSort(wrappers, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
sorter.sort();
}
} catch (AccessDeniedException accessErr) {
// ignore the result if we cannot access the root
}
// add an entry (at the start) to instruct the user to select an item
if (wrappers == null) {
wrappers = new ArrayList<SelectItem>(1);
}
wrappers.add(0, new SelectItem(NO_SELECTION, Application.getMessage(FacesContext.getCurrentInstance(), noSelectionLabel)));
return wrappers;
}
use of org.alfresco.service.cmr.repository.ContentData in project acs-community-packaging by Alfresco.
the class DocumentDetailsDialog method applyInlineEditable.
/**
* Applies the inlineeditable aspect to the current document
*/
public String applyInlineEditable() {
try {
RetryingTransactionHelper txnHelper = Repository.getRetryingTransactionHelper(FacesContext.getCurrentInstance());
RetryingTransactionCallback<Object> callback = new RetryingTransactionCallback<Object>() {
public Object execute() throws Throwable {
// add the inlineeditable aspect to the node
Map<QName, Serializable> props = new HashMap<QName, Serializable>(1, 1.0f);
String contentType = null;
ContentData contentData = (ContentData) getDocument().getProperties().get(ContentModel.PROP_CONTENT);
if (contentData != null) {
contentType = contentData.getMimetype();
}
if (contentType != null) {
// set the property to true by default if the filetype is a known content type
if (MimetypeMap.MIMETYPE_HTML.equals(contentType) || MimetypeMap.MIMETYPE_TEXT_PLAIN.equals(contentType) || MimetypeMap.MIMETYPE_XML.equals(contentType) || MimetypeMap.MIMETYPE_TEXT_CSS.equals(contentType) || MimetypeMap.MIMETYPE_JAVASCRIPT.equals(contentType)) {
props.put(ApplicationModel.PROP_EDITINLINE, true);
}
}
getNodeService().addAspect(getDocument().getNodeRef(), ApplicationModel.ASPECT_INLINEEDITABLE, props);
return null;
}
};
txnHelper.doInTransaction(callback);
// reset the state of the current document
getDocument().reset();
} catch (Throwable e) {
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), MSG_ERROR_ASPECT_INLINEEDITABLE), e.getMessage()), e);
ReportedException.throwIfNecessary(e);
}
// force recreation of the details view - this means the properties sheet component will reinit
return OUTCOME_RETURN;
}
use of org.alfresco.service.cmr.repository.ContentData in project acs-community-packaging by Alfresco.
the class DocumentPropertiesDialog method setupDocumentForAction.
/**
* Event handler called to setup the document for property editing
*
* @param event The event
*/
public void setupDocumentForAction(ActionEvent event) {
this.editableNode = new Node(this.browseBean.getDocument().getNodeRef());
// special case for Mimetype - since this is a sub-property of the ContentData object
// we must extract it so it can be edited in the client, then we check for it later
// and create a new ContentData object to wrap it and it's associated URL
ContentData content = (ContentData) this.editableNode.getProperties().get(ContentModel.PROP_CONTENT);
if (content != null) {
this.editableNode.getProperties().put(TEMP_PROP_MIMETYPE, content.getMimetype());
this.editableNode.getProperties().put(TEMP_PROP_ENCODING, content.getEncoding());
}
this.hasOtherProperties = null;
}
use of org.alfresco.service.cmr.repository.ContentData in project acs-community-packaging by Alfresco.
the class ViewContentPropertiesDialog method init.
// ------------------------------------------------------------------------------
// Dialog implementation
@Override
public void init(Map<String, String> parameters) {
super.init(parameters);
Node document = this.browseBean.getDocument();
if (document != null) {
// setup the editable node
this.viewingNode = new Node(document.getNodeRef());
// special case for Mimetype - since this is a sub-property of the ContentData object
// we must extract it so it can be edited in the client, then we check for it later
// and create a new ContentData object to wrap it and it's associated URL
ContentData content = (ContentData) this.viewingNode.getProperties().get(ContentModel.PROP_CONTENT);
if (content != null) {
this.viewingNode.getProperties().put(TEMP_PROP_MIMETYPE, content.getMimetype());
this.viewingNode.getProperties().put(TEMP_PROP_ENCODING, content.getEncoding());
}
// add the specially handled 'size' property
this.viewingNode.addPropertyResolver("size", this.browseBean.resolverSize);
}
}
Aggregations