@Override public void recordLogin(User user, String remoteAddr) { Vertex userVertex = findByIdUserVertex(user.getUserId()); ExistingElementMutation<Vertex> m = userVertex.prepareMutation(); Date currentLoginDate = UserVisalloProperties.CURRENT_LOGIN_DATE.getPropertyValue(userVertex); if (currentLoginDate != null) { UserVisalloProperties.PREVIOUS_LOGIN_DATE.setProperty( m, currentLoginDate, VISIBILITY.getVisibility()); } String currentLoginRemoteAddr = UserVisalloProperties.CURRENT_LOGIN_REMOTE_ADDR.getPropertyValue(userVertex); if (currentLoginRemoteAddr != null) { UserVisalloProperties.PREVIOUS_LOGIN_REMOTE_ADDR.setProperty( m, currentLoginRemoteAddr, VISIBILITY.getVisibility()); } UserVisalloProperties.CURRENT_LOGIN_DATE.setProperty(m, new Date(), VISIBILITY.getVisibility()); UserVisalloProperties.CURRENT_LOGIN_REMOTE_ADDR.setProperty( m, remoteAddr, VISIBILITY.getVisibility()); int loginCount = UserVisalloProperties.LOGIN_COUNT.getPropertyValue(userVertex, 0); UserVisalloProperties.LOGIN_COUNT.setProperty(m, loginCount + 1, VISIBILITY.getVisibility()); m.save(authorizations); graph.flush(); }
@Override public void setPropertyOnUser(User user, String propertyName, Object value) { if (user instanceof SystemUser) { throw new VisalloException("Cannot set properties on system user"); } Vertex userVertex = findByIdUserVertex(user.getUserId()); userVertex.setProperty(propertyName, value, VISIBILITY.getVisibility(), authorizations); if (user instanceof VertexiumUser) { ((VertexiumUser) user).setProperty(propertyName, value); } }
private void addRdfGraphPropertyWorkerToWhiteList( Vertex vertex, Visibility visibility, Authorizations authorizations) { ExistingElementMutation<Vertex> m = vertex.prepareMutation(); VisalloProperties.GRAPH_PROPERTY_WORKER_WHITE_LIST.addPropertyValue( m, MULTI_KEY, RdfGraphPropertyWorker.class.getName(), visibility); m.save(authorizations); }
@Override public User findByUsername(String username) { username = formatUsername(username); Iterable<Vertex> vertices = graph .query(authorizations) .has(UserVisalloProperties.USERNAME.getPropertyName(), username) .has(VisalloProperties.CONCEPT_TYPE.getPropertyName(), userConceptId) .vertices(); Vertex userVertex = singleOrDefault(vertices, null); if (userVertex == null) { return null; } userVertexCache.put(userVertex.getId(), userVertex); return createFromVertex(userVertex); }
private String saveDetectedObject( Vertex artifactVertex, Metadata metadata, ArtifactDetectedObject detectedObject) { String multiKey = detectedObject.getMultivalueKey(MULTI_VALUE_KEY_PREFIX); VisalloProperties.DETECTED_OBJECT.addPropertyValue( artifactVertex, multiKey, detectedObject, metadata, artifactVertex.getVisibility(), getAuthorizations()); return multiKey; }