/** * Get an optional string associated with a key. * It returns an empty string if there is no such key. If the value is not * a string and is not null, then it is coverted to a string. * * @param key A key string. * @return A string which is the value. */ public String optString(String key) { return optString(key, ""); }
/** * Get an optional string associated with a key. * It returns an empty string if there is no such key. If the value is not * a string and is not null, then it is coverted to a string. * * @param key A key string. * @return A string which is the value. */ public String optString(String key) { return optString(key, ""); }
private static Map<String,String> convertToMap(final JSONObject config) { final Map<String,String> m = new HashMap<String, String>(); if (config != null) { final Iterator itty = config.keys(); while (itty.hasNext()) { final String currentKey = itty.next().toString(); m.put(currentKey, config.optString(currentKey)); } } return m; } }
@Override public String getDisplayName() { String displayName = json.optString("displayName", null); return displayName == null ? getName() : displayName; } }
protected RexsterEdge(final JSONObject rawEdge, final RexsterGraph graph) { super(rawEdge, graph); this.label = rawEdge.optString(RexsterTokens._LABEL); this.outVertex = rawEdge.opt(RexsterTokens._OUTV); this.inVertex = rawEdge.opt(RexsterTokens._INV); }
public <T extends Element> Index<T> createIndex(final String indexName, final Class<T> indexClass, final Parameter... indexParameters) { final String c = getKeyIndexClass(indexClass); final Map<String, Object> data = new HashMap<String, Object>(); data.put(RexsterTokens.CLASS, c); final JSONObject json = new JSONObject(data); final JSONObject index = RestHelper.postResultObject(this.graphURI + RexsterTokens.SLASH_INDICES_SLASH + RestHelper.encode(indexName), json); if (!index.opt(RexsterTokens.NAME).equals(indexName)) throw new RuntimeException("Could not create index: " + index.optString(RexsterTokens.MESSAGE)); return new RexsterIndex<T>(this, indexName, indexClass); }
@Test(dependsOnMethods = { "configuration" }) public void testGenerateKeyES256() { try { JSONObject response = cryptoProvider.generateKey(SignatureAlgorithm.ES256, expirationTime); es256Key = response.optString(KEY_ID); } catch (Exception e) { fail(e.getMessage(), e); } }
@Test(dependsOnMethods = { "configuration" }) public void testGenerateKeyRS256() { try { JSONObject response = cryptoProvider.generateKey(SignatureAlgorithm.RS256, expirationTime); rs256Key = response.optString(KEY_ID); } catch (Exception e) { fail(e.getMessage(), e); } }
@Test(dependsOnMethods = { "configuration" }) public void testGenerateKeyRS384() { try { JSONObject response = cryptoProvider.generateKey(SignatureAlgorithm.RS384, expirationTime); rs384Key = response.optString(KEY_ID); } catch (Exception e) { fail(e.getMessage(), e); } }
@Test(dependsOnMethods = { "configuration" }) public void testGenerateKeyRS512() { try { JSONObject response = cryptoProvider.generateKey(SignatureAlgorithm.RS512, expirationTime); rs512Key = response.optString(KEY_ID); } catch (Exception e) { fail(e.getMessage(), e); } }
@Test(dependsOnMethods = { "configuration" }) public void testGenerateKeyES512() { try { JSONObject response = cryptoProvider.generateKey(SignatureAlgorithm.ES512, expirationTime); es512Key = response.optString(KEY_ID); } catch (Exception e) { fail(e.getMessage(), e); } }
@Test(dependsOnMethods = { "configuration" }) public void testGenerateKeyES384() { try { JSONObject response = cryptoProvider.generateKey(SignatureAlgorithm.ES384, expirationTime); es384Key = response.optString(KEY_ID); } catch (Exception e) { fail(e.getMessage(), e); } }
private String createOpportunityInSalesForce(String accessToken, Opportunity opportunity) { LOGGER.info("About to create opportunity in SalesForce"); WebResource resource = createObjectsResource("/Opportunity/"); JSONObject opportunityJson = salesForceAdapter.createSaleForceRecordFromOpportunity(opportunity); ClientResponse response = doPostRequest(resource, opportunityJson, accessToken); checkAuthorization(response); JSONObject result = checkResponse(response, 201, "Error creating opportunity in SalesForce"); return result.optString("id"); }
private String createOrgIdInSalesForce(String accessToken, OrgId orgId) { LOGGER.info("About to create org id in SalesForce"); WebResource resource = createObjectsResource("/Organization_Identifier__c/"); JSONObject opportunityJson = salesForceAdapter.createSaleForceRecordFromOrgId(orgId); ClientResponse response = doPostRequest(resource, opportunityJson, accessToken); checkAuthorization(response); JSONObject result = checkResponse(response, 201, "Error creating org id in SalesForce"); return result.optString("id"); }
private String createMemberInSalesForce(String accessToken, Member member) { LOGGER.info("About to create member in SalesForce"); WebResource resource = createObjectsResource("/Account/"); JSONObject memberJson = salesForceAdapter.createSaleForceRecordFromMember(member); ClientResponse response = doPostRequest(resource, memberJson, accessToken); checkAuthorization(response); JSONObject result = checkResponse(response, 201, "Error creating member in SalesForce"); return result.optString("id"); }
public static List<DataDependencyEvent> parseDataEventDependencyFromJSON(JSONObject jsonObject) throws JSONException { List<DataDependencyEvent> events = Lists.newArrayList(); JSONArray fields = jsonObject.optJSONArray(Constants.LAST_DATA_EVENTS); for (int i=0; i<fields.length(); i++) { JSONObject eventMap = fields.getJSONObject(i); events.add(new DataDependencyEvent( StringInterner.weakIntern(eventMap.optString(EntityTypes.TEZ_TASK_ATTEMPT_ID.name())), eventMap.optLong(Constants.TIMESTAMP))); } return events; }
private String createContactInSalesForce(String accessToken, Contact contact) { LOGGER.info("About to create contact in SalesForce"); String accountId = contact.getAccountId(); validateSalesForceId(accountId); WebResource resource = createObjectsResource("/Contact/"); JSONObject contactJson = salesForceAdapter.createSaleForceRecordFromContact(contact); ClientResponse response = doPostRequest(resource, contactJson, accessToken); checkAuthorization(response); JSONObject result = checkResponse(response, 201, "Error creating contact in SalesForce"); return result.optString("id"); }
private String createContactRoleInSalesForce(String accessToken, ContactRole contactRole) { LOGGER.info("About to create contact role in SalesForce"); validateSalesForceId(contactRole.getAccountId()); validateSalesForceId(contactRole.getContactId()); WebResource resource = createObjectsResource("/Membership_Contact_Role__c/"); JSONObject contactJson = salesForceAdapter.createSaleForceRecordFromContactRole(contactRole); ClientResponse response = doPostRequest(resource, contactJson, accessToken); checkAuthorization(response); JSONObject result = checkResponse(response, 201, "Error creating contact role in SalesForce"); return result.optString("id"); }
private String createOpportunityContactRoleInSalesForce(String accessToken, OpportunityContactRole contactRole) { LOGGER.info("About to create opportunity contact role in SalesForce"); validateSalesForceId(contactRole.getOpportunityId()); validateSalesForceId(contactRole.getContactId()); WebResource resource = createObjectsResource("/OpportunityContactRole/"); JSONObject contactJson = salesForceAdapter.createSaleForceRecordFromOpportunityContactRole(contactRole); ClientResponse response = doPostRequest(resource, contactJson, accessToken); checkAuthorization(response); JSONObject result = checkResponse(response, 201, "Error creating opportunity contact role in SalesForce"); return result.optString("id"); }
public <T> T getProperty(final String key) { JSONObject rawElement; if (this instanceof Vertex) rawElement = RestHelper.getResultObject(this.graph.getGraphURI() + RexsterTokens.SLASH_VERTICES_SLASH + RestHelper.encode(this.getId()) + RexsterTokens.QUESTION + RexsterTokens.REXSTER_SHOW_TYPES_EQUALS_TRUE); else rawElement = RestHelper.getResultObject(this.graph.getGraphURI() + RexsterTokens.SLASH_EDGES_SLASH + RestHelper.encode(this.getId()) + RexsterTokens.QUESTION + RexsterTokens.REXSTER_SHOW_TYPES_EQUALS_TRUE); JSONObject typedProperty = rawElement.optJSONObject(key); if (null != typedProperty) return (T) RestHelper.typeCast(typedProperty.optString(RexsterTokens.TYPE), typedProperty.opt(RexsterTokens.VALUE)); else return null; }