cancel
Showing results for 
Search instead for 
Did you mean: 

Importar archivos (Solucionado) - Pronto subire un how to

pablo_zapico
Champ in-the-making
Champ in-the-making
Buenos dias

Soy bastante bastante novato en todo esto…. (malo si ya empiezo excusandome, jeje).

Mi problema es el siguiente. Quiero realizar una importación de ficheros he cogido de la api las siguientes lineas:


// specify the location within the Repository to import into
Location location = new Location(new StoreRef("workspace", "SpacesStore") );


// setup an ACP Package Handler to import from an ACP file
ImportPackageHandler handler = new ACPImportPackageHandler(…);


// import (note: in this example we're not interested in progress)
importer.importView(handler, location, null, null);

No he conseguido inizializar la clase ImporterService para poder utilizar el importView.

Ademas de esto entiendo que se debe pasar un fichero acp, me gustaria saber si hay alguna forma de generar estos ficheros…

Un saludo y gracias
41 REPLIES 41

pablo_zapico
Champ in-the-making
Champ in-the-making
Encontre por dnd van los tiros


      titledProps[0] = Utils.createNamedValue(Constants.PROP_TITLE, "PACO");
      titledProps[1] = Utils.createNamedValue(Constants.PROP_DESCRIPTION, "PACO");
      CMLAddAspect addAspect = new CMLAddAspect(
                        Constants.ASPECT_TITLED,
                        titledProps,
                        null,
                        "1");

Esto me funciona, lo que tngo q ver es si me funciona con las propiedades que he creado yo y como ponerlo…

dacedos
Champ in-the-making
Champ in-the-making
por ahi vas muy bien, ahora solo mira como estan construidas esas constant y utiliza tu propio aspect

te pongo un ejemplo

tipo de contenido   <namespace uri="documento.controlado" prefix="controlado"/>
el aspect <aspect  name="controlado:aspectDocumentoControlado">
con la propiedad  <property name="controlado:documento">


NamedValue[] titledProps = new NamedValue[3];
titledProps[0] = Utils.createNamedValue(Constants.PROP_TITLE, name);
titledProps[1] = Utils.createNamedValue(Constants.PROP_DESCRIPTION, "Firmado");
titledProps[2] = Utils.createNamedValue("{documento.controlado}documento", "informe");

String aspectControladoString = ("{documento.controlado}aspectDocumentoControlado");
CMLAddAspect addAspectControlado = new CMLAddAspect(aspectControladoString, titledProps , null, "1");   

cml.setAddAspect(new CMLAddAspect[] {addAspectControlado});

he tratado de resumirte una cosa algo mas larga y compleja y a lo mejor me he dejado algo sin poner!

pablo_zapico
Champ in-the-making
Champ in-the-making
Buenas tardes

Me gustaria poder conseguir algun ejemplo un poca mas claro de esto, xq no acabo de ver como montar esta parte…

Este es el XML que tngo para que me reconozca las nuevas propiedades, esto esta funcionando y desde alfresco me las carga perfectamente


<?xml version="1.0" encoding="UTF-8"?>
<model name="reg:regasocmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
   <description>Custom Model para Registro de Asociaciones</description>
   <author>pablo</author>
   <version>1.0</version>
   <imports>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
      <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
   </imports>
   <namespaces>
      <namespace uri="modelo.regasoc" prefix="reg"/>
   </namespaces>
   <types>
      <type name="reg:regasoc">
         <title>Registro de Asociaciones</title>
         <parent>cm:content</parent>
         <properties>
            <property name="reg:nregistro">
               <title>Nº Registro</title>
               <type>d:text</type>
            </property>
            <property name="reg:nombre">
               <title>Nombre</title>
               <type>d:text</type>
            </property>
            <property name="reg:nexpediente">
               <title>Nº Expediente</title>
               <type>d:text</type>
            </property>
            <property name="reg:seccion">
               <title>Sección</title>
               <type>d:int</type>
            </property>
         </properties>
      </type>
    </types>
</model>


<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>

    <!– Registro de nuevos modelos –>  
    <bean id="extension.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
        <property name="models">
            <list>
                <value>alfresco/extension/RegAsocModel.xml</value>
            </list>
        </property>
    </bean>
        
</beans>

No se si tengo q configurar algun xml mas para crear los aspect y si fuese asi dnd debe de ir este…

gracias

pablo_zapico
Champ in-the-making
Champ in-the-making
Buenos días

La unica parte que no consigo entender es


el aspect <aspect name="controlado:aspectDocumentoControlado">

El resto creo q mas o menos lo he puesto. pero ese aspect es un xml? dnd se encuentra o tengo que crearlo?

dacedos
Champ in-the-making
Champ in-the-making
El aspect se declara en el xml y se puede asociar a un tipo de contenido.

permite separar las propiedades del tipo para hacerlas independientes, asi podrias poner el mismo aspect a varios tipos sin tener que declararlo todo de nuevo (y que alguien me corrija con esto si me equivoco)

para tu codigo asi mas o menos podria quedar asi:

   <types>
         <type name="reg:regasoc">
         <title>Registro de Asociaciones</title>
         <parent>cm:content</parent>
     <mandatory-aspects>
            <aspect>reg:aspectRegasoc</aspect>
         </mandatory-aspects>
      </type>
   </types>

  <aspects>
     <!– Aspect para el tipo folderEspecialidad–>
      <aspect  name="reg:aspectRegasoc">
        <title>Titulo</title>
        <properties>
            <property name="reg:nregistro">
               <title>Nº Registro</title>
               <type>d:text</type>
            </property>
            <property name="reg:nombre">
               <title>Nombre</title>
               <type>d:text</type>
            </property>
            <property name="reg:nexpediente">
               <title>Nº Expediente</title>
               <type>d:text</type>
            </property>
            <property name="reg:seccion">
               <title>Sección</title>
               <type>d:int</type>
            </property>
         </properties>
      </aspect>
    
   </aspects>

pablo_zapico
Champ in-the-making
Champ in-the-making
Gracias…

Ya he configurado todo y me da la siguiente exception: The aspect is invalid: {modelo.regasoc}aspectRegasoc


Puse en la clase java esto:


                NamedValue[] titledProps = new NamedValue[1];
      titledProps[0] = Utils.createNamedValue("{modelo.regasoc}nexpediente", "123");      
      String aspectControladoString = ("{modelo.regasoc}aspectRegasoc");      
      CMLAddAspect addAspect = new CMLAddAspect(
                        aspectControladoString,
                        titledProps,
                        null,
                        "1");      

Y en el RegAsocModel.xml esto:


<?xml version="1.0" encoding="UTF-8"?>
<model name="reg:regasocmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
   <description>Custom Model para Registro de Asociaciones</description>
   <author>SF_Sevilla</author>
   <version>1.0</version>
   <imports>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
      <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
   </imports>
   <namespaces>
      <namespace uri="modelo.regasoc" prefix="reg"/>
   </namespaces>
   <types>
      <type name="reg:regasoc">
        <title>Registro de Asociaciones</title>
        <parent>cm:content</parent>
      <mandatory-aspects>
         <aspect>reg:aspectRegasoc</aspect>
      </mandatory-aspects>
         <properties>
            <property name="reg:nregistro">
               <title>Nº Registro</title>
               <type>d:text</type>
            </property>
            <property name="reg:nombre">
               <title>Nombre</title>
               <type>d:text</type>
            </property>
            <property name="reg:nexpediente">
               <title>Nº Expediente</title>
               <type>d:text</type>
            </property>
            <property name="reg:seccion">
               <title>Sección</title>
               <type>d:int</type>
            </property>
         </properties>
      </type>
    </types>
   
   <aspects>
   <!– Aspect para el tipo folderEspecialidad–>
      <aspect name="reg:aspectRegasoc">
      <title>Registro de Asociaciones</title>
      <properties>
         <property name="reg:nregistro">
            <title>Nº Registro</title>
            <type>d:text</type>
         </property>
         <property name="reg:nombre">
            <title>Nombre</title>
            <type>d:text</type>
         </property>
         <property name="reg:nexpediente">
            <title>Nº Expediente</title>
            <type>d:text</type>
         </property>
         <property name="reg:seccion">
            <title>Sección</title>
            <type>d:int</type>
         </property>
      </properties>
   </aspect>

</aspects>
</model>

pablo_zapico
Champ in-the-making
Champ in-the-making
Puede ser que te tnga q añadir esto en web-client-config-custom.xml?


<config evaluator="reg:aspectRegasoc" condition="modelo.regasoc">

ahora le tengo asi


<config evaluator="reg:aspectregasoc" condition="modelo.regasoc">
   <config evaluator="string-compare" condition="Content Wizards">
      <content-types>
         <type name="reg:regasoc" />
      </content-types>
   </config>

   <config evaluator="string-compare" condition="Action Wizards">
          <subtypes>
              <type name="reg:regasoc"/>
          </subtypes>
   </config>  

   <config evaluator="node-type" condition="reg:regasoc">
      <property-sheet>
         <show-property name="reg:nregistro"/>
         <show-property name="reg:nombre"/>
         <show-property name="reg:nexpediente"/>
         <show-property name="reg:seccion"/>
      </property-sheet>
   </config>
   <config evaluator="string-compare" condition="Advanced Search">
      <advanced-search>
         <content-types>
            <type name="reg:regasoc" />
         </content-types>
         <custom-properties>
            <meta-data type="reg:regasoc" property="reg:nregistro" />
            <meta-data type="reg:regasoc" property="reg:nombre" />
            <meta-data type="reg:regasoc" property="reg:nexpediente" />
            <meta-data type="reg:regasoc" property="reg:seccion" />
         </custom-properties>
      </advanced-search>
   </config>
  

dacedos
Champ in-the-making
Champ in-the-making
prueba con esta otra linea:

String aspectString = Constants.createQNameString("modelo.regasoc", "aspectRegasoc");

Ahora cuando tenga un rato intento mirar tu web-client-config-custom.xml

pablo_zapico
Champ in-the-making
Champ in-the-making
Ok, muchas gracias por la ayuda… sigue fallandome con esa linea. Revisare todo por si acaso se me colo algo

dacedos
Champ in-the-making
Champ in-the-making
bueno, en el web-client-config-custom hay que añadir el aspect

   <config evaluator="string-compare" condition="Action Wizards">
      <subtypes>
       <type name="reg:regasoc"/>
      </subtypes>
      <aspects>
       <aspect name="reg:aspectRegasoc"/>
      </aspects>
   </config>

y el aspect…

   <config evaluator="aspect-name" condition="controlado:aspectDocumentoControlado">
      <property-sheet>
    <show-property name="" />
… (tus propiedades)
       </property-sheet>
   </config>

comprueba, antes de crear el nodo a traves de java que alfresco arranca y te deja crear objetos con el aspect Regasoc