/** * {@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(); } }
/** * {@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(); } }
private CustomPrivilegeStore(FileSystemResource customPrivilegesResource) throws RepositoryException { this.customPrivilegesResource = customPrivilegesResource; try { // make sure path to resource exists if (!customPrivilegesResource.exists()) { customPrivilegesResource.makeParentDirs(); } } catch (FileSystemException e) { String error = "Internal error: Failed to access/create file system resource for custom privileges at " + customPrivilegesResource.getPath(); log.debug(error); throw new RepositoryException(error, e); } }
private CustomPrivilegeStore(FileSystemResource customPrivilegesResource) throws RepositoryException { this.customPrivilegesResource = customPrivilegesResource; try { // make sure path to resource exists if (!customPrivilegesResource.exists()) { customPrivilegesResource.makeParentDirs(); } } catch (FileSystemException e) { String error = "Internal error: Failed to access/create file system resource for custom privileges at " + customPrivilegesResource.getPath(); log.debug(error); throw new RepositoryException(error, e); } }
fsRes.makeParentDirs(); BufferedOutputStream bos = new BufferedOutputStream(fsRes.getOutputStream()); DataOutputStream out = new DataOutputStream(bos); fsRes.makeParentDirs(); bos = new BufferedOutputStream(fsRes.getOutputStream()); out = new DataOutputStream(bos);
/** * 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(); }
new FileSystemResource(nsRegStore, NS_REG_RESOURCE); try { propFile.makeParentDirs(); OutputStream os = propFile.getOutputStream(); Properties props = new Properties(); new FileSystemResource(nsRegStore, NS_IDX_RESOURCE); try { indexFile.makeParentDirs(); OutputStream os = indexFile.getOutputStream(); Properties props = new Properties();
FileSystemResource refsFile = new FileSystemResource(itemStateFS, refsFilePath); try { refsFile.makeParentDirs(); OutputStream os = refsFile.getOutputStream(); BufferedWriter writer = null;
FileSystemResource refsFile = new FileSystemResource(itemStateFS, refsFilePath); try { refsFile.makeParentDirs(); OutputStream os = refsFile.getOutputStream(); BufferedWriter writer = null;
/** * {@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); } }
/** * {@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); } }
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"); } }
FileSystemResource resource = new FileSystemResource(fs, "/privileges/custom_privileges.xml"); if (!resource.exists()) { resource.makeParentDirs();
@Override protected void setUp() throws Exception { super.setUp(); resolver = ((SessionImpl) superuser); // setup the custom privilege file with cyclic references fs = ((RepositoryImpl) superuser.getRepository()).getConfig().getFileSystem(); FileSystemResource resource = new FileSystemResource(fs, "/privileges/custom_privileges.xml"); if (!resource.exists()) { resource.makeParentDirs(); } privilegeRegistry = new PrivilegeRegistry(superuser.getWorkspace().getNamespaceRegistry(), fs); }
FileSystemResource resource = new FileSystemResource(fs, "/privileges/custom_privileges.xml"); if (!resource.exists()) { resource.makeParentDirs();