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;
}
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);
}
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());
}
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());
}
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;
}
Aggregations