Search in sources :

Example 1 with KObjectKey

use of org.uberfire.ext.metadata.model.KObjectKey in project kie-wb-common by kiegroup.

the class KObjectUtil method toKObjectKey.

public static KObjectKey toKObjectKey(final Path path, final String classifier) {
    return new KObjectKey() {

        @Override
        public String getId() {
            return sha1(getType().getName() + "|" + classifier + "|" + getKey());
        }

        @Override
        public MetaType getType() {
            return META_TYPE;
        }

        @Override
        public String getClusterId() {
            final String fsId = ((FileSystemId) path.getFileSystem()).id();
            final String segmentId = ((SegmentedPath) path).getSegmentId();
            return fsId + CLUSTER_ID_SEGMENT_SEPARATOR + segmentId;
        }

        @Override
        public String getSegmentId() {
            return ((SegmentedPath) path).getSegmentId();
        }

        @Override
        public String getKey() {
            return path.toUri().toString();
        }

        @Override
        public String toString() {
            StringBuilder sb = new StringBuilder("KObject{" + ", key='" + getKey() + '\'' + ", id='" + getId() + '\'' + ", type=" + getType() + ", clusterId='" + getClusterId() + '\'' + ", segmentId='" + getSegmentId() + '\'');
            sb.append('}');
            return sb.toString();
        }
    };
}
Also used : KObjectKey(org.uberfire.ext.metadata.model.KObjectKey) FileSystemId(org.uberfire.java.nio.base.FileSystemId) SegmentedPath(org.uberfire.java.nio.base.SegmentedPath) Base64.encodeBase64String(org.apache.commons.codec.binary.Base64.encodeBase64String)

Aggregations

Base64.encodeBase64String (org.apache.commons.codec.binary.Base64.encodeBase64String)1 KObjectKey (org.uberfire.ext.metadata.model.KObjectKey)1 FileSystemId (org.uberfire.java.nio.base.FileSystemId)1 SegmentedPath (org.uberfire.java.nio.base.SegmentedPath)1