Package org.modeshape.jcr.value

Examples of org.modeshape.jcr.value.BinaryKey


    private synchronized BinaryKey generateHash() {
        if (this.hash == null) {
            try {
                byte[] hashBytes = SecureHash.getHash(SecureHash.Algorithm.SHA_1, convertURLtoFile(this.content));
                this.hash = new BinaryKey(hashBytes);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        return this.hash;
View Full Code Here


        try {
            return dbCall(new DBCallable<BinaryValue>() {
                @Override
                public BinaryValue execute( Connection connection ) throws Exception {
                    // prepare new binary key based on SHA-1
                    BinaryKey key = new BinaryKey(temp.getKey().toString());

                    // check for duplicate content
                    Database database = database();

                    if (database.contentExists(key, ALIVE, connection)) {
View Full Code Here

    @Override
    protected String getStoredMimeType( final BinaryValue source ) throws BinaryStoreException {
        return dbCall(new DBCallable<String>() {
            @Override
            public String execute( Connection connection ) throws Exception {
                BinaryKey key = source.getKey();
                if (!database().contentExists(key, true, connection) && !database().contentExists(key, false, connection)) {
                    throw new BinaryStoreException(JcrI18n.unableToFindBinaryValue.text(key, database().getTableName()));
                }
                return database().getMimeType(key, connection);
            }
View Full Code Here

    @Override
    public String getExtractedText( final BinaryValue source ) throws BinaryStoreException {
        return dbCall(new DBCallable<String>() {
            @Override
            public String execute( Connection connection ) throws Exception {
                BinaryKey key = source.getKey();
                if (!database.contentExists(key, true, connection) && !database.contentExists(key, false, connection)) {
                    throw new BinaryStoreException(JcrI18n.unableToFindBinaryValue.text(key, database().getTableName()));
                }
                return database().getExtractedText(key, connection);
            }
View Full Code Here

            tmpFile = File.createTempFile(TEMP_FILE_PREFIX, TEMP_FILE_SUFFIX);
            IoUtil.write(hashingStream, new BufferedOutputStream(new FileOutputStream(tmpFile)),
                         AbstractBinaryStore.MEDIUM_BUFFER_SIZE);
            hashingStream.close();
            byte[] sha1 = hashingStream.getHash();
            BinaryKey key = new BinaryKey(sha1);

            final long numberOfBytes = tmpFile.length();
            if (numberOfBytes < getMinimumBinarySizeInBytes()) {
                // The content is small enough to just store in-memory ...
                byte[] content = IoUtil.readBytes(tmpFile);
View Full Code Here

            if (file.isDirectory()) {
                moveTrashFilesToMainStorage(file);
            } else {
                if (file.canRead() && file.isFile() && file.length() > 0) {
                    // this is an old style file which we need to convert
                    BinaryKey key = new BinaryKey(file.getName());
                    // create the empty shell first
                    File persistedFile = findFile(directory, key, true);
                    // move it to main storage
                    moveFileExclusively(file, persistedFile, key);
                    // and write out a new trash file
View Full Code Here

            return;
        }
        // create a trash file for the main binary
        getTrashFile(key, true);

        BinaryKey textExtractionKey = createKeyFromSourceWithSuffix(key, EXTRACTED_TEXT_SUFFIX);
        File textFile = findFile(directory, textExtractionKey, false);
        if (textFile.exists()) {
            // create a trash file for the extracted text binary
            getTrashFile(textExtractionKey, true);
        }

        BinaryKey mimeTypeKey = createKeyFromSourceWithSuffix(key, MIME_TYPE_SUFFIX);
        File mimeTypeFile = findFile(directory, mimeTypeKey, false);
        if (mimeTypeFile.exists()) {
            // create a trash file for the mime-type binary
            getTrashFile(mimeTypeKey, true);
        }
View Full Code Here

            } else if (fileOrDir.isFile()) {
                File file = fileOrDir;
                if (file.lastModified() < oldestTimestamp) {
                    // we know that the files in the trash have the name as sha1
                    String sha1 = file.getName();
                    BinaryKey key = new BinaryKey(sha1);
                    File persistedFile = findFile(directory, key, false);
                    if (persistedFile.exists() && persistedFile.canRead()) {
                        Lock lock = locks.writeLock(sha1);
                        try {
                            if (persistedFile.exists()) {
View Full Code Here

    @Override
    public String getExtractedText( BinaryValue source ) throws BinaryStoreException {
        if (!binaryValueExists(source)) {
            throw new BinaryStoreException(JcrI18n.unableToFindBinaryValue.text(source.getKey(), directory));
        }
        BinaryKey extractedTextKey = createKeyFromSourceWithSuffix(source.getKey(), EXTRACTED_TEXT_SUFFIX);
        return storedStringAtKey(extractedTextKey);
    }
View Full Code Here

                                       String extractedText ) throws BinaryStoreException {
        // Look for an existing file ...
        if (!binaryValueExists(source)) {
            return;
        }
        BinaryKey extractedTextKey = createKeyFromSourceWithSuffix(source.getKey(), EXTRACTED_TEXT_SUFFIX);
        storeStringAtKey(extractedText, extractedTextKey);
    }
View Full Code Here

TOP

Related Classes of org.modeshape.jcr.value.BinaryKey

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.