001/**
002 * Copyright 2015 DuraSpace, Inc.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.fcrepo.kernel.impl.utils.impl;
017
018import java.net.URI;
019import java.net.URISyntaxException;
020
021import javax.jcr.Property;
022
023import org.modeshape.jcr.value.binary.FileSystemBinaryStore;
024
025/**
026 * @author cabeer
027 */
028public class FileSystemBinaryStoreEntry extends LocalBinaryStoreEntry {
029
030    /**
031     * Create a binary store entry for a property in a filesystem binary store
032     * @param store the store
033     * @param property the property
034     */
035    public FileSystemBinaryStoreEntry(final FileSystemBinaryStore store, final Property property) {
036        super(store, property);
037    }
038
039    @Override
040    public String getExternalIdentifier() {
041        try {
042            final FileSystemBinaryStore store = (FileSystemBinaryStore)store();
043            return new URI("info",
044                              store.toString(),
045                              store.getDirectory().getAbsolutePath(),
046                              binaryKey().toString()).toString();
047        } catch (URISyntaxException e) {
048            return binaryKey().toString();
049        }
050    }
051
052}