05-13-2008 04:03 AM
05-15-2008 05:42 AM
05-15-2008 11:03 AM
05-16-2008 02:25 AM
05-16-2008 03:29 AM
05-16-2008 05:20 AM
<!–*********************************–>
<!–* Createur de filliale *–>
<!–*********************************–>
<bean id="community-make-subsidiary-space" class="org.alfresco.community.repo.MakeSubsidiarySpace" parent="action-executer" >
<property name="nodeService">
<ref bean="nodeService" />
</property>
<property name="ruleService">
<ref bean="RuleService" />
</property>
<property name="actionService">
<ref bean="ActionService" />
</property>
</bean>
<bean id="community-make-subsidiary-space-action-messages" class="org.alfresco.i18n.ResourceBundleBootstrapComponent">
<property name="resourceBundles">
<list>
<value>alfresco/messages/action-executer/community-make-subsidiary-space-action-messages</value>
</list>
</property>
</bean>
community-make-subsidiary-space.title=Créateur d'espace de filliale
community-make-subsidiary-space.description=Initialise la création de l'espace de filliale
package org.alfresco.community.repo;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.action.CompositeAction;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.rule.Rule;
import org.alfresco.service.cmr.rule.RuleService;
import org.alfresco.community.util.MyLogger;
public class MakeSubsidiarySpace extends ActionExecuterAbstractBase{
//private static Log logger = LogFactory.getLog("MakeSubsidiarySpace");
// Add Bean Property on custom-model-context.xml fil on alfresco\extension directory
private NodeService nodeService;
private ActionService actionService;
private RuleService ruleService;
public final static String PARAM_EXECUTE_INHERITED_RULES = "execute-inherited-rules";
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
public void setActionService(ActionService actionService)
{
this.actionService = actionService;
}
public void setRuleService(RuleService ruleService)
{
this.ruleService = ruleService;
}
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
{
MyLogger.debugln("org.alfresco.community.repo.MakeSubsidiarySpace (Start)…",1);
if (this.nodeService.exists(actionedUponNodeRef) == true)
{
MyLogger.debugln("Add rule Processus Space Creator (In)",1);
createRules(actionService, ruleService, actionedUponNodeRef);
}
MyLogger.debugln("org.alfresco.community.repo.MakeSubsidiarySpace (End).",1);
MyLogger.debugln("",1);
}
protected static void createRules(ActionService actionService, RuleService ruleService, NodeRef nodeRef) {
Rule rule = new Rule();
rule.setRuleType("inbound");
// setup the rule and add it to the space
rule.setTitle("Processus Space Creator (In)");
rule.setDescription("Make Processus Space");
rule.applyToChildren(false);
rule.setExecuteAsynchronously(false);
rule.setRuleDisabled(false);
CompositeAction compositeAction = actionService.createCompositeAction();
rule.setAction(compositeAction);
compositeAction.addAction(actionService.createAction("community-make-processus-space"));
//compositeAction.addActionCondition(actionService.createActionCondition("no-condition"));
Map<String,Serializable> actionMap = new HashMap<String, Serializable>();
actionMap.put("type", ContentModel.TYPE_FOLDER);
compositeAction.addActionCondition(actionService.createActionCondition("is-subtype",actionMap));
ruleService.saveRule(nodeRef, rule);
}
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList) {
// No code
}
}
<!–*********************************–>
<!–* Createur d'arborescence *–>
<!–*********************************–>
<bean id="community-make-processus-space" class="org.alfresco.community.repo.MakeProcessusSpace" parent="action-executer" >
<property name="nodeService">
<ref bean="nodeService" />
</property>
<property name="fileFolderService">
<ref bean="FileFolderService" />
</property>
<property name="ruleService">
<ref bean="RuleService" />
</property>
<property name="actionService">
<ref bean="ActionService" />
</property>
</bean>
<bean id="community-make-processus-space-action-messages" class="org.alfresco.i18n.ResourceBundleBootstrapComponent">
<property name="resourceBundles">
<list>
<value>alfresco/messages/action-executer/community-make-processus-space-action-messages</value>
</list>
</property>
</bean>
community-make-processus-space.title=Créateur d'espace de processus
community-make-processus-space.description=Initialise la création de l'espace processus
package org.alfresco.community.repo;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.action.CompositeAction;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.rule.Rule;
import org.alfresco.service.cmr.rule.RuleService;
import org.alfresco.community.definitions.CommunityConstante;
import org.alfresco.community.util.MyLogger;
public class MakeProcessusSpace extends ActionExecuterAbstractBase{
//private static Log logger = LogFactory.getLog("MakeProcessusSpace");
// Add Bean Property on custom-model-context.xml fil on alfresco\extension directory
private NodeService nodeService;
@SuppressWarnings("unused")
private FileFolderService fileFolderService;
private ActionService actionService;
private RuleService ruleService;
public final static String PARAM_EXECUTE_INHERITED_RULES = "execute-inherited-rules";
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
public void setFileFolderService(FileFolderService fileFolderService)
{
this.fileFolderService = fileFolderService;
}
public void setActionService(ActionService actionService)
{
this.actionService = actionService;
}
public void setRuleService(RuleService ruleService)
{
this.ruleService = ruleService;
}
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
{
MyLogger.debugln("org.alfresco.community.repo.MakeProcessusSpace (Start)…",1);
if (this.nodeService.exists(actionedUponNodeRef) == true)
{
MyLogger.debugln("Add rule Validation Sub-Space Creator (In)",1);
createRules(actionService, ruleService, actionedUponNodeRef);
MyLogger.debugln("->" + CommunityConstante.SPACE_DOC,1);
this.fileFolderService.create(actionedUponNodeRef, CommunityConstante.SPACE_DOC, ContentModel.TYPE_FOLDER);
MyLogger.debugln("->" + CommunityConstante.SPACE_EDC,1);
this.fileFolderService.create(actionedUponNodeRef, CommunityConstante.SPACE_EDC, ContentModel.TYPE_FOLDER);
MyLogger.debugln("->" + CommunityConstante.SPACE_FOR,1);
this.fileFolderService.create(actionedUponNodeRef, CommunityConstante.SPACE_FOR, ContentModel.TYPE_FOLDER);
MyLogger.debugln("->" + CommunityConstante.SPACE_IOP,1);
this.fileFolderService.create(actionedUponNodeRef, CommunityConstante.SPACE_IOP, ContentModel.TYPE_FOLDER);
MyLogger.debugln("->" + CommunityConstante.SPACE_PCS,1);
this.fileFolderService.create(actionedUponNodeRef, CommunityConstante.SPACE_PCS, ContentModel.TYPE_FOLDER);
MyLogger.debugln("->" + CommunityConstante.SPACE_PRO,1);
this.fileFolderService.create(actionedUponNodeRef, CommunityConstante.SPACE_PRO, ContentModel.TYPE_FOLDER);
}
MyLogger.debugln("org.alfresco.community.repo.MakeProcessusSpace (End).",1);
MyLogger.debugln("",1);
}
protected static void createRules(ActionService actionService, RuleService ruleService, NodeRef nodeRef) {
Rule rule = new Rule();
rule.setRuleType("inbound");
// setup the rule and add it to the space
rule.setTitle("Validation Sub-Space Creator (In)");
rule.setDescription("Make all validation Sub-Space");
rule.applyToChildren(false);
rule.setExecuteAsynchronously(false);
rule.setRuleDisabled(false);
CompositeAction compositeAction = actionService.createCompositeAction();
rule.setAction(compositeAction);
compositeAction.addAction(actionService.createAction("community-make-validation-subspaces"));
//compositeAction.addActionCondition(actionService.createActionCondition("no-condition"));
Map<String,Serializable> actionMap = new HashMap<String, Serializable>();
actionMap.put("type", ContentModel.TYPE_FOLDER);
compositeAction.addActionCondition(actionService.createActionCondition("is-subtype",actionMap));
ruleService.saveRule(nodeRef, rule);
}
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList) {
// No code
}
}
<!–*********************************–>
<!–* Createur de sous arborescence *–>
<!–*********************************–>
<bean id="community-make-validation-subspaces" class="org.alfresco.community.repo.MakeValidationSubSpaces" parent="action-executer" >
<property name="nodeService">
<ref bean="nodeService" />
</property>
<property name="permissionService">
<ref bean="permissionService" />
</property>
<property name="fileFolderService">
<ref bean="FileFolderService" />
</property>
<property name="ruleService">
<ref bean="RuleService" />
</property>
<property name="actionService">
<ref bean="ActionService" />
</property>
</bean>
<bean id="community-make-validation-subspaces-action-messages" class="org.alfresco.i18n.ResourceBundleBootstrapComponent">
<property name="resourceBundles">
<list>
<value>alfresco/messages/action-executer/community-make-validation-subspaces-action-messages</value>
</list>
</property>
</bean>
community-make-validation-subspaces.title=Créateur de sous espace de validation
community-make-validation-subspaces.description=Créé les sous-espaces de validation
package org.alfresco.community.repo;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.action.CompositeAction;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.rule.Rule;
import org.alfresco.service.cmr.rule.RuleService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.community.definitions.CommunityConstante;
import org.alfresco.community.service.cmr.security.CommunityPermissionService;
import org.alfresco.community.util.MyLogger;
public class MakeValidationSubSpaces extends ActionExecuterAbstractBase{
//private static Log logger = LogFactory.getLog("MakeValidationSubSpaces");
// Add Bean Property on custom-model-context.xml fil on alfresco\extension directory
private NodeService nodeService;
private PermissionService permissionService;
private FileFolderService fileFolderService;
private ActionService actionService;
private RuleService ruleService;
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
public void setFileFolderService(FileFolderService fileFolderService)
{
this.fileFolderService = fileFolderService;
}
public void setActionService(ActionService actionService)
{
this.actionService = actionService;
}
public void setRuleService(RuleService ruleService)
{
this.ruleService = ruleService;
}
public void setPermissionService(PermissionService permissionService)
{
this.permissionService = permissionService;
}
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
{
MyLogger.debugln("org.alfresco.community.repo.MakeValidationSubSpaces (Start)…",1);
if (this.nodeService.exists(actionedUponNodeRef) == true) {
MyLogger.debugln(" ->" + CommunityConstante.SPACE_DRAFTS,1);
this.fileFolderService.create(actionedUponNodeRef, CommunityConstante.SPACE_DRAFTS, ContentModel.TYPE_FOLDER);
MyLogger.debugln(" ->" + CommunityConstante.SPACE_REVIEW_AND_APPROVAL,1);
this.fileFolderService.create(actionedUponNodeRef, CommunityConstante.SPACE_REVIEW_AND_APPROVAL, ContentModel.TYPE_FOLDER);
MyLogger.debugln(" ->" + CommunityConstante.SPACE_PUBLISHED,1);
this.fileFolderService.create(actionedUponNodeRef, CommunityConstante.SPACE_PUBLISHED, ContentModel.TYPE_FOLDER);
MyLogger.debugln(" ->" + CommunityConstante.SPACE_APPROVED,1);
this.fileFolderService.create(actionedUponNodeRef, CommunityConstante.SPACE_APPROVED, ContentModel.TYPE_FOLDER);
MyLogger.debugln(" ->" + CommunityConstante.SPACE_TEMPLATES,1);
this.fileFolderService.create(actionedUponNodeRef, CommunityConstante.SPACE_TEMPLATES, ContentModel.TYPE_FOLDER);
List<ChildAssociationRef> childrenRefs = nodeService.getChildAssocs(actionedUponNodeRef);
for (ChildAssociationRef tchildrenRef : childrenRefs) {
final NodeRef childrenRef = tchildrenRef.getChildRef();
String nodeName = (String)this.nodeService.getProperty(childrenRef, ContentModel.PROP_NAME);
if (nodeName.equals(CommunityConstante.SPACE_DRAFTS)) {
// Add icon
MyLogger.debugln(" -> Add icon",1);
nodeService.setProperty(childrenRef, ApplicationModel.PROP_ICON, CommunityConstante.ICON_DRAFTS_SPACE);
// Set default permissions
MyLogger.debugln(" -> Set permission",1);
permissionService.setInheritParentPermissions(childrenRef, false);
permissionService.setPermission(childrenRef, getGroupName(nodeService,actionedUponNodeRef), CommunityPermissionService.COLLABORATOR,true);
// Add rule
MyLogger.debugln(" -> Add rule Document Preparator (In)",1);
createRules(actionService, ruleService, childrenRef);
}
if (nodeName.equals(CommunityConstante.SPACE_REVIEW_AND_APPROVAL)) {
// Add icon
MyLogger.debugln(" -> Add icon",1);
nodeService.setProperty(childrenRef, ApplicationModel.PROP_ICON, CommunityConstante.ICON_REVIEW_AND_APPROVAL_SPACE);
}
if (nodeName.equals(CommunityConstante.SPACE_APPROVED)) {
// Add icon
MyLogger.debugln(" -> Add icon",1);
nodeService.setProperty(childrenRef, ApplicationModel.PROP_ICON, CommunityConstante.ICON_APPROVED_SPACE);
// Set default permissions
MyLogger.debugln(" -> Set permission",1);
permissionService.setInheritParentPermissions(childrenRef, false);
this.permissionService.setPermission(childrenRef, getGroupName(nodeService,actionedUponNodeRef), PermissionService.CONSUMER,true);
}
if (nodeName.equals(CommunityConstante.SPACE_PUBLISHED)) {
// Add icon
MyLogger.debugln(" -> Add icon",1);
nodeService.setProperty(childrenRef, ApplicationModel.PROP_ICON, CommunityConstante.ICON_PUBLISHED_SPACE);
}
if (nodeName.equals(CommunityConstante.SPACE_TEMPLATES)) {
// Add icon
MyLogger.debugln(" -> Add icon",1);
nodeService.setProperty(childrenRef, ApplicationModel.PROP_ICON, CommunityConstante.ICON_TEMPLATES_SPACE);
}
}
}
MyLogger.debugln("org.alfresco.community.repo.MakeValidationSubSpaces (End).",1);
MyLogger.debugln("",1);
}
protected String getGroupName(NodeService nodeService,NodeRef nodeRef) {
String path = this.nodeService.getPath(nodeRef).toDisplayPath(this.nodeService);
path = path.replace(CommunityConstante.SPACECHAR," ");
String[] Valeurs = path.split("/");
String groupName = CommunityConstante.GROUP_BASE + Valeurs[3].substring(0, 2) + "-" + Valeurs[4].substring(0, 3) + "-" + CommunityConstante.GROUP_COLLABORATORS;
MyLogger.debugln(" -> to " + groupName,1);
return groupName;
}
protected static void createRules(ActionService actionService, RuleService ruleService, NodeRef nodeRef) {
Rule rule = new Rule();
rule.setRuleType("inbound");
// setup the rule and add it to the space
rule.setTitle("Document Preparator (In)");
rule.setDescription("Prepare new document imported in repository");
rule.applyToChildren(true);
rule.setExecuteAsynchronously(false);
rule.setRuleDisabled(false);
CompositeAction compositeAction = actionService.createCompositeAction();
rule.setAction(compositeAction);
compositeAction.addAction(actionService.createAction("community-prepare-document"));
//compositeAction.addActionCondition(actionService.createActionCondition("no-condition"));
Map<String,Serializable> actionMap = new HashMap<String, Serializable>();
actionMap.put("type", ContentModel.TYPE_CONTENT);
compositeAction.addActionCondition(actionService.createActionCondition("is-subtype",actionMap));
ruleService.saveRule(nodeRef, rule);
}
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList) {
// No code
}
}
06-12-2008 08:28 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.