01-19-2010 06:02 AM
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;
}
05-24-2010 05:43 AM
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.