mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged 5.1.N (5.1.2) to 5.2.N (5.2.1)
125605 rmunteanu: Merged 5.1.1 (5.1.1) to 5.1.N (5.1.2) 125498 slanglois: MNT-16155 Update source headers - remove svn:eol-style property on Java and JSP source files git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@125783 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,330 +1,330 @@
|
||||
package org.alfresco.web.bean.content;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.Serializable;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.event.ActionEvent;
|
||||
|
||||
import org.springframework.extensions.config.Config;
|
||||
import org.springframework.extensions.config.ConfigElement;
|
||||
import org.springframework.extensions.config.ConfigService;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.content.filestore.FileContentReader;
|
||||
import org.alfresco.service.cmr.model.FileExistsException;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||
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;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
|
||||
/**
|
||||
* Bean implementation for the "Add Content" dialog
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class AddContentDialog extends BaseContentWizard
|
||||
{
|
||||
private final static String MSG_OK = "ok";
|
||||
private static final long serialVersionUID = 3593557546118692687L;
|
||||
|
||||
protected List<String> inlineEditableMimeTypes;
|
||||
protected File file;
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Dialog implementation
|
||||
|
||||
@Override
|
||||
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);
|
||||
cr.setEncoding(this.encoding);
|
||||
// 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 = DefaultTypeConverter.INSTANCE.convert(String.class, contentProps.get(ContentModel.PROP_TITLE));
|
||||
this.description = DefaultTypeConverter.INSTANCE.convert(String.class, contentProps.get(ContentModel.PROP_DESCRIPTION));
|
||||
}
|
||||
|
||||
// default the title to the file name if not set
|
||||
if (this.title == null)
|
||||
{
|
||||
this.title = this.fileName;
|
||||
}
|
||||
|
||||
// determine whether inline editing should be enabled by default.
|
||||
// if the mime type of the added file is in the list of mime types
|
||||
// configured in "Content Wizards" then enable inline editing
|
||||
List<String> mimeTypes = getInlineEditableMimeTypes();
|
||||
if (mimeTypes.contains(this.mimeType))
|
||||
{
|
||||
this.inlineEdit = true;
|
||||
}
|
||||
|
||||
saveContent(this.file, null);
|
||||
|
||||
// return default outcome
|
||||
return outcome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Map<String, String> parameters)
|
||||
{
|
||||
super.init(parameters);
|
||||
|
||||
clearUpload();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doPostCommitProcessing(FacesContext context, String outcome)
|
||||
{
|
||||
clearUpload();
|
||||
|
||||
// as we were successful, go to the set properties dialog if asked
|
||||
// to otherwise just return
|
||||
if (this.showOtherProperties)
|
||||
{
|
||||
// check whether the created node is checked out, if a 'check out'
|
||||
// rule is present in the space the new node will be and an
|
||||
// attempt to modify the properties will cause an error (ALF-438)
|
||||
if (getNodeService().hasAspect(this.createdNode, ContentModel.ASPECT_LOCKABLE))
|
||||
{
|
||||
Utils.addErrorMessage(Application.getMessage(FacesContext.getCurrentInstance(), MSG_NODE_LOCKED));
|
||||
return outcome;
|
||||
}
|
||||
else
|
||||
{
|
||||
// we are going to immediately edit the properties so we need
|
||||
// to setup the BrowseBean context appropriately
|
||||
this.browseBean.setDocument(new Node(this.createdNode));
|
||||
|
||||
return "dialog:setContentProperties";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return outcome;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultFinishOutcome()
|
||||
{
|
||||
// as we are using this dialog outside the dialog framework
|
||||
// just go back to the main page
|
||||
|
||||
return "dialog:close:browse";
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Bean getters and setters
|
||||
|
||||
/**
|
||||
* @return Returns the message to display when a file has been uploaded
|
||||
*/
|
||||
public String getFileUploadSuccessMsg()
|
||||
{
|
||||
// NOTE: This is a far from ideal solution but will do until we have
|
||||
// a pure JSF upload solution working. This method is only called
|
||||
// after a file is uploaded, so we can calculate the mime type and
|
||||
// determine whether to enable inline editing in here.
|
||||
FacesContext fc = FacesContext.getCurrentInstance();
|
||||
|
||||
// Identify the mimetype as best as we can
|
||||
this.mimeType = Repository.getMimeTypeForFile(fc, this.fileName, this.file);
|
||||
|
||||
// Identify the encoding as best we can (only really important for text based formats)
|
||||
this.encoding = "UTF-8";
|
||||
InputStream is = null;
|
||||
try
|
||||
{
|
||||
if (this.file != null)
|
||||
{
|
||||
is = new BufferedInputStream(new FileInputStream(this.file));
|
||||
this.encoding = Repository.guessEncoding(fc, is, this.mimeType);
|
||||
}
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
// Not terminal
|
||||
logger.error("Failed to get encoding from file: " + this.fileName, e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
try { is.close(); } catch (Throwable e) {} // Includes NPE
|
||||
}
|
||||
|
||||
// Offer inline editing for HTML only
|
||||
this.inlineEdit = (this.mimeType.equals(MimetypeMap.MIMETYPE_HTML));
|
||||
|
||||
// get the file upload message
|
||||
String msg = Application.getMessage(FacesContext.getCurrentInstance(), "file_upload_success");
|
||||
return MessageFormat.format(msg, new Object[] {Utils.encode(getFileName())});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the name of the file
|
||||
*/
|
||||
public String getFileName()
|
||||
{
|
||||
// try and retrieve the file and filename from the file upload bean
|
||||
// representing the file we previously uploaded.
|
||||
FacesContext ctx = FacesContext.getCurrentInstance();
|
||||
FileUploadBean fileBean = (FileUploadBean)ctx.getExternalContext().getSessionMap().
|
||||
get(FileUploadBean.FILE_UPLOAD_BEAN_NAME);
|
||||
if (fileBean != null)
|
||||
{
|
||||
this.file = fileBean.getFile();
|
||||
this.fileName = fileBean.getFileName();
|
||||
}
|
||||
|
||||
return this.fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fileName The name of the file
|
||||
*/
|
||||
public void setFileName(String fileName)
|
||||
{
|
||||
this.fileName = fileName;
|
||||
|
||||
// we also need to keep the file upload bean in sync
|
||||
FacesContext ctx = FacesContext.getCurrentInstance();
|
||||
FileUploadBean fileBean = (FileUploadBean)ctx.getExternalContext().getSessionMap().
|
||||
get(FileUploadBean.FILE_UPLOAD_BEAN_NAME);
|
||||
if (fileBean != null)
|
||||
{
|
||||
fileBean.setFileName(this.fileName);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Action event handlers
|
||||
|
||||
/**
|
||||
* Action listener called when the add content dialog is called
|
||||
*/
|
||||
public void start(ActionEvent event)
|
||||
{
|
||||
// NOTE: this is a temporary solution to allow us to use the new dialog
|
||||
// framework beans outside of the dialog framework, we need to do
|
||||
// this because the uploading requires a separate non-JSF form, this
|
||||
// approach can not be used in the current dialog framework. Until
|
||||
// we have a pure JSF upload solution we need this initialisation
|
||||
|
||||
init(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Action handler called when the user wishes to remove an uploaded file
|
||||
*/
|
||||
public String removeUploadedFile()
|
||||
{
|
||||
clearUpload();
|
||||
|
||||
// also clear the file name
|
||||
this.fileName = null;
|
||||
|
||||
// refresh the current page
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Action handler called when the dialog is cancelled
|
||||
*/
|
||||
public String cancel()
|
||||
{
|
||||
clearUpload();
|
||||
return "dialog:close";
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Helper Methods
|
||||
|
||||
/**
|
||||
* Deletes the uploaded file and removes the FileUploadBean from the session
|
||||
*/
|
||||
protected void clearUpload()
|
||||
{
|
||||
// delete the temporary file we uploaded earlier
|
||||
if (this.file != null)
|
||||
{
|
||||
this.file.delete();
|
||||
}
|
||||
|
||||
this.file = null;
|
||||
|
||||
// remove the file upload bean from the session
|
||||
FacesContext ctx = FacesContext.getCurrentInstance();
|
||||
ctx.getExternalContext().getSessionMap().remove(FileUploadBean.FILE_UPLOAD_BEAN_NAME);
|
||||
}
|
||||
|
||||
protected List<String> getInlineEditableMimeTypes()
|
||||
{
|
||||
if ((this.inlineEditableMimeTypes == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance())))
|
||||
{
|
||||
this.inlineEditableMimeTypes = new ArrayList<String>(8);
|
||||
|
||||
// get the create mime types list from the config
|
||||
ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());
|
||||
Config wizardCfg = svc.getConfig("Content Wizards");
|
||||
if (wizardCfg != null)
|
||||
{
|
||||
ConfigElement typesCfg = wizardCfg.getConfigElement("create-mime-types");
|
||||
if (typesCfg != null)
|
||||
{
|
||||
for (ConfigElement child : typesCfg.getChildren())
|
||||
{
|
||||
String currentMimeType = child.getAttribute("name");
|
||||
this.inlineEditableMimeTypes.add(currentMimeType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.inlineEditableMimeTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFinishButtonLabel()
|
||||
{
|
||||
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), MSG_OK);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String formatErrorMessage(Throwable exception)
|
||||
{
|
||||
if (exception instanceof FileExistsException)
|
||||
{
|
||||
return MessageFormat.format(Application.getMessage(
|
||||
FacesContext.getCurrentInstance(), Repository.ERROR_EXISTS),
|
||||
((FileExistsException)exception).getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
return MessageFormat.format(Application.getMessage(
|
||||
FacesContext.getCurrentInstance(), "error_content"),
|
||||
exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
package org.alfresco.web.bean.content;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.Serializable;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.event.ActionEvent;
|
||||
|
||||
import org.springframework.extensions.config.Config;
|
||||
import org.springframework.extensions.config.ConfigElement;
|
||||
import org.springframework.extensions.config.ConfigService;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.content.filestore.FileContentReader;
|
||||
import org.alfresco.service.cmr.model.FileExistsException;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||
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;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
|
||||
/**
|
||||
* Bean implementation for the "Add Content" dialog
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class AddContentDialog extends BaseContentWizard
|
||||
{
|
||||
private final static String MSG_OK = "ok";
|
||||
private static final long serialVersionUID = 3593557546118692687L;
|
||||
|
||||
protected List<String> inlineEditableMimeTypes;
|
||||
protected File file;
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Dialog implementation
|
||||
|
||||
@Override
|
||||
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);
|
||||
cr.setEncoding(this.encoding);
|
||||
// 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 = DefaultTypeConverter.INSTANCE.convert(String.class, contentProps.get(ContentModel.PROP_TITLE));
|
||||
this.description = DefaultTypeConverter.INSTANCE.convert(String.class, contentProps.get(ContentModel.PROP_DESCRIPTION));
|
||||
}
|
||||
|
||||
// default the title to the file name if not set
|
||||
if (this.title == null)
|
||||
{
|
||||
this.title = this.fileName;
|
||||
}
|
||||
|
||||
// determine whether inline editing should be enabled by default.
|
||||
// if the mime type of the added file is in the list of mime types
|
||||
// configured in "Content Wizards" then enable inline editing
|
||||
List<String> mimeTypes = getInlineEditableMimeTypes();
|
||||
if (mimeTypes.contains(this.mimeType))
|
||||
{
|
||||
this.inlineEdit = true;
|
||||
}
|
||||
|
||||
saveContent(this.file, null);
|
||||
|
||||
// return default outcome
|
||||
return outcome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Map<String, String> parameters)
|
||||
{
|
||||
super.init(parameters);
|
||||
|
||||
clearUpload();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doPostCommitProcessing(FacesContext context, String outcome)
|
||||
{
|
||||
clearUpload();
|
||||
|
||||
// as we were successful, go to the set properties dialog if asked
|
||||
// to otherwise just return
|
||||
if (this.showOtherProperties)
|
||||
{
|
||||
// check whether the created node is checked out, if a 'check out'
|
||||
// rule is present in the space the new node will be and an
|
||||
// attempt to modify the properties will cause an error (ALF-438)
|
||||
if (getNodeService().hasAspect(this.createdNode, ContentModel.ASPECT_LOCKABLE))
|
||||
{
|
||||
Utils.addErrorMessage(Application.getMessage(FacesContext.getCurrentInstance(), MSG_NODE_LOCKED));
|
||||
return outcome;
|
||||
}
|
||||
else
|
||||
{
|
||||
// we are going to immediately edit the properties so we need
|
||||
// to setup the BrowseBean context appropriately
|
||||
this.browseBean.setDocument(new Node(this.createdNode));
|
||||
|
||||
return "dialog:setContentProperties";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return outcome;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultFinishOutcome()
|
||||
{
|
||||
// as we are using this dialog outside the dialog framework
|
||||
// just go back to the main page
|
||||
|
||||
return "dialog:close:browse";
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Bean getters and setters
|
||||
|
||||
/**
|
||||
* @return Returns the message to display when a file has been uploaded
|
||||
*/
|
||||
public String getFileUploadSuccessMsg()
|
||||
{
|
||||
// NOTE: This is a far from ideal solution but will do until we have
|
||||
// a pure JSF upload solution working. This method is only called
|
||||
// after a file is uploaded, so we can calculate the mime type and
|
||||
// determine whether to enable inline editing in here.
|
||||
FacesContext fc = FacesContext.getCurrentInstance();
|
||||
|
||||
// Identify the mimetype as best as we can
|
||||
this.mimeType = Repository.getMimeTypeForFile(fc, this.fileName, this.file);
|
||||
|
||||
// Identify the encoding as best we can (only really important for text based formats)
|
||||
this.encoding = "UTF-8";
|
||||
InputStream is = null;
|
||||
try
|
||||
{
|
||||
if (this.file != null)
|
||||
{
|
||||
is = new BufferedInputStream(new FileInputStream(this.file));
|
||||
this.encoding = Repository.guessEncoding(fc, is, this.mimeType);
|
||||
}
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
// Not terminal
|
||||
logger.error("Failed to get encoding from file: " + this.fileName, e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
try { is.close(); } catch (Throwable e) {} // Includes NPE
|
||||
}
|
||||
|
||||
// Offer inline editing for HTML only
|
||||
this.inlineEdit = (this.mimeType.equals(MimetypeMap.MIMETYPE_HTML));
|
||||
|
||||
// get the file upload message
|
||||
String msg = Application.getMessage(FacesContext.getCurrentInstance(), "file_upload_success");
|
||||
return MessageFormat.format(msg, new Object[] {Utils.encode(getFileName())});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the name of the file
|
||||
*/
|
||||
public String getFileName()
|
||||
{
|
||||
// try and retrieve the file and filename from the file upload bean
|
||||
// representing the file we previously uploaded.
|
||||
FacesContext ctx = FacesContext.getCurrentInstance();
|
||||
FileUploadBean fileBean = (FileUploadBean)ctx.getExternalContext().getSessionMap().
|
||||
get(FileUploadBean.FILE_UPLOAD_BEAN_NAME);
|
||||
if (fileBean != null)
|
||||
{
|
||||
this.file = fileBean.getFile();
|
||||
this.fileName = fileBean.getFileName();
|
||||
}
|
||||
|
||||
return this.fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fileName The name of the file
|
||||
*/
|
||||
public void setFileName(String fileName)
|
||||
{
|
||||
this.fileName = fileName;
|
||||
|
||||
// we also need to keep the file upload bean in sync
|
||||
FacesContext ctx = FacesContext.getCurrentInstance();
|
||||
FileUploadBean fileBean = (FileUploadBean)ctx.getExternalContext().getSessionMap().
|
||||
get(FileUploadBean.FILE_UPLOAD_BEAN_NAME);
|
||||
if (fileBean != null)
|
||||
{
|
||||
fileBean.setFileName(this.fileName);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Action event handlers
|
||||
|
||||
/**
|
||||
* Action listener called when the add content dialog is called
|
||||
*/
|
||||
public void start(ActionEvent event)
|
||||
{
|
||||
// NOTE: this is a temporary solution to allow us to use the new dialog
|
||||
// framework beans outside of the dialog framework, we need to do
|
||||
// this because the uploading requires a separate non-JSF form, this
|
||||
// approach can not be used in the current dialog framework. Until
|
||||
// we have a pure JSF upload solution we need this initialisation
|
||||
|
||||
init(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Action handler called when the user wishes to remove an uploaded file
|
||||
*/
|
||||
public String removeUploadedFile()
|
||||
{
|
||||
clearUpload();
|
||||
|
||||
// also clear the file name
|
||||
this.fileName = null;
|
||||
|
||||
// refresh the current page
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Action handler called when the dialog is cancelled
|
||||
*/
|
||||
public String cancel()
|
||||
{
|
||||
clearUpload();
|
||||
return "dialog:close";
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Helper Methods
|
||||
|
||||
/**
|
||||
* Deletes the uploaded file and removes the FileUploadBean from the session
|
||||
*/
|
||||
protected void clearUpload()
|
||||
{
|
||||
// delete the temporary file we uploaded earlier
|
||||
if (this.file != null)
|
||||
{
|
||||
this.file.delete();
|
||||
}
|
||||
|
||||
this.file = null;
|
||||
|
||||
// remove the file upload bean from the session
|
||||
FacesContext ctx = FacesContext.getCurrentInstance();
|
||||
ctx.getExternalContext().getSessionMap().remove(FileUploadBean.FILE_UPLOAD_BEAN_NAME);
|
||||
}
|
||||
|
||||
protected List<String> getInlineEditableMimeTypes()
|
||||
{
|
||||
if ((this.inlineEditableMimeTypes == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance())))
|
||||
{
|
||||
this.inlineEditableMimeTypes = new ArrayList<String>(8);
|
||||
|
||||
// get the create mime types list from the config
|
||||
ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());
|
||||
Config wizardCfg = svc.getConfig("Content Wizards");
|
||||
if (wizardCfg != null)
|
||||
{
|
||||
ConfigElement typesCfg = wizardCfg.getConfigElement("create-mime-types");
|
||||
if (typesCfg != null)
|
||||
{
|
||||
for (ConfigElement child : typesCfg.getChildren())
|
||||
{
|
||||
String currentMimeType = child.getAttribute("name");
|
||||
this.inlineEditableMimeTypes.add(currentMimeType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.inlineEditableMimeTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFinishButtonLabel()
|
||||
{
|
||||
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), MSG_OK);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String formatErrorMessage(Throwable exception)
|
||||
{
|
||||
if (exception instanceof FileExistsException)
|
||||
{
|
||||
return MessageFormat.format(Application.getMessage(
|
||||
FacesContext.getCurrentInstance(), Repository.ERROR_EXISTS),
|
||||
((FileExistsException)exception).getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
return MessageFormat.format(Application.getMessage(
|
||||
FacesContext.getCurrentInstance(), "error_content"),
|
||||
exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,260 +1,260 @@
|
||||
package org.alfresco.web.bean.content;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.event.ValueChangeEvent;
|
||||
import javax.faces.model.SelectItem;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.service.cmr.model.FileExistsException;
|
||||
import org.alfresco.web.app.AlfrescoNavigationHandler;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.data.IDataContainer;
|
||||
import org.alfresco.web.data.QuickSort;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.config.Config;
|
||||
import org.springframework.extensions.config.ConfigElement;
|
||||
import org.springframework.extensions.config.ConfigService;
|
||||
|
||||
/**
|
||||
* Bean implementation for the "Create Content Wizard" dialog
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class CreateContentWizard extends BaseContentWizard
|
||||
{
|
||||
private static final long serialVersionUID = -2740634368271194418L;
|
||||
|
||||
protected String content = null;
|
||||
protected List<SelectItem> createMimeTypes;
|
||||
|
||||
private static Log logger = LogFactory.getLog(CreateContentWizard.class);
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Wizard implementation
|
||||
|
||||
|
||||
@Override
|
||||
public String finish()
|
||||
{
|
||||
String result = super.finish();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome)
|
||||
throws Exception
|
||||
{
|
||||
saveContent(null, this.content);
|
||||
|
||||
// return the default outcome
|
||||
return outcome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Map<String, String> parameters)
|
||||
{
|
||||
super.init(parameters);
|
||||
|
||||
this.content = null;
|
||||
this.inlineEdit = true;
|
||||
this.mimeType = MimetypeMap.MIMETYPE_HTML;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getNextButtonDisabled()
|
||||
{
|
||||
// TODO: Allow the next button state to be configured so that
|
||||
// wizard implementations don't have to worry about
|
||||
// checking step numbers
|
||||
|
||||
boolean disabled = false;
|
||||
int step = Application.getWizardManager().getCurrentStep();
|
||||
switch(step)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
disabled = (this.fileName == null || this.fileName.length() == 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return disabled;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean getFinishButtonDisabled()
|
||||
{
|
||||
boolean disabled = false;
|
||||
int step = Application.getWizardManager().getCurrentStep();
|
||||
switch(step)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
disabled = (this.fileName == null || this.fileName.length() == 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return disabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doPostCommitProcessing(FacesContext context, String outcome)
|
||||
{
|
||||
// as we were successful, go to the set properties dialog if asked
|
||||
// to otherwise just return
|
||||
if (this.showOtherProperties)
|
||||
{
|
||||
// check whether the created node is checked out, if a 'check out'
|
||||
// rule is present in the space the new node will be and an
|
||||
// attempt to modify the properties will cause an error (ALF-438)
|
||||
if (getNodeService().hasAspect(this.createdNode, ContentModel.ASPECT_LOCKABLE))
|
||||
{
|
||||
Utils.addErrorMessage(Application.getMessage(FacesContext.getCurrentInstance(), MSG_NODE_LOCKED));
|
||||
return outcome;
|
||||
}
|
||||
else
|
||||
{
|
||||
// we are going to immediately edit the properties so we need
|
||||
// to setup the BrowseBean context appropriately
|
||||
this.browseBean.setDocument(new Node(this.createdNode));
|
||||
|
||||
return getDefaultFinishOutcome() + AlfrescoNavigationHandler.OUTCOME_SEPARATOR +
|
||||
"dialog:setContentProperties";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return outcome;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Bean Getters and Setters
|
||||
|
||||
/**
|
||||
* @return Returns the content from the edited form.
|
||||
*/
|
||||
public String getContent()
|
||||
{
|
||||
return this.content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param content The content to edit (should be clear initially)
|
||||
*/
|
||||
public void setContent(String content)
|
||||
{
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns a list of mime types to allow the user to select from
|
||||
*/
|
||||
public List<SelectItem> getCreateMimeTypes()
|
||||
{
|
||||
if ((this.createMimeTypes == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance())))
|
||||
{
|
||||
FacesContext context = FacesContext.getCurrentInstance();
|
||||
|
||||
// add the well known object type to start with
|
||||
this.createMimeTypes = new ArrayList<SelectItem>(5);
|
||||
|
||||
// add the configured create mime types to the list
|
||||
ConfigService svc = Application.getConfigService(context);
|
||||
Config wizardCfg = svc.getConfig("Content Wizards");
|
||||
if (wizardCfg != null)
|
||||
{
|
||||
ConfigElement typesCfg = wizardCfg.getConfigElement("create-mime-types");
|
||||
if (typesCfg != null)
|
||||
{
|
||||
for (ConfigElement child : typesCfg.getChildren())
|
||||
{
|
||||
String currentMimeType = child.getAttribute("name");
|
||||
if (currentMimeType != null)
|
||||
{
|
||||
String label = getSummaryMimeType(currentMimeType);
|
||||
this.createMimeTypes.add(new SelectItem(currentMimeType, label));
|
||||
}
|
||||
}
|
||||
|
||||
// make sure the list is sorted by the label
|
||||
QuickSort sorter = new QuickSort(this.objectTypes, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
|
||||
sorter.sort();
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.warn("Could not find 'create-mime-types' configuration element");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.warn("Could not find 'Content Wizards' configuration section");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return this.createMimeTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the summary data for the wizard.
|
||||
*/
|
||||
public String getSummary()
|
||||
{
|
||||
ResourceBundle bundle = Application.getBundle(FacesContext.getCurrentInstance());
|
||||
|
||||
// TODO: show first few lines of content here?
|
||||
return buildSummary(
|
||||
new String[] {bundle.getString("file_name"),
|
||||
bundle.getString("type"),
|
||||
bundle.getString("content_type")},
|
||||
new String[] {Utils.encode(this.fileName), getSummaryObjectType(),
|
||||
getSummaryMimeType(this.mimeType)});
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Action event handlers
|
||||
|
||||
/**
|
||||
* Create content type value changed by the user
|
||||
*/
|
||||
public void createContentChanged(ValueChangeEvent event)
|
||||
{
|
||||
// clear the content as HTML is not compatible with the plain text box etc.
|
||||
this.content = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String formatErrorMessage(Throwable exception)
|
||||
{
|
||||
if (exception instanceof FileExistsException)
|
||||
{
|
||||
return MessageFormat.format(Application.getMessage(
|
||||
FacesContext.getCurrentInstance(), Repository.ERROR_EXISTS),
|
||||
((FileExistsException)exception).getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
return MessageFormat.format(Application.getMessage(
|
||||
FacesContext.getCurrentInstance(), "error_content"),
|
||||
exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
package org.alfresco.web.bean.content;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.event.ValueChangeEvent;
|
||||
import javax.faces.model.SelectItem;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.service.cmr.model.FileExistsException;
|
||||
import org.alfresco.web.app.AlfrescoNavigationHandler;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.data.IDataContainer;
|
||||
import org.alfresco.web.data.QuickSort;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.config.Config;
|
||||
import org.springframework.extensions.config.ConfigElement;
|
||||
import org.springframework.extensions.config.ConfigService;
|
||||
|
||||
/**
|
||||
* Bean implementation for the "Create Content Wizard" dialog
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class CreateContentWizard extends BaseContentWizard
|
||||
{
|
||||
private static final long serialVersionUID = -2740634368271194418L;
|
||||
|
||||
protected String content = null;
|
||||
protected List<SelectItem> createMimeTypes;
|
||||
|
||||
private static Log logger = LogFactory.getLog(CreateContentWizard.class);
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Wizard implementation
|
||||
|
||||
|
||||
@Override
|
||||
public String finish()
|
||||
{
|
||||
String result = super.finish();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome)
|
||||
throws Exception
|
||||
{
|
||||
saveContent(null, this.content);
|
||||
|
||||
// return the default outcome
|
||||
return outcome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Map<String, String> parameters)
|
||||
{
|
||||
super.init(parameters);
|
||||
|
||||
this.content = null;
|
||||
this.inlineEdit = true;
|
||||
this.mimeType = MimetypeMap.MIMETYPE_HTML;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getNextButtonDisabled()
|
||||
{
|
||||
// TODO: Allow the next button state to be configured so that
|
||||
// wizard implementations don't have to worry about
|
||||
// checking step numbers
|
||||
|
||||
boolean disabled = false;
|
||||
int step = Application.getWizardManager().getCurrentStep();
|
||||
switch(step)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
disabled = (this.fileName == null || this.fileName.length() == 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return disabled;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean getFinishButtonDisabled()
|
||||
{
|
||||
boolean disabled = false;
|
||||
int step = Application.getWizardManager().getCurrentStep();
|
||||
switch(step)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
disabled = (this.fileName == null || this.fileName.length() == 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return disabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doPostCommitProcessing(FacesContext context, String outcome)
|
||||
{
|
||||
// as we were successful, go to the set properties dialog if asked
|
||||
// to otherwise just return
|
||||
if (this.showOtherProperties)
|
||||
{
|
||||
// check whether the created node is checked out, if a 'check out'
|
||||
// rule is present in the space the new node will be and an
|
||||
// attempt to modify the properties will cause an error (ALF-438)
|
||||
if (getNodeService().hasAspect(this.createdNode, ContentModel.ASPECT_LOCKABLE))
|
||||
{
|
||||
Utils.addErrorMessage(Application.getMessage(FacesContext.getCurrentInstance(), MSG_NODE_LOCKED));
|
||||
return outcome;
|
||||
}
|
||||
else
|
||||
{
|
||||
// we are going to immediately edit the properties so we need
|
||||
// to setup the BrowseBean context appropriately
|
||||
this.browseBean.setDocument(new Node(this.createdNode));
|
||||
|
||||
return getDefaultFinishOutcome() + AlfrescoNavigationHandler.OUTCOME_SEPARATOR +
|
||||
"dialog:setContentProperties";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return outcome;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Bean Getters and Setters
|
||||
|
||||
/**
|
||||
* @return Returns the content from the edited form.
|
||||
*/
|
||||
public String getContent()
|
||||
{
|
||||
return this.content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param content The content to edit (should be clear initially)
|
||||
*/
|
||||
public void setContent(String content)
|
||||
{
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns a list of mime types to allow the user to select from
|
||||
*/
|
||||
public List<SelectItem> getCreateMimeTypes()
|
||||
{
|
||||
if ((this.createMimeTypes == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance())))
|
||||
{
|
||||
FacesContext context = FacesContext.getCurrentInstance();
|
||||
|
||||
// add the well known object type to start with
|
||||
this.createMimeTypes = new ArrayList<SelectItem>(5);
|
||||
|
||||
// add the configured create mime types to the list
|
||||
ConfigService svc = Application.getConfigService(context);
|
||||
Config wizardCfg = svc.getConfig("Content Wizards");
|
||||
if (wizardCfg != null)
|
||||
{
|
||||
ConfigElement typesCfg = wizardCfg.getConfigElement("create-mime-types");
|
||||
if (typesCfg != null)
|
||||
{
|
||||
for (ConfigElement child : typesCfg.getChildren())
|
||||
{
|
||||
String currentMimeType = child.getAttribute("name");
|
||||
if (currentMimeType != null)
|
||||
{
|
||||
String label = getSummaryMimeType(currentMimeType);
|
||||
this.createMimeTypes.add(new SelectItem(currentMimeType, label));
|
||||
}
|
||||
}
|
||||
|
||||
// make sure the list is sorted by the label
|
||||
QuickSort sorter = new QuickSort(this.objectTypes, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
|
||||
sorter.sort();
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.warn("Could not find 'create-mime-types' configuration element");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.warn("Could not find 'Content Wizards' configuration section");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return this.createMimeTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the summary data for the wizard.
|
||||
*/
|
||||
public String getSummary()
|
||||
{
|
||||
ResourceBundle bundle = Application.getBundle(FacesContext.getCurrentInstance());
|
||||
|
||||
// TODO: show first few lines of content here?
|
||||
return buildSummary(
|
||||
new String[] {bundle.getString("file_name"),
|
||||
bundle.getString("type"),
|
||||
bundle.getString("content_type")},
|
||||
new String[] {Utils.encode(this.fileName), getSummaryObjectType(),
|
||||
getSummaryMimeType(this.mimeType)});
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Action event handlers
|
||||
|
||||
/**
|
||||
* Create content type value changed by the user
|
||||
*/
|
||||
public void createContentChanged(ValueChangeEvent event)
|
||||
{
|
||||
// clear the content as HTML is not compatible with the plain text box etc.
|
||||
this.content = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String formatErrorMessage(Throwable exception)
|
||||
{
|
||||
if (exception instanceof FileExistsException)
|
||||
{
|
||||
return MessageFormat.format(Application.getMessage(
|
||||
FacesContext.getCurrentInstance(), Repository.ERROR_EXISTS),
|
||||
((FileExistsException)exception).getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
return MessageFormat.format(Application.getMessage(
|
||||
FacesContext.getCurrentInstance(), "error_content"),
|
||||
exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,155 +1,155 @@
|
||||
package org.alfresco.web.bean.content;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.ml.MultilingualContentService;
|
||||
import org.alfresco.web.app.AlfrescoNavigationHandler;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Bean implementation for the "Delete Content" dialog
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class DeleteContentDialog extends BaseDialogBean
|
||||
{
|
||||
private static final long serialVersionUID = 4199496011879649213L;
|
||||
|
||||
transient private MultilingualContentService multilingualContentService;
|
||||
|
||||
private static final Log logger = LogFactory.getLog(DeleteContentDialog.class);
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Dialog implementation
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome)
|
||||
throws Exception
|
||||
{
|
||||
// get the content to delete
|
||||
Node node = this.browseBean.getDocument();
|
||||
if (node != null)
|
||||
{
|
||||
if(ContentModel.TYPE_MULTILINGUAL_CONTAINER.equals(node.getType()))
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Trying to delete multilingual container: " + node.getId() + " and its translations" );
|
||||
|
||||
// delete the mlContainer and its translations
|
||||
getMultilingualContentService().deleteTranslationContainer(node.getNodeRef());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Trying to delete content node: " + node.getId());
|
||||
|
||||
// delete the node
|
||||
this.getNodeService().deleteNode(node.getNodeRef());
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.warn("WARNING: delete called without a current Document!");
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doPostCommitProcessing(FacesContext context, String outcome)
|
||||
{
|
||||
// clear action context
|
||||
this.browseBean.setDocument(null);
|
||||
|
||||
// setting the outcome will show the browse view again
|
||||
return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME +
|
||||
AlfrescoNavigationHandler.OUTCOME_SEPARATOR + "browse";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getErrorMessageId()
|
||||
{
|
||||
return "error_delete_file";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFinishButtonDisabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Bean Getters and Setters
|
||||
|
||||
/**
|
||||
* Returns the confirmation to display to the user before deleting the content.
|
||||
*
|
||||
* @return The formatted message to display
|
||||
*/
|
||||
public String getConfirmMessage()
|
||||
{
|
||||
String fileConfirmMsg = null;
|
||||
|
||||
Node document = this.browseBean.getDocument();
|
||||
|
||||
if(document.getType().equals(ContentModel.TYPE_MULTILINGUAL_CONTAINER))
|
||||
{
|
||||
fileConfirmMsg = Application.getMessage(FacesContext.getCurrentInstance(),
|
||||
"delete_ml_container_confirm");
|
||||
}
|
||||
else if(document.hasAspect(ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION))
|
||||
{
|
||||
fileConfirmMsg = Application.getMessage(FacesContext.getCurrentInstance(),
|
||||
"delete_empty_translation_confirm");
|
||||
}
|
||||
else if(document.hasAspect(ContentModel.ASPECT_MULTILINGUAL_DOCUMENT))
|
||||
{
|
||||
fileConfirmMsg = Application.getMessage(FacesContext.getCurrentInstance(),
|
||||
"delete_translation_confirm");
|
||||
}
|
||||
else
|
||||
{
|
||||
String strHasMultipleParents = this.parameters.get("hasMultipleParents");
|
||||
if (strHasMultipleParents != null && "true".equals(strHasMultipleParents))
|
||||
{
|
||||
fileConfirmMsg = Application.getMessage(FacesContext.getCurrentInstance(),
|
||||
"delete_file_multiple_parents_confirm");
|
||||
}
|
||||
else
|
||||
{
|
||||
fileConfirmMsg = Application.getMessage(FacesContext.getCurrentInstance(),
|
||||
"delete_file_confirm");
|
||||
}
|
||||
}
|
||||
|
||||
return MessageFormat.format(fileConfirmMsg,
|
||||
new Object[] {document.getName()});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param multilingualContentService the Multilingual Content Service to set
|
||||
*/
|
||||
public void setMultilingualContentService(MultilingualContentService multilingualContentService)
|
||||
{
|
||||
this.multilingualContentService = multilingualContentService;
|
||||
}
|
||||
|
||||
protected MultilingualContentService getMultilingualContentService()
|
||||
{
|
||||
if (multilingualContentService == null)
|
||||
{
|
||||
multilingualContentService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getMultilingualContentService();
|
||||
}
|
||||
return multilingualContentService;
|
||||
}
|
||||
|
||||
}
|
||||
package org.alfresco.web.bean.content;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.ml.MultilingualContentService;
|
||||
import org.alfresco.web.app.AlfrescoNavigationHandler;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Bean implementation for the "Delete Content" dialog
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class DeleteContentDialog extends BaseDialogBean
|
||||
{
|
||||
private static final long serialVersionUID = 4199496011879649213L;
|
||||
|
||||
transient private MultilingualContentService multilingualContentService;
|
||||
|
||||
private static final Log logger = LogFactory.getLog(DeleteContentDialog.class);
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Dialog implementation
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome)
|
||||
throws Exception
|
||||
{
|
||||
// get the content to delete
|
||||
Node node = this.browseBean.getDocument();
|
||||
if (node != null)
|
||||
{
|
||||
if(ContentModel.TYPE_MULTILINGUAL_CONTAINER.equals(node.getType()))
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Trying to delete multilingual container: " + node.getId() + " and its translations" );
|
||||
|
||||
// delete the mlContainer and its translations
|
||||
getMultilingualContentService().deleteTranslationContainer(node.getNodeRef());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Trying to delete content node: " + node.getId());
|
||||
|
||||
// delete the node
|
||||
this.getNodeService().deleteNode(node.getNodeRef());
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.warn("WARNING: delete called without a current Document!");
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doPostCommitProcessing(FacesContext context, String outcome)
|
||||
{
|
||||
// clear action context
|
||||
this.browseBean.setDocument(null);
|
||||
|
||||
// setting the outcome will show the browse view again
|
||||
return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME +
|
||||
AlfrescoNavigationHandler.OUTCOME_SEPARATOR + "browse";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getErrorMessageId()
|
||||
{
|
||||
return "error_delete_file";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFinishButtonDisabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Bean Getters and Setters
|
||||
|
||||
/**
|
||||
* Returns the confirmation to display to the user before deleting the content.
|
||||
*
|
||||
* @return The formatted message to display
|
||||
*/
|
||||
public String getConfirmMessage()
|
||||
{
|
||||
String fileConfirmMsg = null;
|
||||
|
||||
Node document = this.browseBean.getDocument();
|
||||
|
||||
if(document.getType().equals(ContentModel.TYPE_MULTILINGUAL_CONTAINER))
|
||||
{
|
||||
fileConfirmMsg = Application.getMessage(FacesContext.getCurrentInstance(),
|
||||
"delete_ml_container_confirm");
|
||||
}
|
||||
else if(document.hasAspect(ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION))
|
||||
{
|
||||
fileConfirmMsg = Application.getMessage(FacesContext.getCurrentInstance(),
|
||||
"delete_empty_translation_confirm");
|
||||
}
|
||||
else if(document.hasAspect(ContentModel.ASPECT_MULTILINGUAL_DOCUMENT))
|
||||
{
|
||||
fileConfirmMsg = Application.getMessage(FacesContext.getCurrentInstance(),
|
||||
"delete_translation_confirm");
|
||||
}
|
||||
else
|
||||
{
|
||||
String strHasMultipleParents = this.parameters.get("hasMultipleParents");
|
||||
if (strHasMultipleParents != null && "true".equals(strHasMultipleParents))
|
||||
{
|
||||
fileConfirmMsg = Application.getMessage(FacesContext.getCurrentInstance(),
|
||||
"delete_file_multiple_parents_confirm");
|
||||
}
|
||||
else
|
||||
{
|
||||
fileConfirmMsg = Application.getMessage(FacesContext.getCurrentInstance(),
|
||||
"delete_file_confirm");
|
||||
}
|
||||
}
|
||||
|
||||
return MessageFormat.format(fileConfirmMsg,
|
||||
new Object[] {document.getName()});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param multilingualContentService the Multilingual Content Service to set
|
||||
*/
|
||||
public void setMultilingualContentService(MultilingualContentService multilingualContentService)
|
||||
{
|
||||
this.multilingualContentService = multilingualContentService;
|
||||
}
|
||||
|
||||
protected MultilingualContentService getMultilingualContentService()
|
||||
{
|
||||
if (multilingualContentService == null)
|
||||
{
|
||||
multilingualContentService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getMultilingualContentService();
|
||||
}
|
||||
return multilingualContentService;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,306 +1,306 @@
|
||||
package org.alfresco.web.bean.content;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.service.cmr.model.FileExistsException;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
|
||||
/**
|
||||
* Bean implementation of the "Edit Content Properties" dialog.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class EditContentPropertiesDialog extends BaseDialogBean
|
||||
{
|
||||
private static final long serialVersionUID = -5681296528149487178L;
|
||||
|
||||
protected static final String TEMP_PROP_MIMETYPE = "mimetype";
|
||||
protected static final String TEMP_PROP_ENCODING = "encoding";
|
||||
|
||||
protected Node editableNode;
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Dialog implementation
|
||||
|
||||
@Override
|
||||
public void init(Map<String, String> parameters)
|
||||
{
|
||||
super.init(parameters);
|
||||
|
||||
// setup the editable node
|
||||
this.editableNode = initEditableNode();
|
||||
|
||||
if(editableNode != null)
|
||||
{
|
||||
|
||||
// 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Init the editable Node
|
||||
*/
|
||||
protected Node initEditableNode()
|
||||
{
|
||||
final Node document = this.browseBean.getDocument();
|
||||
if (document != null)
|
||||
{
|
||||
return new Node(document.getNodeRef());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome)
|
||||
throws Exception
|
||||
{
|
||||
NodeRef nodeRef = this.editableNode.getNodeRef();
|
||||
Map<String, Object> editedProps = this.editableNode.getProperties();
|
||||
|
||||
// get the name and move the node as necessary
|
||||
String name = (String) editedProps.get(ContentModel.PROP_NAME);
|
||||
if (name != null)
|
||||
{
|
||||
getFileFolderService().rename(nodeRef, name);
|
||||
}
|
||||
|
||||
// we need to put all the properties from the editable bag back into
|
||||
// the format expected by the repository
|
||||
Map<QName, Serializable> repoProps = this.getNodeService().getProperties(nodeRef);
|
||||
|
||||
// Extract and deal with the special mimetype property for ContentData
|
||||
String mimetype = (String) editedProps.get(TEMP_PROP_MIMETYPE);
|
||||
if (mimetype != null)
|
||||
{
|
||||
// remove temporary prop from list so it isn't saved with the others
|
||||
editedProps.remove(TEMP_PROP_MIMETYPE);
|
||||
ContentData contentData = (ContentData)editedProps.get(ContentModel.PROP_CONTENT);
|
||||
if (contentData != null)
|
||||
{
|
||||
contentData = ContentData.setMimetype(contentData, mimetype);
|
||||
editedProps.put(ContentModel.PROP_CONTENT.toString(), contentData);
|
||||
}
|
||||
}
|
||||
// Extract and deal with the special encoding property for ContentData
|
||||
String encoding = (String) editedProps.get(TEMP_PROP_ENCODING);
|
||||
if (encoding != null)
|
||||
{
|
||||
// remove temporary prop from list so it isn't saved with the others
|
||||
editedProps.remove(TEMP_PROP_ENCODING);
|
||||
ContentData contentData = (ContentData) editedProps.get(ContentModel.PROP_CONTENT);
|
||||
if (contentData != null)
|
||||
{
|
||||
contentData = ContentData.setEncoding(contentData, encoding);
|
||||
editedProps.put(ContentModel.PROP_CONTENT.toString(), contentData);
|
||||
}
|
||||
}
|
||||
|
||||
// add the "author" aspect if required, properties will get set below
|
||||
if (this.getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_AUTHOR) == false)
|
||||
{
|
||||
this.getNodeService().addAspect(nodeRef, ContentModel.ASPECT_AUTHOR, null);
|
||||
}
|
||||
|
||||
// add the "titled" aspect if required, properties will get set below
|
||||
if (this.getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_TITLED) == false)
|
||||
{
|
||||
getNodeService().addAspect(nodeRef, ContentModel.ASPECT_TITLED, null);
|
||||
}
|
||||
|
||||
// add the remaining properties
|
||||
Iterator<String> iterProps = editedProps.keySet().iterator();
|
||||
while (iterProps.hasNext())
|
||||
{
|
||||
String propName = iterProps.next();
|
||||
QName qname = QName.createQName(propName);
|
||||
|
||||
// make sure the property is represented correctly
|
||||
Serializable propValue = (Serializable)editedProps.get(propName);
|
||||
|
||||
// check for empty strings when using number types, set to null in this case
|
||||
if (propValue instanceof String)
|
||||
{
|
||||
PropertyDefinition propDef = this.getDictionaryService().getProperty(qname);
|
||||
if (((String)propValue).length() == 0)
|
||||
{
|
||||
if (propDef != null)
|
||||
{
|
||||
if (propDef.getDataType().getName().equals(DataTypeDefinition.DOUBLE) ||
|
||||
propDef.getDataType().getName().equals(DataTypeDefinition.FLOAT) ||
|
||||
propDef.getDataType().getName().equals(DataTypeDefinition.INT) ||
|
||||
propDef.getDataType().getName().equals(DataTypeDefinition.LONG))
|
||||
{
|
||||
propValue = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
// handle locale strings to Locale objects
|
||||
else if (propDef != null && propDef.getDataType().getName().equals(DataTypeDefinition.LOCALE))
|
||||
{
|
||||
propValue = I18NUtil.parseLocale((String)propValue);
|
||||
}
|
||||
}
|
||||
|
||||
repoProps.put(qname, propValue);
|
||||
}
|
||||
|
||||
// send the properties back to the repository
|
||||
this.getNodeService().setProperties(nodeRef, repoProps);
|
||||
|
||||
// we also need to persist any association changes that may have been made
|
||||
|
||||
// add any associations added in the UI
|
||||
Map<String, Map<String, AssociationRef>> addedAssocs = this.editableNode.getAddedAssociations();
|
||||
for (Map<String, AssociationRef> typedAssoc : addedAssocs.values())
|
||||
{
|
||||
for (AssociationRef assoc : typedAssoc.values())
|
||||
{
|
||||
this.getNodeService().createAssociation(assoc.getSourceRef(), assoc.getTargetRef(), assoc.getTypeQName());
|
||||
}
|
||||
}
|
||||
|
||||
// remove any association removed in the UI
|
||||
Map<String, Map<String, AssociationRef>> removedAssocs = this.editableNode.getRemovedAssociations();
|
||||
for (Map<String, AssociationRef> typedAssoc : removedAssocs.values())
|
||||
{
|
||||
for (AssociationRef assoc : typedAssoc.values())
|
||||
{
|
||||
this.getNodeService().removeAssociation(assoc.getSourceRef(), assoc.getTargetRef(), assoc.getTypeQName());
|
||||
}
|
||||
}
|
||||
|
||||
// add any child associations added in the UI
|
||||
Map<String, Map<String, ChildAssociationRef>> addedChildAssocs = this.editableNode.getAddedChildAssociations();
|
||||
for (Map<String, ChildAssociationRef> typedAssoc : addedChildAssocs.values())
|
||||
{
|
||||
for (ChildAssociationRef assoc : typedAssoc.values())
|
||||
{
|
||||
this.getNodeService().addChild(assoc.getParentRef(), assoc.getChildRef(), assoc.getTypeQName(), assoc.getTypeQName());
|
||||
}
|
||||
}
|
||||
|
||||
// remove any child association removed in the UI
|
||||
Map<String, Map<String, ChildAssociationRef>> removedChildAssocs = this.editableNode.getRemovedChildAssociations();
|
||||
for (Map<String, ChildAssociationRef> typedAssoc : removedChildAssocs.values())
|
||||
{
|
||||
for (ChildAssociationRef assoc : typedAssoc.values())
|
||||
{
|
||||
this.getNodeService().removeChild(assoc.getParentRef(), assoc.getChildRef());
|
||||
}
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doPostCommitProcessing(FacesContext context, String outcome)
|
||||
{
|
||||
// reset the document held by the browse bean as it's just been updated
|
||||
this.browseBean.getDocument().reset();
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats the error message to display if an error occurs during finish processing
|
||||
*
|
||||
* @param exception The exception
|
||||
* @return The formatted message
|
||||
*/
|
||||
@Override
|
||||
protected String formatErrorMessage(Throwable exception)
|
||||
{
|
||||
if(editableNode != null)
|
||||
{
|
||||
|
||||
// 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());
|
||||
}
|
||||
}
|
||||
|
||||
if (exception instanceof FileExistsException)
|
||||
{
|
||||
return MessageFormat.format(Application.getMessage(
|
||||
FacesContext.getCurrentInstance(), Repository.ERROR_EXISTS),
|
||||
((FileExistsException)exception).getName());
|
||||
}
|
||||
else if (exception instanceof InvalidNodeRefException)
|
||||
{
|
||||
return MessageFormat.format(Application.getMessage(
|
||||
FacesContext.getCurrentInstance(), Repository.ERROR_NODEREF),
|
||||
new Object[] {this.browseBean.getDocument().getId()});
|
||||
}
|
||||
else
|
||||
{
|
||||
return super.formatErrorMessage(exception);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getErrorOutcome(Throwable exception)
|
||||
{
|
||||
if (exception instanceof InvalidNodeRefException)
|
||||
{
|
||||
// this failure means the node no longer exists - we cannot show
|
||||
// the content properties screen again so go back to the main page
|
||||
return "browse";
|
||||
}
|
||||
else
|
||||
{
|
||||
return super.getErrorOutcome(exception);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFinishButtonDisabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Bean getters and setters
|
||||
|
||||
/**
|
||||
* Returns the node being edited
|
||||
*
|
||||
* @return The node being edited
|
||||
*/
|
||||
public Node getEditableNode()
|
||||
{
|
||||
return this.editableNode;
|
||||
}
|
||||
}
|
||||
package org.alfresco.web.bean.content;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.service.cmr.model.FileExistsException;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
|
||||
/**
|
||||
* Bean implementation of the "Edit Content Properties" dialog.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class EditContentPropertiesDialog extends BaseDialogBean
|
||||
{
|
||||
private static final long serialVersionUID = -5681296528149487178L;
|
||||
|
||||
protected static final String TEMP_PROP_MIMETYPE = "mimetype";
|
||||
protected static final String TEMP_PROP_ENCODING = "encoding";
|
||||
|
||||
protected Node editableNode;
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Dialog implementation
|
||||
|
||||
@Override
|
||||
public void init(Map<String, String> parameters)
|
||||
{
|
||||
super.init(parameters);
|
||||
|
||||
// setup the editable node
|
||||
this.editableNode = initEditableNode();
|
||||
|
||||
if(editableNode != null)
|
||||
{
|
||||
|
||||
// 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Init the editable Node
|
||||
*/
|
||||
protected Node initEditableNode()
|
||||
{
|
||||
final Node document = this.browseBean.getDocument();
|
||||
if (document != null)
|
||||
{
|
||||
return new Node(document.getNodeRef());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome)
|
||||
throws Exception
|
||||
{
|
||||
NodeRef nodeRef = this.editableNode.getNodeRef();
|
||||
Map<String, Object> editedProps = this.editableNode.getProperties();
|
||||
|
||||
// get the name and move the node as necessary
|
||||
String name = (String) editedProps.get(ContentModel.PROP_NAME);
|
||||
if (name != null)
|
||||
{
|
||||
getFileFolderService().rename(nodeRef, name);
|
||||
}
|
||||
|
||||
// we need to put all the properties from the editable bag back into
|
||||
// the format expected by the repository
|
||||
Map<QName, Serializable> repoProps = this.getNodeService().getProperties(nodeRef);
|
||||
|
||||
// Extract and deal with the special mimetype property for ContentData
|
||||
String mimetype = (String) editedProps.get(TEMP_PROP_MIMETYPE);
|
||||
if (mimetype != null)
|
||||
{
|
||||
// remove temporary prop from list so it isn't saved with the others
|
||||
editedProps.remove(TEMP_PROP_MIMETYPE);
|
||||
ContentData contentData = (ContentData)editedProps.get(ContentModel.PROP_CONTENT);
|
||||
if (contentData != null)
|
||||
{
|
||||
contentData = ContentData.setMimetype(contentData, mimetype);
|
||||
editedProps.put(ContentModel.PROP_CONTENT.toString(), contentData);
|
||||
}
|
||||
}
|
||||
// Extract and deal with the special encoding property for ContentData
|
||||
String encoding = (String) editedProps.get(TEMP_PROP_ENCODING);
|
||||
if (encoding != null)
|
||||
{
|
||||
// remove temporary prop from list so it isn't saved with the others
|
||||
editedProps.remove(TEMP_PROP_ENCODING);
|
||||
ContentData contentData = (ContentData) editedProps.get(ContentModel.PROP_CONTENT);
|
||||
if (contentData != null)
|
||||
{
|
||||
contentData = ContentData.setEncoding(contentData, encoding);
|
||||
editedProps.put(ContentModel.PROP_CONTENT.toString(), contentData);
|
||||
}
|
||||
}
|
||||
|
||||
// add the "author" aspect if required, properties will get set below
|
||||
if (this.getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_AUTHOR) == false)
|
||||
{
|
||||
this.getNodeService().addAspect(nodeRef, ContentModel.ASPECT_AUTHOR, null);
|
||||
}
|
||||
|
||||
// add the "titled" aspect if required, properties will get set below
|
||||
if (this.getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_TITLED) == false)
|
||||
{
|
||||
getNodeService().addAspect(nodeRef, ContentModel.ASPECT_TITLED, null);
|
||||
}
|
||||
|
||||
// add the remaining properties
|
||||
Iterator<String> iterProps = editedProps.keySet().iterator();
|
||||
while (iterProps.hasNext())
|
||||
{
|
||||
String propName = iterProps.next();
|
||||
QName qname = QName.createQName(propName);
|
||||
|
||||
// make sure the property is represented correctly
|
||||
Serializable propValue = (Serializable)editedProps.get(propName);
|
||||
|
||||
// check for empty strings when using number types, set to null in this case
|
||||
if (propValue instanceof String)
|
||||
{
|
||||
PropertyDefinition propDef = this.getDictionaryService().getProperty(qname);
|
||||
if (((String)propValue).length() == 0)
|
||||
{
|
||||
if (propDef != null)
|
||||
{
|
||||
if (propDef.getDataType().getName().equals(DataTypeDefinition.DOUBLE) ||
|
||||
propDef.getDataType().getName().equals(DataTypeDefinition.FLOAT) ||
|
||||
propDef.getDataType().getName().equals(DataTypeDefinition.INT) ||
|
||||
propDef.getDataType().getName().equals(DataTypeDefinition.LONG))
|
||||
{
|
||||
propValue = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
// handle locale strings to Locale objects
|
||||
else if (propDef != null && propDef.getDataType().getName().equals(DataTypeDefinition.LOCALE))
|
||||
{
|
||||
propValue = I18NUtil.parseLocale((String)propValue);
|
||||
}
|
||||
}
|
||||
|
||||
repoProps.put(qname, propValue);
|
||||
}
|
||||
|
||||
// send the properties back to the repository
|
||||
this.getNodeService().setProperties(nodeRef, repoProps);
|
||||
|
||||
// we also need to persist any association changes that may have been made
|
||||
|
||||
// add any associations added in the UI
|
||||
Map<String, Map<String, AssociationRef>> addedAssocs = this.editableNode.getAddedAssociations();
|
||||
for (Map<String, AssociationRef> typedAssoc : addedAssocs.values())
|
||||
{
|
||||
for (AssociationRef assoc : typedAssoc.values())
|
||||
{
|
||||
this.getNodeService().createAssociation(assoc.getSourceRef(), assoc.getTargetRef(), assoc.getTypeQName());
|
||||
}
|
||||
}
|
||||
|
||||
// remove any association removed in the UI
|
||||
Map<String, Map<String, AssociationRef>> removedAssocs = this.editableNode.getRemovedAssociations();
|
||||
for (Map<String, AssociationRef> typedAssoc : removedAssocs.values())
|
||||
{
|
||||
for (AssociationRef assoc : typedAssoc.values())
|
||||
{
|
||||
this.getNodeService().removeAssociation(assoc.getSourceRef(), assoc.getTargetRef(), assoc.getTypeQName());
|
||||
}
|
||||
}
|
||||
|
||||
// add any child associations added in the UI
|
||||
Map<String, Map<String, ChildAssociationRef>> addedChildAssocs = this.editableNode.getAddedChildAssociations();
|
||||
for (Map<String, ChildAssociationRef> typedAssoc : addedChildAssocs.values())
|
||||
{
|
||||
for (ChildAssociationRef assoc : typedAssoc.values())
|
||||
{
|
||||
this.getNodeService().addChild(assoc.getParentRef(), assoc.getChildRef(), assoc.getTypeQName(), assoc.getTypeQName());
|
||||
}
|
||||
}
|
||||
|
||||
// remove any child association removed in the UI
|
||||
Map<String, Map<String, ChildAssociationRef>> removedChildAssocs = this.editableNode.getRemovedChildAssociations();
|
||||
for (Map<String, ChildAssociationRef> typedAssoc : removedChildAssocs.values())
|
||||
{
|
||||
for (ChildAssociationRef assoc : typedAssoc.values())
|
||||
{
|
||||
this.getNodeService().removeChild(assoc.getParentRef(), assoc.getChildRef());
|
||||
}
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doPostCommitProcessing(FacesContext context, String outcome)
|
||||
{
|
||||
// reset the document held by the browse bean as it's just been updated
|
||||
this.browseBean.getDocument().reset();
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats the error message to display if an error occurs during finish processing
|
||||
*
|
||||
* @param exception The exception
|
||||
* @return The formatted message
|
||||
*/
|
||||
@Override
|
||||
protected String formatErrorMessage(Throwable exception)
|
||||
{
|
||||
if(editableNode != null)
|
||||
{
|
||||
|
||||
// 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());
|
||||
}
|
||||
}
|
||||
|
||||
if (exception instanceof FileExistsException)
|
||||
{
|
||||
return MessageFormat.format(Application.getMessage(
|
||||
FacesContext.getCurrentInstance(), Repository.ERROR_EXISTS),
|
||||
((FileExistsException)exception).getName());
|
||||
}
|
||||
else if (exception instanceof InvalidNodeRefException)
|
||||
{
|
||||
return MessageFormat.format(Application.getMessage(
|
||||
FacesContext.getCurrentInstance(), Repository.ERROR_NODEREF),
|
||||
new Object[] {this.browseBean.getDocument().getId()});
|
||||
}
|
||||
else
|
||||
{
|
||||
return super.formatErrorMessage(exception);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getErrorOutcome(Throwable exception)
|
||||
{
|
||||
if (exception instanceof InvalidNodeRefException)
|
||||
{
|
||||
// this failure means the node no longer exists - we cannot show
|
||||
// the content properties screen again so go back to the main page
|
||||
return "browse";
|
||||
}
|
||||
else
|
||||
{
|
||||
return super.getErrorOutcome(exception);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFinishButtonDisabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Bean getters and setters
|
||||
|
||||
/**
|
||||
* Returns the node being edited
|
||||
*
|
||||
* @return The node being edited
|
||||
*/
|
||||
public Node getEditableNode()
|
||||
{
|
||||
return this.editableNode;
|
||||
}
|
||||
}
|
||||
|
@@ -1,160 +1,160 @@
|
||||
package org.alfresco.web.bean.content;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.ApplicationModel;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.actions.handlers.SimpleWorkflowHandler;
|
||||
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.ui.common.ReportedException;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
|
||||
public class EditSimpleWorkflowDialog extends BaseDialogBean
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 7203447561571625990L;
|
||||
|
||||
private static final String MSG_ERROR_UPDATE_SIMPLEWORKFLOW = "error_update_simpleworkflow";
|
||||
|
||||
protected Map<String, Serializable> workflowProperties;
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||
{
|
||||
saveWorkflow();
|
||||
return outcome;
|
||||
}
|
||||
|
||||
public boolean getFinishButtonDisabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public Node getNode()
|
||||
{
|
||||
return this.browseBean.getDocument();
|
||||
}
|
||||
|
||||
public Node getDocument()
|
||||
{
|
||||
return this.getNode();
|
||||
}
|
||||
|
||||
public String saveWorkflow()
|
||||
{
|
||||
String outcome = "cancel";
|
||||
|
||||
try
|
||||
{
|
||||
Map<QName, Serializable> updateProps = getNodeService().getProperties(getNode().getNodeRef());
|
||||
|
||||
// update the simple workflow properties
|
||||
|
||||
// set the approve step name
|
||||
updateProps.put(ApplicationModel.PROP_APPROVE_STEP, workflowProperties.get(SimpleWorkflowHandler.PROP_APPROVE_STEP_NAME));
|
||||
|
||||
// specify whether the approve step will copy or move the content
|
||||
boolean approveMove = true;
|
||||
String approveAction = (String) workflowProperties.get(SimpleWorkflowHandler.PROP_APPROVE_ACTION);
|
||||
if (approveAction != null && approveAction.equals("copy"))
|
||||
{
|
||||
approveMove = false;
|
||||
}
|
||||
updateProps.put(ApplicationModel.PROP_APPROVE_MOVE, Boolean.valueOf(approveMove));
|
||||
|
||||
// create node ref representation of the destination folder
|
||||
updateProps.put(ApplicationModel.PROP_APPROVE_FOLDER, workflowProperties.get(SimpleWorkflowHandler.PROP_APPROVE_FOLDER));
|
||||
|
||||
// determine whether there should be a reject step
|
||||
boolean requireReject = true;
|
||||
String rejectStepPresent = (String) workflowProperties.get(SimpleWorkflowHandler.PROP_REJECT_STEP_PRESENT);
|
||||
if (rejectStepPresent != null && rejectStepPresent.equals("no"))
|
||||
{
|
||||
requireReject = false;
|
||||
}
|
||||
|
||||
if (requireReject)
|
||||
{
|
||||
// set the reject step name
|
||||
updateProps.put(ApplicationModel.PROP_REJECT_STEP, workflowProperties.get(SimpleWorkflowHandler.PROP_REJECT_STEP_NAME));
|
||||
|
||||
// specify whether the reject step will copy or move the content
|
||||
boolean rejectMove = true;
|
||||
String rejectAction = (String) workflowProperties.get(SimpleWorkflowHandler.PROP_REJECT_ACTION);
|
||||
if (rejectAction != null && rejectAction.equals("copy"))
|
||||
{
|
||||
rejectMove = false;
|
||||
}
|
||||
updateProps.put(ApplicationModel.PROP_REJECT_MOVE, Boolean.valueOf(rejectMove));
|
||||
|
||||
// create node ref representation of the destination folder
|
||||
updateProps.put(ApplicationModel.PROP_REJECT_FOLDER, workflowProperties.get(SimpleWorkflowHandler.PROP_REJECT_FOLDER));
|
||||
}
|
||||
else
|
||||
{
|
||||
// set all the reject properties to null to signify there should
|
||||
// be no reject step
|
||||
updateProps.put(ApplicationModel.PROP_REJECT_STEP, null);
|
||||
updateProps.put(ApplicationModel.PROP_REJECT_MOVE, null);
|
||||
updateProps.put(ApplicationModel.PROP_REJECT_FOLDER, null);
|
||||
}
|
||||
|
||||
// set the properties on the node
|
||||
getNodeService().setProperties(getNode().getNodeRef(), updateProps);
|
||||
getNode().reset();
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), MSG_ERROR_UPDATE_SIMPLEWORKFLOW), e.getMessage()), e);
|
||||
ReportedException.throwIfNecessary(e);
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
public Map<String, Serializable> getWorkflowProperties()
|
||||
{
|
||||
if (this.workflowProperties == null && getNode().hasAspect(ApplicationModel.ASPECT_SIMPLE_WORKFLOW))
|
||||
{
|
||||
// get the exisiting properties for the node
|
||||
Map<String, Object> props = getNode().getProperties();
|
||||
|
||||
String approveStepName = (String) props.get(ApplicationModel.PROP_APPROVE_STEP.toString());
|
||||
String rejectStepName = (String) props.get(ApplicationModel.PROP_REJECT_STEP.toString());
|
||||
|
||||
Boolean approveMove = (Boolean) props.get(ApplicationModel.PROP_APPROVE_MOVE.toString());
|
||||
Boolean rejectMove = (Boolean) props.get(ApplicationModel.PROP_REJECT_MOVE.toString());
|
||||
|
||||
NodeRef approveFolder = (NodeRef) props.get(ApplicationModel.PROP_APPROVE_FOLDER.toString());
|
||||
NodeRef rejectFolder = (NodeRef) props.get(ApplicationModel.PROP_REJECT_FOLDER.toString());
|
||||
|
||||
// put the workflow properties in a separate map for use by the JSP
|
||||
this.workflowProperties = new HashMap<String, Serializable>(7);
|
||||
this.workflowProperties.put(SimpleWorkflowHandler.PROP_APPROVE_STEP_NAME, approveStepName);
|
||||
this.workflowProperties.put(SimpleWorkflowHandler.PROP_APPROVE_ACTION, approveMove ? "move" : "copy");
|
||||
this.workflowProperties.put(SimpleWorkflowHandler.PROP_APPROVE_FOLDER, approveFolder);
|
||||
|
||||
if (rejectStepName == null || rejectMove == null || rejectFolder == null)
|
||||
{
|
||||
this.workflowProperties.put(SimpleWorkflowHandler.PROP_REJECT_STEP_PRESENT, "no");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.workflowProperties.put(SimpleWorkflowHandler.PROP_REJECT_STEP_PRESENT, "yes");
|
||||
this.workflowProperties.put(SimpleWorkflowHandler.PROP_REJECT_STEP_NAME, rejectStepName);
|
||||
this.workflowProperties.put(SimpleWorkflowHandler.PROP_REJECT_ACTION, rejectMove ? "move" : "copy");
|
||||
this.workflowProperties.put(SimpleWorkflowHandler.PROP_REJECT_FOLDER, rejectFolder);
|
||||
}
|
||||
}
|
||||
|
||||
return this.workflowProperties;
|
||||
}
|
||||
}
|
||||
package org.alfresco.web.bean.content;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.ApplicationModel;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.actions.handlers.SimpleWorkflowHandler;
|
||||
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.ui.common.ReportedException;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
|
||||
public class EditSimpleWorkflowDialog extends BaseDialogBean
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 7203447561571625990L;
|
||||
|
||||
private static final String MSG_ERROR_UPDATE_SIMPLEWORKFLOW = "error_update_simpleworkflow";
|
||||
|
||||
protected Map<String, Serializable> workflowProperties;
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||
{
|
||||
saveWorkflow();
|
||||
return outcome;
|
||||
}
|
||||
|
||||
public boolean getFinishButtonDisabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public Node getNode()
|
||||
{
|
||||
return this.browseBean.getDocument();
|
||||
}
|
||||
|
||||
public Node getDocument()
|
||||
{
|
||||
return this.getNode();
|
||||
}
|
||||
|
||||
public String saveWorkflow()
|
||||
{
|
||||
String outcome = "cancel";
|
||||
|
||||
try
|
||||
{
|
||||
Map<QName, Serializable> updateProps = getNodeService().getProperties(getNode().getNodeRef());
|
||||
|
||||
// update the simple workflow properties
|
||||
|
||||
// set the approve step name
|
||||
updateProps.put(ApplicationModel.PROP_APPROVE_STEP, workflowProperties.get(SimpleWorkflowHandler.PROP_APPROVE_STEP_NAME));
|
||||
|
||||
// specify whether the approve step will copy or move the content
|
||||
boolean approveMove = true;
|
||||
String approveAction = (String) workflowProperties.get(SimpleWorkflowHandler.PROP_APPROVE_ACTION);
|
||||
if (approveAction != null && approveAction.equals("copy"))
|
||||
{
|
||||
approveMove = false;
|
||||
}
|
||||
updateProps.put(ApplicationModel.PROP_APPROVE_MOVE, Boolean.valueOf(approveMove));
|
||||
|
||||
// create node ref representation of the destination folder
|
||||
updateProps.put(ApplicationModel.PROP_APPROVE_FOLDER, workflowProperties.get(SimpleWorkflowHandler.PROP_APPROVE_FOLDER));
|
||||
|
||||
// determine whether there should be a reject step
|
||||
boolean requireReject = true;
|
||||
String rejectStepPresent = (String) workflowProperties.get(SimpleWorkflowHandler.PROP_REJECT_STEP_PRESENT);
|
||||
if (rejectStepPresent != null && rejectStepPresent.equals("no"))
|
||||
{
|
||||
requireReject = false;
|
||||
}
|
||||
|
||||
if (requireReject)
|
||||
{
|
||||
// set the reject step name
|
||||
updateProps.put(ApplicationModel.PROP_REJECT_STEP, workflowProperties.get(SimpleWorkflowHandler.PROP_REJECT_STEP_NAME));
|
||||
|
||||
// specify whether the reject step will copy or move the content
|
||||
boolean rejectMove = true;
|
||||
String rejectAction = (String) workflowProperties.get(SimpleWorkflowHandler.PROP_REJECT_ACTION);
|
||||
if (rejectAction != null && rejectAction.equals("copy"))
|
||||
{
|
||||
rejectMove = false;
|
||||
}
|
||||
updateProps.put(ApplicationModel.PROP_REJECT_MOVE, Boolean.valueOf(rejectMove));
|
||||
|
||||
// create node ref representation of the destination folder
|
||||
updateProps.put(ApplicationModel.PROP_REJECT_FOLDER, workflowProperties.get(SimpleWorkflowHandler.PROP_REJECT_FOLDER));
|
||||
}
|
||||
else
|
||||
{
|
||||
// set all the reject properties to null to signify there should
|
||||
// be no reject step
|
||||
updateProps.put(ApplicationModel.PROP_REJECT_STEP, null);
|
||||
updateProps.put(ApplicationModel.PROP_REJECT_MOVE, null);
|
||||
updateProps.put(ApplicationModel.PROP_REJECT_FOLDER, null);
|
||||
}
|
||||
|
||||
// set the properties on the node
|
||||
getNodeService().setProperties(getNode().getNodeRef(), updateProps);
|
||||
getNode().reset();
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), MSG_ERROR_UPDATE_SIMPLEWORKFLOW), e.getMessage()), e);
|
||||
ReportedException.throwIfNecessary(e);
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
public Map<String, Serializable> getWorkflowProperties()
|
||||
{
|
||||
if (this.workflowProperties == null && getNode().hasAspect(ApplicationModel.ASPECT_SIMPLE_WORKFLOW))
|
||||
{
|
||||
// get the exisiting properties for the node
|
||||
Map<String, Object> props = getNode().getProperties();
|
||||
|
||||
String approveStepName = (String) props.get(ApplicationModel.PROP_APPROVE_STEP.toString());
|
||||
String rejectStepName = (String) props.get(ApplicationModel.PROP_REJECT_STEP.toString());
|
||||
|
||||
Boolean approveMove = (Boolean) props.get(ApplicationModel.PROP_APPROVE_MOVE.toString());
|
||||
Boolean rejectMove = (Boolean) props.get(ApplicationModel.PROP_REJECT_MOVE.toString());
|
||||
|
||||
NodeRef approveFolder = (NodeRef) props.get(ApplicationModel.PROP_APPROVE_FOLDER.toString());
|
||||
NodeRef rejectFolder = (NodeRef) props.get(ApplicationModel.PROP_REJECT_FOLDER.toString());
|
||||
|
||||
// put the workflow properties in a separate map for use by the JSP
|
||||
this.workflowProperties = new HashMap<String, Serializable>(7);
|
||||
this.workflowProperties.put(SimpleWorkflowHandler.PROP_APPROVE_STEP_NAME, approveStepName);
|
||||
this.workflowProperties.put(SimpleWorkflowHandler.PROP_APPROVE_ACTION, approveMove ? "move" : "copy");
|
||||
this.workflowProperties.put(SimpleWorkflowHandler.PROP_APPROVE_FOLDER, approveFolder);
|
||||
|
||||
if (rejectStepName == null || rejectMove == null || rejectFolder == null)
|
||||
{
|
||||
this.workflowProperties.put(SimpleWorkflowHandler.PROP_REJECT_STEP_PRESENT, "no");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.workflowProperties.put(SimpleWorkflowHandler.PROP_REJECT_STEP_PRESENT, "yes");
|
||||
this.workflowProperties.put(SimpleWorkflowHandler.PROP_REJECT_STEP_NAME, rejectStepName);
|
||||
this.workflowProperties.put(SimpleWorkflowHandler.PROP_REJECT_ACTION, rejectMove ? "move" : "copy");
|
||||
this.workflowProperties.put(SimpleWorkflowHandler.PROP_REJECT_FOLDER, rejectFolder);
|
||||
}
|
||||
}
|
||||
|
||||
return this.workflowProperties;
|
||||
}
|
||||
}
|
||||
|
@@ -1,43 +1,43 @@
|
||||
package org.alfresco.web.bean.content;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.wizard.BaseInviteUsersWizard;
|
||||
|
||||
/**
|
||||
* Concrete implementation providing the ability to invite users to content.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class InviteContentUsersWizard extends BaseInviteUsersWizard
|
||||
{
|
||||
private static final long serialVersionUID = 9198783146031469545L;
|
||||
|
||||
@Override
|
||||
protected Set<String> getPermissionsForType()
|
||||
{
|
||||
// Let the permission service do the caching to allow for dynamic model updates, etc.
|
||||
return this.permissionService.getSettablePermissions(getNode().getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Node getNode()
|
||||
{
|
||||
return this.browseBean.getDocument();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getEmailTemplateXPath()
|
||||
{
|
||||
FacesContext fc = FacesContext.getCurrentInstance();
|
||||
String xpath = Application.getRootPath(fc) + "/" +
|
||||
Application.getGlossaryFolderName(fc) + "/" +
|
||||
Application.getEmailTemplatesFolderName(fc) + "/" +
|
||||
Application.getNotifyEmailTemplatesFolderName(fc) + "//*";
|
||||
return xpath;
|
||||
}
|
||||
}
|
||||
package org.alfresco.web.bean.content;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.wizard.BaseInviteUsersWizard;
|
||||
|
||||
/**
|
||||
* Concrete implementation providing the ability to invite users to content.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class InviteContentUsersWizard extends BaseInviteUsersWizard
|
||||
{
|
||||
private static final long serialVersionUID = 9198783146031469545L;
|
||||
|
||||
@Override
|
||||
protected Set<String> getPermissionsForType()
|
||||
{
|
||||
// Let the permission service do the caching to allow for dynamic model updates, etc.
|
||||
return this.permissionService.getSettablePermissions(getNode().getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Node getNode()
|
||||
{
|
||||
return this.browseBean.getDocument();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getEmailTemplateXPath()
|
||||
{
|
||||
FacesContext fc = FacesContext.getCurrentInstance();
|
||||
String xpath = Application.getRootPath(fc) + "/" +
|
||||
Application.getGlossaryFolderName(fc) + "/" +
|
||||
Application.getEmailTemplatesFolderName(fc) + "/" +
|
||||
Application.getNotifyEmailTemplatesFolderName(fc) + "//*";
|
||||
return xpath;
|
||||
}
|
||||
}
|
||||
|
@@ -1,29 +1,29 @@
|
||||
package org.alfresco.web.bean.content;
|
||||
|
||||
import org.alfresco.web.app.AlfrescoNavigationHandler;
|
||||
|
||||
/**
|
||||
* Bean implementation of the "Set Content Properties" dialog.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class SetContentPropertiesDialog extends EditContentPropertiesDialog
|
||||
{
|
||||
private static final long serialVersionUID = -7705362669371767349L;
|
||||
|
||||
@Override
|
||||
protected String getDefaultCancelOutcome()
|
||||
{
|
||||
return super.getDefaultCancelOutcome() +
|
||||
AlfrescoNavigationHandler.OUTCOME_SEPARATOR +
|
||||
"browse";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultFinishOutcome()
|
||||
{
|
||||
return super.getDefaultFinishOutcome() +
|
||||
AlfrescoNavigationHandler.OUTCOME_SEPARATOR +
|
||||
"browse";
|
||||
}
|
||||
}
|
||||
package org.alfresco.web.bean.content;
|
||||
|
||||
import org.alfresco.web.app.AlfrescoNavigationHandler;
|
||||
|
||||
/**
|
||||
* Bean implementation of the "Set Content Properties" dialog.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class SetContentPropertiesDialog extends EditContentPropertiesDialog
|
||||
{
|
||||
private static final long serialVersionUID = -7705362669371767349L;
|
||||
|
||||
@Override
|
||||
protected String getDefaultCancelOutcome()
|
||||
{
|
||||
return super.getDefaultCancelOutcome() +
|
||||
AlfrescoNavigationHandler.OUTCOME_SEPARATOR +
|
||||
"browse";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultFinishOutcome()
|
||||
{
|
||||
return super.getDefaultFinishOutcome() +
|
||||
AlfrescoNavigationHandler.OUTCOME_SEPARATOR +
|
||||
"browse";
|
||||
}
|
||||
}
|
||||
|
@@ -1,88 +1,88 @@
|
||||
package org.alfresco.web.bean.content;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
|
||||
/**
|
||||
* Bean implementation of the "View Content Properties" dialog.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class ViewContentPropertiesDialog extends BaseDialogBean
|
||||
{
|
||||
private static final long serialVersionUID = -867609607881256449L;
|
||||
|
||||
protected static final String TEMP_PROP_MIMETYPE = "mimetype";
|
||||
protected static final String TEMP_PROP_ENCODING = "encoding";
|
||||
|
||||
protected Node viewingNode;
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome)
|
||||
throws Exception
|
||||
{
|
||||
// nothing to do as the finish button is not shown and the dialog is read only
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCancelButtonLabel()
|
||||
{
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), "close");
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Bean getters and setters
|
||||
|
||||
/**
|
||||
* Returns the node being viewed
|
||||
*
|
||||
* @return The node being viewed
|
||||
*/
|
||||
public Node getViewingNode()
|
||||
{
|
||||
return this.viewingNode;
|
||||
}
|
||||
}
|
||||
package org.alfresco.web.bean.content;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
|
||||
/**
|
||||
* Bean implementation of the "View Content Properties" dialog.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class ViewContentPropertiesDialog extends BaseDialogBean
|
||||
{
|
||||
private static final long serialVersionUID = -867609607881256449L;
|
||||
|
||||
protected static final String TEMP_PROP_MIMETYPE = "mimetype";
|
||||
protected static final String TEMP_PROP_ENCODING = "encoding";
|
||||
|
||||
protected Node viewingNode;
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome)
|
||||
throws Exception
|
||||
{
|
||||
// nothing to do as the finish button is not shown and the dialog is read only
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCancelButtonLabel()
|
||||
{
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), "close");
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Bean getters and setters
|
||||
|
||||
/**
|
||||
* Returns the node being viewed
|
||||
*
|
||||
* @return The node being viewed
|
||||
*/
|
||||
public Node getViewingNode()
|
||||
{
|
||||
return this.viewingNode;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user