Java Code Examples for org.json.simple.JSONObject#get()

The following examples show how to use org.json.simple.JSONObject#get() . 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: UtilsStaticAnalyzer.java    From apogen with Apache License 2.0 7 votes vote down vote up
/**
 * sets the Edge objects of a class with the information retrieved in the
 * result.json file
 * 
 * @param state
 * @param edges
 * @param s
 */
private static void setConnections(Object state, JSONArray edges, State s) {

	for (int j = 0; j < edges.size(); j++) {
		JSONObject connection = (JSONObject) edges.get(j);

		if (connection.get("from").equals((String) state)) {
			Edge e = new Edge((String) connection.get("from"), (String) connection.get("to"));

			e.setVia((String) connection.get("id"));
			e.setEvent((String) (String) connection.get("eventType"));

			s.addConnection(e);
		}
	}

}
 
Example 2
Source File: ProductService.java    From singleton with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public DropVersionDTO getVersionInfo(String productName, String version)
		throws L3APIException {
	DropVersionDTO versioninfo = new DropVersionDTO();
	String jsonStr;
	try {
		jsonStr = productdao.getVersionInfo(productName, version);
	} catch (DataException e) {
		throw new L3APIException("Failed to get drop version info for " + productName
				+ ConstantsChar.BACKSLASH + version, e);
	}
	JSONObject jo = JSONUtils.string2JSON(jsonStr);
	String dropId = jo.get(ConstantsKeys.DROP_ID) == null ? ""
			: (String) jo.get(ConstantsKeys.DROP_ID);
	versioninfo.setDropId(dropId);
	return getDropVersion( versioninfo, jo, version);
}
 
Example 3
Source File: Performance.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 6 votes vote down vote up
/**
    * parse and map the pages and its page timings
    *
    * @param data json data
    * @return json map
    */
  
private static JSONObject getPageMap(String data) {
       JSONObject pageMap = new JSONObject();
       JSONObject ob = (JSONObject) JSONValue.parse(data);
       for (Object tc : ob.keySet()) {
           JSONArray hars = (JSONArray) ((JSONObject) ob.get(tc)).get("har");
           for (Object e : hars) {
               JSONObject har = (JSONObject) ((JSONObject) e).get("har");
               JSONObject page = (JSONObject) ((JSONArray) (((JSONObject) har.get("log")).get("pages"))).get(0);
               Object pagename = ((JSONObject) har.get("config")).get("name");
               if (!pageMap.containsKey(pagename)) {
                   pageMap.put(pagename, new JSONArray());
               }
               JSONObject pageData = (JSONObject) page.get("pageTimings");
               pageData.put("config", har.get("config"));
               ((JSONArray) pageMap.get(pagename)).add(pageData);
           }
       }
       return pageMap;
   }
 
Example 4
Source File: NodeJsDataProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public String getDocForModule(final String moduleName) {
    Object jsonValue;
    JSONArray modules = getModules();
    if (modules != null) {
        for (int i = 0; i < modules.size(); i++) {
            jsonValue = modules.get(i);
            if (jsonValue != null && jsonValue instanceof JSONObject) {
                JSONObject jsonModule = (JSONObject) jsonValue;
                jsonValue = jsonModule.get(NAME);
                if (jsonValue != null && jsonValue instanceof String && moduleName.equals(((String) jsonValue).toLowerCase())) {
                    jsonValue = jsonModule.get(DESCRIPTION);
                    if (jsonValue != null && jsonValue instanceof String) {
                        return (String) jsonValue;
                    }
                }
            }
        }
    }
    return null;
}
 
Example 5
Source File: DiscordClient.java    From Discord4J with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Attempts to get the id of a game based on its name
 * 
 * @param gameName The game name (nullable!)
 * @return The game id, the Optional will be empty if the game couldn't be found
 */
public Optional<Long> getGameIDByGame(String gameName) {
    if (gameName == null || gameName.isEmpty() || gameName.equals("null"))
        return Optional.empty();

    for (Object object : games) {
        if (!(object instanceof JSONObject))
            continue;
    
        JSONObject jsonObject = (JSONObject)object;
        String name = (String) jsonObject.get("name");
        if (name != null) {
            if (name.equalsIgnoreCase(gameName))
                return Optional.ofNullable((Long) jsonObject.get("id"));
        }
    }

    return Optional.empty();
}
 
Example 6
Source File: APIMappingUtil.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a DTO consisting a single conversion policy
 *
 * @param conversionPolicyStr conversion policy string
 * @return ConversionPolicyInfoDTO consisting given conversion policy string
 * @throws APIManagementException
 */
public static ResourcePolicyInfoDTO fromResourcePolicyStrToInfoDTO(String conversionPolicyStr)
        throws APIManagementException {
    ResourcePolicyInfoDTO policyInfoDTO = new ResourcePolicyInfoDTO();
    if (StringUtils.isNotEmpty(conversionPolicyStr)) {
        try {
            JSONObject conversionPolicyObj = (JSONObject) new JSONParser().parse(conversionPolicyStr);
            for (Object key : conversionPolicyObj.keySet()) {
                JSONObject policyInfo = (JSONObject) conversionPolicyObj.get(key);
                String keyStr = ((String) key);
                policyInfoDTO.setId(policyInfo.get(RestApiConstants.SEQUENCE_ARTIFACT_ID).toString());
                policyInfoDTO.setHttpVerb(policyInfo.get(RestApiConstants.HTTP_METHOD).toString());
                policyInfoDTO.setResourcePath(keyStr.substring(0, keyStr.lastIndexOf("_")));
                policyInfoDTO.setContent(policyInfo.get(RestApiConstants.SEQUENCE_CONTENT).toString());
            }
        } catch (ParseException e) {
            throw new APIManagementException("Couldn't parse the conversion policy string.", e);
        }
    }
    return policyInfoDTO;
}
 
Example 7
Source File: CacheUtil.java    From singleton with Eclipse Public License 2.0 5 votes vote down vote up
public static void cacheSessionAndToken(WebApplicationContext webApplicationContext,String authenticationResult) {
    JSONObject jsonObj=JSONUtils.string2JSON(authenticationResult);
    String sessionID=(String) jsonObj.get("sessionID");
    String token=(String) jsonObj.get("token");
    MockServletContext application = (MockServletContext) webApplicationContext.getServletContext();
    application.setAttribute("sessionID", sessionID);
    application.setAttribute("token", token);
}
 
Example 8
Source File: HttpLogClient.java    From certificate-transparency-java with Apache License 2.0 5 votes vote down vote up
/**
 * Parses the CT Log's json response into a proper proto.
 *
 * @param responseBody Response string to parse.
 * @return SCT filled from the JSON input.
 */
static Ct.SignedCertificateTimestamp parseServerResponse(String responseBody) {
  if (responseBody == null) {
    return null;
  }

  JSONObject parsedResponse = (JSONObject) JSONValue.parse(responseBody);
  Ct.SignedCertificateTimestamp.Builder builder = Ct.SignedCertificateTimestamp.newBuilder();

  int numericVersion = ((Number) parsedResponse.get("sct_version")).intValue();
  Ct.Version version = Ct.Version.valueOf(numericVersion);
  if (version == null) {
    throw new IllegalArgumentException(
        String.format("Input JSON has an invalid version: %d", numericVersion));
  }
  builder.setVersion(version);
  Ct.LogID.Builder logIdBuilder = Ct.LogID.newBuilder();
  logIdBuilder.setKeyId(
      ByteString.copyFrom(Base64.decodeBase64((String) parsedResponse.get("id"))));
  builder.setId(logIdBuilder.build());
  builder.setTimestamp(((Number) parsedResponse.get("timestamp")).longValue());
  String extensions = (String) parsedResponse.get("extensions");
  if (!extensions.isEmpty()) {
    builder.setExtensions(ByteString.copyFrom(Base64.decodeBase64(extensions)));
  }

  String base64Signature = (String) parsedResponse.get("signature");
  builder.setSignature(
      Deserializer.parseDigitallySignedFromBinary(
          new ByteArrayInputStream(Base64.decodeBase64(base64Signature))));
  return builder.build();
}
 
Example 9
Source File: JSONDeviceSceneSpecImpl.java    From openhab1-addons with Eclipse Public License 2.0 5 votes vote down vote up
public JSONDeviceSceneSpecImpl(JSONObject jObject) {
    if (jObject.get(JSONApiResponseKeysEnum.DEVICE_GET_SCENE_MODE_SCENE_ID.getKey()) != null) {
        int val = -1;
        try {
            val = Integer.parseInt(
                    jObject.get(JSONApiResponseKeysEnum.DEVICE_GET_SCENE_MODE_SCENE_ID.getKey()).toString());
        } catch (java.lang.NumberFormatException e) {
            logger.error("NumberFormatException by getting sceneID: "
                    + jObject.get(JSONApiResponseKeysEnum.DEVICE_GET_SCENE_MODE_SCENE_ID.getKey()).toString());
        }

        if (val > -1) {
            this.scene = SceneEnum.getScene(val);
        }
    }

    if (jObject.get(JSONApiResponseKeysEnum.DEVICE_GET_SCENE_MODE_DONT_CARE.getKey()) != null) {
        this.dontcare = jObject.get(JSONApiResponseKeysEnum.DEVICE_GET_SCENE_MODE_DONT_CARE.getKey()).toString()
                .equals("true");
    }

    if (jObject.get(JSONApiResponseKeysEnum.DEVICE_GET_SCENE_MODE_LOCAL_PRIO.getKey()) != null) {
        this.localPrio = jObject.get(JSONApiResponseKeysEnum.DEVICE_GET_SCENE_MODE_LOCAL_PRIO.getKey()).toString()
                .equals("true");
    }

    if (jObject.get(JSONApiResponseKeysEnum.DEVICE_GET_SCENE_MODE_SPECIAL_MODE.getKey()) != null) {
        this.specialMode = jObject.get(JSONApiResponseKeysEnum.DEVICE_GET_SCENE_MODE_SPECIAL_MODE.getKey())
                .toString().equals("true");
    }

    if (jObject.get(JSONApiResponseKeysEnum.DEVICE_GET_SCENE_MODE_FLASH_MODE.getKey()) != null) {
        this.flashMode = jObject.get(JSONApiResponseKeysEnum.DEVICE_GET_SCENE_MODE_FLASH_MODE.getKey()).toString()
                .equals("true");
    }
}
 
Example 10
Source File: TextClickerPybossaFormatter.java    From AIDR with GNU Affero General Public License v3.0 5 votes vote down vote up
private void handleTranslationItem(Long taskQueueID,String answer, JSONObject info, ClientAppAnswer clientAppAnswer, int cutOffSize){

        try{
            String tweetID = String.valueOf(info.get("tweetid"));
            String tweet = (String)info.get("tweet");
            if(tweet == null){
                tweet = (String)info.get("text");
            }
            String author= (String)info.get("author");
            String lat= (String)info.get("lat");
            String lng= (String)info.get("lon");
            String url= (String)info.get("url");
            String created = (String)info.get("timestamp");

            Long taskID;
            if(info.get("taskid") == null){
                taskID =  taskQueueID;
            }
            else{
                taskID = (Long)info.get("taskid");
            }


            if(taskQueueID!=null && taskID!=null && tweetID!=null && (tweet!=null && !tweet.isEmpty())) {
                System.out.println("handleTranslationItem :" + taskQueueID);
                this.setTranslateRequired(true);
                createTaskTranslation(taskID, tweetID, tweet, author, lat, lng, url, taskQueueID, created, clientAppAnswer);

            }
        }
        catch(Exception e){
            System.out.println("handleTranslationItem- exception :" + e.getMessage());
            this.setTranslateRequired(false);
        }

    }
 
Example 11
Source File: CacheUtil.java    From singleton with Eclipse Public License 2.0 5 votes vote down vote up
public static void cacheSessionAndToken(WebApplicationContext webApplicationContext,String authenticationResult) {
    JSONObject jsonObj=JSONUtils.string2JSON(authenticationResult);
    String sessionID=(String) jsonObj.get("sessionID");
    String token=(String) jsonObj.get("token");
    MockServletContext application = (MockServletContext) webApplicationContext.getServletContext();
    application.setAttribute("sessionID", sessionID);
    application.setAttribute("token", token);
}
 
Example 12
Source File: Role.java    From io with Apache License 2.0 5 votes vote down vote up
/**
 * This method is use to initialize various class variables and parent class variables.
 * @param as Accessor
 * @param json JSONObject
 */
public void initialize(Accessor as, JSONObject json) {
    super.initialize(as);
    if (json != null) {
        rawData = json;
        name = (String) json.get("Name");
        boxname = (String) json.get("_Box.Name");
    }
    this.account = new ODataLinkManager(as, this);
    this.relation = new ODataLinkManager(as, this);
    this.extCell = new ODataLinkManager(as, this);
    this.extRole = new ODataLinkManager(as, this);
}
 
Example 13
Source File: FileOpenSaveDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void setProperties( Object[] arguments ) throws ParseException {
  if ( arguments.length == 1 ) {
    String jsonString = (String) arguments[ 0 ];
    JSONParser jsonParser = new JSONParser();
    JSONObject jsonObject = (JSONObject) jsonParser.parse( jsonString );
    objectId = (String) jsonObject.get( OBJECT_ID_PARAM );
    name = (String) jsonObject.get( NAME_PARAM );
    path = (String) jsonObject.get( PATH_PARAM );
    parentPath = (String) jsonObject.get( PARENT_PARAM );
    connection = (String) jsonObject.get( CONNECTION_PARAM );
    provider = (String) jsonObject.get( PROVIDER_PARAM );
    type = (String) jsonObject.get( TYPE_PARAM );
  }
}
 
Example 14
Source File: LUISGrammarEvaluator.java    From JVoiceXML with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Parse the response from LUIS.
 * @param model the current datamodel
 * @param input the input stream to the response entity
 * @return parsed semantic interpretation
 * @throws IOException parsing error
 * @throws ParseException parsing error
 * @throws SemanticError error evaluating the result in the datamodel
 */
private Object parseLUISResponse(final DataModel model,
        final InputStream input)
        throws IOException, ParseException, SemanticError {
    final InputStreamReader reader = new InputStreamReader(input);
    final JSONParser parser = new JSONParser();
    final JSONObject object = (JSONObject) parser.parse(reader);
    final JSONObject topScoringIntent = 
            (JSONObject) object.get("topScoringIntent");
    final DataModel interpretationModel = model.newInstance();
    interpretationModel.createScope();
    interpretationModel.createVariable("out", model.createNewObject());
    Object out =  interpretationModel.readVariable("out", Object.class);
    final String intent = (String) topScoringIntent.get("intent");
    final Double score = (Double) topScoringIntent.get("score");
    LOGGER.info("detected intent '" + intent + "' (" + score + ")");
    interpretationModel.createVariableFor(out, "nlu-intent", intent);
    interpretationModel.createVariableFor(out, intent,
            model.createNewObject());
    final Object intentObject = interpretationModel.readVariable(
            "out." + intent, Object.class);
    final JSONArray entities = (JSONArray) object.get("entities");
    if (entities.isEmpty()) {
        return intent;
    }
    for (int i = 0; i < entities.size(); i++) {
        final JSONObject currentEntity = (JSONObject) entities.get(i);
        final String type = (String) currentEntity.get("type");
        final String value = (String) currentEntity.get("entity");
        final Double entityScore = (Double) currentEntity.get("score");
        LOGGER.info("detected entity '" + type + "'='" + value + "' ("
                + entityScore + ")");
        interpretationModel.createVariableFor(intentObject, type, value);
    }

    final Object interpretation =
            interpretationModel.readVariable("out", Object.class);
    final String log = interpretationModel.toString(interpretation);
    LOGGER.info("created semantic interpretation '" + log + "'");
    return interpretation;
}
 
Example 15
Source File: DRequirements.java    From SeaCloudsPlatform with Apache License 2.0 4 votes vote down vote up
private String parseString(JSONObject jnode, String key) {
    Object value = jnode.get(key);
    
    String result = (value == null)? "" : value.toString();
    return result;
}
 
Example 16
Source File: AclTest.java    From io with Apache License 2.0 4 votes vote down vote up
/**
 * BoxレベルACL設定Principalのallとroleの同時設定確認テスト.
 */
@Test
public final void BoxレベルACL設定Principalのallとroleの同時設定確認テスト() {
    try {
        // Principal:all Privilege:read
        // Principal:role1 Privilege:write
        // のACLをbox1に設定
        setAclAllandRole(TEST_CELL1, TOKEN, HttpStatus.SC_OK, TEST_CELL1 + "/" + BOX_NAME,
                "box/acl-setting-all-role.txt", "role1", "<D:read/>", "<D:write/>", "");

        // PROPFINDでACLの確認
        CellUtils.propfind(TEST_CELL1 + "/" + BOX_NAME,
                TOKEN, DEPTH, HttpStatus.SC_MULTI_STATUS);

        // account1でbox1を操作
        // 認証
        JSONObject json = ResourceUtils.getLocalTokenByPassAuth(TEST_CELL1, "account1", "password1", -1);
        // トークン取得
        String tokenStr = (String) json.get(OAuth2Helper.Key.ACCESS_TOKEN);

        // Box1に対してGET(可能)
        ResourceUtils.accessResource("", tokenStr, HttpStatus.SC_OK, Setup.TEST_BOX1, TEST_CELL1);
        // トークン空でもbox1に対してGET(可能)
        ResourceUtils.accessResource("", "", HttpStatus.SC_OK, Setup.TEST_BOX1, TEST_CELL1);
        // AuthorizationHedderが無しでもbox1に対してGET(可能)
        ResourceUtils.accessResourceNoAuth("", HttpStatus.SC_OK, TEST_CELL1);

        // Box1に対してPUT(可能)
        DavResourceUtils.createWebDavFile(Setup.TEST_CELL1, tokenStr, "box/dav-put.txt", "hoge", Setup.TEST_BOX1,
                "text.txt", HttpStatus.SC_CREATED);
        // トークン空でもbox1に対してPUT(不可:認証エラー)
        DavResourceUtils.createWebDavFile(Setup.TEST_CELL1, "", "box/dav-put.txt", "hoge", Setup.TEST_BOX1,
                "text.txt", HttpStatus.SC_UNAUTHORIZED);
        // AuthorizationHedderが無しでもbox1に対してPUT(不可:認証エラー)
        DavResourceUtils.createWebDavFileNoAuthHeader(Setup.TEST_CELL1, "box/dav-put.txt", "hoge", Setup.TEST_BOX1,
                "text.txt", HttpStatus.SC_UNAUTHORIZED);
    } finally {
        // コレクションの削除
        DavResourceUtils.deleteWebDavFile("box/dav-delete.txt", Setup.TEST_CELL1, TOKEN,
                "text.txt", -1, Setup.TEST_BOX1);

        // ACLの設定を元に戻す
        Http.request("box/acl-authtest.txt")
                .with("cellPath", TEST_CELL1)
                .with("colname", "")
                .with("roleBaseUrl", UrlUtils.roleResource(TEST_CELL1, null, ""))
                .with("token", AbstractCase.MASTER_TOKEN_NAME)
                .with("level", "")
                .returns()
                .statusCode(HttpStatus.SC_OK);
    }
}
 
Example 17
Source File: CKANBackendImpl.java    From fiware-cygnus with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void expirateRecordsCache(long expirationTime) throws CygnusRuntimeError, CygnusPersistenceError {
    // Iterate on the cached resource IDs
    cache.startResIterator();
    
    while (cache.hasNextRes()) {
        // Get the next resource ID
        String resId = cache.getNextResId();
        
        // Create the filters for a datastore deletion
        String filters = "";

        // Get the record pages, some variables
        int offset = 0;
        boolean morePages = true;

        do {
            // Get the records within the current page
            JSONObject result = (JSONObject) getRecords(resId, null, offset, RECORDSPERPAGE).get("result");
            JSONArray records = (JSONArray) result.get("records");

            try {
                for (Object recordObj : records) {
                    JSONObject record = (JSONObject) recordObj;
                    long id = (Long) record.get("_id");
                    String recvTime = (String) record.get("recvTime");
                    long recordTime = CommonUtils.getMilliseconds(recvTime);
                    long currentTime = new Date().getTime();

                    if (recordTime < (currentTime - (expirationTime * 1000))) {
                        if (filters.isEmpty()) {
                            filters += "{\"_id\":[" + id;
                        } else {
                            filters += "," + id;
                        } // if else
                    } else {
                        // Since records are sorted by _id, once the first not expirated record is found the loop
                        // can finish
                        morePages = false;
                        break;
                    } // if else
                } // for
            } catch (ParseException e) {
                throw new CygnusRuntimeError("Data expiration error", "ParseException", e.getMessage());
            } // try catch

            if (records.isEmpty()) {
                morePages = false;
            } else {
                offset += RECORDSPERPAGE;
            } // if else
        } while (morePages);
        
        if (filters.isEmpty()) {
            LOGGER.debug("No records to be deleted");
        } else {
            filters += "]}";
            LOGGER.debug("Records to be deleted, resId=" + resId + ", filters=" + filters);
            deleteRecords(resId, filters);
        } // if else
    } // while
}
 
Example 18
Source File: Updater.java    From ServerTutorial with MIT License 4 votes vote down vote up
/**
 * Make a connection to the BukkitDev API and request the newest file's details.
 *
 * @return true if successful.
 */
private boolean read() {
    try {
        final URLConnection conn = this.url.openConnection();
        conn.setConnectTimeout(5000);

        if (this.apiKey != null) {
            conn.addRequestProperty("X-API-Key", this.apiKey);
        }
        conn.addRequestProperty("User-Agent", Updater.USER_AGENT);

        conn.setDoOutput(true);

        final BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        final String response = reader.readLine();

        final JSONArray array = (JSONArray) JSONValue.parse(response);

        if (array.isEmpty()) {
            this.plugin.getLogger().warning("The updater could not find any files for the project id " + this.id);
            this.result = UpdateResult.FAIL_BADID;
            return false;
        }

        JSONObject latestUpdate = (JSONObject) array.get(array.size() - 1);
        this.versionName = (String) latestUpdate.get(Updater.TITLE_VALUE);
        this.versionLink = (String) latestUpdate.get(Updater.LINK_VALUE);
        this.versionType = (String) latestUpdate.get(Updater.TYPE_VALUE);
        this.versionGameVersion = (String) latestUpdate.get(Updater.VERSION_VALUE);

        return true;
    } catch (final IOException e) {
        if (e.getMessage().contains("HTTP response code: 403")) {
            this.plugin.getLogger().severe("dev.bukkit.org rejected the API key provided in " +
                    "plugins/Updater/config.yml");
            this.plugin.getLogger().severe("Please double-check your configuration to ensure it is correct.");
            this.result = UpdateResult.FAIL_APIKEY;
        } else {
            this.plugin.getLogger().severe("The updater could not contact dev.bukkit.org for updating.");
            this.plugin.getLogger().severe("If you have not recently modified your configuration and this is the " +
                    "first time you are seeing this message, the site may be experiencing temporary downtime.");
            this.result = UpdateResult.FAIL_DBO;
        }
        this.plugin.getLogger().log(Level.SEVERE, null, e);
        return false;
    }
}
 
Example 19
Source File: UserDataPropertyDateTimeTest.java    From io with Apache License 2.0 4 votes vote down vote up
/**
 * DynamicPropertyをnullにして更新できること.
 */
@SuppressWarnings("unchecked")
@Test
public final void DynamicPropertyをnullにして更新できること() {
    final String time = "/Date(1359340262406)/";
    // リクエストボディを設定
    JSONObject body = new JSONObject();
    body.put("__id", USERDATA_ID);
    body.put(PROP_NAME, time);

    try {
        createEntities();
        createProperty(EdmSimpleType.DATETIME.getFullyQualifiedTypeName(), null);

        // ユーザデータ作成
        TResponse response = createUserData(body, HttpStatus.SC_CREATED,
                cellName, boxName, COL_NAME, ENTITY_TYPE_NAME);

        JSONObject json = response.bodyAsJson();
        JSONObject results = (JSONObject) ((JSONObject) json.get("d")).get("results");
        String value = results.get(PROP_NAME).toString();
        assertEquals(time, value);

        body.put(PROP_NAME, null);
        body.put("nullprop", null);
        // ユーザデータ更新
        updateUserData(cellName, boxName, COL_NAME, ENTITY_TYPE_NAME, USERDATA_ID, body);

        // ユーザデータ一件取得
        TResponse getResponse = getUserData(cellName, boxName, COL_NAME, ENTITY_TYPE_NAME, USERDATA_ID,
                Setup.MASTER_TOKEN_NAME, HttpStatus.SC_OK);
        JSONObject getJson = getResponse.bodyAsJson();
        JSONObject getResults = (JSONObject) ((JSONObject) getJson.get("d")).get("results");
        String getValue = (String) getResults.get(PROP_NAME);
        assertEquals(null, getValue);

    } finally {
        // ユーザデータ削除
        deleteUserData(USERDATA_ID);

        deleteProperty();
        deleteEntities();
    }
}
 
Example 20
Source File: TestHttpFSServer.java    From hadoop with Apache License 2.0 3 votes vote down vote up
/**
 * Given the JSON output from the GETFILESTATUS call, return the
 * 'permission' value.
 *
 * @param statusJson JSON from GETFILESTATUS
 * @return The value of 'permission' in statusJson
 * @throws Exception
 */
private String getPerms ( String statusJson ) throws Exception {
  JSONParser parser = new JSONParser();
  JSONObject jsonObject = (JSONObject) parser.parse(statusJson);
  JSONObject details = (JSONObject) jsonObject.get("FileStatus");
  return (String) details.get("permission");
}