public Fichero obtenerDocumentoGD(String dir, Fichero fichero) throws Exception
{
if (fichero.getNombreFichero()==null){
return null;
}
Fichero respuesta = new Fichero();
File f1 = null;
String nombreFichero=fichero.getNombreFichero().toLowerCase();
WebServiceFactory.setEndpointAddress(URL);
WebServiceFactory.setTimeoutMilliseconds(TIMEOUT);
AuthenticationUtils.startSession(USERNAME,PASSWORD);
ContentServiceSoapBindingStub contentService = WebServiceFactory.getContentService();
String space = PATH + "/*[@cm:name=\""+ dir + "\"]" + "/*[@cm:name=\""+nombreFichero+"\"]";
Reference i=new Reference(STORE,null,space);
try {
Node[] nodes;
nodes = WebServiceFactory.getRepositoryService().get(new Predicate(new Reference[] {i}, STORE, null));
if (nodes != null && nodes.length > 0) {
Content[] readResult = WebServiceFactory.getContentService().read(new Predicate(new Reference[] {nodes[0].getReference()}, STORE, null), Constants.PROP_CONTENT);
Content content = readResult[0];
ContentUtils.copyContentToFile(content, new File("C:/docs/temp/ejemplo.txt"));
// Definir la ruta donde se recuperará el fichero
f1 = new File("C:/docs/temp/" + fichero.getNombreFichero());
FileInputStream fis = new FileInputStream(f1);
byte[] entryBytes = null;
// Recuperar el fichero definido.
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len;
while ((len = fis.read(buffer, 0, 1024)) > -1) {
bos.write(buffer, 0, len);
}
bos.flush();
fis.close();
entryBytes = bos.toByteArray();
pasar(entryBytes);
// logger.info("El fichero no se ha recuperado correctamente el
// fichero de la ruta especificada.");
respuesta.setCodigoFichero(fichero.getCodigoFichero());
respuesta.setFichero(entryBytes);
respuesta.setNombreFichero(fichero.getNombreFichero());
respuesta.setRutaFichero("C:/docs/temp");
} else {
}
} catch (Exception e)
{
e.printStackTrace();
return null;
}
finally
{
AuthenticationUtils.endSession();
if (f1!=null){
}
}
return respuesta;
}
public byte[] search(String id, String path, ContentServiceSoapBindingStub contentRepository) throws Exception{
Reference reference = new Reference(STORE, id, path);
Content[] readResult = contentRepository.read(new Predicate(new Reference[]{reference}, STORE, null), Constants.PROP_CONTENT);
byte[] contentBytes = null;
if(readResult!=null){
Content content = (Content) readResult[0];
contentBytes = UtilsFile.getByteContent(content);
}
return contentBytes;
}
fileTemp = File.createTempFile(AlfrescoKeys.FILE_TEMP
, "."
+ ext);
// Se convierte el contenido en un fichero temporal
ContentUtils.copyContentToFile(content, fileTemp);
Content from pre 2016 and from language groups that have been closed.
Content is read-only.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.