Merged up to HEAD.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3129 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-06-16 19:18:30 +00:00
parent 77df6eb45d
commit d2f8666983
39 changed files with 2129 additions and 1142 deletions

View File

@@ -0,0 +1,64 @@
package org.alfresco.web.bean.actions.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import org.alfresco.repo.action.executer.AddFeaturesActionExecuter;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.actions.BaseActionWizard;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Action handler implementation for the "add-features" action.
*
* @author gavinc
*/
public class AddFeaturesHandler extends BaseActionHandler
{
protected static final String PROP_ASPECT = "aspect";
public String getJSPPath()
{
return getJSPPath(AddFeaturesActionExecuter.NAME);
}
public void prepareForSave(Map<String, Serializable> actionProps,
Map<String, Serializable> repoParams)
{
QName aspect = Repository.resolveToQName((String)actionProps.get(PROP_ASPECT));
repoParams.put(AddFeaturesActionExecuter.PARAM_ASPECT_NAME, aspect);
}
public void prepareForEdit(Map<String, Serializable> actionProps,
Map<String, Serializable> repoParams)
{
QName aspect = (QName)repoParams.get(AddFeaturesActionExecuter.PARAM_ASPECT_NAME);
actionProps.put(PROP_ASPECT, aspect.toString());
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> actionProps)
{
String label = null;
String aspect = (String)actionProps.get(PROP_ASPECT);
// find the label used by looking through the SelectItem list
for (SelectItem item : ((BaseActionWizard)wizard).getAspects())
{
if (item.getValue().equals(aspect))
{
label = item.getLabel();
break;
}
}
return MessageFormat.format(Application.getMessage(context, "action_add_features"),
new Object[] {label});
}
}

View File

@@ -0,0 +1,34 @@
package org.alfresco.web.bean.actions.handlers;
import java.io.Serializable;
import java.util.Map;
import org.alfresco.web.bean.actions.IHandler;
/**
* Base class for all action handler implementations.
*
* @author gavinc
*/
public abstract class BaseActionHandler implements IHandler
{
protected static final String ACTION_PAGES_LOCATION = "/jsp/actions/";
protected static final String PROP_DESTINATION = "destinationLocation";
public void setupUIDefaults(Map<String, Serializable> actionProps)
{
// do nothing by default, only those action handlers that need
// to setup defaults need override this method
}
/**
* Given the action name, generates the default path for the JSP
*
* @param actionName The name of the action
* @return The path to the JSP used for the action
*/
protected String getJSPPath(String actionName)
{
return ACTION_PAGES_LOCATION + actionName + ".jsp";
}
}

View File

@@ -0,0 +1,72 @@
package org.alfresco.web.bean.actions.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.repo.action.executer.CheckInActionExecuter;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Action handler implementation for the "check-in" action.
*
* @author gavinc
*/
public class CheckInHandler extends BaseActionHandler
{
protected static final String PROP_CHECKIN_DESC = "checkinDescription";
protected static final String PROP_CHECKIN_MINOR = "checkinMinorChange";
@Override
public void setupUIDefaults(Map<String, Serializable> actionProps)
{
actionProps.put(PROP_CHECKIN_MINOR, new Boolean(true));
}
public String getJSPPath()
{
return getJSPPath(CheckInActionExecuter.NAME);
}
public void prepareForSave(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
repoProps.put(CheckInActionExecuter.PARAM_DESCRIPTION,
actionProps.get(PROP_CHECKIN_DESC));
repoProps.put(CheckInActionExecuter.PARAM_MINOR_CHANGE,
actionProps.get(PROP_CHECKIN_MINOR));
}
public void prepareForEdit(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
String checkDesc = (String)repoProps.get(CheckInActionExecuter.PARAM_DESCRIPTION);
actionProps.put(PROP_CHECKIN_DESC, checkDesc);
Boolean minorChange = (Boolean)repoProps.get(CheckInActionExecuter.PARAM_MINOR_CHANGE);
actionProps.put(PROP_CHECKIN_MINOR, minorChange);
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> actionProps)
{
String comment = (String)actionProps.get(PROP_CHECKIN_DESC);
Boolean minorChange = (Boolean)actionProps.get(PROP_CHECKIN_MINOR);
String change = null;
if (minorChange != null && minorChange.booleanValue())
{
change = Application.getMessage(context, "minor_change");
}
else
{
change = Application.getMessage(context, "major_change");
}
return MessageFormat.format(Application.getMessage(context, "action_check_in"),
new Object[] {change, comment});
}
}

View File

@@ -0,0 +1,63 @@
package org.alfresco.web.bean.actions.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.executer.CheckOutActionExecuter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Action handler implementation for the "check-out" action.
*
* @author gavinc
*/
public class CheckOutHandler extends BaseActionHandler
{
public String getJSPPath()
{
return getJSPPath(CheckOutActionExecuter.NAME);
}
public void prepareForSave(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
// specify the location the checked out working copy should go
// add the destination space id to the action properties
NodeRef destNodeRef = (NodeRef)actionProps.get(PROP_DESTINATION);
repoProps.put(CheckOutActionExecuter.PARAM_DESTINATION_FOLDER, destNodeRef);
// add the type and name of the association to create when the
// check out is performed
repoProps.put(CheckOutActionExecuter.PARAM_ASSOC_TYPE_QNAME,
ContentModel.ASSOC_CONTAINS);
repoProps.put(CheckOutActionExecuter.PARAM_ASSOC_QNAME,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "checkout"));
}
public void prepareForEdit(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
NodeRef destNodeRef = (NodeRef)repoProps.get(CheckOutActionExecuter.PARAM_DESTINATION_FOLDER);
actionProps.put(PROP_DESTINATION, destNodeRef);
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> actionProps)
{
NodeRef space = (NodeRef)actionProps.get(PROP_DESTINATION);
String spaceName = Repository.getNameForNode(
Repository.getServiceRegistry(context).getNodeService(), space);
return MessageFormat.format(Application.getMessage(context, "action_check_out"),
new Object[] {spaceName});
}
}

View File

@@ -0,0 +1,63 @@
package org.alfresco.web.bean.actions.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.executer.CopyActionExecuter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Action handler implementation for the "copy" action.
*
* @author gavinc
*/
public class CopyHandler extends BaseActionHandler
{
public String getJSPPath()
{
return getJSPPath(CopyActionExecuter.NAME);
}
public void prepareForSave(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
// add the destination space id to the action properties
NodeRef destNodeRef = (NodeRef)actionProps.get(PROP_DESTINATION);
repoProps.put(CopyActionExecuter.PARAM_DESTINATION_FOLDER, destNodeRef);
// add the type and name of the association to create when the copy
// is performed
repoProps.put(CopyActionExecuter.PARAM_ASSOC_TYPE_QNAME,
ContentModel.ASSOC_CONTAINS);
repoProps.put(CopyActionExecuter.PARAM_ASSOC_QNAME,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "copy"));
}
public void prepareForEdit(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
NodeRef destNodeRef = (NodeRef)repoProps.get(CopyActionExecuter.PARAM_DESTINATION_FOLDER);
actionProps.put(PROP_DESTINATION, destNodeRef);
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> actionProps)
{
NodeRef space = (NodeRef)actionProps.get(PROP_DESTINATION);
String spaceName = Repository.getNameForNode(
Repository.getServiceRegistry(context).getNodeService(), space);
return MessageFormat.format(Application.getMessage(context, "action_copy"),
new Object[] {spaceName});
}
}

View File

@@ -0,0 +1,58 @@
package org.alfresco.web.bean.actions.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.repo.action.executer.ImporterActionExecuter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Action handler implementation for the "import" action.
*
* @author gavinc
*/
public class ImportHandler extends BaseActionHandler
{
protected static final String IMPORT_ENCODING = "UTF-8";
public String getJSPPath()
{
return getJSPPath(ImporterActionExecuter.NAME);
}
public void prepareForSave(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
// add the encoding
repoProps.put(ImporterActionExecuter.PARAM_ENCODING, IMPORT_ENCODING);
// add the destination for the import
NodeRef destNodeRef = (NodeRef)actionProps.get(PROP_DESTINATION);
repoProps.put(ImporterActionExecuter.PARAM_DESTINATION_FOLDER, destNodeRef);
}
public void prepareForEdit(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
NodeRef destNodeRef = (NodeRef)repoProps.get(
ImporterActionExecuter.PARAM_DESTINATION_FOLDER);
actionProps.put(PROP_DESTINATION, destNodeRef);
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> actionProps)
{
NodeRef space = (NodeRef)actionProps.get(PROP_DESTINATION);
String spaceName = Repository.getNameForNode(
Repository.getServiceRegistry(context).getNodeService(), space);
return MessageFormat.format(Application.getMessage(context, "action_import"),
new Object[] {spaceName});
}
}

View File

@@ -0,0 +1,60 @@
package org.alfresco.web.bean.actions.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.executer.LinkCategoryActionExecuter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Action handler implementation for the "link-category" action.
*
* @author gavinc
*/
public class LinkCategoryHandler extends BaseActionHandler
{
protected static final String PROP_CATEGORY = "category";
public String getJSPPath()
{
return getJSPPath(LinkCategoryActionExecuter.NAME);
}
public void prepareForSave(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
// add the classifiable aspect
repoProps.put(LinkCategoryActionExecuter.PARAM_CATEGORY_ASPECT,
ContentModel.ASPECT_GEN_CLASSIFIABLE);
// put the selected category in the action params
NodeRef catNodeRef = (NodeRef)actionProps.get(PROP_CATEGORY);
repoProps.put(LinkCategoryActionExecuter.PARAM_CATEGORY_VALUE,
catNodeRef);
}
public void prepareForEdit(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
NodeRef catNodeRef = (NodeRef)repoProps.get(LinkCategoryActionExecuter.PARAM_CATEGORY_VALUE);
actionProps.put(PROP_CATEGORY, catNodeRef);
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> actionProps)
{
NodeRef cat = (NodeRef)actionProps.get(PROP_CATEGORY);
String name = Repository.getNameForNode(
Repository.getServiceRegistry(context).getNodeService(), cat);
return MessageFormat.format(Application.getMessage(context, "action_link_category"),
new Object[] {name});
}
}

View File

@@ -0,0 +1,144 @@
package org.alfresco.web.bean.actions.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.repo.action.executer.MailActionExecuter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.actions.BaseActionWizard;
import org.alfresco.web.bean.actions.BaseActionWizard.RecipientWrapper;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Action handler implementation for the "mail" action.
*
* @author gavinc
*/
public class MailHandler extends BaseActionHandler
{
public static final String PROP_TO = "to";
public static final String PROP_FROM = "from";
public static final String PROP_MESSAGE = "message";
public static final String PROP_SUBJECT = "subject";
public static final String PROP_TEMPLATE = "template";
public String getJSPPath()
{
return getJSPPath(MailActionExecuter.NAME);
}
public void prepareForSave(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
// get hold of the current wizard so we can extract some data from it
BaseActionWizard wizard = (BaseActionWizard)Application.
getWizardManager().getBean();
// add the person(s) it's going to as a list of authorities
List<String> recipients = new ArrayList<String>(wizard.getEmailRecipients().size());
for (int i=0; i < wizard.getEmailRecipients().size(); i++)
{
RecipientWrapper wrapper = wizard.getEmailRecipients().get(i);
recipients.add(wrapper.getAuthority());
}
repoProps.put(MailActionExecuter.PARAM_TO_MANY, (Serializable)recipients);
// add the actual email text to send
repoProps.put(MailActionExecuter.PARAM_TEXT, actionProps.get(PROP_MESSAGE));
// add the subject for the email
repoProps.put(MailActionExecuter.PARAM_SUBJECT, actionProps.get(PROP_SUBJECT));
// add the from address
String from = Application.getClientConfig(FacesContext.getCurrentInstance()).getFromEmailAddress();
repoProps.put(MailActionExecuter.PARAM_FROM, from);
// add the template if one was selected by the user
if (wizard.getUsingTemplate() != null)
{
repoProps.put(MailActionExecuter.PARAM_TEMPLATE, new NodeRef(Repository.getStoreRef(),
wizard.getUsingTemplate()));
}
}
public void prepareForEdit(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
// get hold of the current wizard so we can extract some data from it
BaseActionWizard wizard = (BaseActionWizard)Application.
getWizardManager().getBean();
String subject = (String)repoProps.get(MailActionExecuter.PARAM_SUBJECT);
actionProps.put(PROP_SUBJECT, subject);
String message = (String)repoProps.get(MailActionExecuter.PARAM_TEXT);
actionProps.put(PROP_MESSAGE, message);
// handle single email or multiple authority recipients
String to = (String)repoProps.get(MailActionExecuter.PARAM_TO);
if (to != null)
{
actionProps.put(PROP_TO, to);
}
else
{
List<String> recipients = (List<String>)repoProps.get(MailActionExecuter.PARAM_TO_MANY);
if (recipients != null && recipients.size() != 0)
{
// rebuild the list of RecipientWrapper objects from the stored action
for (String authority : recipients)
{
wizard.getEmailRecipients().add(
new RecipientWrapper(wizard.displayLabelForAuthority(authority),
authority));
}
}
}
NodeRef templateRef = (NodeRef)repoProps.get(MailActionExecuter.PARAM_TEMPLATE);
if (templateRef != null)
{
actionProps.put(PROP_TEMPLATE, templateRef.getId());
wizard.setUsingTemplate(templateRef.getId());
}
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> actionProps)
{
BaseActionWizard actionWizard = (BaseActionWizard)wizard;
String addresses = (String)actionProps.get(PROP_TO);
if (addresses == null || addresses.length() == 0)
{
if (actionWizard.getEmailRecipients().size() != 0)
{
StringBuilder builder = new StringBuilder();
for (int i=0; i < actionWizard.getEmailRecipients().size(); i++)
{
RecipientWrapper wrapper = actionWizard.getEmailRecipients().get(i);
if (i != 0)
{
builder.append(", ");
}
builder.append(wrapper.getName());
}
addresses = builder.toString();
}
}
return MessageFormat.format(Application.getMessage(context, "action_mail"),
new Object[] {addresses});
}
}

View File

@@ -0,0 +1,62 @@
package org.alfresco.web.bean.actions.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.executer.MoveActionExecuter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Action handler for the "move" action.
*
* @author gavinc
*/
public class MoveHandler extends BaseActionHandler
{
public String getJSPPath()
{
return getJSPPath(MoveActionExecuter.NAME);
}
public void prepareForSave(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
// add the destination space id to the action properties
NodeRef destNodeRef = (NodeRef)actionProps.get(PROP_DESTINATION);
repoProps.put(MoveActionExecuter.PARAM_DESTINATION_FOLDER, destNodeRef);
// add the type and name of the association to create when the move
// is performed
repoProps.put(MoveActionExecuter.PARAM_ASSOC_TYPE_QNAME,
ContentModel.ASSOC_CONTAINS);
repoProps.put(MoveActionExecuter.PARAM_ASSOC_QNAME,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "move"));
}
public void prepareForEdit(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
NodeRef destNodeRef = (NodeRef)repoProps.get(MoveActionExecuter.PARAM_DESTINATION_FOLDER);
actionProps.put(PROP_DESTINATION, destNodeRef);
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> actionProps)
{
NodeRef space = (NodeRef)actionProps.get(PROP_DESTINATION);
String spaceName = Repository.getNameForNode(
Repository.getServiceRegistry(context).getNodeService(), space);
return MessageFormat.format(Application.getMessage(context, "action_move"),
new Object[] {spaceName});
}
}

View File

@@ -0,0 +1,65 @@
package org.alfresco.web.bean.actions.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import org.alfresco.repo.action.executer.RemoveFeaturesActionExecuter;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.actions.BaseActionWizard;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Action handler for the "remove-features" action.
*
* @author gavinc
*/
public class RemoveFeaturesHandler extends BaseActionHandler
{
protected static final String PROP_ASPECT = "aspect";
public String getJSPPath()
{
return getJSPPath(RemoveFeaturesActionExecuter.NAME);
}
public void prepareForSave(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
QName aspect = Repository.resolveToQName((String)actionProps.get(PROP_ASPECT));
repoProps.put(RemoveFeaturesActionExecuter.PARAM_ASPECT_NAME, aspect);
}
public void prepareForEdit(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
QName aspect = (QName)repoProps.get(RemoveFeaturesActionExecuter.PARAM_ASPECT_NAME);
actionProps.put(PROP_ASPECT, aspect.toString());
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> actionProps)
{
String label = null;
String aspect = (String)actionProps.get(PROP_ASPECT);
// find the label used by looking through the SelectItem list
for (SelectItem item : ((BaseActionWizard)wizard).getAspects())
{
if (item.getValue().equals(aspect))
{
label = item.getLabel();
break;
}
}
return MessageFormat.format(Application.getMessage(context, "action_remove_features"),
new Object[] {label});
}
}

View File

@@ -0,0 +1,63 @@
package org.alfresco.web.bean.actions.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.repo.action.executer.ScriptActionExecutor;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.web.app.Application;
import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.bean.NavigationBean;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Action handler for the "script" action.
*
* @author gavinc
*/
public class ScriptHandler extends BaseActionHandler
{
protected static final String PROP_SCRIPT = "script";
public String getJSPPath()
{
return getJSPPath(ScriptActionExecutor.NAME);
}
public void prepareForSave(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
// add the selected script noderef to the action properties
String id = (String)actionProps.get(PROP_SCRIPT);
NodeRef scriptRef = new NodeRef(Repository.getStoreRef(), id);
repoProps.put(ScriptActionExecutor.PARAM_SCRIPTREF, scriptRef);
NavigationBean navBean = (NavigationBean)FacesHelper.getManagedBean(
FacesContext.getCurrentInstance(), "NavigationBean");
repoProps.put(ScriptActionExecutor.PARAM_SPACEREF,
navBean.getCurrentNode().getNodeRef());
}
public void prepareForEdit(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
NodeRef scriptRef = (NodeRef)repoProps.get(ScriptActionExecutor.PARAM_SCRIPTREF);
actionProps.put(PROP_SCRIPT, scriptRef.getId());
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> actionProps)
{
String id = (String)actionProps.get(PROP_SCRIPT);
NodeRef scriptRef = new NodeRef(Repository.getStoreRef(), id);
String scriptName = Repository.getNameForNode(
Repository.getServiceRegistry(context).getNodeService(), scriptRef);
return MessageFormat.format(Application.getMessage(context, "action_script"),
new Object[] {scriptName});
}
}

View File

@@ -0,0 +1,181 @@
package org.alfresco.web.bean.actions.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.repo.action.executer.SimpleWorkflowActionExecuter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Action handler for the "simple-workflow" action.
*
* @author gavinc
*/
public class SimpleWorkflowHandler extends BaseActionHandler
{
public static final String PROP_APPROVE_STEP_NAME = "approveStepName";
public static final String PROP_APPROVE_ACTION = "approveAction";
public static final String PROP_APPROVE_FOLDER = "approveFolder";
public static final String PROP_REJECT_STEP_PRESENT = "rejectStepPresent";
public static final String PROP_REJECT_STEP_NAME = "rejectStepName";
public static final String PROP_REJECT_ACTION = "rejectAction";
public static final String PROP_REJECT_FOLDER = "rejectFolder";
@Override
public void setupUIDefaults(Map<String, Serializable> actionProps)
{
actionProps.put(PROP_APPROVE_ACTION, "move");
actionProps.put(PROP_REJECT_STEP_PRESENT, "yes");
actionProps.put(PROP_REJECT_ACTION, "move");
}
public String getJSPPath()
{
return getJSPPath(SimpleWorkflowActionExecuter.NAME);
}
public void prepareForSave(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
// add the approve step name
repoProps.put(SimpleWorkflowActionExecuter.PARAM_APPROVE_STEP,
(String)actionProps.get(PROP_APPROVE_STEP_NAME));
// add whether the approve step will copy or move the content
boolean approveMove = true;
String approveAction = (String)actionProps.get(PROP_APPROVE_ACTION);
if (approveAction != null && approveAction.equals("copy"))
{
approveMove = false;
}
repoProps.put(SimpleWorkflowActionExecuter.PARAM_APPROVE_MOVE, Boolean.valueOf(approveMove));
// add the destination folder of the content
NodeRef approveDestNodeRef = null;
Object approveDestNode = actionProps.get(PROP_APPROVE_FOLDER);
if (approveDestNode instanceof NodeRef)
{
approveDestNodeRef = (NodeRef)approveDestNode;
}
else if (approveDestNode instanceof String)
{
approveDestNodeRef = new NodeRef((String)approveDestNode);
}
repoProps.put(SimpleWorkflowActionExecuter.PARAM_APPROVE_FOLDER, approveDestNodeRef);
// determine whether we have a reject step or not
boolean requireReject = true;
String rejectStepPresent = (String)actionProps.get(PROP_REJECT_STEP_PRESENT);
if (rejectStepPresent != null && rejectStepPresent.equals("no"))
{
requireReject = false;
}
if (requireReject)
{
// add the reject step name
repoProps.put(SimpleWorkflowActionExecuter.PARAM_REJECT_STEP,
(String)actionProps.get(PROP_REJECT_STEP_NAME));
// add whether the reject step will copy or move the content
boolean rejectMove = true;
String rejectAction = (String)actionProps.get(PROP_REJECT_ACTION);
if (rejectAction != null && rejectAction.equals("copy"))
{
rejectMove = false;
}
repoProps.put(SimpleWorkflowActionExecuter.PARAM_REJECT_MOVE, Boolean.valueOf(rejectMove));
// add the destination folder of the content
NodeRef rejectDestNodeRef = null;
Object rejectDestNode = actionProps.get(PROP_REJECT_FOLDER);
if (rejectDestNode instanceof NodeRef)
{
rejectDestNodeRef = (NodeRef)rejectDestNode;
}
else if (rejectDestNode instanceof String)
{
rejectDestNodeRef = new NodeRef((String)rejectDestNode);
}
repoProps.put(SimpleWorkflowActionExecuter.PARAM_REJECT_FOLDER, rejectDestNodeRef);
}
}
public void prepareForEdit(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
String approveStep = (String)repoProps.get(SimpleWorkflowActionExecuter.PARAM_APPROVE_STEP);
Boolean approveMove = (Boolean)repoProps.get(SimpleWorkflowActionExecuter.PARAM_APPROVE_MOVE);
NodeRef approveFolderNode = (NodeRef)repoProps.get(
SimpleWorkflowActionExecuter.PARAM_APPROVE_FOLDER);
String rejectStep = (String)repoProps.get(SimpleWorkflowActionExecuter.PARAM_REJECT_STEP);
Boolean rejectMove = (Boolean)repoProps.get(SimpleWorkflowActionExecuter.PARAM_REJECT_MOVE);
NodeRef rejectFolderNode = (NodeRef)repoProps.get(
SimpleWorkflowActionExecuter.PARAM_REJECT_FOLDER);
actionProps.put(PROP_APPROVE_STEP_NAME, approveStep);
actionProps.put(PROP_APPROVE_ACTION, approveMove ? "move" : "copy");
actionProps.put(PROP_APPROVE_FOLDER, approveFolderNode);
if (rejectStep == null && rejectMove == null && rejectFolderNode == null)
{
actionProps.put(PROP_REJECT_STEP_PRESENT, "no");
actionProps.put(PROP_REJECT_ACTION, "move");
}
else
{
actionProps.put(PROP_REJECT_STEP_PRESENT, "yes");
actionProps.put(PROP_REJECT_STEP_NAME, rejectStep);
actionProps.put(PROP_REJECT_ACTION, rejectMove ? "move" : "copy");
actionProps.put(PROP_REJECT_FOLDER, rejectFolderNode);
}
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> actionProps)
{
NodeService nodeService = Repository.getServiceRegistry(context).getNodeService();
String approveStepName = (String)actionProps.get(PROP_APPROVE_STEP_NAME);
String approveAction = (String)actionProps.get(PROP_APPROVE_ACTION);
NodeRef approveFolder = (NodeRef)actionProps.get(PROP_APPROVE_FOLDER);
String approveFolderName = Repository.getNameForNode(nodeService, approveFolder);
String approveMsg = MessageFormat.format(
Application.getMessage(context, "action_simple_workflow"),
new Object[] {Application.getMessage(context, approveAction),
approveFolderName, approveStepName});
String rejectMsg = null;
String rejectStep = (String)actionProps.get(PROP_REJECT_STEP_PRESENT);
if (rejectStep != null && "yes".equals(rejectStep))
{
String rejectStepName = (String)actionProps.get(PROP_REJECT_STEP_NAME);
String rejectAction = (String)actionProps.get(PROP_REJECT_ACTION);
NodeRef rejectFolder = (NodeRef)actionProps.get(PROP_REJECT_FOLDER);
String rejectFolderName = Repository.getNameForNode(nodeService, rejectFolder);
rejectMsg = MessageFormat.format(
Application.getMessage(context, "action_simple_workflow"),
new Object[] {Application.getMessage(context, rejectAction),
rejectFolderName, rejectStepName});
}
StringBuilder builder = new StringBuilder(approveMsg);
if (rejectMsg != null)
{
builder.append(" ");
builder.append(rejectMsg);
}
return builder.toString();
}
}

View File

@@ -0,0 +1,63 @@
package org.alfresco.web.bean.actions.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import org.alfresco.repo.action.executer.SpecialiseTypeActionExecuter;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.actions.BaseActionWizard;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Action handler for the "specialise-type" action.
*
* @author gavinc
*/
public class SpecialiseTypeHandler extends BaseActionHandler
{
public static final String PROP_OBJECT_TYPE = "objecttype";
public String getJSPPath()
{
return getJSPPath(SpecialiseTypeActionExecuter.NAME);
}
public void prepareForSave(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
String objectType = (String)actionProps.get(PROP_OBJECT_TYPE);
repoProps.put(SpecialiseTypeActionExecuter.PARAM_TYPE_NAME,
QName.createQName(objectType));
}
public void prepareForEdit(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
QName specialiseType = (QName)repoProps.get(SpecialiseTypeActionExecuter.PARAM_TYPE_NAME);
actionProps.put(PROP_OBJECT_TYPE, specialiseType.toString());
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> actionProps)
{
String label = null;
String objectType = (String)actionProps.get(PROP_OBJECT_TYPE);
for (SelectItem item : ((BaseActionWizard)wizard).getObjectTypes())
{
if (item.getValue().equals(objectType) == true)
{
label = item.getLabel();
break;
}
}
return MessageFormat.format(Application.getMessage(context, "action_specialise_type"),
new Object[] {label});
}
}

View File

@@ -0,0 +1,85 @@
package org.alfresco.web.bean.actions.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.executer.TransformActionExecuter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.actions.BaseActionWizard;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Action handler for the "transform" action.
*
* @author gavinc
*/
public class TransformHandler extends BaseActionHandler
{
protected static final String PROP_TRANSFORMER = "transformer";
public String getJSPPath()
{
return getJSPPath(TransformActionExecuter.NAME);
}
public void prepareForSave(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
// add the transformer to use
repoProps.put(TransformActionExecuter.PARAM_MIME_TYPE,
actionProps.get(PROP_TRANSFORMER));
// add the destination space id to the action properties
NodeRef destNodeRef = (NodeRef)actionProps.get(PROP_DESTINATION);
repoProps.put(TransformActionExecuter.PARAM_DESTINATION_FOLDER, destNodeRef);
// add the type and name of the association to create when the copy
// is performed
repoProps.put(TransformActionExecuter.PARAM_ASSOC_TYPE_QNAME,
ContentModel.ASSOC_CONTAINS);
repoProps.put(TransformActionExecuter.PARAM_ASSOC_QNAME,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "copy"));
}
public void prepareForEdit(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
String transformer = (String)repoProps.get(TransformActionExecuter.PARAM_MIME_TYPE);
actionProps.put(PROP_TRANSFORMER, transformer);
NodeRef destNodeRef = (NodeRef)repoProps.get(TransformActionExecuter.PARAM_DESTINATION_FOLDER);
actionProps.put(PROP_DESTINATION, destNodeRef);
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> actionProps)
{
String label = null;
NodeRef space = (NodeRef)actionProps.get(PROP_DESTINATION);
String name = Repository.getNameForNode(
Repository.getServiceRegistry(context).getNodeService(), space);
String transformer = (String)actionProps.get(PROP_TRANSFORMER);
// find the label used by looking through the SelectItem list
for (SelectItem item : ((BaseActionWizard)wizard).getTransformers())
{
if (item.getValue().equals(transformer))
{
label = item.getLabel();
break;
}
}
return MessageFormat.format(Application.getMessage(context, "action_transform"),
new Object[] {name, label});
}
}

View File

@@ -0,0 +1,95 @@
package org.alfresco.web.bean.actions.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.executer.ImageTransformActionExecuter;
import org.alfresco.repo.action.executer.TransformActionExecuter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.actions.BaseActionWizard;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Action handler for the "transform-image" action.
*
* @author gavinc
*/
public class TransformImageHandler extends BaseActionHandler
{
protected static final String PROP_IMAGE_TRANSFORMER = "imageTransformer";
protected static final String PROP_TRANSFORM_OPTIONS = "transformOptions";
public String getJSPPath()
{
return getJSPPath(ImageTransformActionExecuter.NAME);
}
public void prepareForSave(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
// add the transformer to use
repoProps.put(ImageTransformActionExecuter.PARAM_MIME_TYPE,
actionProps.get(PROP_IMAGE_TRANSFORMER));
// add the options
repoProps.put(ImageTransformActionExecuter.PARAM_CONVERT_COMMAND,
actionProps.get(PROP_TRANSFORM_OPTIONS));
// add the destination space id to the action properties
NodeRef destNodeRef = (NodeRef)actionProps.get(PROP_DESTINATION);
repoProps.put(ImageTransformActionExecuter.PARAM_DESTINATION_FOLDER, destNodeRef);
// add the type and name of the association to create when the copy
// is performed
repoProps.put(TransformActionExecuter.PARAM_ASSOC_TYPE_QNAME,
ContentModel.ASSOC_CONTAINS);
repoProps.put(TransformActionExecuter.PARAM_ASSOC_QNAME,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "copy"));
}
public void prepareForEdit(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
String transformer = (String)repoProps.get(TransformActionExecuter.PARAM_MIME_TYPE);
actionProps.put(PROP_IMAGE_TRANSFORMER, transformer);
String options = (String)repoProps.get(ImageTransformActionExecuter.PARAM_CONVERT_COMMAND);
actionProps.put(PROP_TRANSFORM_OPTIONS, options != null ? options : "");
NodeRef destNodeRef = (NodeRef)repoProps.get(ImageTransformActionExecuter.PARAM_DESTINATION_FOLDER);
actionProps.put(PROP_DESTINATION, destNodeRef);
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> actionProps)
{
String label = null;
NodeRef space = (NodeRef)actionProps.get(PROP_DESTINATION);
String name = Repository.getNameForNode(
Repository.getServiceRegistry(context).getNodeService(), space);
String transformer = (String)actionProps.get(PROP_IMAGE_TRANSFORMER);
String option = (String)actionProps.get(PROP_TRANSFORM_OPTIONS);
// find the label used by looking through the SelectItem list
for (SelectItem item : ((BaseActionWizard)wizard).getImageTransformers())
{
if (item.getValue().equals(transformer))
{
label = item.getLabel();
break;
}
}
return MessageFormat.format(Application.getMessage(context, "action_transform_image"),
new Object[] {name, label, option});
}
}