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.
RdoAlfresco rdo = new RdoAlfresco(); // Start the session AuthenticationUtils.startSession(LOGIN, PASS); System.out.println("Se ha logado!!"); // Create a reference to the parent where we want to create content Store storeRef = new Store(Constants.WORKSPACE_STORE, "SpacesStore"); ParentReference companyHomeParent = new ParentReference(storeRef, null, "/app:company_home" + "/cm:"+ codAplicacion + "/cm:" + directorio, Constants.ASSOC_CONTAINS, null); System.out.println("Ha creado el ruta de referencia!!"); // Assign name String name = "Web Services sample " + nameDoc + " (" + System.currentTimeMillis() + ")"; companyHomeParent.setChildName("cm:" + name); System.out.println("Ha asignado el nombre!!"); // Construct CML statement to create content node // Note: Assign "1" as a local id, so we can refer to it in subsequent // CML statements within the same CML block NamedValue[] contentProps = new NamedValue[1]; contentProps[0] = Utils.createNamedValue(Constants.PROP_NAME, name); CMLCreate create = new CMLCreate("1", companyHomeParent, null, null, null, Constants.TYPE_CONTENT, contentProps); System.out.println("Ha asignado el nombre!!"); // Construct CML statement to add titled aspect NamedValue[] titledProps = new NamedValue[2]; titledProps[0] = Utils.createNamedValue(Constants.PROP_TITLE, name); titledProps[1] = Utils.createNamedValue(Constants.PROP_DESCRIPTION, name); CMLAddAspect addAspect = new CMLAddAspect(Constants.ASPECT_TITLED, titledProps, null, "1"); System.out.println("Ha creado el addAspect!!"); // Construct CML Block CML cml = new CML(); cml.setCreate(new CMLCreate[] {create}); cml.setAddAspect(new CMLAddAspect[] {addAspect}); System.out.println("Ha construido el CML Block!!"); // Issue CML statement via Repository Web Service and retrieve result // Note: Batching of multiple statements into a single web call String url = "http://localhost:8090/alfresco/api"; UpdateResult[] result = WebServiceFactory.getRepositoryService(url).update(cml); Reference content = result[0].getDestination(); System.out.println("Ha construido el UpdateResult!!"); //Write ContentServiceSoapBindingStub contentService = WebServiceFactory.getContentService(); System.out.println("Ha obtenido el contentService!!"); //Se le asigna el mimetype del documento ContentFormat contentFormat = new ContentFormat(mimetype, "UTF-8"); System.out.println("Ha obtenido el contentFormat!!"); //Obtengo los bytes del Documento a Subir byte[] fileBytes = getBytesFile(rutaFile); Content contentRef = contentService.write(content, Constants.PROP_CONTENT, fileBytes, contentFormat); System.out.println("FIN!!! Content Length: " + contentRef.getLength()); rdo.setTamanyo(contentRef.getLength()); rdo.setMimetype(contentRef.getFormat().getMimetype()); rdo.setCodRdo("200"); //OK!!!