private TermQuery createDescriptorQuery(PropertyFileDescriptor descriptor) { return new TermQuery(new Term(FIELD_FULL_PATH, descriptor.fullPath().toString())); }
private void serveFile(PropertyFileDescriptor fileDescriptor, HttpServletResponse resp) throws IOException { URI path = fileDescriptor.absolutPath(); File file = new File(path.path()); ServletOutputStream outputStream = resp.getOutputStream(); if (!file.exists()) { resp.setStatus(HttpServletResponse.SC_NOT_FOUND); resp.sendError(HttpServletResponse.SC_NOT_FOUND, "Resource " + fileDescriptor.fullPath() + " does not exist"); } else { resp.setContentLength((int) file.length()); resp.setContentType("application/octet-stream"); writeFileToStream(file, outputStream); } outputStream.flush(); }
@Override public void saveProperties(PropertyFileDescriptor descriptor, PropertyFile file, boolean autoTranslate) { if(!active) { logger.error("Received save request while not active"); throw new IllegalStateException("The PropertiesPersistanceService is deactivated"); } try { PropertyFileDescriptor adaptedDescriptor = workspace.cdoView().getObject(descriptor); PropertyFile writeCopy = createCopy(file); // create a write copy to be independent of future writes queue.put(new PropertyTuple(adaptedDescriptor, writeCopy, autoTranslate)); } catch (InterruptedException e) { throw new RuntimeException("Interrupted while trying to save " + descriptor.fullPath(), e); } }
break; case REPLACE: writer.deleteDocuments(new Term(QueryService.FIELD_FULL_PATH, documentTuple.getDescriptor().fullPath().toString())); for (Document document : documents) { writer.addDocument(document);
Field pathField = new Field(QueryService.FIELD_FULL_PATH, descriptor.fullPath().toString(), Store.YES, Index.NOT_ANALYZED); doc.add(pathField); CDOID cdoID = descriptor.cdoID();