Search in sources :

Example 6 with Visibility

use of org.vertexium.Visibility in project vertexium by visallo.

the class DataInputStreamUtils method decodeProperties.

public static Iterable<Property> decodeProperties(AccumuloGraph graph, DataInputStream in, List<MetadataEntry> metadataEntries, FetchHints fetchHints) throws IOException {
    List<Property> results = new ArrayList<>();
    while (true) {
        int propId = in.read();
        if (propId == ElementData.PROP_END) {
            break;
        } else if (propId != ElementData.PROP_START) {
            throw new IOException("Unexpected prop id: " + propId);
        }
        String propertyKey = graph.getNameSubstitutionStrategy().inflate(decodeString(in));
        String propertyName = graph.getNameSubstitutionStrategy().inflate(decodeString(in));
        Visibility propertyVisibility = new Visibility(decodeString(in));
        long propertyTimestamp = in.readLong();
        int propertyValueLength = in.readInt();
        byte[] propertyValue = new byte[propertyValueLength];
        int read = in.read(propertyValue);
        if (read != propertyValueLength) {
            throw new IOException("Unexpected data length expected " + propertyValueLength + " found " + read);
        }
        Set<String> propertyHiddenVisibilitiesStringSet = decodeStringSet(in);
        Set<Visibility> propertyHiddenVisibilities = null;
        if (propertyHiddenVisibilitiesStringSet != null) {
            propertyHiddenVisibilities = propertyHiddenVisibilitiesStringSet.stream().map(Visibility::new).collect(Collectors.toSet());
        }
        LazyPropertyMetadata metadata = decodePropertyMetadata(in, metadataEntries);
        results.add(new LazyMutableProperty(graph, graph.getVertexiumSerializer(), propertyKey, propertyName, propertyValue, metadata, propertyHiddenVisibilities, propertyVisibility, propertyTimestamp, fetchHints));
    }
    return results;
}
Also used : ArrayList(java.util.ArrayList) IOException(java.io.IOException) Visibility(org.vertexium.Visibility) Property(org.vertexium.Property)

Example 7 with Visibility

use of org.vertexium.Visibility in project vertexium by visallo.

the class ElasticsearchPropertyNameInfo method parse.

public static ElasticsearchPropertyNameInfo parse(Graph graph, PropertyNameVisibilitiesStore propertyNameVisibilitiesStore, String rawPropertyName) {
    Matcher m = PROPERTY_NAME_PATTERN.matcher(rawPropertyName);
    if (!m.matches()) {
        return null;
    }
    String propertyName = m.group(1);
    String visibilityHash = m.group(2);
    Visibility propertyVisibility;
    if (visibilityHash == null) {
        propertyVisibility = null;
    } else {
        // stop leading _
        visibilityHash = visibilityHash.substring(1);
        propertyVisibility = propertyNameVisibilitiesStore.getVisibilityFromHash(graph, visibilityHash);
    }
    return new ElasticsearchPropertyNameInfo(propertyName, propertyVisibility);
}
Also used : Matcher(java.util.regex.Matcher) Visibility(org.vertexium.Visibility)

Example 8 with Visibility

use of org.vertexium.Visibility in project vertexium by visallo.

the class ExistingElementMutationImplTest method testHasChangesNewElementVisibility.

@Test
public void testHasChangesNewElementVisibility() {
    mutation.alterElementVisibility(new Visibility(""));
    assertTrue("should have changes", mutation.hasChanges());
}
Also used : Visibility(org.vertexium.Visibility) Test(org.junit.Test)

Example 9 with Visibility

use of org.vertexium.Visibility in project vertexium by visallo.

the class ExistingElementMutationImplTest method testHasChangesProperties.

@Test
public void testHasChangesProperties() {
    mutation.addPropertyValue("key1", "name1", "Hello", new Visibility(""));
    assertTrue("should have changes", mutation.hasChanges());
}
Also used : Visibility(org.vertexium.Visibility) Test(org.junit.Test)

Example 10 with Visibility

use of org.vertexium.Visibility in project vertexium by visallo.

the class MetadataTablePropertyNameVisibilitiesStore method getHashes.

public Collection<String> getHashes(Graph graph, String propertyName, Authorizations authorizations) {
    List<String> results = new ArrayList<>();
    String prefix = getPropertyNameVisibilityToHashPrefix(propertyName);
    for (GraphMetadataEntry metadata : graph.getMetadataWithPrefix(prefix)) {
        String visibilityString = metadata.getKey().substring(prefix.length());
        Visibility visibility = getVisibility(visibilityString);
        if (authorizations.canRead(visibility)) {
            String hash = (String) metadata.getValue();
            results.add(hash);
        }
    }
    return results;
}
Also used : GraphMetadataEntry(org.vertexium.GraphMetadataEntry) Visibility(org.vertexium.Visibility)

Aggregations

Visibility (org.vertexium.Visibility)11 Test (org.junit.Test)6 GraphMetadataEntry (org.vertexium.GraphMetadataEntry)2 MutablePropertyImpl (org.vertexium.property.MutablePropertyImpl)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Matcher (java.util.regex.Matcher)1 Property (org.vertexium.Property)1