11-18-2010 05:36 AM
11-18-2010 11:44 AM
11-29-2010 10:29 AM
public void registerOtrosDocumentos(Integer numExpediente, File file,
String fileName){
String container = ExpedienteModel.EXPEDIENTE_OTROS_DOCUMENTOS;
this.saveFile(numExpediente, file, fileName, container);
}
private NodeRef saveFile(Integer numExpediente, File file, String fileName, String container){
String xpath = "/app:company_home/" +
"cm:" + ExpedienteModel.EXPEDIENTE_NAME_PREFIX + numExpediente + container;
StoreRef storeRef = StoreRef.STORE_REF_WORKSPACE_SPACESSTORE;
NodeRef rootNodeRef = serviceRegistry.getNodeService().getRootNode(storeRef);
List<NodeRef> results = this.serviceRegistry.getSearchService()
.selectNodes(rootNodeRef, xpath, null, this.serviceRegistry.getNamespaceService(), false);
String name;
if(fileName == null){
name = file.getName();
}else{
name = fileName;
}
FileInfo fileInfo = this.serviceRegistry.getFileFolderService().create(
results.get(0),
name,
ContentModel.TYPE_CONTENT);
NodeRef fileNodeRef = fileInfo.getNodeRef();
ContentWriter writer = this.serviceRegistry.getContentService()
.getWriter(fileNodeRef, ContentModel.PROP_CONTENT, true);
writer.setEncoding(getEncoding());
if (file != null)
{
writer.putContent(file);
}
return fileNodeRef;
}
public List<OtrosDocumentos> otrosDocumentos(Integer numExpediente)
throws FileNotFoundException{
List<OtrosDocumentos> otrosDocs = new ArrayList<OtrosDocumentos>();
String xpath = "/app:company_home/" +
"cm:" + ExpedienteModel.EXPEDIENTE_NAME_PREFIX + numExpediente +
ExpedienteModel.EXPEDIENTE_OTROS_DOCUMENTOS + "/*";
StoreRef storeRef = StoreRef.STORE_REF_WORKSPACE_SPACESSTORE;
NodeRef rootNodeRef = serviceRegistry.getNodeService().getRootNode(storeRef);
List<NodeRef> results = this.serviceRegistry.getSearchService()
.selectNodes(rootNodeRef, xpath, null, this.serviceRegistry.getNamespaceService(), false);
for(NodeRef nodeRef: results){
if(nodeRef!=null){
Node node = new Node(nodeRef);
if(node != null){
String url = DownloadContentServlet.generateDownloadURL(nodeRef, node.getName());
otrosDocs.add(new OtrosDocumentos(node.getName(), url, nodeRef.getId()));
}
}
}
if(otrosDocs.size()>0){
return otrosDocs;
}else{
return null;
}
}
11-29-2010 12:23 PM
11-29-2010 01:08 PM
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.