Search in sources :

Example 11 with APIException

use of com.liferay.ide.core.remote.APIException in project liferay-ide by liferay.

the class ServerManagerConnection method isAlive.

public boolean isAlive() throws APIException {
    JSONObject status = null;
    Object jsonResponse = getJSONAPI(getIsAliveAPI());
    if (jsonResponse instanceof JSONObject) {
        status = (JSONObject) jsonResponse;
    } else {
        // $NON-NLS-1$
        throw new APIException(getIsAliveAPI(), "Unable to connect to server manager.");
    }
    if (isSuccess(status)) {
        return true;
    }
    return false;
}
Also used : APIException(com.liferay.ide.core.remote.APIException) JSONObject(org.json.JSONObject) JSONObject(org.json.JSONObject)

Example 12 with APIException

use of com.liferay.ide.core.remote.APIException in project liferay-ide by liferay.

the class ServerManagerConnection method getLiferayPlugins.

public List<String> getLiferayPlugins() {
    List<String> retval = new ArrayList<String>();
    Object response = null;
    try {
        response = getJSONAPI(getPluginsAPI());
    } catch (APIException e1) {
        LiferayServerCore.logError(e1);
    }
    if (response instanceof JSONObject) {
        JSONObject json = (JSONObject) response;
        try {
            if (isSuccess(json)) {
                JSONArray jsonPlugins = getJSONOutput(json);
                for (int i = 0; i < jsonPlugins.length(); i++) {
                    retval.add(jsonPlugins.get(i).toString());
                }
            }
        } catch (Exception e) {
            LiferayServerCore.logError(e);
        }
    }
    return retval;
}
Also used : APIException(com.liferay.ide.core.remote.APIException) JSONObject(org.json.JSONObject) ArrayList(java.util.ArrayList) JSONArray(org.json.JSONArray) JSONObject(org.json.JSONObject) APIException(com.liferay.ide.core.remote.APIException) JSONException(org.json.JSONException)

Example 13 with APIException

use of com.liferay.ide.core.remote.APIException in project liferay-ide by liferay.

the class PortalConnection method getStructureTemplates.

public JSONArray getStructureTemplates(long groupId, long structureId) throws APIException {
    JSONArray structureTemplates = null;
    // $NON-NLS-1$ //$NON-NLS-2$
    Object jsonResponse = getJSONAPI(GET_STRUCTURE_TEMPLATES_API, "groupId", groupId, "structureId", structureId);
    if (jsonResponse instanceof JSONArray) {
        structureTemplates = (JSONArray) jsonResponse;
    } else {
        // $NON-NLS-1$
        throw new APIException(GET_STRUCTURE_TEMPLATES_API, "Unable to get JSONArray");
    }
    return structureTemplates;
}
Also used : APIException(com.liferay.ide.core.remote.APIException) JSONArray(org.json.JSONArray) JSONObject(org.json.JSONObject)

Example 14 with APIException

use of com.liferay.ide.core.remote.APIException in project liferay-ide by liferay.

the class PortalConnection method getCompanyIdByVirtualHost.

public JSONObject getCompanyIdByVirtualHost() throws APIException {
    JSONObject company = null;
    // $NON-NLS-1$
    Object jsonResponse = getJSONAPI(GET_COMPANY_BY_VIRTUAL_HOST_API, "virtualHost", getHost());
    if (jsonResponse instanceof JSONObject) {
        company = (JSONObject) jsonResponse;
    } else {
        // $NON-NLS-1$
        throw new APIException(GET_COMPANY_BY_VIRTUAL_HOST_API, "Unable to get JSONObject");
    }
    return company;
}
Also used : APIException(com.liferay.ide.core.remote.APIException) JSONObject(org.json.JSONObject) JSONObject(org.json.JSONObject)

Aggregations

APIException (com.liferay.ide.core.remote.APIException)14 JSONObject (org.json.JSONObject)11 JSONArray (org.json.JSONArray)5 JSONException (org.json.JSONException)4 File (java.io.File)2 MultipartEntity (org.apache.http.entity.mime.MultipartEntity)2 FileBody (org.apache.http.entity.mime.content.FileBody)2 IProject (org.eclipse.core.resources.IProject)2 CoreException (org.eclipse.core.runtime.CoreException)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 ILiferayProject (com.liferay.ide.core.ILiferayProject)1 FMDebugTarget (com.liferay.ide.portal.core.debug.fm.FMDebugTarget)1 IServerManagerConnection (com.liferay.ide.server.remote.IServerManagerConnection)1 ArrayList (java.util.ArrayList)1 HttpPost (org.apache.http.client.methods.HttpPost)1 HttpPut (org.apache.http.client.methods.HttpPut)1 IPath (org.eclipse.core.runtime.IPath)1 IDebugTarget (org.eclipse.debug.core.model.IDebugTarget)1 IModule (org.eclipse.wst.server.core.IModule)1 IServer (org.eclipse.wst.server.core.IServer)1