As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
Please visit the following wiki page for instructions:http://wiki.alfresco.com/wiki/Custom_Share_Action_UICheers,:: Erik
If you could explain exactly what you are trying to do I can hopefully give you some tips.Cheers, Erik
import java.sql.Connection; import java.sql.PreparedStatement; import java.util.Date; import java.util.List; import org.alfresco.repo.action.ParameterDefinitionImpl; import org.alfresco.repo.action.executer.ActionExecuterAbstractBase; import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.action.ParameterDefinition; import org.alfresco.service.cmr.dictionary.DataTypeDefinition; import org.alfresco.service.cmr.repository.CopyService; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.namespace.QName; import org.alfresco.web.bean.generator.BaseComponentGenerator; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import ak.wf.DatabaseUtil; /** * @author Christopher Jiménez Valverde * * 24/11/2011 */ public class MiAccion extends ActionExecuterAbstractBase { @Override protected void executeImpl(Action action, NodeRef actionedUponNodeRef) { // TODO Auto-generated method stub if (nodeService.exists(actionedUponNodeRef)) // sigue existiendo? { insertarDatos(action.getCreator(), action.getCreatedDate()); NodeRef destinationParent = (NodeRef) action .getParameterValue(PARAM_DESTINATION_FOLDER); QName destinationAssocTypeQName = (QName) action .getParameterValue(PARAM_ASSOC_TYPE_QNAME); QName destinationAssocQName = (QName) action .getParameterValue(PARAM_ASSOC_QNAME); boolean deepCopy = false; this.copyService.copy(actionedUponNodeRef, destinationParent, destinationAssocTypeQName, destinationAssocQName, deepCopy); } } @Override protected void addParameterDefinitions(List<ParameterDefinition> paramList) { // TODO Auto-generated method stub paramList.add(new ParameterDefinitionImpl(PARAM_DESTINATION_FOLDER, DataTypeDefinition.NODE_REF, true, getParamDisplayLabel(PARAM_DESTINATION_FOLDER))); paramList.add(new ParameterDefinitionImpl(PARAM_ASSOC_TYPE_QNAME, DataTypeDefinition.QNAME, true, getParamDisplayLabel(PARAM_ASSOC_TYPE_QNAME))); paramList.add(new ParameterDefinitionImpl(PARAM_ASSOC_QNAME, DataTypeDefinition.QNAME, true, getParamDisplayLabel(PARAM_ASSOC_QNAME))); paramList.add(new ParameterDefinitionImpl(PARAM_DEEP_COPY, DataTypeDefinition.BOOLEAN, false, getParamDisplayLabel(PARAM_DEEP_COPY))); } private boolean insertarDatos(String asignado, Date date) { try { PreparedStatement stmt = null; Connection cnx = DatabaseUtil.getConnectionFactory() .getConnection(); stmt = cnx .prepareStatement("INSERT INTO listaAsignados(asignado,fecha) VALUES (?,?)"); stmt.setString(1, asignado); @SuppressWarnings("deprecation") java.sql.Date d = new java.sql.Date(date.getYear(), date.getMonth(), date.getDay()); stmt.setDate(2, d); stmt.execute(); stmt.close(); return true; } catch (Exception e) { System.out.println(e.toString()); logger.error(e.toString()); return false; } } /** * @return the nodeService */ public NodeService getNodeService() { return nodeService; } /** * @param nodeService * the nodeService to set */ public void setNodeService(NodeService nodeService) { this.nodeService = nodeService; } /** * @return the copyService */ public CopyService getCopyService() { return copyService; } /** * @param copyService * the copyService to set */ public void setCopyService(CopyService copyService) { this.copyService = copyService; } private static Log logger = LogFactory.getLog(BaseComponentGenerator.class); private NodeService nodeService; private CopyService copyService; public static final String NAME = "custom-copy"; public static final String PARAM_DESTINATION_FOLDER = "destination-folder"; public static final String PARAM_ASSOC_TYPE_QNAME = "assoc-type"; public static final String PARAM_ASSOC_QNAME = "assoc-name"; public static final String PARAM_DEEP_COPY = "deep-copy"; }
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'> <!– Add aspect custom action –> <beans> <bean id="custom-copy" class="ak.acciones.MiAccion" parent="action-executer"> <property name="nodeService"> <ref bean="nodeService" /> </property> <property name="copyService"> <ref bean="copyService"/> </property> <!– <property name="publicAction"> <value>false</value> </property> –> </bean> <bean id="custom-action-messages" class="org.alfresco.i18n.ResourceBundleBootstrapComponent"> <property name="resourceBundles"> <list> <value>ak.acciones.Mi-action-messages</value> </list> </property> </bean> </beans>