Examples of BinaryKey


Examples of org.modeshape.jcr.value.BinaryKey

    }

    @Override
    public void storeExtractedText( final BinaryValue binary,
                                    String extractedText ) throws BinaryStoreException {
        final BinaryKey key = binary.getKey();
        Lock lock = lockFactory.writeLock(lockKeyFrom(key));
        try {
            final String metadataKey = metadataKeyFrom(key);
            final Metadata metadata = metadataCache.get(metadataKey);
            if (metadata == null) {
View Full Code Here

Examples of org.modeshape.jcr.value.BinaryKey

                        }
                        String keyString = key.toString();
                        if (!isMetadataKey(keyString)) {
                            return;
                        }
                        BinaryKey binaryKey = binaryKeyFromCacheKey(keyString);
                        if (allBinaryUsedKeys.contains(binaryKey)) {
                            return;
                        }
                        Metadata metadata = metadataCache.get(key);
                        if (!metadata.isUnused()) {
View Full Code Here

Examples of org.modeshape.jcr.value.BinaryKey

        public void restoreBinaryFile( File binaryFile ) {
            if (!binaryFile.exists()) return;
            if (!binaryFile.canRead()) {
                I18n msg = JcrI18n.problemsReadingBinaryFromBackup;
                BinaryKey key = binaryKeyFor(binaryFile);
                problems.addError(msg, key.toString(), repositoryName(), backupLocation());
            }
            try {
                InputStream stream = new FileInputStream(binaryFile);
                try {
                    BinaryValue stored = binaryStore.storeValue(stream, false);
                    assert stored.getKey().equals(binaryKeyFor(binaryFile));
                } finally {
                    stream.close();
                }
            } catch (FileNotFoundException e) {
                // We already checked that it exists and is readable, so this shouldn't happen. But ...
                I18n msg = JcrI18n.problemsReadingBinaryFromBackup;
                BinaryKey key = binaryKeyFor(binaryFile);
                problems.addError(e, msg, key.toString(), repositoryName(), backupLocation());
            } catch (BinaryStoreException e) {
                I18n msg = JcrI18n.problemsRestoringBinaryFromBackup;
                BinaryKey key = binaryKeyFor(binaryFile);
                problems.addError(e, msg, key.toString(), repositoryName(), backupLocation(), e.getMessage());
            } catch (IOException e) {
                I18n msg = JcrI18n.problemsRestoringBinaryFromBackup;
                BinaryKey key = binaryKeyFor(binaryFile);
                problems.addError(e, msg, key.toString(), repositoryName(), backupLocation(), e.getMessage());
            }
        }
View Full Code Here

Examples of org.modeshape.jcr.value.BinaryKey

        }

        protected BinaryKey binaryKeyFor( File binaryFile ) {
            String filename = binaryFile.getName();
            String sha1 = filename.replace(BINARY_EXTENSION, "");
            return new BinaryKey(sha1);
        }
View Full Code Here

Examples of org.modeshape.jcr.value.BinaryKey

    public GitBinaryValue( ObjectId id,
                           ObjectLoader loader,
                           String sourceName,
                           String nameHint,
                           MimeTypeDetector mimeTypeDetector ) {
        super(new BinaryKey(id.getName()), sourceName, id.getName(), loader.getSize(), nameHint, mimeTypeDetector);
        this.loader = loader;
    }
View Full Code Here

Examples of org.modeshape.jcr.value.BinaryKey

                    writer.addProperty(GitLexicon.COMMITTED, committed);
                    writer.addProperty(GitLexicon.TITLE, fileCommit.getShortMessage());
                    // Create the BinaryValue ...
                    ObjectId fileObjectId = tw.getObjectId(0);
                    ObjectLoader fileLoader = repository.open(fileObjectId);
                    BinaryKey key = new BinaryKey(fileObjectId.getName());
                    BinaryValue value = values.binaryFor(key, fileLoader.getSize());
                    if (value == null) {
                        // It wasn't found in the binary store ...
                        if (fileLoader.isLarge()) {
                            // Too large to hold in memory, so use the binary store (which reads the file immediately) ...
View Full Code Here

Examples of org.modeshape.jcr.value.BinaryKey

            } else if (fieldValue instanceof org.modeshape.jcr.api.Binary && !(fieldValue instanceof InMemoryBinaryValue)) {
                sha1 = ((org.modeshape.jcr.api.Binary)fieldValue).getHexHash();
            }

            if (sha1 != null) {
                BinaryKey binaryKey = new BinaryKey(sha1);
                // Find the document metadata and decrement the usage count ...
                EditableDocument sha1Usage = documentStore.edit(keyForBinaryReferenceDocument(sha1), false);
                if (sha1Usage != null) {
                    Long countValue = sha1Usage.getLong(REFERENCE_COUNT);
                    assert countValue != null;
View Full Code Here

Examples of org.modeshape.jcr.value.BinaryKey

                return externalBinaryValue != null ? externalBinaryValue : EmptyBinaryValue.INSTANCE;
            }
            if (!Null.matches(valueStr = doc.getString(SHA1_FIELD))) {
                long size = doc.getLong(LENGTH_FIELD);
                try {
                    return binaries.find(new BinaryKey(valueStr), size);
                } catch (BinaryStoreException e) {
                    throw new RuntimeException(e);
                }
            }
        }
View Full Code Here

Examples of org.modeshape.jcr.value.BinaryKey

        for (int i = 0; i < repCount; i++) {
            // upload a file which should mark the binary as used
            tools.uploadFile(session, "/file1.txt", resourceStream("io/file1.txt"));
            session.save();
            BinaryValue storedValue = (BinaryValue)session.getProperty("/file1.txt/jcr:content/jcr:data").getBinary();
            BinaryKey key = storedValue.getKey();
            assertTrue("Binary not stored", binaryStore().hasBinary(key));

            // remove the file, which should move the binary to trash
            session.getNode("/file1.txt").remove();
            session.save();
View Full Code Here

Examples of org.modeshape.jcr.value.BinaryKey

        FileUtil.delete("target/persistent_repository/");
        String config = "config/repo-config-persistent-legacy-fsbinary.json";
        // copy the test-resources legacy structure onto the configured one
        FileUtil.copy(new File("src/test/resources/legacy_fs_binarystore"), new File("target/legacy_fs_binarystore"));
        // this is coming from the test resources
        final BinaryKey binaryKey = new BinaryKey("ef2138973a86a8929eebe7bf52419b7cde73ba0a");
        // first run is empty, so no upgrades will be performed but we'll decrement the last upgrade ID to force an upgrade next
        // restart
        startRunStop(new RepositoryOperation() {
            @Override
            public Void call() throws Exception {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.