Merged 5.2.N (5.2.1) to HEAD (5.2)

125783 rmunteanu: 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/HEAD/root@127809 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2016-06-03 16:45:04 +00:00
parent 4818f7ccf5
commit 22512d8c9e
265 changed files with 44099 additions and 44099 deletions

View File

@@ -1,87 +1,87 @@
package org.alfresco.web.bean.spaces;
import java.text.MessageFormat;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.TemplateSupportBean;
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.ReportedException;
import org.alfresco.web.ui.common.Utils;
public class ApplyDocTemplateDialog extends BaseDialogBean
{
private static final long serialVersionUID = -9098279672434597354L;
private static final String DIALOG_CLOSE = "dialog:close";
private static final String MSG_APPLY_TEMPLATE = "apply_template";
private final static String MSG_LEFT_QUOTE = "left_qoute";
private final static String MSG_RIGHT_QUOTE = "right_quote";
protected String template;
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
if (this.template != null && this.template.equals(TemplateSupportBean.NO_SELECTION) == false)
{
try
{
// apply the templatable aspect if required
if (getNode().hasAspect(ContentModel.ASPECT_TEMPLATABLE) == false)
{
this.getNodeService().addAspect(getNode().getNodeRef(), ContentModel.ASPECT_TEMPLATABLE, null);
}
// get the selected template from the Template Picker
NodeRef templateRef = new NodeRef(Repository.getStoreRef(), this.template);
// set the template NodeRef into the templatable aspect property
this.getNodeService().setProperty(getNode().getNodeRef(), ContentModel.PROP_TEMPLATE, templateRef);
// reset node details for next refresh of details page
getNode().reset();
}
catch (Exception e)
{
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), e.getMessage()), e);
ReportedException.throwIfNecessary(e);
}
}
return DIALOG_CLOSE;
}
public String getContainerTitle()
{
FacesContext fc = FacesContext.getCurrentInstance();
return Application.getMessage(fc, MSG_APPLY_TEMPLATE) + " " + Application.getMessage(fc, MSG_LEFT_QUOTE) + getName() + Application.getMessage(fc, MSG_RIGHT_QUOTE);
}
public String getTemplate()
{
// return current template if it exists
NodeRef ref = (NodeRef) getNode().getProperties().get(ContentModel.PROP_TEMPLATE);
return ref != null ? ref.getId() : this.template;
}
public void setTemplate(String template)
{
this.template = template;
}
public Node getNode()
{
return this.browseBean.getDocument();
}
public String getName()
{
return getNode().getName();
}
package org.alfresco.web.bean.spaces;
import java.text.MessageFormat;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.TemplateSupportBean;
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.ReportedException;
import org.alfresco.web.ui.common.Utils;
public class ApplyDocTemplateDialog extends BaseDialogBean
{
private static final long serialVersionUID = -9098279672434597354L;
private static final String DIALOG_CLOSE = "dialog:close";
private static final String MSG_APPLY_TEMPLATE = "apply_template";
private final static String MSG_LEFT_QUOTE = "left_qoute";
private final static String MSG_RIGHT_QUOTE = "right_quote";
protected String template;
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
if (this.template != null && this.template.equals(TemplateSupportBean.NO_SELECTION) == false)
{
try
{
// apply the templatable aspect if required
if (getNode().hasAspect(ContentModel.ASPECT_TEMPLATABLE) == false)
{
this.getNodeService().addAspect(getNode().getNodeRef(), ContentModel.ASPECT_TEMPLATABLE, null);
}
// get the selected template from the Template Picker
NodeRef templateRef = new NodeRef(Repository.getStoreRef(), this.template);
// set the template NodeRef into the templatable aspect property
this.getNodeService().setProperty(getNode().getNodeRef(), ContentModel.PROP_TEMPLATE, templateRef);
// reset node details for next refresh of details page
getNode().reset();
}
catch (Exception e)
{
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), e.getMessage()), e);
ReportedException.throwIfNecessary(e);
}
}
return DIALOG_CLOSE;
}
public String getContainerTitle()
{
FacesContext fc = FacesContext.getCurrentInstance();
return Application.getMessage(fc, MSG_APPLY_TEMPLATE) + " " + Application.getMessage(fc, MSG_LEFT_QUOTE) + getName() + Application.getMessage(fc, MSG_RIGHT_QUOTE);
}
public String getTemplate()
{
// return current template if it exists
NodeRef ref = (NodeRef) getNode().getProperties().get(ContentModel.PROP_TEMPLATE);
return ref != null ? ref.getId() : this.template;
}
public void setTemplate(String template)
{
this.template = template;
}
public Node getNode()
{
return this.browseBean.getDocument();
}
public String getName()
{
return getNode().getName();
}
}

View File

@@ -1,96 +1,96 @@
package org.alfresco.web.bean.spaces;
import java.text.MessageFormat;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import org.alfresco.model.ApplicationModel;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.TemplateSupportBean;
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.ReportedException;
import org.alfresco.web.ui.common.Utils;
public class ApplyRssTemplateDialog extends BaseDialogBean
{
private static final long serialVersionUID = 9207265799149337182L;
private static final String DIALOG_CLOSE = "dialog:close";
private static final String MSG_APPLY_RSS_FEED = "apply_rss_feed";
private final static String MSG_LEFT_QUOTE = "left_qoute";
private final static String MSG_RIGHT_QUOTE = "right_quote";
private String rssTemplate;
public void setRSSTemplate(String rssTemplate)
{
this.rssTemplate = rssTemplate;
}
/**
* @return Returns the current RSS Template ID.
*/
public String getRSSTemplate()
{
// return current template if it exists
NodeRef ref = (NodeRef) getNode().getProperties().get(ApplicationModel.PROP_FEEDTEMPLATE);
return ref != null ? ref.getId() : this.rssTemplate;
}
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
applyRSSTemplate(null);
return DIALOG_CLOSE;
}
public String getContainerTitle()
{
FacesContext fc = FacesContext.getCurrentInstance();
return Application.getMessage(fc, MSG_APPLY_RSS_FEED) + " " + Application.getMessage(fc, MSG_LEFT_QUOTE) + getNode().getName() + Application.getMessage(fc, MSG_RIGHT_QUOTE);
}
public void applyRSSTemplate(ActionEvent event)
{
if (this.rssTemplate != null && this.rssTemplate.equals(TemplateSupportBean.NO_SELECTION) == false)
{
try
{
// apply the feedsource aspect if required
if (getNode().hasAspect(ApplicationModel.ASPECT_FEEDSOURCE) == false)
{
this.getNodeService().addAspect(getNode().getNodeRef(), ApplicationModel.ASPECT_FEEDSOURCE, null);
}
// get the selected template Id from the Template Picker
NodeRef templateRef = new NodeRef(Repository.getStoreRef(), this.rssTemplate);
// set the template NodeRef into the templatable aspect property
this.getNodeService().setProperty(getNode().getNodeRef(), ApplicationModel.PROP_FEEDTEMPLATE, templateRef);
// reset node details for next refresh of details page
getNode().reset();
}
catch (Exception e)
{
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), e.getMessage()), e);
ReportedException.throwIfNecessary(e);
}
}
}
/**
* Returns the Node this bean is currently representing
*
* @return The Node
*/
public Node getNode()
{
return this.browseBean.getActionSpace();
}
package org.alfresco.web.bean.spaces;
import java.text.MessageFormat;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import org.alfresco.model.ApplicationModel;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.TemplateSupportBean;
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.ReportedException;
import org.alfresco.web.ui.common.Utils;
public class ApplyRssTemplateDialog extends BaseDialogBean
{
private static final long serialVersionUID = 9207265799149337182L;
private static final String DIALOG_CLOSE = "dialog:close";
private static final String MSG_APPLY_RSS_FEED = "apply_rss_feed";
private final static String MSG_LEFT_QUOTE = "left_qoute";
private final static String MSG_RIGHT_QUOTE = "right_quote";
private String rssTemplate;
public void setRSSTemplate(String rssTemplate)
{
this.rssTemplate = rssTemplate;
}
/**
* @return Returns the current RSS Template ID.
*/
public String getRSSTemplate()
{
// return current template if it exists
NodeRef ref = (NodeRef) getNode().getProperties().get(ApplicationModel.PROP_FEEDTEMPLATE);
return ref != null ? ref.getId() : this.rssTemplate;
}
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
applyRSSTemplate(null);
return DIALOG_CLOSE;
}
public String getContainerTitle()
{
FacesContext fc = FacesContext.getCurrentInstance();
return Application.getMessage(fc, MSG_APPLY_RSS_FEED) + " " + Application.getMessage(fc, MSG_LEFT_QUOTE) + getNode().getName() + Application.getMessage(fc, MSG_RIGHT_QUOTE);
}
public void applyRSSTemplate(ActionEvent event)
{
if (this.rssTemplate != null && this.rssTemplate.equals(TemplateSupportBean.NO_SELECTION) == false)
{
try
{
// apply the feedsource aspect if required
if (getNode().hasAspect(ApplicationModel.ASPECT_FEEDSOURCE) == false)
{
this.getNodeService().addAspect(getNode().getNodeRef(), ApplicationModel.ASPECT_FEEDSOURCE, null);
}
// get the selected template Id from the Template Picker
NodeRef templateRef = new NodeRef(Repository.getStoreRef(), this.rssTemplate);
// set the template NodeRef into the templatable aspect property
this.getNodeService().setProperty(getNode().getNodeRef(), ApplicationModel.PROP_FEEDTEMPLATE, templateRef);
// reset node details for next refresh of details page
getNode().reset();
}
catch (Exception e)
{
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), e.getMessage()), e);
ReportedException.throwIfNecessary(e);
}
}
}
/**
* Returns the Node this bean is currently representing
*
* @return The Node
*/
public Node getNode()
{
return this.browseBean.getActionSpace();
}
}

View File

@@ -1,87 +1,87 @@
package org.alfresco.web.bean.spaces;
import java.text.MessageFormat;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.TemplateSupportBean;
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.ReportedException;
import org.alfresco.web.ui.common.Utils;
public class ApplySpaceTemplateDialog extends BaseDialogBean
{
private static final long serialVersionUID = -3019234033026890265L;
private static final String DIALOG_CLOSE = "dialog:close";
private static final String MSG_APPLY_TEMPLATE = "apply_template";
private final static String MSG_LEFT_QUOTE = "left_qoute";
private final static String MSG_RIGHT_QUOTE = "right_quote";
protected String template;
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
applyTemplate(null);
return DIALOG_CLOSE;
}
public String getContainerTitle()
{
FacesContext fc = FacesContext.getCurrentInstance();
return Application.getMessage(fc, MSG_APPLY_TEMPLATE) + " " + Application.getMessage(fc, MSG_LEFT_QUOTE) + getNode().getName() + Application.getMessage(fc, MSG_RIGHT_QUOTE);
}
public void applyTemplate(ActionEvent event)
{
if (this.template != null && this.template.equals(TemplateSupportBean.NO_SELECTION) == false)
{
try
{
// apply the templatable aspect if required
if (getNode().hasAspect(ContentModel.ASPECT_TEMPLATABLE) == false)
{
this.getNodeService().addAspect(getNode().getNodeRef(), ContentModel.ASPECT_TEMPLATABLE, null);
}
// get the selected template from the Template Picker
NodeRef templateRef = new NodeRef(Repository.getStoreRef(), this.template);
// set the template NodeRef into the templatable aspect property
this.getNodeService().setProperty(getNode().getNodeRef(), ContentModel.PROP_TEMPLATE, templateRef);
// reset node details for next refresh of details page
getNode().reset();
}
catch (Exception e)
{
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), e.getMessage()), e);
ReportedException.throwIfNecessary(e);
}
}
}
public Node getNode()
{
return this.browseBean.getActionSpace();
}
public String getTemplate()
{
// return current template if it exists
NodeRef ref = (NodeRef) getNode().getProperties().get(ContentModel.PROP_TEMPLATE);
return ref != null ? ref.getId() : this.template;
}
public void setTemplate(String template)
{
this.template = template;
}
package org.alfresco.web.bean.spaces;
import java.text.MessageFormat;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.TemplateSupportBean;
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.ReportedException;
import org.alfresco.web.ui.common.Utils;
public class ApplySpaceTemplateDialog extends BaseDialogBean
{
private static final long serialVersionUID = -3019234033026890265L;
private static final String DIALOG_CLOSE = "dialog:close";
private static final String MSG_APPLY_TEMPLATE = "apply_template";
private final static String MSG_LEFT_QUOTE = "left_qoute";
private final static String MSG_RIGHT_QUOTE = "right_quote";
protected String template;
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
applyTemplate(null);
return DIALOG_CLOSE;
}
public String getContainerTitle()
{
FacesContext fc = FacesContext.getCurrentInstance();
return Application.getMessage(fc, MSG_APPLY_TEMPLATE) + " " + Application.getMessage(fc, MSG_LEFT_QUOTE) + getNode().getName() + Application.getMessage(fc, MSG_RIGHT_QUOTE);
}
public void applyTemplate(ActionEvent event)
{
if (this.template != null && this.template.equals(TemplateSupportBean.NO_SELECTION) == false)
{
try
{
// apply the templatable aspect if required
if (getNode().hasAspect(ContentModel.ASPECT_TEMPLATABLE) == false)
{
this.getNodeService().addAspect(getNode().getNodeRef(), ContentModel.ASPECT_TEMPLATABLE, null);
}
// get the selected template from the Template Picker
NodeRef templateRef = new NodeRef(Repository.getStoreRef(), this.template);
// set the template NodeRef into the templatable aspect property
this.getNodeService().setProperty(getNode().getNodeRef(), ContentModel.PROP_TEMPLATE, templateRef);
// reset node details for next refresh of details page
getNode().reset();
}
catch (Exception e)
{
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), e.getMessage()), e);
ReportedException.throwIfNecessary(e);
}
}
}
public Node getNode()
{
return this.browseBean.getActionSpace();
}
public String getTemplate()
{
// return current template if it exists
NodeRef ref = (NodeRef) getNode().getProperties().get(ContentModel.PROP_TEMPLATE);
return ref != null ? ref.getId() : this.template;
}
public void setTemplate(String template)
{
this.template = template;
}
}

View File

@@ -1,320 +1,320 @@
package org.alfresco.web.bean.spaces;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.transaction.UserTransaction;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.dictionary.TypeDefinition;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.service.transaction.TransactionService;
import org.alfresco.web.app.AlfrescoNavigationHandler;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.content.DeleteContentDialog;
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 Space" dialog
*
* @author gavinc
*/
public class DeleteSpaceDialog extends BaseDialogBean
{
private static final long serialVersionUID = 5960844637376808571L;
private static final Log logger = LogFactory.getLog(DeleteContentDialog.class);
private static final String DELETE_ALL = "all";
private static final String DELETE_FILES = "files";
private static final String DELETE_FOLDERS = "folders";
private static final String DELETE_CONTENTS = "contents";
private String deleteMode = DELETE_ALL;
private boolean executeRules = true;
private boolean archiveNodes = true;
protected boolean hasMultipleParents = false;
// ------------------------------------------------------------------------------
// Dialog implementation
@Override
public void init(Map<String, String> parameters)
{
super.init(parameters);
this.hasMultipleParents = false;
String strHasMultipleParents = this.parameters.get("hasMultipleParents");
if (strHasMultipleParents != null && "true".equals(strHasMultipleParents))
{
this.hasMultipleParents = true;
}
}
@Override
protected String finishImpl(FacesContext context, String outcome)
throws Exception
{
final boolean isAdmin = this.navigator.getCurrentUser().isAdmin();
// get the space to delete
Node node = this.browseBean.getActionSpace();
if (node != null)
{
// force cache of name property so we can use it after the delete
node.getName();
if (logger.isDebugEnabled())
logger.debug("Trying to delete space: " + node.getId() + " using delete mode: " + this.deleteMode);
try
{
if (isAdmin && !this.executeRules)
{
Repository.getServiceRegistry(context).getRuleService().disableRules();
}
if (DELETE_ALL.equals(this.deleteMode))
{
NodeRef nodeRef = node.getNodeRef();
// Check the node still exists
if (this.getNodeService().exists(nodeRef))
{
if (isAdmin && !this.archiveNodes)
{
this.getNodeService().addAspect(node.getNodeRef(), ContentModel.ASPECT_TEMPORARY, null);
}
// ensure the node still exists before deleting
if (this.getNodeService().exists(node.getNodeRef()))
{
this.getNodeService().deleteNode(node.getNodeRef());
}
}
}
else
{
List<ChildAssociationRef> childRefs = this.getNodeService().getChildAssocs(node.getNodeRef(),
ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
List<NodeRef> deleteRefs = new ArrayList<NodeRef>(childRefs.size());
for (ChildAssociationRef ref : childRefs)
{
NodeRef nodeRef = ref.getChildRef();
if (this.getNodeService().exists(nodeRef))
{
if (DELETE_CONTENTS.equals(this.deleteMode))
{
deleteRefs.add(nodeRef);
}
else
{
// find it's type so we can see if it's a node we are interested in
QName type = this.getNodeService().getType(nodeRef);
// make sure the type is defined in the data dictionary
TypeDefinition typeDef = this.getDictionaryService().getType(type);
if (typeDef != null)
{
if (DELETE_FOLDERS.equals(this.deleteMode))
{
// look for folder type
if (this.getDictionaryService().isSubClass(type, ContentModel.TYPE_FOLDER) == true &&
this.getDictionaryService().isSubClass(type, ContentModel.TYPE_SYSTEM_FOLDER) == false)
{
deleteRefs.add(nodeRef);
}
}
else if (DELETE_FILES.equals(this.deleteMode))
{
// look for content file type
if (this.getDictionaryService().isSubClass(type, ContentModel.TYPE_CONTENT))
{
deleteRefs.add(nodeRef);
}
}
}
}
}
}
// delete the list of refs
TransactionService txService = Repository.getServiceRegistry(context).getTransactionService();
for (NodeRef nodeRef : deleteRefs)
{
UserTransaction tx = null;
try
{
tx = txService.getNonPropagatingUserTransaction();
tx.begin();
if (isAdmin && !this.archiveNodes)
{
this.getNodeService().addAspect(nodeRef, ContentModel.ASPECT_TEMPORARY, null);
}
// ensure the node still exists before deleting
if (this.getNodeService().exists(node.getNodeRef()))
{
this.getNodeService().deleteNode(nodeRef);
}
tx.commit();
}
catch (Throwable err)
{
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
}
}
}
}
finally
{
if (isAdmin && !this.executeRules)
{
Repository.getServiceRegistry(context).getRuleService().enableRules();
}
}
}
else
{
logger.warn("WARNING: delete called without a current Space!");
}
return outcome;
}
@Override
protected String doPostCommitProcessing(FacesContext context, String outcome)
{
Node node = this.browseBean.getActionSpace();
if (node != null && this.getNodeService().exists(node.getNodeRef()) == false)
{
// remove this node from the breadcrumb if required
this.browseBean.removeSpaceFromBreadcrumb(node);
// clear action context
this.browseBean.setActionSpace(null);
// setting the outcome will show the browse view again
return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME +
AlfrescoNavigationHandler.OUTCOME_SEPARATOR + "browse";
}
else
{
return outcome;
}
}
@Override
protected String getErrorMessageId()
{
return "error_delete_space";
}
@Override
public boolean getFinishButtonDisabled()
{
return false;
}
protected String getConfirmMessageId()
{
return "delete_space_confirm";
}
// ------------------------------------------------------------------------------
// 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 = Application.getMessage(FacesContext.getCurrentInstance(),
getConfirmMessageId());
Node node = this.browseBean.getActionSpace();
if (node != null)
{
return MessageFormat.format(fileConfirmMsg, new Object[] {node.getName()});
}
else
{
return Application.getMessage(FacesContext.getCurrentInstance(),
"delete_node_not_found");
}
}
/**
* @return Returns the delete operation mode.
*/
public String getDeleteMode()
{
return this.deleteMode;
}
/**
* @param deleteMode The delete operation mode to set.
*/
public void setDeleteMode(String deleteMode)
{
this.deleteMode = deleteMode;
}
/**
* @return true if the space has multiple parents
*/
public boolean getHasMultipleParents()
{
return this.hasMultipleParents;
}
/**
* @return true to execute rules during delete
*/
public boolean getExecuteRules()
{
return this.executeRules;
}
/**
* @param executeRules execute rules during delete
*/
public void setExecuteRules(boolean executeRules)
{
this.executeRules = executeRules;
}
/**
* @return true to archive nodes during delete
*/
public boolean getArchiveNodes()
{
return this.archiveNodes;
}
/**
* @param archiveNodes archive nodes during delete
*/
public void setArchiveNodes(boolean archiveNodes)
{
this.archiveNodes = archiveNodes;
}
}
package org.alfresco.web.bean.spaces;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.transaction.UserTransaction;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.dictionary.TypeDefinition;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.service.transaction.TransactionService;
import org.alfresco.web.app.AlfrescoNavigationHandler;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.content.DeleteContentDialog;
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 Space" dialog
*
* @author gavinc
*/
public class DeleteSpaceDialog extends BaseDialogBean
{
private static final long serialVersionUID = 5960844637376808571L;
private static final Log logger = LogFactory.getLog(DeleteContentDialog.class);
private static final String DELETE_ALL = "all";
private static final String DELETE_FILES = "files";
private static final String DELETE_FOLDERS = "folders";
private static final String DELETE_CONTENTS = "contents";
private String deleteMode = DELETE_ALL;
private boolean executeRules = true;
private boolean archiveNodes = true;
protected boolean hasMultipleParents = false;
// ------------------------------------------------------------------------------
// Dialog implementation
@Override
public void init(Map<String, String> parameters)
{
super.init(parameters);
this.hasMultipleParents = false;
String strHasMultipleParents = this.parameters.get("hasMultipleParents");
if (strHasMultipleParents != null && "true".equals(strHasMultipleParents))
{
this.hasMultipleParents = true;
}
}
@Override
protected String finishImpl(FacesContext context, String outcome)
throws Exception
{
final boolean isAdmin = this.navigator.getCurrentUser().isAdmin();
// get the space to delete
Node node = this.browseBean.getActionSpace();
if (node != null)
{
// force cache of name property so we can use it after the delete
node.getName();
if (logger.isDebugEnabled())
logger.debug("Trying to delete space: " + node.getId() + " using delete mode: " + this.deleteMode);
try
{
if (isAdmin && !this.executeRules)
{
Repository.getServiceRegistry(context).getRuleService().disableRules();
}
if (DELETE_ALL.equals(this.deleteMode))
{
NodeRef nodeRef = node.getNodeRef();
// Check the node still exists
if (this.getNodeService().exists(nodeRef))
{
if (isAdmin && !this.archiveNodes)
{
this.getNodeService().addAspect(node.getNodeRef(), ContentModel.ASPECT_TEMPORARY, null);
}
// ensure the node still exists before deleting
if (this.getNodeService().exists(node.getNodeRef()))
{
this.getNodeService().deleteNode(node.getNodeRef());
}
}
}
else
{
List<ChildAssociationRef> childRefs = this.getNodeService().getChildAssocs(node.getNodeRef(),
ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
List<NodeRef> deleteRefs = new ArrayList<NodeRef>(childRefs.size());
for (ChildAssociationRef ref : childRefs)
{
NodeRef nodeRef = ref.getChildRef();
if (this.getNodeService().exists(nodeRef))
{
if (DELETE_CONTENTS.equals(this.deleteMode))
{
deleteRefs.add(nodeRef);
}
else
{
// find it's type so we can see if it's a node we are interested in
QName type = this.getNodeService().getType(nodeRef);
// make sure the type is defined in the data dictionary
TypeDefinition typeDef = this.getDictionaryService().getType(type);
if (typeDef != null)
{
if (DELETE_FOLDERS.equals(this.deleteMode))
{
// look for folder type
if (this.getDictionaryService().isSubClass(type, ContentModel.TYPE_FOLDER) == true &&
this.getDictionaryService().isSubClass(type, ContentModel.TYPE_SYSTEM_FOLDER) == false)
{
deleteRefs.add(nodeRef);
}
}
else if (DELETE_FILES.equals(this.deleteMode))
{
// look for content file type
if (this.getDictionaryService().isSubClass(type, ContentModel.TYPE_CONTENT))
{
deleteRefs.add(nodeRef);
}
}
}
}
}
}
// delete the list of refs
TransactionService txService = Repository.getServiceRegistry(context).getTransactionService();
for (NodeRef nodeRef : deleteRefs)
{
UserTransaction tx = null;
try
{
tx = txService.getNonPropagatingUserTransaction();
tx.begin();
if (isAdmin && !this.archiveNodes)
{
this.getNodeService().addAspect(nodeRef, ContentModel.ASPECT_TEMPORARY, null);
}
// ensure the node still exists before deleting
if (this.getNodeService().exists(node.getNodeRef()))
{
this.getNodeService().deleteNode(nodeRef);
}
tx.commit();
}
catch (Throwable err)
{
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
}
}
}
}
finally
{
if (isAdmin && !this.executeRules)
{
Repository.getServiceRegistry(context).getRuleService().enableRules();
}
}
}
else
{
logger.warn("WARNING: delete called without a current Space!");
}
return outcome;
}
@Override
protected String doPostCommitProcessing(FacesContext context, String outcome)
{
Node node = this.browseBean.getActionSpace();
if (node != null && this.getNodeService().exists(node.getNodeRef()) == false)
{
// remove this node from the breadcrumb if required
this.browseBean.removeSpaceFromBreadcrumb(node);
// clear action context
this.browseBean.setActionSpace(null);
// setting the outcome will show the browse view again
return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME +
AlfrescoNavigationHandler.OUTCOME_SEPARATOR + "browse";
}
else
{
return outcome;
}
}
@Override
protected String getErrorMessageId()
{
return "error_delete_space";
}
@Override
public boolean getFinishButtonDisabled()
{
return false;
}
protected String getConfirmMessageId()
{
return "delete_space_confirm";
}
// ------------------------------------------------------------------------------
// 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 = Application.getMessage(FacesContext.getCurrentInstance(),
getConfirmMessageId());
Node node = this.browseBean.getActionSpace();
if (node != null)
{
return MessageFormat.format(fileConfirmMsg, new Object[] {node.getName()});
}
else
{
return Application.getMessage(FacesContext.getCurrentInstance(),
"delete_node_not_found");
}
}
/**
* @return Returns the delete operation mode.
*/
public String getDeleteMode()
{
return this.deleteMode;
}
/**
* @param deleteMode The delete operation mode to set.
*/
public void setDeleteMode(String deleteMode)
{
this.deleteMode = deleteMode;
}
/**
* @return true if the space has multiple parents
*/
public boolean getHasMultipleParents()
{
return this.hasMultipleParents;
}
/**
* @return true to execute rules during delete
*/
public boolean getExecuteRules()
{
return this.executeRules;
}
/**
* @param executeRules execute rules during delete
*/
public void setExecuteRules(boolean executeRules)
{
this.executeRules = executeRules;
}
/**
* @return true to archive nodes during delete
*/
public boolean getArchiveNodes()
{
return this.archiveNodes;
}
/**
* @param archiveNodes archive nodes during delete
*/
public void setArchiveNodes(boolean archiveNodes)
{
this.archiveNodes = archiveNodes;
}
}

View File

@@ -1,176 +1,176 @@
package org.alfresco.web.bean.spaces;
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.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
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.bean.repository.Repository;
import org.alfresco.web.ui.common.ReportedException;
import org.alfresco.web.ui.common.Utils;
public class EditSimpleWorkflowDialog extends BaseDialogBean
{
private static final long serialVersionUID = 5997327694341960824L;
protected Map<String, Serializable> workflowProperties;
private static final String MSG_ERROR_UPDATE_SIMPLEWORKFLOW = "error_update_simpleworkflow";
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
saveWorkflow();
return outcome;
}
public boolean getFinishButtonDisabled()
{
return false;
}
public String saveWorkflow()
{
String outcome = "cancel";
try
{
RetryingTransactionHelper txnHelper = Repository.getRetryingTransactionHelper(FacesContext.getCurrentInstance());
RetryingTransactionCallback<Object> callback = new RetryingTransactionCallback<Object>()
{
public Object execute() throws Throwable
{
// firstly retrieve all the properties for the current node
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);
return null;
}
};
txnHelper.doInTransaction(callback);
// reset the state of the current node so it reflects the changes just made
getNode().reset();
outcome = "finish";
}
catch (Throwable e)
{
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), MSG_ERROR_UPDATE_SIMPLEWORKFLOW), e.getMessage()), e);
ReportedException.throwIfNecessary(e);
}
return outcome;
}
/**
* Returns the properties for the attached workflow as a map
*
* @return Properties of the attached workflow, null if there is no workflow
*/
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;
}
public Node getNode()
{
return this.browseBean.getActionSpace();
}
}
package org.alfresco.web.bean.spaces;
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.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
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.bean.repository.Repository;
import org.alfresco.web.ui.common.ReportedException;
import org.alfresco.web.ui.common.Utils;
public class EditSimpleWorkflowDialog extends BaseDialogBean
{
private static final long serialVersionUID = 5997327694341960824L;
protected Map<String, Serializable> workflowProperties;
private static final String MSG_ERROR_UPDATE_SIMPLEWORKFLOW = "error_update_simpleworkflow";
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
saveWorkflow();
return outcome;
}
public boolean getFinishButtonDisabled()
{
return false;
}
public String saveWorkflow()
{
String outcome = "cancel";
try
{
RetryingTransactionHelper txnHelper = Repository.getRetryingTransactionHelper(FacesContext.getCurrentInstance());
RetryingTransactionCallback<Object> callback = new RetryingTransactionCallback<Object>()
{
public Object execute() throws Throwable
{
// firstly retrieve all the properties for the current node
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);
return null;
}
};
txnHelper.doInTransaction(callback);
// reset the state of the current node so it reflects the changes just made
getNode().reset();
outcome = "finish";
}
catch (Throwable e)
{
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), MSG_ERROR_UPDATE_SIMPLEWORKFLOW), e.getMessage()), e);
ReportedException.throwIfNecessary(e);
}
return outcome;
}
/**
* Returns the properties for the attached workflow as a map
*
* @return Properties of the attached workflow, null if there is no workflow
*/
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;
}
public Node getNode()
{
return this.browseBean.getActionSpace();
}
}

View File

@@ -1,181 +1,181 @@
package org.alfresco.web.bean.spaces;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.AlfrescoNavigationHandler;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Node;
/**
* Dialog bean to edit an existing space.
*
* @author gavinc
*/
public class EditSpaceDialog extends CreateSpaceDialog
{
private static final long serialVersionUID = 6090397957979372269L;
protected Node editableNode;
@Override
public void init(Map<String, String> parameters)
{
super.init(parameters);
// setup the space being edited
this.editableNode = initEditableNode();
this.spaceType = this.editableNode.getType().toString();
}
@Override
public boolean getFinishButtonDisabled()
{
return false;
}
/**
* Init the editable Node
*/
protected Node initEditableNode()
{
return new Node(this.browseBean.getActionSpace().getNodeRef());
}
@Override
public String getFinishButtonLabel()
{
return Application.getMessage(FacesContext.getCurrentInstance(), "ok");
}
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
// update the existing node in the repository
NodeRef nodeRef = this.editableNode.getNodeRef();
Map<String, Object> editedProps = this.editableNode.getProperties();
// handle the name property separately, perform a rename in case it changed
String name = (String)editedProps.get(ContentModel.PROP_NAME);
if (name != null)
{
this.getFileFolderService().rename(nodeRef, name);
}
// build the properties to add to the repository
Map<QName, Serializable> repoProps = new HashMap<QName, Serializable>(7);
// overwrite the current properties with the edited ones
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 != null) && (propValue instanceof String) &&
(propValue.toString().length() == 0))
{
PropertyDefinition propDef = this.getDictionaryService().getProperty(qname);
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;
}
}
}
repoProps.put(qname, propValue);
}
// add the new properties back to the repository
this.getNodeService().addProperties(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());
}
}
// do nothing by default, subclasses can override if necessary
return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME;
}
@Override
protected String doPostCommitProcessing(FacesContext context, String outcome)
{
this.browseBean.getActionSpace().reset();
return outcome;
}
// ------------------------------------------------------------------------------
// 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.spaces;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.AlfrescoNavigationHandler;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Node;
/**
* Dialog bean to edit an existing space.
*
* @author gavinc
*/
public class EditSpaceDialog extends CreateSpaceDialog
{
private static final long serialVersionUID = 6090397957979372269L;
protected Node editableNode;
@Override
public void init(Map<String, String> parameters)
{
super.init(parameters);
// setup the space being edited
this.editableNode = initEditableNode();
this.spaceType = this.editableNode.getType().toString();
}
@Override
public boolean getFinishButtonDisabled()
{
return false;
}
/**
* Init the editable Node
*/
protected Node initEditableNode()
{
return new Node(this.browseBean.getActionSpace().getNodeRef());
}
@Override
public String getFinishButtonLabel()
{
return Application.getMessage(FacesContext.getCurrentInstance(), "ok");
}
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
// update the existing node in the repository
NodeRef nodeRef = this.editableNode.getNodeRef();
Map<String, Object> editedProps = this.editableNode.getProperties();
// handle the name property separately, perform a rename in case it changed
String name = (String)editedProps.get(ContentModel.PROP_NAME);
if (name != null)
{
this.getFileFolderService().rename(nodeRef, name);
}
// build the properties to add to the repository
Map<QName, Serializable> repoProps = new HashMap<QName, Serializable>(7);
// overwrite the current properties with the edited ones
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 != null) && (propValue instanceof String) &&
(propValue.toString().length() == 0))
{
PropertyDefinition propDef = this.getDictionaryService().getProperty(qname);
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;
}
}
}
repoProps.put(qname, propValue);
}
// add the new properties back to the repository
this.getNodeService().addProperties(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());
}
}
// do nothing by default, subclasses can override if necessary
return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME;
}
@Override
protected String doPostCommitProcessing(FacesContext context, String outcome)
{
this.browseBean.getActionSpace().reset();
return outcome;
}
// ------------------------------------------------------------------------------
// Bean getters and setters
/**
* Returns the node being edited
*
* @return The node being edited
*/
public Node getEditableNode()
{
return this.editableNode;
}
}

View File

@@ -1,43 +1,43 @@
package org.alfresco.web.bean.spaces;
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 a space.
*
* @author gavinc
*/
public class InviteSpaceUsersWizard extends BaseInviteUsersWizard
{
private static final long serialVersionUID = -1584891656721183347L;
@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.getActionSpace();
}
@Override
protected String getEmailTemplateXPath()
{
FacesContext fc = FacesContext.getCurrentInstance();
String xpath = Application.getRootPath(fc) + "/" +
Application.getGlossaryFolderName(fc) + "/" +
Application.getEmailTemplatesFolderName(fc) + "/" +
Application.getInviteEmailTemplatesFolderName(fc) + "//*";
return xpath;
}
}
package org.alfresco.web.bean.spaces;
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 a space.
*
* @author gavinc
*/
public class InviteSpaceUsersWizard extends BaseInviteUsersWizard
{
private static final long serialVersionUID = -1584891656721183347L;
@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.getActionSpace();
}
@Override
protected String getEmailTemplateXPath()
{
FacesContext fc = FacesContext.getCurrentInstance();
String xpath = Application.getRootPath(fc) + "/" +
Application.getGlossaryFolderName(fc) + "/" +
Application.getEmailTemplatesFolderName(fc) + "/" +
Application.getInviteEmailTemplatesFolderName(fc) + "//*";
return xpath;
}
}