mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
- Added metadata extractor to add content dialog
- Author aspect is now always added when content is created git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2813 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,13 +1,19 @@
|
||||
package org.alfresco.web.bean.content;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.event.ActionEvent;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.content.filestore.FileContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.FileUploadBean;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
@@ -29,6 +35,25 @@ public class AddContentDialog extends BaseContentWizard
|
||||
protected String finishImpl(FacesContext context, String outcome)
|
||||
throws Exception
|
||||
{
|
||||
// Try and extract metadata from the file
|
||||
ContentReader cr = new FileContentReader(this.file);
|
||||
cr.setMimetype(this.mimeType);
|
||||
// create properties for content type
|
||||
Map<QName, Serializable> contentProps = new HashMap<QName, Serializable>(5, 1.0f);
|
||||
|
||||
if (Repository.extractMetadata(FacesContext.getCurrentInstance(), cr, contentProps))
|
||||
{
|
||||
this.author = (String)(contentProps.get(ContentModel.PROP_AUTHOR));
|
||||
this.title = (String)(contentProps.get(ContentModel.PROP_TITLE));
|
||||
this.description = (String)(contentProps.get(ContentModel.PROP_DESCRIPTION));
|
||||
}
|
||||
|
||||
// default the title to the file name if not set
|
||||
if (this.title == null)
|
||||
{
|
||||
this.title = this.fileName;
|
||||
}
|
||||
|
||||
saveContent(this.file, null);
|
||||
|
||||
// return default outcome
|
||||
|
Reference in New Issue
Block a user