11-18-2010 05:27 AM
11-18-2010 07:04 AM
11-29-2010 11:14 AM
public void registerOtrosDocumentos(Integer numDossier, File file,
String fileName){
String container = ExpedienteModel.DOSSIER_DOCUMENTS;
this.saveFile(numDossier, file, fileName, container);
}
private NodeRef saveFile(Integer numDossier, File file, String fileName, String container){
String xpath = "/app:company_home/" +
"cm:" + DossierModel.DOSSIER_NAME_PREFIX + numDossier+ 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<Documents> getDocuments(Integer numDossier)
throws FileNotFoundException{
List<Documents> docs = new ArrayList<Documents>();
String xpath = "/app:company_home/" +
"cm:" + DossierModel.DOSSIER_NAME_PREFIX + numDossier+
DossierModel.DOSSIER_DOCUMENTS + "/*";
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());
docs.add(new Documents(node.getName(), url, nodeRef.getId()));
}
}
}
if(docs.size()>0){
return docs;
}else{
return null;
}
}
11-29-2010 11:33 AM
String xpath = "/app:company_home/" +
"cm:" + ISO9075.encode(DossierModel.DOSSIER_NAME_PREFIX + numDossier+ container);
Hope this helps.
11-29-2010 01:09 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.