Example usage for com.liferay.portal.kernel.json JSONFactoryUtil createJSONObject

List of usage examples for com.liferay.portal.kernel.json JSONFactoryUtil createJSONObject

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.json JSONFactoryUtil createJSONObject.

Prototype

public static JSONObject createJSONObject(String json) throws JSONException 

Source Link

Usage

From source file:at.graz.meduni.bibbox.liferay.portlet.service.impl.ApplicationInstanceServiceImpl.java

License:Open Source License

@JSONWebService(value = "/test")
public void getTestAPI(String string) {
    try {/*from   w  ww .j a  va 2 s . co m*/
        JSONFactoryUtil.createJSONObject(string);
    } catch (JSONException e) {
        System.out.println("ERROR creating Json Object");
        e.printStackTrace();
    }
    try {
        String string2 = "{MYSQL_PASSWORD=, INSTITUTE_NAME=BIBBOX Demo Biobank, MYSQL_USER=openspecimen, TOMCAT_MANAGER_USER=admin, TOMCAT_MANAGER_PASSWORD=}";
        JSONFactoryUtil.createJSONObject(string2);
    } catch (JSONException e) {
        System.out.println("ERROR creating Json Object 2");
        e.printStackTrace();
    }
}

From source file:at.graz.meduni.bibbox.liferay.portlet.service.impl.ApplicationInstanceServiceImpl.java

License:Open Source License

private JSONObject getApplicationStoreItemDeveloperVersion(String applicationname) {
    try {//w  ww  .j  av a 2  s  .c o  m
        UpdateGitRepository updategitrepository = new UpdateGitRepository();
        String jsonstring = "";
        String applicationfolder = BibboxConfigReader.getApplicationFolder(applicationname, "development");
        if (updategitrepository.checkIfLocalRepositoryExists(applicationfolder)) {
            updategitrepository.updateLocalGitRepository(applicationfolder);
            jsonstring = BibboxConfigReader.readApplicationsStoreJsonFile(applicationfolder + "/appinfo.json");
        } else {
            updategitrepository.cloneRepositoryToFolder(applicationfolder, applicationname);
            jsonstring = BibboxConfigReader.readApplicationsStoreJsonFile(applicationfolder + "/appinfo.json");
        }
        return JSONFactoryUtil.createJSONObject(jsonstring);
    } catch (JSONException e) {
        System.err.println(FormatExceptionMessage.formatExceptionMessage("error", log_portlet_, log_classname_,
                "getApplicationStoreItemDeveloperVersion(String applicationname)",
                "Error reading application store jason file. Applicationname:" + applicationname));
        e.printStackTrace();
    }
    return JSONFactoryUtil.createJSONObject();
}

From source file:at.graz.meduni.bibbox.liferay.portlet.service.impl.ApplicationInstanceServiceImpl.java

License:Open Source License

private JSONObject getApplicationStoreItemVersion(String applicationname, String version) {
    try {//from  w ww . j  a  v  a 2 s  .  c om
        UpdateGitRepository updategitrepository = new UpdateGitRepository();
        String jsonstring = "";
        String applicationfolder = BibboxConfigReader.getApplicationFolder(applicationname, version);
        String applicationfolderdevelopment = BibboxConfigReader.getApplicationFolder(applicationname,
                "development");
        if (updategitrepository.checkIfLocalRepositoryExists(applicationfolder)) {
            jsonstring = BibboxConfigReader.readApplicationsStoreJsonFile(applicationfolder + "/appinfo.json");
        } else {
            if (!updategitrepository.checkIfLocalRepositoryExists(applicationfolderdevelopment)) {
                updategitrepository.cloneRepositoryToFolder(applicationfolderdevelopment, applicationname);
            } else {
                updategitrepository.updateLocalGitRepository(applicationfolderdevelopment);
            }
            updategitrepository.createTagFodler(applicationname, version);
            jsonstring = BibboxConfigReader.readApplicationsStoreJsonFile(applicationfolder + "/appinfo.json");
        }
        return JSONFactoryUtil.createJSONObject(jsonstring);
    } catch (JSONException e) {
        System.err.println(FormatExceptionMessage.formatExceptionMessage("error", log_portlet_, log_classname_,
                "getApplicationStoreItemVersion(String applicationname, String version)",
                "Error reading application store json file. Applicationname:" + applicationname + " Version: "
                        + version));
        e.printStackTrace();
    }
    return JSONFactoryUtil.createJSONObject();
}

From source file:bean.CustomNotificationHandler.java

@Override
protected String getBody(UserNotificationEvent userNotificationEvent, ServiceContext serviceContext)
        throws Exception {
    JSONObject jsonObject = JSONFactoryUtil.createJSONObject(userNotificationEvent.getPayload());
    fullName = jsonObject.getString("fullName");
    bodyText = jsonObject.getString("message");
    body = StringUtil.replace(getBodyTemplate(), new String[] { "[$FULL_NAME$]", "[$BODY_TEXT$]" },
            new String[] { fullName, bodyText });
    return body;// w  ww  . jav a2  s  . c o m
}

From source file:ch.inofix.data.model.impl.MeasurementImpl.java

License:Open Source License

public Map<String, String> getDataMap() {

    JSONObject jsonObject = null;//from  w w w  . j a va  2s.c o  m
    Map<String, String> map = new HashMap<String, String>();

    try {
        jsonObject = JSONFactoryUtil.createJSONObject(GetterUtil.getString(getData()));

        Iterator<String> keys = jsonObject.keys();

        while (keys.hasNext()) {

            String key = keys.next();

            map.put(key, jsonObject.getString(key));

        }

    } catch (JSONException e) {
        _log.error(e);
    }

    return map;

}

From source file:com.beorn.paymentapi.model.ApiPaymentMethod.java

License:Open Source License

public static ApiPaymentMethod fromJSONObject(String json) throws JSONException {
    return fromJSON(JSONFactoryUtil.createJSONObject(json));
}

From source file:com.beorn.paymentapi.model.ApiTransaction.java

License:Open Source License

public static ApiTransaction fromJSONObject(String json) throws JSONException {
    return fromJSON(JSONFactoryUtil.createJSONObject(json));
}

From source file:com.beorn.paymentpluginapi.test.ConfigValidatorTestBase.java

License:Open Source License

@Test
public void testEmptyConfig() throws Exception {
    String configString = "configString";

    mockStatic(JSONFactoryUtil.class);

    JSONObject config = mock(JSONObject.class);
    when(JSONFactoryUtil.createJSONObject(configString)).thenReturn(config);

    ConfigValidator validator = getValidator();

    Assert.assertFalse(validator.isValid(configString));
}

From source file:com.beorn.paymentpluginapi.test.ConfigValidatorTestBase.java

License:Open Source License

@Test
public void testNullConfig() throws Exception {
    String configString = "configString";

    mockStatic(JSONFactoryUtil.class);

    JSONObject config = mock(JSONObject.class);

    when(JSONFactoryUtil.createJSONObject(configString)).thenReturn(config);
    when(config.has(Mockito.anyString())).thenReturn(true);
    when(config.getJSONObject(Mockito.anyString())).thenReturn(config);

    ConfigValidator validator = getValidator();

    Assert.assertTrue(validator.isValid(configString));
}

From source file:com.beorn.paymentpluginapi.validator.BaseConfigValidator.java

License:Open Source License

public boolean isValid(String config) {
    try {/*from w  w w .java2s  . co  m*/
        JSONObject configObject = JSONFactoryUtil.createJSONObject(config);

        if (_configDescription != null && !_configDescription.isValid(configObject))
            return false;

        return isValid(configObject);

    } catch (JSONException e) {
        _log.error(e);
        return false;
    }
}