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;
}
}
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.