Java Code Examples for com.tinkerpop.blueprints.Vertex#getProperty()

The following examples show how to use com.tinkerpop.blueprints.Vertex#getProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OrientGraphDatabase.java    From graphdb-benchmarks with Apache License 2.0 6 votes vote down vote up
@Override
public int reInitializeCommunities()
{
    Map<Integer, Integer> initCommunities = new HashMap<Integer, Integer>();
    int communityCounter = 0;
    for (Vertex v : graph.getVertices())
    {
        int communityId = v.getProperty(COMMUNITY);
        if (!initCommunities.containsKey(communityId))
        {
            initCommunities.put(communityId, communityCounter);
            communityCounter++;
        }
        int newCommunityId = initCommunities.get(communityId);
        ((OrientVertex) v).setProperties(COMMUNITY, newCommunityId, NODE_COMMUNITY, newCommunityId);
        ((OrientVertex) v).save();
    }
    return communityCounter;
}
 
Example 2
Source File: AbstractUserRule.java    From light with Apache License 2.0 6 votes vote down vote up
protected String activateUser(Map<String, Object> data) throws Exception {
    String email = (String)data.get("email");
    String code = (String)data.get("code");
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try {
        graph.begin();
        Vertex user = graph.getVertexByKey("User.email", email);
        if(user != null) {
            String s = user.getProperty("code");
            if(code.equals(s)) {
                user.removeProperty("code");
            }
        }
        graph.commit();
    } catch (Exception e) {
        logger.error("Exception:", e);
        graph.rollback();
        throw e;
    } finally {
        graph.shutdown();
    }
    return code;
}
 
Example 3
Source File: AbstractUserRule.java    From light with Apache License 2.0 6 votes vote down vote up
boolean checkRefreshToken(Vertex credential, String clientId, String refreshToken) throws Exception {
    boolean result = false;
    if(credential != null && refreshToken != null) {
        Map clientRefreshTokens = credential.getProperty("clientRefreshTokens");
        if(clientRefreshTokens != null) {
            List<String> refreshTokens = (List)clientRefreshTokens.get(clientId);
            if(refreshTokens != null) {
                String hashedRefreshToken = HashUtil.md5(refreshToken);
                for(String token: refreshTokens) {
                    if(hashedRefreshToken.equals(token)) {
                        result = true;
                        break;
                    }
                }
            }
        } else {
            logger.error("There is no refresh tokens");
        }
    }
    return result;
}
 
Example 4
Source File: OFlowTransformerTest.java    From orientdb-etl with Apache License 2.0 6 votes vote down vote up
@Test
public void testSkip() {
  process("{source: { content: { value: 'name,surname\nJay,Miner\nJay,Test' } }, extractor : { row: {} },"
      + " transformers: [{csv: {}}, {vertex: {class:'V'}}, {flow:{operation:'skip',if: 'name <> \'Jay\''}},{field:{fieldName:'name', value:'3'}}"
      + "], loader: { orientdb: { dbURL: 'memory:ETLBaseTest', dbType:'graph' } } }");

  assertEquals(2, graph.countVertices("V"));

  Iterator<Vertex> it = graph.getVertices().iterator();

  Vertex v1 = it.next();
  Object value1 = v1.getProperty("name");
  assertEquals("3", value1);

  Vertex v2 = it.next();
  Object value2 = v2.getProperty("name");
  assertEquals("3", value2);
}
 
Example 5
Source File: DbService.java    From light with Apache License 2.0 6 votes vote down vote up
public static long getCount(String className, Map<String, Object> criteria) {
    long count = 0;
    StringBuilder sql = new StringBuilder("SELECT COUNT(*) as count FROM ").append(className);
    String whereClause = DbService.getWhereClause(criteria);
    if(whereClause != null && whereClause.length() > 0) {
        sql.append(whereClause);
    }
    logger.debug("sql={}", sql);
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try {
        Iterable<Vertex> it =  graph.command(new OCommandSQL(sql.toString())).execute();
        if(it != null) {
            Vertex v = it.iterator().next();
            count = v.getProperty("count");
        }
    } catch (Exception e) {
        logger.error("Exception:", e);
        throw e;
    } finally {
        graph.shutdown();
    }
    return count;
}
 
Example 6
Source File: AbstractUserRule.java    From light with Apache License 2.0 5 votes vote down vote up
protected void logOut(Map<String, Object> data) throws Exception {
    String refreshToken = (String)data.get("refreshToken");
    if(refreshToken != null) {
        OrientGraph graph = ServiceLocator.getInstance().getGraph();
        try {
            graph.begin();
            Vertex user = graph.getVertexByKey("User.userId", data.get("userId"));
            if(user != null) {
                Vertex credential = user.getProperty("credential");
                if(credential != null) {
                    // now remove the refresh token
                    String clientId = (String)data.get("clientId");
                    logger.debug("logOut to remove refreshToken {} from clientId {}" , refreshToken, clientId);
                    Map clientRefreshTokens = credential.getProperty("clientRefreshTokens");
                    if(clientRefreshTokens != null) {
                        // logged in before, check if logged in from the host.
                        List<String> refreshTokens = (List)clientRefreshTokens.get(clientId);
                        if(refreshTokens != null) {
                            String hashedRefreshToken = HashUtil.md5(refreshToken);
                            refreshTokens.remove(hashedRefreshToken);
                        }
                    } else {
                        logger.error("There is no refresh tokens");
                    }
                }
            }
            graph.commit();
        } catch (Exception e) {
            logger.error("Exception:", e);
            graph.rollback();
            throw e;
        } finally {
            graph.shutdown();
        }
    } else {
        logger.debug("There is no hashedRefreshToken as user didn't pass in refresh token when logging out. Do nothing");
    }
}
 
Example 7
Source File: CurieAdder.java    From SciGraph with Apache License 2.0 5 votes vote down vote up
void addCuries(Graph graph) {
  for (Vertex vertex: graph.getVertices()) {
    String iri = (String)vertex.getProperty(CommonProperties.IRI);
    Optional<String> curie = curieUtil.getCurie(iri);
    if (curie.isPresent()) {
      vertex.setProperty(CommonProperties.CURIE, curie.get());
    }
  }
}
 
Example 8
Source File: TitanGraphDatabase.java    From graphdb-benchmarks with Apache License 2.0 5 votes vote down vote up
@Override
public Set<Integer> getNodesFromCommunity(int community)
{
    Set<Integer> nodes = new HashSet<Integer>();
    Iterable<Vertex> iter = titanGraph.getVertices(COMMUNITY, community);
    for (Vertex v : iter)
    {
        Integer nodeId = v.getProperty(NODE_ID);
        nodes.add(nodeId);
    }
    return nodes;
}
 
Example 9
Source File: TitanGraphDatabase.java    From graphdb-benchmarks with Apache License 2.0 5 votes vote down vote up
@Override
public int getCommunitySize(int community)
{
    Iterable<Vertex> vertices = titanGraph.getVertices(COMMUNITY, community);
    Set<Integer> nodeCommunities = new HashSet<Integer>();
    for (Vertex v : vertices)
    {
        int nodeCommunity = v.getProperty(NODE_COMMUNITY);
        if (!nodeCommunities.contains(nodeCommunity))
        {
            nodeCommunities.add(nodeCommunity);
        }
    }
    return nodeCommunities.size();
}
 
Example 10
Source File: DelAccessRule.java    From light with Apache License 2.0 4 votes vote down vote up
public boolean execute (Object ...objects) throws Exception {
    Map<String, Object> inputMap = (Map<String, Object>) objects[0];
    Map<String, Object> data = (Map<String, Object>) inputMap.get("data");
    Map<String, Object> user = (Map<String, Object>) inputMap.get("user");
    String rid = (String)data.get("@rid");
    int inputVersion = (int)data.get("@version");
    String ruleClass = (String)data.get("ruleClass");
    String error = null;

    if(user == null) {
        error = "Login is required";
        inputMap.put("responseCode", 401);
    } else {
        List roles = (List)user.get("roles");
        if(!roles.contains("owner") && !roles.contains("admin") && !roles.contains("ruleAdmin")) {
            error = "Role owner or admin or ruleAdmin is required to delete rule";
            inputMap.put("responseCode", 403);
        } else {
            String host = (String)user.get("host");
            if(host != null && !host.equals(data.get("host"))) {
                error = "User can only delete access control from host: " + host;
                inputMap.put("responseCode", 403);
            } else {
                // check if the access control exist or not.
                OrientGraph graph = ServiceLocator.getInstance().getGraph();
                try {
                    Vertex access = DbService.getVertexByRid(graph, rid);
                    if(access == null) {
                        error = "Access control with @rid " + rid + " cannot be found";
                        inputMap.put("responseCode", 404);
                    } else {
                        int storedVersion = access.getProperty("@version");
                        if(inputVersion != storedVersion) {
                            error = "Deleting version " + inputVersion + " doesn't match stored version " + storedVersion;
                            inputMap.put("responseCode", 400);
                        } else {
                            Map eventMap = getEventMap(inputMap);
                            Map<String, Object> eventData = (Map<String, Object>)eventMap.get("data");
                            inputMap.put("eventMap", eventMap);
                            eventData.put("ruleClass", ruleClass);
                            eventData.put("updateDate", new java.util.Date());
                            eventData.put("updateUserId", user.get("userId"));
                        }
                    }
                } catch (Exception e) {
                    logger.error("Exception:", e);
                    throw e;
                } finally {
                    graph.shutdown();
                }
            }
        }
    }

    if(error != null) {
        inputMap.put("result", error);
        return false;
    } else {
        return true;
    }
}
 
Example 11
Source File: AbstractConfigRule.java    From light with Apache License 2.0 4 votes vote down vote up
public boolean updHostConfig (Object ...objects) throws Exception {
    Map<String, Object> inputMap = (Map<String, Object>) objects[0];
    Map<String, Object> data = (Map<String, Object>) inputMap.get("data");
    String rid = (String) data.get("@rid");
    String host = (String) data.get("host");
    String configId = null;
    Map<String, Object> user = (Map<String, Object>) inputMap.get("user");
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try {
        String userHost = (String)user.get("host");
        if(userHost != null && !userHost.equals(host)) {
            inputMap.put("result", "You can only update config from host: " + host);
            inputMap.put("responseCode", 401);
            return false;
        } else {
            Vertex config = DbService.getVertexByRid(graph, rid);
            if(config != null) {
                Map eventMap = getEventMap(inputMap);
                Map<String, Object> eventData = (Map<String, Object>)eventMap.get("data");
                inputMap.put("eventMap", eventMap);
                eventData.putAll((Map<String, Object>)inputMap.get("data"));
                eventData.put("updateDate", new java.util.Date());
                eventData.put("updateUserId", user.get("userId"));
                configId = config.getProperty("configId");

                String properties = (String)data.get("properties");
                if(properties != null) {
                    Map<String, Object> map = mapper.readValue(properties,
                            new TypeReference<HashMap<String, Object>>() {
                            });
                    eventData.put("properties", map);
                }
            } else {
                inputMap.put("result",  "@rid " + rid + " cannot be found");
                inputMap.put("responseCode", 404);
                return false;
            }
        }
    } catch (Exception e) {
        logger.error("Exception:", e);
        throw e;
    } finally {
        graph.shutdown();
    }
    Map<String, Object> configMap = ServiceLocator.getInstance().getMemoryImage("configMap");
    ConcurrentMap<Object, Object> cache = (ConcurrentMap<Object, Object>)configMap.get("cache");
    if(cache != null) {
        cache.clear();
    }
    return true;
}
 
Example 12
Source File: Value.java    From org.openntf.domino with Apache License 2.0 4 votes vote down vote up
@Override
public Map getHits(final Map<CharSequence, Set<CharSequence>> filterMap) {
	Map<CharSequence, Map<CharSequence, List<CharSequence>>> result = new LinkedHashMap<CharSequence, Map<CharSequence, List<CharSequence>>>();
	Set<CharSequence> replicas = null;
	Set<CharSequence> forms = null;
	Set<CharSequence> fields = null;
	if (filterMap.containsKey(Value.REPLICA_KEY)) {
		replicas = filterMap.get(Value.REPLICA_KEY);
	}
	if (filterMap.containsKey(Value.FORM_KEY)) {
		forms = filterMap.get(Value.FORM_KEY);
	}
	if (filterMap.containsKey(Value.FIELD_KEY)) {
		fields = filterMap.get(Value.FIELD_KEY);
	}
	for (CharSequence replid : (replicas != null ? replicas : CaseInsensitiveString.toCaseInsensitive(getHitRepls()))) {
		Map<CharSequence, List<CharSequence>> fieldMap = new LinkedHashMap<CharSequence, List<CharSequence>>();
		String itemname = IndexDatabase.VALUE_MAP_PREFIX + replid;
		Vertex v = asVertex();
		Object raw = v.getProperty(itemname);
		if (raw != null && raw instanceof Map) {
			Map m = (Map) raw;
			for (Object key : (fields != null ? fields : CaseInsensitiveString.toCaseInsensitive(m.keySet()))) {
				List<CharSequence> addresses = new ArrayList<CharSequence>();
				Object raw2 = m.get(key);
				if (raw2 instanceof Collection) {
					for (Object rawline : (Collection) raw2) {
						if (rawline instanceof CharSequence) {
							String line = ((CharSequence) rawline).toString();
							CaseInsensitiveString form = new CaseInsensitiveString(line.substring(33));
							if (forms != null) {
								for (CharSequence curForm : forms) {
									if (form.equals(curForm)) {
										addresses.add(line);
										break;
									}
								}
							} else {
								addresses.add(line);
							}
						}
					}
				}
				if (!addresses.isEmpty()) {
					fieldMap.put(String.valueOf(key), addresses);
				}
			}
		}
		if (!fieldMap.isEmpty()) {
			result.put(replid, fieldMap);
		}
	}
	return result;
}
 
Example 13
Source File: VertexWrapper.java    From incubator-atlas with Apache License 2.0 4 votes vote down vote up
private String getVertexType(Vertex v) {
    return v.getProperty(Constants.ENTITY_TYPE_PROPERTY_KEY);
}
 
Example 14
Source File: RefreshTokenRule.java    From light with Apache License 2.0 4 votes vote down vote up
public boolean execute (Object ...objects) throws Exception {
    Map<String, Object> inputMap = (Map<String, Object>) objects[0];
    Map<String, Object> data = (Map<String, Object>) inputMap.get("data");
    String error = null;

    String refreshToken = (String)data.get("refreshToken");
    String userId = (String)data.get("userId");
    String clientId = (String)data.get("clientId");
    if(refreshToken == null || userId == null || clientId == null) {
        inputMap.put("responseCode", 401);
        error = "Refresh token or userId or clientId is missing";
    } else {
        OrientGraph graph = ServiceLocator.getInstance().getGraph();
        try {
            Vertex user = getUserByUserId(graph, userId);
            if(user != null) {
                Vertex credential = user.getProperty("credential");
                if (checkRefreshToken(credential, clientId, refreshToken)) {
                    // since here is using refresh token, it is always generate short term access token.
                    String jwt = generateToken(user, clientId, false);
                    if (jwt != null) {
                        Map<String, String> tokens = new HashMap<String, String>();
                        tokens.put("accessToken", jwt);
                        inputMap.put("result", mapper.writeValueAsString(tokens));
                    }
                } else {
                    error = "Invalid refresh token";
                    inputMap.put("responseCode", 400);
                }
            } else {
                error = "The userId " + userId + " has not been registered";
                inputMap.put("responseCode", 400);
            }
        } catch (Exception e) {
            logger.error("Exception:", e);
            throw e;
        } finally {
            graph.shutdown();
        }
    }
    if(error != null) {
        inputMap.put("result", error);
        return false;
    } else {
        return true;
    }
}
 
Example 15
Source File: UnlockUserRule.java    From light with Apache License 2.0 4 votes vote down vote up
public boolean execute (Object ...objects) throws Exception {
    Map<String, Object> inputMap = (Map<String, Object>) objects[0];
    Map<String, Object> data = (Map<String, Object>) inputMap.get("data");
    Map<String, Object> user = (Map<String, Object>) inputMap.get("user");
    String rid = (String) data.get("@rid");
    String error = null;
    String host = (String)user.get("host");
    if(host != null && !host.equals(data.get("host"))) {
        error = "User can only unlock user from host: " + host;
        inputMap.put("responseCode", 401);
    } else {
        OrientGraph graph = ServiceLocator.getInstance().getGraph();
        try {
            Vertex lockUser = null;
            if(rid != null) {
                lockUser = DbService.getVertexByRid(graph, rid);
                if(lockUser != null) {
                    if(lockUser.getProperty("locked") != null && !(Boolean)lockUser.getProperty("locked")) {
                        error = "User with @rid " + rid + " is not locked";
                        inputMap.put("responseCode", 400);
                    } else {
                        Map eventMap = getEventMap(inputMap);
                        Map<String, Object> eventData = (Map<String, Object>)eventMap.get("data");
                        inputMap.put("eventMap", eventMap);
                        eventData.put("userId", lockUser.getProperty("userId"));
                        eventData.put("locked", false);
                        eventData.put("updateDate", new java.util.Date());
                        eventData.put("updateUserId", user.get("userId"));
                    }
                } else {
                    error = "User with @rid " + rid + " cannot be found.";
                    inputMap.put("responseCode", 404);
                }
            } else {
                error = "@rid is required";
                inputMap.put("responseCode", 400);
            }
        } catch (Exception e) {
            logger.error("Exception:", e);
            throw e;
        } finally {
            graph.shutdown();
        }
    }
    if(error != null) {
        inputMap.put("result", error);
        return false;
    } else {
        return true;
    }
}
 
Example 16
Source File: AddDependencyRule.java    From light with Apache License 2.0 4 votes vote down vote up
public boolean execute (Object ...objects) throws Exception {
    Map<String, Object> inputMap = (Map<String, Object>)objects[0];
    Map<String, Object> data = (Map<String, Object>)inputMap.get("data");
    String host = (String)data.get("host");
    String source = (String)data.get("source");
    String dest = (String)data.get("desc");
    String error = null;
    Map<String, Object> user = (Map<String, Object>) inputMap.get("user");
    String userHost = (String)user.get("host");
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try {
        Vertex sourceRule = DbService.getVertexByRid(graph, source);
        Vertex destRule = DbService.getVertexByRid(graph, dest);
        if(sourceRule == null || destRule == null) {
            error = "source rule or destination rule doesn't exist";
            inputMap.put("responseCode", 400);
        } else {
            String sourceRuleClass = sourceRule.getProperty("ruleClass");
            String destRuleClass = destRule.getProperty("ruleClass");
            if(userHost != null) {
                if (!userHost.equals(host)) {
                    error = "You can only add dependency from host: " + host;
                    inputMap.put("responseCode", 403);
                } else {
                    // make sure dest ruleClass contains host.
                    if(!destRuleClass.contains(host)) {
                        error = "Destination rule doesn't belong to the host " + host;
                        inputMap.put("responseCode", 403);
                    } else {
                        // check if there is an depend edge from source to dest
                        boolean hasEdge = false;
                        for (Edge edge : (Iterable<Edge>) sourceRule.getEdges(Direction.OUT, "Own")) {
                            if(edge.getVertex(Direction.IN) == destRule) hasEdge = true;
                        }
                        if(hasEdge) {
                            error = "There is depend edge between source rule and dest rule";
                            inputMap.put("responseCode", 400);
                        } else {
                            Map eventMap = getEventMap(inputMap);
                            Map<String, Object> eventData = (Map<String, Object>)eventMap.get("data");
                            inputMap.put("eventMap", eventMap);
                            eventData.put("sourceRuleClass", sourceRuleClass);
                            eventData.put("destRuleClass", destRuleClass);
                            eventData.put("content", data.get("content"));
                            eventData.put("createDate", new java.util.Date());
                            eventData.put("createUserId", user.get("userId"));
                        }
                    }
                }
            }

        }
    } catch (Exception e) {
        logger.error("Exception:", e);
        throw e;
    } finally {
        graph.shutdown();
    }
    if(error != null) {
        inputMap.put("result", error);
        return false;
    } else {
        return true;
    }
}
 
Example 17
Source File: LockUserRule.java    From light with Apache License 2.0 4 votes vote down vote up
public boolean execute (Object ...objects) throws Exception {
    Map<String, Object> inputMap = (Map<String, Object>) objects[0];
    Map<String, Object> data = (Map<String, Object>) inputMap.get("data");
    Map<String, Object> user = (Map<String, Object>) inputMap.get("user");
    String rid = (String) data.get("@rid");
    String error = null;
    String host = (String)user.get("host");
    if(host != null && !host.equals(data.get("host"))) {
        error = "User can only lock user from host: " + host;
        inputMap.put("responseCode", 401);
    } else {
        OrientGraph graph = ServiceLocator.getInstance().getGraph();
        try {
            Vertex lockUser = null;
            if(rid != null) {
                lockUser = DbService.getVertexByRid(graph, rid);
                if(lockUser != null) {
                    if(lockUser.getProperty("locked") != null && (Boolean)lockUser.getProperty("locked")) {
                        error = "User with @rid " + rid + " has been locked already";
                        inputMap.put("responseCode", 400);
                    } else {
                        Map eventMap = getEventMap(inputMap);
                        Map<String, Object> eventData = (Map<String, Object>)eventMap.get("data");
                        inputMap.put("eventMap", eventMap);
                        eventData.put("userId", lockUser.getProperty("userId"));
                        eventData.put("locked", true);
                        eventData.put("updateDate", new java.util.Date());
                        eventData.put("updateUserId", user.get("userId"));
                    }
                } else {
                    error = "User with @rid " + rid + " cannot be found.";
                    inputMap.put("responseCode", 404);
                }
            } else {
                error = "@rid is required";
                inputMap.put("responseCode", 400);
            }
        } catch (Exception e) {
            logger.error("Exception:", e);
            throw e;
        } finally {
            graph.shutdown();
        }
    }
    if(error != null) {
        inputMap.put("result", error);
        return false;
    } else {
        return true;
    }
}
 
Example 18
Source File: AbstractConfigRule.java    From light with Apache License 2.0 4 votes vote down vote up
public boolean delHostConfig(Object ...objects) throws Exception {
    Map<String, Object> inputMap = (Map<String, Object>) objects[0];
    Map<String, Object> data = (Map<String, Object>) inputMap.get("data");
    String rid = (String) data.get("@rid");
    String host = (String) data.get("host");
    String configId = null;
    String error = null;
    Map<String, Object> user = (Map<String, Object>) inputMap.get("user");
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try {
        String userHost = (String)user.get("host");
        if(userHost != null && !userHost.equals(host)) {
            error = "You can only delete config from host: " + host;
            inputMap.put("responseCode", 401);
        } else {
            Vertex config = DbService.getVertexByRid(graph, rid);
            if(config != null) {
                Map eventMap = getEventMap(inputMap);
                Map<String, Object> eventData = (Map<String, Object>)eventMap.get("data");
                inputMap.put("eventMap", eventMap);
                eventData.put("host", host);
                configId = config.getProperty("configId");
                eventData.put("configId", configId);
            } else {
                error = "@rid " + rid + " doesn't exist on host " + host;
                inputMap.put("responseCode", 404);
            }
        }
    } catch (Exception e) {
        logger.error("Exception:", e);
        throw e;
    } finally {
        graph.shutdown();
    }
    if(error != null) {
        inputMap.put("result", error);
        return false;
    } else {
        // update the branch tree as one of branch has changed.
        Map<String, Object> configMap = ServiceLocator.getInstance().getMemoryImage("configMap");
        ConcurrentMap<Object, Object> cache = (ConcurrentMap<Object, Object>)configMap.get("cache");
        if(cache != null) {
            cache.clear();
        }
        return true;
    }
}
 
Example 19
Source File: DelPageRule.java    From light with Apache License 2.0 4 votes vote down vote up
public boolean execute (Object ...objects) throws Exception {
    Map<String, Object> inputMap = (Map<String, Object>)objects[0];
    HttpServerExchange exchange = (HttpServerExchange)inputMap.get("exchange");
    Map<String, Object> data = (Map<String, Object>)inputMap.get("data");
    Map<String, Object> user = (Map<String, Object>) inputMap.get("user");
    String rid = (String) data.get("@rid");
    String host = (String) data.get("host");
    String error = null;
    String userHost = (String)user.get("host");
    if(userHost != null && !userHost.equals(host)) {
        error = "You can only delete page from host: " + host;
        inputMap.put("responseCode", 403);
    } else {
        OrientGraph graph = ServiceLocator.getInstance().getGraph();
        try {
            Vertex page = DbService.getVertexByRid(graph, rid);
            if(page != null) {
                int inputVersion = (int)data.get("@version");
                int storedVersion = page.getProperty("@version");
                if(inputVersion != storedVersion) {
                    inputMap.put("responseCode", 400);
                    error = "Deleting version " + inputVersion + " doesn't match stored version " + storedVersion;
                } else {
                    Map eventMap = getEventMap(inputMap);
                    Map<String, Object> eventData = (Map<String, Object>)eventMap.get("data");
                    inputMap.put("eventMap", eventMap);
                    eventData.put("pageId", page.getProperty("pageId"));
                }
            } else {
                error = "Page with @rid " + rid + " doesn't exist";
                inputMap.put("responseCode", 400);
            }
        } catch (Exception e) {
            logger.error("Exception:", e);
            throw e;
        } finally {
            graph.shutdown();
        }
    }
    if(error != null) {
        inputMap.put("result", error);
        return false;
    } else {
        return true;
    }
}
 
Example 20
Source File: DEdge.java    From org.openntf.domino with Apache License 2.0 4 votes vote down vote up
@Override
public Object getOtherVertexProperty(final Vertex vertex, final String property) {
	Vertex other = getOtherVertex(vertex);
	return other.getProperty(property);
}