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
Tenia mal una linea a de codigo


El codigo que tengo puesto ahora en el fichero web-client-config-custom.xml es:


<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>
        <aspects>
         <aspect name="reg:aspectregasoc"/>
        </aspects>
   </config>  

<config evaluator="aspect-name" condition="reg:aspectregasoc">
      <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>

Me da error desde java. desde alfresco no me da error pero me han dejado de salir las opciones nuevas del modelo al crear el contenido. En java mismo error q antes

pablo_zapico
Champ in-the-making
Champ in-the-making
Vale la cosa es q tenia q dejar tb la anterior. Desde alfresco ya me vuelve a ir correctamente, pero desde java sigue petando

dacedos
Champ in-the-making
Champ in-the-making
bueno intenta con algo como esto

NamedValue[] contentProps = new NamedValue[1];
contentProps[0] = Utils.createNamedValue(Constants.PROP_NAME, name);

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

NamedValue[] titledProps = new NamedValue[7];

titledProps[0] = Utils.createNamedValue(Constants.PROP_TITLE, name);
titledProps[1] = Utils.createNamedValue(Constants.PROP_DESCRIPTION, "desc");
titledProps[2] = Utils.createNamedValue(createQNameString("modelo.regasoc", "nregistro"), "registo");
titledProps[3] = Utils.createNamedValue(createQNameString("modelo.regasoc", "nombre"), "nombre");
titledProps[4] = Utils.createNamedValue(createQNameString("modelo.regasoc", "nexpediente"), "nexpediente");
titledProps[5] = Utils.createNamedValue(createQNameString("modelo.regasoc", "seccion"), "seccion");
titledProps[6] = Utils.createNamedValue(createQNameString("modelo.regasoc", "nregistro"), 0);

CMLAddAspect addAspect = new CMLAddAspect(aspectString, propsAspect, null, "1");   

CMLCreate create = new CMLCreate("1", companyHomeParent, companyHomeParent.getUuid(), Constants.ASSOC_CONTAINS, null, Constants.PROP_CONTENT, contentProps);
cml = new CML();
cml.setCreate(new CMLCreate[] {create});
cml.setAddAspect(new CMLAddAspect[] {addAspect});

pablo_zapico
Champ in-the-making
Champ in-the-making
Pasa una cosa q creo puede ser interesante si lo pongo tal cual me da el siguiente error

NumberFormatException: For input string: &quot;seccion&quot, la cosa es que seccion tiene q ser int y estaba puesto "Seccion", si lo pongo int, me vuelve a dar el error de siempre.
Pero visto esto quiero pensar que cargar si que carga el aspecto, la cosa es xq da ese puñetero error

Por cierto cuando pases por Asturias me avisas que te debo unas cuantas sidras…

dacedos
Champ in-the-making
Champ in-the-making
sobre el xml… intenta no poner los acentos, a Alfresco no le gustan, le he revisado y bueno, con ese cambio me aparece el tipo sin problemas.

Estaba revisando lo de crear un nodo

pablo_zapico
Champ in-the-making
Champ in-the-making
no tngo ningun acento. Desde el propio alfresco me funciona bien, la cosa es cuando intento desde el servicioWeb enviar el contenido que me dice que el aspect no es valido.

dacedos
Champ in-the-making
Champ in-the-making
Si que es verdad el problema del int… y ahora mismo no se como arreglarlo porque NamedValue solo acepta String, a lo mejor deberias dejarlo como String y hacer el casting en java si recuperas el valor, no lo se,

aqui te dejo el codigo que crea un nodo en guest_home/test llamado NOMBRE de tipo reg:regesoc con ese aspect y valor en las propiedades


      AuthenticationUtils.startSession("admin", "admin");
      Store store = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
      String tipo = "http://www.alfresco.org/model/content/1.0";
      String carpeta = "esp";
      String id_tipo = "cm:";
      String dir = "/app:company_home/app:guest_home/"+ id_tipo + carpeta;
      RepositoryServiceSoapBindingStub repositoryService =WebServiceFactory.getRepositoryService();
      ContentServiceSoapBindingStub contentService =WebServiceFactory.getContentService();

      ParentReference companyHomeParent = new ParentReference(store, null, dir, Constants.ASSOC_CONTAINS,
            Constants.createQNameString(tipo, carpeta));
      NamedValue[] contentProps = new NamedValue[1];
      contentProps[0] = Utils.createNamedValue(Constants.PROP_NAME, "NOMBRE");

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

      NamedValue[] titledProps = new NamedValue[7];

      titledProps[0] = Utils.createNamedValue(Constants.PROP_TITLE, "NOMBRE");
      titledProps[1] = Utils.createNamedValue(Constants.PROP_DESCRIPTION, "desc");
      titledProps[2] = Utils.createNamedValue(Constants.createQNameString("modelo.regasoc", "nregistro"), "registo");
      titledProps[3] = Utils.createNamedValue(Constants.createQNameString("modelo.regasoc", "nombre"), "nombre");
      titledProps[4] = Utils.createNamedValue(Constants.createQNameString("modelo.regasoc", "nexpediente"), "nexpediente");
      titledProps[5] = Utils.createNamedValue(Constants.createQNameString("modelo.regasoc", "seccion"), "seccion");
      titledProps[6] = Utils.createNamedValue(Constants.createQNameString("modelo.regasoc", "nregistro"), "0");

      CMLAddAspect addAspect = new CMLAddAspect(aspectString, titledProps, null, "1");  
      CML cml = new CML();
      companyHomeParent.setChildName(id_tipo + "NOMBRE");

      CMLCreate create = new CMLCreate("1", companyHomeParent, companyHomeParent.getUuid(), Constants.ASSOC_CONTAINS, null, Constants.PROP_CONTENT, contentProps);
      cml = new CML();
      cml.setCreate(new CMLCreate[] {create});
      cml.setAddAspect(new CMLAddAspect[] {addAspect});
      UpdateResult[] result;

         result = repositoryService.update(cml);

      Reference content = result[0].getDestination();

      // Write some content
      String temporal = "helloworld";
      byte[] bytes = temporal.getBytes();
      ContentFormat format = new ContentFormat("text/plain", "UTF-8");
      // Write the content
      contentService.write(content, Constants.PROP_CONTENT, bytes, format);
      } catch (RepositoryFault e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
      } catch (RemoteException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
      }
    }


y este seria el aspect del xml:
   <aspects>
     <!– Aspect para el tipo folderEspecialidad–>
      <aspect  name="reg:aspectRegasoc">
         <title>Regasoc</title>
        <properties>
            <property name="reg:nregistro">
               <title>Numero Registro</title>
               <type>d:text</type>
            </property>
            <property name="reg:nombre">
               <title>Nombre</title>
               <type>d:text</type>
            </property>
            <property name="reg:nexpediente">
               <title>Numero Expediente</title>
               <type>d:text</type>
            </property>
            <property name="reg:seccion">
               <title>Seccion</title>
               <type>d:text</type>
            </property>
         </properties>

      </aspect>

pablo_zapico
Champ in-the-making
Champ in-the-making
Puse exacmente el mismo codigo java q tu y el aspect y me sigue fallando, lo cual quiere decir q si a ti te funciona es xq algo he configurado mal. Te pego lo que he configurado y donde….

RegAsocModel-Context.xml


<?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>

RegAsocModel.xml


<?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>
      <mandatory-aspects>
         <aspect>reg:aspectRegasoc</aspect>
      </mandatory-aspects>
         <properties>
            <property name="reg:nregistro">
               <title>Numero Registro</title>
               <type>d:text</type>
            </property>
            <property name="reg:nombre">
               <title>Nombre</title>
               <type>d:text</type>
            </property>
            <property name="reg:nexpediente">
               <title>Numero Expediente</title>
               <type>d:text</type>
            </property>
            <property name="reg:seccion">
               <title>Seccion</title>
               <type>d:int</type>
            </property>
         </properties>
      </type>
    </types>
   
   <aspects>
   <!– Aspect para el tipo folderEspecialidad–>
      <aspect name="reg:aspectRegasoc">
      <title>regasoc</title>
      <properties>
         <property name="reg:nregistro">
            <title>Numero Registro</title>
            <type>d:text</type>
         </property>
         <property name="reg:nombre">
            <title>Nombre</title>
            <type>d:text</type>
         </property>
         <property name="reg:nexpediente">
            <title>Numero Expediente</title>
            <type>d:text</type>
         </property>
         <property name="reg:seccion">
            <title>Seccion</title>
            <type>d:text</type>
         </property>
      </properties>
   </aspect>
</aspects>
</model>

y por ultimo web-client-config-custom.xml


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

   <config evaluator="aspect-name" condition="reg:aspectRegasoc">
      <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="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>
  

Ya no se q mirar ni donde, no se si a lo mejor pudieras pasarme tus configuraciones…no se

Gracias

dacedos
Champ in-the-making
Champ in-the-making
quita la parte de las propiedades que hay donde declaras el tipo, para eso usamos el aspect

pablo_zapico
Champ in-the-making
Champ in-the-making
Ya esta, Por fin…..

Bueno no se que paso pero dejo todo de funcionar, ni arrancaba el server ni nada, asi q cogi me lo cargue todo…vi que el server arrancaba, volvi hacer todo paso a paso revisando todo lo que tu me comentaste y funciono a la primera…


Muchas gracias por la ayuda.