02-04-2009 03:26 AM
    …
                     <config>   
           <actions>
              <action id="asignar_aspecto_portal">
                 <permissions>
                      <permission allow="true">Write</permission>
                      <permission allow="false">Read</permission>                  
                   </permissions>
                   <label-id>portal-action.label</label-id>
                   <image>/images/extension/aspectos_portal.gif</image>
                   <action>wizard:asignarAspectoPortal</action>
                   <action-listener>#{WizardManager.setupParameters}</action-listener>
                   <params>
                      <param name="id">#{actionContext.id}</param>
                   </params>
                </action>
                
                <action-group id="doc_details_actions">
                   <action idref="asignar_aspecto_portal" />
                 </action-group>
                
                <action-group id="document_browse_menu">               
                   <action idref="asignar_aspecto_portal" />
             </action-group>
                
           </actions>
       </config>
       
       <config>
          <wizards>   
           <wizard name="asignarAspectoPortal" managed-bean="PortalAspectoWizard"
                        title-id="portal-action.title" description-id="portal-action.description"
                        icon="/images/icons/new_rule_large.gif">
                  
                   <step name="portal-action.aspectos" title-id="portal-action.aspectos" description-id="portal-action.aspectos_step">
                      <page path="/jsp/extension/seleccionAspectosPortal.jsp"
                            title-id="portal-action.seleccion"
                            description-id="portal-action.seleccion_desc"
                            instruction-id="portal-action.select_aspect_portal" />
                   </step>
                   <step name="portal-action.resumen" title-id="portal-action.resumen" description-id="portal-action.resumen_step_description">
                      <page path="/jsp/extension/resumenAspectosPortal.jsp"
                            title-id="portal-action.resumen"
                            description-id="portal-action.resumen_desc"
                            instruction-id="portal-action.public_portal_finish_instruction" />
                   </step>
                   <step name="portal-action.editar_propiedades" title-id="portal-action.editar_propiedades" description-id="portal-action.editar_propiedades_step">
                      <page path="/jsp/extension/editarPropiedades.jsp"
                            title-id="portal-action.editar_propiedades_aspecto"
                            description-id="portal-action.editar_propiedades_aspecto_desc"
                            instruction-id="portal-action.editar_propiedades_aspecto_portal" />
                   </step>
           </wizard>
          </wizards>
       </config>
    …
    package ceh.juntadeandalucia.es.accion.portal;
    import java.io.Serializable;
    import java.text.MessageFormat;
    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.List;
    import java.util.Map;
    import java.util.ResourceBundle;
    import java.util.Set;
    import javax.faces.context.FacesContext;
    import javax.faces.model.SelectItem;
    import org.alfresco.config.Config;
    import org.alfresco.config.ConfigElement;
    import org.alfresco.config.ConfigService;
    import org.alfresco.i18n.I18NUtil;
    import org.alfresco.model.ContentModel;
    import org.alfresco.service.cmr.action.ActionService;
    import org.alfresco.service.cmr.dictionary.AspectDefinition;
    import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
    import org.alfresco.service.cmr.dictionary.DictionaryService;
    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.ContentData;
    import org.alfresco.service.cmr.repository.MimetypeService;
    import org.alfresco.service.cmr.repository.NodeRef;
    import org.alfresco.service.cmr.repository.NodeService;
    import org.alfresco.service.cmr.search.SearchService;
    import org.alfresco.service.cmr.security.AuthorityService;
    import org.alfresco.service.cmr.security.PersonService;
    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;
    import org.alfresco.web.bean.repository.Repository;
    import org.alfresco.web.bean.wizard.BaseWizardBean;
    import org.alfresco.web.data.IDataContainer;
    import org.alfresco.web.data.QuickSort;
    import org.alfresco.web.ui.common.Utils;
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    public class PortalAspectoWizard extends BaseWizardBean{
       /**
        *
        */
       private static final long serialVersionUID = 3823201765059829402L;
        /** The logger */
        private static Log logger = LogFactory.getLog(PortalAspectoWizard.class);
       
        protected List<SelectItem> aspects;
        protected String aspect;
       
        protected Node editableNode;
       
        protected static final String TEMP_PROP_MIMETYPE = "mimetype";
        protected static final String TEMP_PROP_ENCODING = "encoding";
       
        protected ActionService actionService;
        protected MimetypeService mimetypeService;
        protected NodeService nodeService;
        protected SearchService searchService;
        protected DictionaryService dictionaryService;
        protected PersonService personService;
        protected AuthorityService authorityService;
       
        public PortalAspectoWizard(){
           
        }
       
        public void init(Map<String, String> parameters){
           logger.info("_____________Metodo init_____________");
           super.init(parameters);
           
            // setup the editable node
            this.editableNode = initEditableNode();
            logger.info("_____________el valor de this.editableNode es: " + this.editableNode.getName() +"_____________");
           
           
            // special case for Mimetype - since this is a sub-property of the ContentData object
            // we must extract it so it can be edited in the client, then we check for it later
            // and create a new ContentData object to wrap it and it's associated URL
            ContentData content = (ContentData)this.editableNode.getProperties().get(ContentModel.PROP_CONTENT);
           
            if (content != null)
            {
               this.editableNode.getProperties().put(TEMP_PROP_MIMETYPE, content.getMimetype());
               this.editableNode.getProperties().put(TEMP_PROP_ENCODING, content.getEncoding());
            }
           this.aspect = null;
           
        }
       
        /**
         * Init the editable Node
         */
        protected Node initEditableNode(){
           logger.info("_____________Metodo initEditableNode_____________");       
           
           NodeRef nodeRef = null;
           
           if(this.browseBean != null){
              Node node  = this.browseBean.getDocument();
              if(node != null){
                 nodeRef = node.getNodeRef();
                 if(nodeRef == null){
                    logger.info("_____________nodeRef es nulo_____________");       
                    nodeRef = new NodeRef(Repository.getStoreRef(), this.parameters.get("id"));
                 }else{
                    logger.info("_____________No Es nulo, nodeRef:" + nodeRef.getId() + "_____________");          
                 }             
              }else{
                 logger.info("_____________node es nulo_____________");       
                 nodeRef = new NodeRef(Repository.getStoreRef(), this.parameters.get("id"));             
              }
           }else{
              logger.info("_____________this.browseBean es nulo_____________");      
              nodeRef = new NodeRef(Repository.getStoreRef(), this.parameters.get("id"));
           }      
           
           return new Node(nodeRef);
        }
       
           
       public List<SelectItem> getAspects(){
          logger.info("_____________Metodo getAspects_____________");
             if (this.aspects == null)
             {          
                ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());            
                Config wizardCfg = svc.getConfig("Action Wizards");
                
                if (wizardCfg != null)
                {              
                   ConfigElement aspectsCfg = wizardCfg.getConfigElement("aspects");
                   if (aspectsCfg != null)
                   {   
                      FacesContext context = FacesContext.getCurrentInstance();
                      this.aspects = new ArrayList<SelectItem>();
                      for (ConfigElement child : aspectsCfg.getChildren())
                      {
                         QName idQName = Repository.resolveToQName(child.getAttribute("name"));
                                             
                         //Si se trata de alguno de los aspectos pertenecientes al modelo de contenidos para Port@l
                         //entonces se añade a la lista de aspectos
                         if(idQName.getLocalName().equals(PortalModel.ASPECTO_ACTUALIDAD.getLocalName()) || idQName.getLocalName().equals(PortalModel.ASPECTO_BANNER.getLocalName()) ||
                               idQName.getLocalName().equals(PortalModel.ASPECTO_CONCURSO.getLocalName()) || idQName.getLocalName().equals(PortalModel.ASPECTO_CONGRESOS_JORNADAS_CURSOS.getLocalName()) ||
                               idQName.getLocalName().equals(PortalModel.ASPECTO_CONVOCATORIA.getLocalName()) || idQName.getLocalName().equals(PortalModel.ASPECTO_DOCUMENTO.getLocalName()) ||
                               idQName.getLocalName().equals(PortalModel.ASPECTO_ENLACE_INTERES.getLocalName()) || idQName.getLocalName().equals(PortalModel.ASPECTO_FORMULARIO_TEXTO.getLocalName()) ||
                               idQName.getLocalName().equals(PortalModel.ASPECTO_MODELOS_FORMULARIO.getLocalName()) || idQName.getLocalName().equals(PortalModel.ASPECTO_NORMATIVA.getLocalName()) ||
                               idQName.getLocalName().equals(PortalModel.ASPECTO_PUBLICACION.getLocalName())
                               ){                                               
                            // try and get the display label from config
                            String label = Utils.getDisplayLabel(context, child);
                           
                            // if there wasn't a client based label try and get it from the dictionary
                            if (label == null)
                            {
                               AspectDefinition aspectDef = this.getDictionaryService().getAspect(idQName);
                               if (aspectDef != null)
                               {
                                  label = aspectDef.getTitle();
                               }
                               else
                               {
                                  label = idQName.getLocalName();
                               }
                               logger.info("_____________LABEL: " + label + "_____________");                           
                            }
                           
                            this.aspects.add(new SelectItem(idQName.toString(), label));
                           
                         }
                      }
                      
                      // make sure the list is sorted by the label
                      QuickSort sorter = new QuickSort(this.aspects, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
                      sorter.sort();
                   } else{
                      logger.info("_____________aspectCfg: NULO_____________");
                   }
                }
             }
           logger.info("_____________Tamano de los aspectos: " + this.aspects.size() + "_____________");
             return this.aspects;
          }
       
       public String getAspect(){
            logger.info("_____________Metodo getAspects_____________");
             return aspect;
          }
          public void setAspect(String aspect){
            logger.info("_____________Metodo setAspect: " + aspect + "_____________");
             this.aspect = aspect;
            
             logger.info("_____________modificado el this.aspect_____________");
             // add the selected aspect (the properties page after the wizard
             // will allow us to set the properties)
             QName aspectToAdd = Repository.resolveToQName(this.aspect);
             logger.info("_____________Aspecto a anadir: " + aspectToAdd + "_____________");        
            
             NodeRef nodeRef = new NodeRef(Repository.getStoreRef(), this.parameters.get("id"));
            
                  if(this.getNodeService().hasAspect(nodeRef, PortalModel.ASPECTO_ACTUALIDAD)){
                   logger.info("_____________El nodo tiene el aspecto Actualidad_____________");
                  
                   if(aspectToAdd.equals(PortalModel.ASPECTO_ACTUALIDAD) == false){
                       logger.info("_____________El aspecto a anadir no es igual a Actualidad que ya esta aplicado, por eso borramos uno para insertar el otro_____________");           
                       this.getNodeService().removeAspect(nodeRef,  PortalModel.ASPECTO_ACTUALIDAD);
                       this.getNodeService().addAspect(nodeRef, aspectToAdd, null);
                    }else{
                       logger.info("_____________El aspecto a anadir es igual a Actualidad que ya esta aplicado, asi que no hacemos nada_____________");       
                    }
                }else if(this.getNodeService().hasAspect(nodeRef, PortalModel.ASPECTO_BANNER)){
                   logger.info("_____________El nodo tiene el aspecto Banner_____________");
                  
                   if(aspectToAdd.equals(PortalModel.ASPECTO_BANNER) == false){
                       logger.info("_____________El aspecto a anadir no es igual a Banner que ya esta aplicado, por eso borramos uno para insertar el otro_____________");           
                       this.getNodeService().removeAspect(nodeRef,  PortalModel.ASPECTO_BANNER);
                       this.getNodeService().addAspect(nodeRef, aspectToAdd, null);
                    }else{
                       logger.info("_____________El aspecto a anadir es igual a Banner que ya esta aplicado, asi que no hacemos nada_____________");       
                    }
                  
                }else if(this.getNodeService().hasAspect(nodeRef, PortalModel.ASPECTO_CONCURSO)){
                   logger.info("_____________El nodo tiene el aspecto Concurso_____________");
                   if(aspectToAdd.equals(PortalModel.ASPECTO_CONCURSO) == false){
                       logger.info("_____________El aspecto a anadir no es igual a Concurso que ya esta aplicado, por eso borramos uno para insertar el otro_____________");           
                       this.getNodeService().removeAspect(nodeRef,  PortalModel.ASPECTO_CONCURSO);
                       this.getNodeService().addAspect(nodeRef, aspectToAdd, null);
                    }else{
                       logger.info("_____________El aspecto a anadir es igual a Concurso que ya esta aplicado, asi que no hacemos nada_____________");       
                    }
                }else if(this.getNodeService().hasAspect(nodeRef, PortalModel.ASPECTO_CONGRESOS_JORNADAS_CURSOS)){
                   logger.info("_____________El nodo tiene el aspecto Congresos Jornadas Cursos_____________");
                   if(aspectToAdd.equals(PortalModel.ASPECTO_CONGRESOS_JORNADAS_CURSOS) == false){
                       logger.info("_____________El aspecto a anadir no es igual a Congresos Jornadas Cursos que ya esta aplicado, por eso borramos uno para insertar el otro_____________");           
                       this.getNodeService().removeAspect(nodeRef,  PortalModel.ASPECTO_CONGRESOS_JORNADAS_CURSOS);
                       this.getNodeService().addAspect(nodeRef, aspectToAdd, null);
                    }else{
                       logger.info("_____________El aspecto a anadir es igual a Congresos Jornadas Cursos que ya esta aplicado, asi que no hacemos nada_____________");       
                    }
                }else if(this.getNodeService().hasAspect(nodeRef, PortalModel.ASPECTO_CONVOCATORIA)){
                   logger.info("_____________El nodo tiene el aspecto Convocatoria_____________");
                   if(aspectToAdd.equals(PortalModel.ASPECTO_CONVOCATORIA) == false){
                       logger.info("_____________El aspecto a anadir no es igual a Convocatoria que ya esta aplicado, por eso borramos uno para insertar el otro_____________");           
                       this.getNodeService().removeAspect(nodeRef,  PortalModel.ASPECTO_CONVOCATORIA);
                       this.getNodeService().addAspect(nodeRef, aspectToAdd, null);
                    }else{
                       logger.info("_____________El aspecto a anadir es igual a Convocatoria que ya esta aplicado, asi que no hacemos nada_____________");       
                    }
                }else if(this.getNodeService().hasAspect(nodeRef, PortalModel.ASPECTO_DOCUMENTO)){
                   logger.info("_____________El nodo tiene el aspecto Documento_____________");
                   if(aspectToAdd.equals(PortalModel.ASPECTO_DOCUMENTO) == false){
                       logger.info("_____________El aspecto a anadir no es igual a Documento que ya esta aplicado, por eso borramos uno para insertar el otro_____________");           
                       this.getNodeService().removeAspect(nodeRef,  PortalModel.ASPECTO_DOCUMENTO);
                       this.getNodeService().addAspect(nodeRef, aspectToAdd, null);
                    }else{
                       logger.info("_____________El aspecto a anadir es igual a Documento que ya esta aplicado, asi que no hacemos nada_____________");       
                    }
                }else if(this.getNodeService().hasAspect(nodeRef, PortalModel.ASPECTO_ENLACE_INTERES)){
                   logger.info("_____________El nodo tiene el aspecto Enlace Interes_____________");
                   if(aspectToAdd.equals(PortalModel.ASPECTO_ENLACE_INTERES) == false){
                       logger.info("_____________El aspecto a anadir no es igual a Enlace Interes que ya esta aplicado, por eso borramos uno para insertar el otro_____________");           
                       this.getNodeService().removeAspect(nodeRef,  PortalModel.ASPECTO_ENLACE_INTERES);
                       this.getNodeService().addAspect(nodeRef, aspectToAdd, null);
                    }else{
                       logger.info("_____________El aspecto a anadir es igual a Enlace Interes que ya esta aplicado, asi que no hacemos nada_____________");       
                    }
                }else if(this.getNodeService().hasAspect(nodeRef, PortalModel.ASPECTO_FORMULARIO_TEXTO)){
                   logger.info("_____________El nodo tiene el aspecto Formulario Texto_____________");
                   if(aspectToAdd.equals(PortalModel.ASPECTO_FORMULARIO_TEXTO) == false){
                       logger.info("_____________El aspecto a anadir no es igual a Formulario Texto que ya esta aplicado, por eso borramos uno para insertar el otro_____________");           
                       this.getNodeService().removeAspect(nodeRef,  PortalModel.ASPECTO_FORMULARIO_TEXTO);
                       this.getNodeService().addAspect(nodeRef, aspectToAdd, null);
                    }else{
                       logger.info("_____________El aspecto a anadir es igual a Formulario Texto que ya esta aplicado, asi que no hacemos nada_____________");       
                    }
                }else if(this.getNodeService().hasAspect(nodeRef, PortalModel.ASPECTO_MODELOS_FORMULARIO)){
                   logger.info("_____________El nodo tiene el aspecto Modelos Formulario_____________");
                   if(aspectToAdd.equals(PortalModel.ASPECTO_MODELOS_FORMULARIO) == false){
                       logger.info("_____________El aspecto a anadir no es igual a Modelos Formulario que ya esta aplicado, por eso borramos uno para insertar el otro_____________");           
                       this.getNodeService().removeAspect(nodeRef,  PortalModel.ASPECTO_MODELOS_FORMULARIO);
                       this.getNodeService().addAspect(nodeRef, aspectToAdd, null);
                    }else{
                       logger.info("_____________El aspecto a anadir es igual a Modelos Formulario que ya esta aplicado, asi que no hacemos nada_____________");       
                    }
                }else if(this.getNodeService().hasAspect(nodeRef, PortalModel.ASPECTO_NORMATIVA)){
                   logger.info("_____________El nodo tiene el aspecto Normativa_____________");
                   if(aspectToAdd.equals(PortalModel.ASPECTO_NORMATIVA) == false){
                       logger.info("_____________El aspecto a anadir no es igual a Normativa que ya esta aplicado, por eso borramos uno para insertar el otro_____________");           
                       this.getNodeService().removeAspect(nodeRef,  PortalModel.ASPECTO_NORMATIVA);
                       this.getNodeService().addAspect(nodeRef, aspectToAdd, null);
                    }else{
                       logger.info("_____________El aspecto a anadir es igual a Normativa que ya esta aplicado, asi que no hacemos nada_____________");       
                    }
                }else if(this.getNodeService().hasAspect(nodeRef, PortalModel.ASPECTO_PUBLICACION)){
                   logger.info("_____________El nodo tiene el aspecto Publicacion_____________");
                   if(aspectToAdd.equals(PortalModel.ASPECTO_PUBLICACION) == false){
                       logger.info("_____________El aspecto a anadir no es igual a Publicacion que ya esta aplicado, por eso borramos uno para insertar el otro_____________");           
                       this.getNodeService().removeAspect(nodeRef,  PortalModel.ASPECTO_PUBLICACION);
                       this.getNodeService().addAspect(nodeRef, aspectToAdd, null);
                    }else{
                       logger.info("_____________El aspecto a anadir es igual a Publicacion que ya esta aplicado, asi que no hacemos nada_____________");       
                    }              
                }else{
                   logger.info("_____________NO TIENE NIGUN ASPECTO DE PORTAL_____________");           
                   this.getNodeService().addAspect(nodeRef, aspectToAdd, null);
                }
       }
          
          
          public String getSummary(){        
             logger.info("_____________Método getSummary_____________");
             StringBuilder actionsSummary = new StringBuilder();                  
             QName qname = QName.createQName(this.aspect);
             
             actionsSummary.append(qname.getLocalName());
             actionsSummary.append("<br>");
               
            logger.info("_____________actionsSummary:" + actionsSummary.toString() + "_____________");                  
             ResourceBundle bundle = Application.getBundle(FacesContext.getCurrentInstance());
             return buildSummary(
                   new String[] {bundle.getString("portal.add_aspecto_portal")},
                   new String[] {actionsSummary.toString()});
          }
          
          
       // ——————————————————————————
          // Bean getters and setters
          /**
           * Returns the node being edited
           *
           * @return The node being edited
           */
          public Node getEditableNode(){
             return this.editableNode;
          }
          
       protected String finishImpl(FacesContext context, String outcome) throws Exception{
             
          logger.info("_____________finishImpl: " + outcome + "_____________");   
             
           NodeRef nodeRef = this.editableNode.getNodeRef();
           logger.info("_____________nodeRef: " + nodeRef.getStoreRef() + "/" + nodeRef.getId() +  "_____________");   
           Map<String, Object> editedProps = this.editableNode.getProperties();
          
           // get the name and move the node as necessary
           String name = (String) editedProps.get(ContentModel.PROP_NAME);
           if (name != null)
           {
              logger.info("_____________name: " + name + "_____________");   
              getFileFolderService().rename(nodeRef, name);
           }
          
           // we need to put all the properties from the editable bag back into
           // the format expected by the repository
           Map<QName, Serializable> repoProps = this.getNodeService().getProperties(nodeRef);
          
           // Extract and deal with the special mimetype property for ContentData
           String mimetype = (String) editedProps.get(TEMP_PROP_MIMETYPE);
           if (mimetype != null)
           {
              // remove temporary prop from list so it isn't saved with the others
              editedProps.remove(TEMP_PROP_MIMETYPE);
              ContentData contentData = (ContentData)editedProps.get(ContentModel.PROP_CONTENT);
              if (contentData != null)
              {
                 contentData = ContentData.setMimetype(contentData, mimetype);
                 editedProps.put(ContentModel.PROP_CONTENT.toString(), contentData);
              }
           }
           // Extract and deal with the special encoding property for ContentData
           String encoding = (String) editedProps.get(TEMP_PROP_ENCODING);
           if (encoding != null)
           {
              // remove temporary prop from list so it isn't saved with the others
              editedProps.remove(TEMP_PROP_ENCODING);
              ContentData contentData = (ContentData) editedProps.get(ContentModel.PROP_CONTENT);
              if (contentData != null)
              {
                 contentData = ContentData.setEncoding(contentData, encoding);
                 editedProps.put(ContentModel.PROP_CONTENT.toString(), contentData);
              }
           }
          
           // add the "author" aspect if required, properties will get set below
           if (this.getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_AUTHOR) == false)
           {
              this.getNodeService().addAspect(nodeRef, ContentModel.ASPECT_AUTHOR, null);
           }
          
           // add the "titled" aspect if required, properties will get set below
           if (this.getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_TITLED) == false)
           {
              getNodeService().addAspect(nodeRef, ContentModel.ASPECT_TITLED, null);
           }
          
           /////////////////////////////////////////////////////////////////////////////////////////////////
           //Añado el aspecto seleccionado si no ha sido añadido correctamente en el metodo setAspect
           if(this.getNodeService().hasAspect(nodeRef, Repository.resolveToQName(this.aspect)) == false){
                 logger.info("_____________finishImpl: como no tiene el aspecto se lo aplico aqui_____________");
              getNodeService().addAspect(nodeRef, Repository.resolveToQName(this.aspect), null);
           }else{
              logger.info("_____________finishImpl: aqui ya tiene el aspecto : no hago nada mas_____________");          
           }
           /////////////////////////////////////////////////////////////////////////////////////////////////
          
           // add the remaining properties
           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 instanceof String)
              {
                 PropertyDefinition propDef = this.getDictionaryService().getProperty(qname);
                 if (((String)propValue).length() == 0)
                 {
                    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;
                       }
                    }
                 }
                 // handle locale strings to Locale objects
                 else if (propDef != null && propDef.getDataType().getName().equals(DataTypeDefinition.LOCALE))
                 {
                    propValue = I18NUtil.parseLocale((String)propValue);
                 }
              }
              
              repoProps.put(qname, propValue);
           }
          
           // send the properties back to the repository
           this.getNodeService().setProperties(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());
              }
           }
          
           logger.info("_____________FIN finishImpl: outcome = " + outcome +"_____________");
           
           if(this.browseBean.getDocument().hasAspect(Repository.resolveToQName(this.aspect)) == false){
              logger.info("_____________EL DOCUMENTO NO TIENE EL ASPECTO_____________");          
              this.browseBean.externalAccessRefresh();
           }else{
              logger.info("_____________EL DOCUMENTO TIENE EL ASPECTO_____________");
           }
                  
           return outcome;
    }
          
        
          protected String getDefaultCancelOutcome(){
             logger.info("_____________getDefaultCancelOutcome_____________");
           
             if(this.aspect != null && !"".equals(this.aspect)){
                QName aspectToAdd = Repository.resolveToQName(this.aspect);       
                
                NodeRef nodeRef = new NodeRef(Repository.getStoreRef(), this.parameters.get("id"));
                
                if(this.getNodeService().hasAspect(nodeRef, aspectToAdd)){
                   logger.info("_____________El nodo tiene el aspecto y se lo quitamos_____________");              
                   this.getNodeService().removeAspect(nodeRef, aspectToAdd);
                }            
             }
             return AlfrescoNavigationHandler.CLOSE_WIZARD_OUTCOME;
          }
          
          public void setActionService(ActionService actionService){
               this.actionService = actionService;
           }
          public void setMimetypeService(MimetypeService mimetypeService){
             this.mimetypeService = mimetypeService;
          }
          public void setNodeService(NodeService nodeService){
             this.nodeService = nodeService;
          }
          public void setSearchService(SearchService searchService){
             this.searchService = searchService;
          }
          public void setDictionaryService(DictionaryService dictionaryService){
             this.dictionaryService = dictionaryService;
          }
          public void setPersonService(PersonService personService){
             this.personService = personService;
          }
          public void setAuthorityService(AuthorityService authorityService){
             this.authorityService = authorityService;
          }
    }
 
					
				
		
02-04-2009 04:03 AM
NodeRef parent = this.navigator.getCurrentNode().getNodeRef();
browseBean.setupContentAction(parent.getId(), true);
02-04-2009 05:00 AM
browseBean.setupContentAction(nodeRef.getId(), true);
 
					
				
				
			
		
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.