Package org.apache.jackrabbit.core.fs

Examples of org.apache.jackrabbit.core.fs.FileSystemResource


    private boolean initialized;

    public RetentionRegistryImpl(SessionImpl session, FileSystem fs) throws RepositoryException {
        this.session = session;
        this.retentionFile = new FileSystemResource(fs, FileSystem.SEPARATOR + FILE_NAME);

        // start listening to added/changed or removed holds and retention policies.
        Workspace wsp = session.getWorkspace();
        // register eventlistener to be informed about new/removed holds and retention plcs.
        int types = Event.PROPERTY_ADDED | Event.PROPERTY_REMOVED | Event.PROPERTY_CHANGED;
View Full Code Here


    public void init(String homeDir) throws RepositoryException {
        if (delayedDelete) {
            // First initialize the identifiersToDeleteFile
            LocalFileSystem fileSystem = new LocalFileSystem();
            fileSystem.setRoot(new File(homeDir));
            identifiersToDeleteFile = new FileSystemResource(fileSystem, FileSystem.SEPARATOR
                    + IDENTIFIERS_TO_DELETE_FILE_KEY);
        }
        moveDataTaskThread = new Thread(new MoveDataTask(),
                "Jackrabbit-MulitDataStore-MoveDataTaskThread");
        moveDataTaskThread.setDaemon(true);
View Full Code Here

                // in BLOB store and discard old value instance (e.g. temp file)
                if (blobStore instanceof ResourceBasedBLOBStore) {
                    // optimization: if the BLOB store is resource-based
                    // retrieve the resource directly rather than having
                    // to read the BLOB from an input stream
                    FileSystemResource fsRes =
                            ((ResourceBasedBLOBStore) blobStore).getResource(blobId);
                    values[i] = InternalValue.create(fsRes);
                } else {
                    in = blobStore.get(blobId);
                    try {
View Full Code Here

                // in the BLOB store
                if (blobStore instanceof ResourceBasedBLOBStore) {
                    // optimization: if the BLOB store is resource-based
                    // retrieve the resource directly rather than having
                    // to read the BLOB from an input stream
                    FileSystemResource fsRes =
                            ((ResourceBasedBLOBStore) blobStore).getResource(s);
                    val = InternalValue.create(fsRes);
                } else {
                    InputStream is = blobStore.get(s);
                    try {
View Full Code Here

                            // in the BLOB store
                            if (blobStore instanceof ResourceBasedBLOBStore) {
                                // optimization: if the BLOB store is resource-based
                                // retrieve the resource directly rather than having
                                // to read the BLOB from an input stream
                                FileSystemResource fsRes =
                                        ((ResourceBasedBLOBStore) blobStore).getResource(content);
                                values.add(InternalValue.create(fsRes));
                            } else {
                                InputStream in = blobStore.get(content);
                                try {
View Full Code Here

            throw new IllegalStateException("not initialized");
        }

        NodeId id = state.getNodeId();
        String nodeFilePath = buildNodeFilePath(id);
        FileSystemResource nodeFile = new FileSystemResource(itemStateFS, nodeFilePath);
        try {
            nodeFile.makeParentDirs();
            OutputStream os = nodeFile.getOutputStream();
            Writer writer = null;
            try {
                String encoding = DEFAULT_ENCODING;
                try {
                    writer = new BufferedWriter(new OutputStreamWriter(os, encoding));
View Full Code Here

     */
    public LockManagerImpl(SessionImpl session, FileSystem fs)
            throws RepositoryException {

        this.sysSession = session;
        this.locksFile = new FileSystemResource(fs, FileSystem.SEPARATOR + LOCKS_FILE);

        session.getWorkspace().getObservationManager().
                addEventListener(this, Event.NODE_ADDED | Event.NODE_REMOVED,
                        "/", true, null, null, true);

View Full Code Here

        if (!initialized) {
            throw new IllegalStateException("not initialized");
        }

        String propFilePath = buildPropFilePath(state.getPropertyId());
        FileSystemResource propFile = new FileSystemResource(itemStateFS, propFilePath);
        try {
            propFile.makeParentDirs();
            OutputStream os = propFile.getOutputStream();
            // write property state to xml file
            Writer writer = null;
            try {
                String encoding = DEFAULT_ENCODING;
                try {
                    writer = new BufferedWriter(new OutputStreamWriter(os, encoding));
                } catch (UnsupportedEncodingException e) {
                    // should never get here!
                    OutputStreamWriter osw = new OutputStreamWriter(os);
                    encoding = osw.getEncoding();
                    writer = new BufferedWriter(osw);
                }

                String typeName;
                int type = state.getType();
                try {
                    typeName = PropertyType.nameFromValue(type);
                } catch (IllegalArgumentException iae) {
                    // should never be getting here
                    throw new ItemStateException("unexpected property-type ordinal: " + type, iae);
                }

                writer.write("<?xml version=\"1.0\" encoding=\"" + encoding + "\"?>\n");
                writer.write("<" + PROPERTY_ELEMENT + " "
                        + NAME_ATTRIBUTE + "=\"" + Text.encodeIllegalXMLCharacters(state.getName().toString()) + "\" "
                        + PARENTUUID_ATTRIBUTE + "=\"" + state.getParentId() + "\" "
                        + MULTIVALUED_ATTRIBUTE + "=\"" + Boolean.toString(state.isMultiValued()) + "\" "
                        + DEFINITIONID_ATTRIBUTE + "=\"" + state.getDefinitionId().toString() + "\" "
                        + MODCOUNT_ATTRIBUTE + "=\"" + state.getModCount() + "\" "
                        + TYPE_ATTRIBUTE + "=\"" + typeName + "\">\n");
                // values
                writer.write("\t<" + VALUES_ELEMENT + ">\n");
                InternalValue[] values = state.getValues();
                if (values != null) {
                    for (int i = 0; i < values.length; i++) {
                        writer.write("\t\t<" + VALUE_ELEMENT + ">");
                        InternalValue val = values[i];
                        if (val != null) {
                            if (type == PropertyType.BINARY) {
                                // special handling required for binary value:
                                // put binary value in BLOB store
                                InputStream in = val.getStream();
                                String blobId = blobStore.createId(state.getPropertyId(), i);
                                try {
                                    blobStore.put(blobId, in, val.getLength());
                                } finally {
                                    IOUtils.closeQuietly(in);
                                }
                                // store id of BLOB as property value
                                writer.write(blobId);
                                // replace value instance with value backed by resource
                                // in BLOB store and discard old value instance (e.g. temp file)
                                if (blobStore instanceof ResourceBasedBLOBStore) {
                                    // optimization: if the BLOB store is resource-based
                                    // retrieve the resource directly rather than having
                                    // to read the BLOB from an input stream
                                    FileSystemResource fsRes =
                                            ((ResourceBasedBLOBStore) blobStore).getResource(blobId);
                                    values[i] = InternalValue.create(fsRes);
                                } else {
                                    in = blobStore.get(blobId);
                                    try {
View Full Code Here

            throw new IllegalStateException("not initialized");
        }

        NodeId id = state.getNodeId();
        String nodeFilePath = buildNodeFilePath(id);
        FileSystemResource nodeFile = new FileSystemResource(itemStateFS, nodeFilePath);
        try {
            if (nodeFile.exists()) {
                // delete resource and prune empty parent folders
                nodeFile.delete(true);
            }
        } catch (FileSystemException fse) {
            String msg = "failed to delete node state: " + id;
            log.debug(msg);
            throw new ItemStateException(msg, fse);
View Full Code Here

                }
            }
        }
        // delete property file
        String propFilePath = buildPropFilePath(state.getPropertyId());
        FileSystemResource propFile = new FileSystemResource(itemStateFS, propFilePath);
        try {
            if (propFile.exists()) {
                // delete resource and prune empty parent folders
                propFile.delete(true);
            }
        } catch (FileSystemException fse) {
            String msg = "failed to delete property state: " + state.getParentId() + "/" + state.getName();
            log.debug(msg);
            throw new ItemStateException(msg, fse);
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.core.fs.FileSystemResource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.