/** * {@inheritDoc} */ public void put(String blobId, InputStream in, long size) throws Exception { // the blobId is an absolute file system path FileSystemResource internalBlobFile = new FileSystemResource(fs, blobId); internalBlobFile.makeParentDirs(); OutputStream out = internalBlobFile.getOutputStream(); try { IOUtils.copy(in, out); } finally { out.close(); } }
/** * Saves the lookup table to the filesystem resource. */ protected void save() { try { OutputStream out = file.getOutputStream(); try { Properties properties = new Properties(); for (Map.Entry<String, Integer> entry : stringToIndex.entrySet()) { properties.setProperty( entry.getKey(), entry.getValue().toString()); } properties.store(out, "string index"); } finally { out.close(); } lastModified = file.lastModified(); } catch (Exception e) { throw new IllegalStateException("Unable to store lookup table", e); } }
/** * Purges the delayedDeletedFile. * * @return boolean true if it was successful otherwise false */ private boolean purgeDelayedDeleteFile() { BufferedWriter writer = null; try { writer = new BufferedWriter(new OutputStreamWriter( identifiersToDeleteFile.getOutputStream())); writer.write(""); return true; } catch (Exception e) { log.warn("I/O error while purging (stacktrace on DEBUG log level) the " + IDENTIFIERS_TO_DELETE_FILE_KEY + " file '" + identifiersToDeleteFile.getPath() + "': " + e.getMessage()); log.debug("Root cause: ", e); return false; } finally { IOUtils.closeQuietly(writer); } }
/** * Saves the lookup table to the filesystem resource. */ protected void save() { try { OutputStream out = file.getOutputStream(); try { Properties properties = new Properties(); for (Map.Entry<String, Integer> entry : stringToIndex.entrySet()) { properties.setProperty( entry.getKey(), entry.getValue().toString()); } properties.store(out, "string index"); } finally { out.close(); } lastModified = file.lastModified(); } catch (Exception e) { throw new IllegalStateException("Unable to store lookup table", e); } }
/** * Purges the delayedDeletedFile. * * @return boolean true if it was successful otherwise false */ private boolean purgeDelayedDeleteFile() { BufferedWriter writer = null; try { writer = new BufferedWriter(new OutputStreamWriter( identifiersToDeleteFile.getOutputStream())); writer.write(""); return true; } catch (Exception e) { log.warn("I/O error while purging (stacktrace on DEBUG log level) the " + IDENTIFIERS_TO_DELETE_FILE_KEY + " file '" + identifiersToDeleteFile.getPath() + "': " + e.getMessage()); log.debug("Root cause: ", e); return false; } finally { IOUtils.closeQuietly(writer); } }
/** * Purges the delayedDeletedFile. * * @return boolean true if it was successful otherwise false */ private boolean purgeDelayedDeleteFile() { BufferedWriter writer = null; try { writer = new BufferedWriter(new OutputStreamWriter( identifiersToDeleteFile.getOutputStream())); writer.write(""); return true; } catch (Exception e) { log.warn("I/O error while purging (stacktrace on DEBUG log level) the " + IDENTIFIERS_TO_DELETE_FILE_KEY + " file '" + identifiersToDeleteFile.getPath() + "': " + e.getMessage()); log.debug("Root cause: ", e); return false; } finally { IOUtils.closeQuietly(writer); } }
/** * {@inheritDoc} */ public void put(String blobId, InputStream in, long size) throws Exception { // the blobId is an absolute file system path FileSystemResource internalBlobFile = new FileSystemResource(fs, blobId); internalBlobFile.makeParentDirs(); OutputStream out = internalBlobFile.getOutputStream(); try { IOUtils.copy(in, out); } finally { out.close(); } }
/** * Creates a new hashmap index and loads the lookup tables from the * filesystem resource. If it does not exist yet, it will create a new one. * * @param file the filesystem resource that stores the lookup tables. * * @throws IOException if an I/O error occurs. * @throws FileSystemException if an I/O error occurs. */ public FileBasedIndex(FileSystemResource file) throws FileSystemException, IOException { this.file = file; if (!file.exists()) { file.makeParentDirs(); file.getOutputStream().close(); } load(); }
/** * Creates a new hashmap index and loads the lookup tables from the * filesystem resource. If it does not exist yet, it will create a new one. * * @param file the filesystem resource that stores the lookup tables. * * @throws IOException if an I/O error occurs. * @throws FileSystemException if an I/O error occurs. */ public FileBasedIndex(FileSystemResource file) throws FileSystemException, IOException { this.file = file; if (!file.exists()) { file.makeParentDirs(); file.getOutputStream().close(); } load(); }
try { refsFile.makeParentDirs(); OutputStream os = refsFile.getOutputStream(); BufferedWriter writer = null; try {
/** * {@inheritDoc} */ protected void store(NodeReferences refs) throws ItemStateException { if (!initialized) { throw new IllegalStateException("not initialized"); } String refsFilePath = buildNodeReferencesFilePath(refs.getTargetId()); FileSystemResource refsFile = new FileSystemResource(itemStateFS, refsFilePath); try { refsFile.makeParentDirs(); OutputStream out = new BufferedOutputStream(refsFile.getOutputStream()); try { Serializer.serialize(refs, out); } finally { out.close(); } } catch (Exception e) { String msg = "failed to store " + refs; log.debug(msg); throw new ItemStateException(msg, e); } }
/** * {@inheritDoc} */ protected void store(NodeReferences refs) throws ItemStateException { if (!initialized) { throw new IllegalStateException("not initialized"); } String refsFilePath = buildNodeReferencesFilePath(refs.getTargetId()); FileSystemResource refsFile = new FileSystemResource(itemStateFS, refsFilePath); try { refsFile.makeParentDirs(); OutputStream out = new BufferedOutputStream(refsFile.getOutputStream()); try { Serializer.serialize(refs, out); } finally { out.close(); } } catch (Exception e) { String msg = "failed to store " + refs; log.debug(msg); throw new ItemStateException(msg, e); } }
throws RepositoryException { try { OutputStream out = customNodeTypesResource.getOutputStream(); try { store.store(out, nsReg);
/** * {@inheritDoc} */ protected void store(NodeState state) throws ItemStateException { if (!initialized) { throw new IllegalStateException("not initialized"); } String nodeFilePath = buildNodeFilePath(state.getNodeId()); FileSystemResource nodeFile = new FileSystemResource(itemStateFS, nodeFilePath); try { nodeFile.makeParentDirs(); BufferedOutputStream out = new BufferedOutputStream(nodeFile.getOutputStream()); try { // serialize node state Serializer.serialize(state, out); } finally { out.close(); } } catch (Exception e) { String msg = "failed to write node state: " + state.getNodeId(); log.debug(msg); throw new ItemStateException(msg, e); } }
/** * {@inheritDoc} */ protected void store(NodeState state) throws ItemStateException { if (!initialized) { throw new IllegalStateException("not initialized"); } String nodeFilePath = buildNodeFilePath(state.getNodeId()); FileSystemResource nodeFile = new FileSystemResource(itemStateFS, nodeFilePath); try { nodeFile.makeParentDirs(); BufferedOutputStream out = new BufferedOutputStream(nodeFile.getOutputStream()); try { // serialize node state Serializer.serialize(state, out); } finally { out.close(); } } catch (Exception e) { String msg = "failed to write node state: " + state.getNodeId(); log.debug(msg); throw new ItemStateException(msg, e); } }
/** * {@inheritDoc} */ protected void store(PropertyState state) throws ItemStateException { if (!initialized) { throw new IllegalStateException("not initialized"); } String propFilePath = buildPropFilePath(state.getPropertyId()); FileSystemResource propFile = new FileSystemResource(itemStateFS, propFilePath); try { propFile.makeParentDirs(); BufferedOutputStream out = new BufferedOutputStream(propFile.getOutputStream()); try { // serialize property state Serializer.serialize(state, out, blobStore); } finally { out.close(); } } catch (Exception e) { String msg = "failed to store property state: " + state.getParentId() + "/" + state.getName(); log.debug(msg); throw new ItemStateException(msg, e); } }
/** * {@inheritDoc} */ protected void store(PropertyState state) throws ItemStateException { if (!initialized) { throw new IllegalStateException("not initialized"); } String propFilePath = buildPropFilePath(state.getPropertyId()); FileSystemResource propFile = new FileSystemResource(itemStateFS, propFilePath); try { propFile.makeParentDirs(); BufferedOutputStream out = new BufferedOutputStream(propFile.getOutputStream()); try { // serialize property state Serializer.serialize(state, out, blobStore); } finally { out.close(); } } catch (Exception e) { String msg = "failed to store property state: " + state.getParentId() + "/" + state.getName(); log.debug(msg); throw new ItemStateException(msg, e); } }
private FileSystem createFileSystem() { FileSystem fs = new MemoryFileSystem(); BufferedWriter writer = null; try { fs.createFolder("/"); FileSystemResource file = new FileSystemResource(fs, "/retention"); writer = new BufferedWriter(new OutputStreamWriter(file.getOutputStream())); writer.write(((NodeImpl) childN).getNodeId().toString()); } catch (FileSystemException e) { log.error(e.getMessage()); } catch (IOException e) { log.error(e.getMessage()); } finally { IOUtils.closeQuietly(writer); } return fs; }
public void testInvalidCustomDefinitions() throws RepositoryException, FileSystemException, IOException { // setup the custom privilege file with cyclic references FileSystem fs = ((RepositoryImpl) superuser.getRepository()).getConfig().getFileSystem(); FileSystemResource resource = new FileSystemResource(fs, "/privileges/custom_privileges.xml"); if (!resource.exists()) { resource.makeParentDirs(); } StringBuilder sb = new StringBuilder(); sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><privileges><privilege isAbstract=\"false\" name=\"test\"><contains name=\"test2\"/></privilege></privileges>"); Writer writer = new OutputStreamWriter(resource.getOutputStream(), "utf-8"); writer.write(sb.toString()); writer.flush(); writer.close(); try { new PrivilegeRegistry(superuser.getWorkspace().getNamespaceRegistry(), fs); fail("Invalid names must be detected upon registry startup."); } catch (RepositoryException e) { // success } finally { fs.deleteFolder("/privileges"); } }
Name test5 = nf.create(Name.NS_DEFAULT_URI, "test5"); OutputStream out = resource.getOutputStream(); try { List<PrivilegeDefinition> defs = new ArrayList<PrivilegeDefinition>();