package org.alfresco.repo.action.executer;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Map;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.policy.BehaviourFilter;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.QName;
public class ChangeDateActionExecuter extends ActionExecuterAbstractBase
{
private NodeService nodeService;
private BehaviourFilter policyBehaviourFilter;;
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
public void setBehaviourFilter(BehaviourFilter policyBehaviourFilter)
{
this.policyBehaviourFilter = policyBehaviourFilter;
}
@Override
public void executeImpl(Action action, NodeRef actionedUponNodeRef)
{
if (nodeService.exists(actionedUponNodeRef))
{
try
{
// recupera le proprietà del nodo corrente
Map<QName, Serializable> props = nodeService.getProperties(actionedUponNodeRef);
Date modified = new SimpleDateFormat("yyyy-MM-dd").parse("2013-01-01");
Date created = new SimpleDateFormat("yyyy-MM-dd").parse("2013-01-02");
props.put(ContentModel.PROP_MODIFIED, modified);
props.put(ContentModel.PROP_CREATED, created);
// >>>>>>>>>>>>>>> NOTA BENE
// disabilita il behaviour dell'aspetto Autitable in modo da permettere la modifica
policyBehaviourFilter.disableBehaviour(actionedUponNodeRef, ContentModel.ASPECT_AUDITABLE);
nodeService.setProperties(actionedUponNodeRef, props);
}
catch (InvalidNodeRefException EX_in)
{
// […]
}
catch (ParseException EX_pe)
{
// […]
}
finally
{
policyBehaviourFilter.enableBehaviour(actionedUponNodeRef, ContentModel.ASPECT_AUDITABLE);
}
}
}
@Override
protected void addParameterDefinitions(List<ParameterDefinition> arg0)
{
// TODO Auto-generated method stub
}
}
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<bean id="ChangeDateActionExecuter" class="org.alfresco.repo.action.executer.ChangeDateActionExecuter" parent="action-executer" init-method="init">
<property name="NodeService">
<ref bean="nodeService" />
</property>
<property name="BehaviourFilter">
<ref bean="policyBehaviourFilter" />
</property>
</bean>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<entry key="cm:created">2013-07-31T12:40:19.789+02:00</entry>
<entry key="cm:author">Pippo</entry>
<entry key="cm:modified">2013-08-28T16:04:23.321+02:00</entry>
<entry key="cm:modifier">Pluto</entry>
<entry key="cm:publisher"> </entry>
<entry key="cm:contributor"> </entry>
<entry key="cm:type"> </entry>
<entry key="cm:identifier"> </entry>
<entry key="cm:dcsource"> </entry>
<entry key="cm:coverage"> </entry>
<entry key="cm:rights"> </entry>
<entry key="cm:subject"> </entry>
</properties>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<entry key="cm:created">2013-07-31T12:40:19.789+02:00</entry>
<entry key="cm:author">Pippo</entry>
<entry key="cm:modified">2013-07-31T12:40:19.789+02:00</entry>
<entry key="cm:modifier">Pippo</entry>
<entry key="cm:publisher"> </entry>
<entry key="cm:contributor"> </entry>
<entry key="cm:type"> </entry>
<entry key="cm:identifier"> </entry>
<entry key="cm:dcsource"> </entry>
<entry key="cm:coverage"> </entry>
<entry key="cm:rights"> </entry>
<entry key="cm:subject"> </entry>
</properties>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<entry key="cm:created">2013-07-31T12:40:19.789+02:00</entry>
<entry key="cm:author">Pippo</entry>
<entry key="cm:modified">2013-08-24T09:27:33.654+02:00</entry>
<entry key="cm:modifier">Paperino</entry>
<entry key="cm:publisher"> </entry>
<entry key="cm:contributor"> </entry>
<entry key="cm:type"> </entry>
<entry key="cm:identifier"> </entry>
<entry key="cm:dcsource"> </entry>
<entry key="cm:coverage"> </entry>
<entry key="cm:rights"> </entry>
<entry key="cm:subject"> </entry>
</properties>
Archive content from product discussions in Italian.
This group is now closed and content is read-only.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.