Search in sources :

Example 1 with RestResponse

use of com.runwaysdk.mvc.RestResponse in project geoprism-registry by terraframe.

the class ETLController method importEdgeJson.

@Endpoint(url = "import-edge-json", method = ServletMethod.POST, error = ErrorSerialization.JSON)
public ResponseIF importEdgeJson(ClientRequestIF request, @RequestParamter(name = "relationshipType") String relationshipType, @RequestParamter(name = "graphTypeCode") String graphTypeCode, @RequestParamter(name = "startDate") String startDate, @RequestParamter(name = "endDate") String endDate, @RequestParamter(name = "file") MultipartFileParameter file) throws IOException, JSONException, ParseException {
    try (InputStream stream = file.getInputStream()) {
        Date sDate = startDate != null ? GeoRegistryUtil.parseDate(startDate) : null;
        Date eDate = endDate != null ? GeoRegistryUtil.parseDate(endDate) : null;
        service.importEdgeJson(request.getSessionId(), relationshipType, graphTypeCode, sDate, eDate, stream);
        return new RestResponse();
    }
}
Also used : InputStream(java.io.InputStream) RestResponse(com.runwaysdk.mvc.RestResponse) Date(java.util.Date) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 2 with RestResponse

use of com.runwaysdk.mvc.RestResponse in project geoprism-registry by terraframe.

the class DirectedAcyclicGraphController method removeChild.

@Endpoint(url = "remove-child", method = ServletMethod.POST, error = ErrorSerialization.JSON)
public ResponseIF removeChild(ClientRequestIF request, @RequestParamter(name = "parentCode", required = true) String parentCode, @RequestParamter(name = "parentTypeCode", required = true) String parentTypeCode, @RequestParamter(name = "childCode", required = true) String childCode, @RequestParamter(name = "childTypeCode", required = true) String childTypeCode, @RequestParamter(name = "directedGraphCode", required = true) String directedGraphCode, @RequestParamter(name = "startDate", required = true) String startDateStr, @RequestParamter(name = "endDate", required = true) String endDateStr) {
    Date startDate = GeoRegistryUtil.parseDate(startDateStr, true);
    Date endDate = GeoRegistryUtil.parseDate(endDateStr, true);
    this.service.removeChild(request.getSessionId(), parentCode, parentTypeCode, childCode, childTypeCode, directedGraphCode, startDate, endDate);
    return new RestResponse();
}
Also used : RestResponse(com.runwaysdk.mvc.RestResponse) Date(java.util.Date) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 3 with RestResponse

use of com.runwaysdk.mvc.RestResponse in project geoprism-registry by terraframe.

the class RegistryAccountController method apply.

@Endpoint(method = ServletMethod.POST, error = ErrorSerialization.JSON)
public ResponseIF apply(ClientRequestIF request, @RequestParamter(name = "account", required = true) String account, @RequestParamter(name = "roleNames") String roleNames) throws JSONException {
    String[] roleNameArray = null;
    if (roleNames != null) {
        JSONArray arr = new JSONArray(roleNames);
        roleNameArray = new String[arr.length()];
        for (int i = 0; i < arr.length(); i++) {
            roleNameArray[i] = arr.getString(i);
        }
    }
    JSONObject user = this.accountService.apply(request.getSessionId(), account, roleNameArray);
    RegistryRole[] registryRoles = this.accountService.getRolesForUser(request.getSessionId(), user.getString(GeoprismUserDTO.OID));
    JsonArray rolesJSONArray = this.createRoleMap(registryRoles);
    RestResponse response = new RestResponse();
    response.set("user", user);
    response.set("roles", new JSONArray(rolesJSONArray.toString()));
    return response;
}
Also used : JsonArray(com.google.gson.JsonArray) RegistryRole(org.commongeoregistry.adapter.metadata.RegistryRole) JSONObject(org.json.JSONObject) RestResponse(com.runwaysdk.mvc.RestResponse) JSONArray(org.json.JSONArray) Endpoint(com.runwaysdk.mvc.Endpoint) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 4 with RestResponse

use of com.runwaysdk.mvc.RestResponse in project geoprism-registry by terraframe.

the class RegistryAccountController method newInvite.

/**
 * @param request
 * @param organizationCodes
 *          comma delimited list of registry codes. Returns all registry roles
 *          if empty.
 * @return
 * @throws JSONException
 */
@Endpoint(method = ServletMethod.POST, error = ErrorSerialization.JSON)
public ResponseIF newInvite(ClientRequestIF request, @RequestParamter(name = "organizationCodes") String organizationCodes) throws JSONException {
    String[] orgCodeArray = null;
    if (organizationCodes != null) {
        JSONArray arr = new JSONArray(organizationCodes);
        orgCodeArray = new String[arr.length()];
        for (int i = 0; i < arr.length(); i++) {
            orgCodeArray[i] = arr.getString(i);
        }
    } else {
        orgCodeArray = new String[0];
    }
    JSONObject user = new JSONObject();
    user.put("newInstance", true);
    RegistryRole[] registryRoles = this.accountService.getRolesForOrganization(request.getSessionId(), orgCodeArray);
    JsonArray rolesJSONArray = this.createRoleMap(registryRoles);
    RestResponse response = new RestResponse();
    response.set("user", user);
    response.set("roles", new JSONArray(rolesJSONArray.toString()));
    return response;
}
Also used : JsonArray(com.google.gson.JsonArray) RegistryRole(org.commongeoregistry.adapter.metadata.RegistryRole) JSONObject(org.json.JSONObject) RestResponse(com.runwaysdk.mvc.RestResponse) JSONArray(org.json.JSONArray) Endpoint(com.runwaysdk.mvc.Endpoint) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 5 with RestResponse

use of com.runwaysdk.mvc.RestResponse in project geoprism-registry by terraframe.

the class RegistryAccountController method edit.

@Endpoint(method = ServletMethod.POST, error = ErrorSerialization.JSON)
public ResponseIF edit(ClientRequestIF request, @RequestParamter(name = "oid", required = true) String oid) throws JSONException {
    JSONObject user = this.accountService.lock(request.getSessionId(), oid);
    RegistryRole[] registryRoles = this.accountService.getRolesForUser(request.getSessionId(), oid);
    JsonArray rolesJSONArray = this.createRoleMap(registryRoles);
    RestResponse response = new RestResponse();
    response.set("user", user);
    response.set("roles", new JSONArray(rolesJSONArray.toString()));
    return response;
}
Also used : JsonArray(com.google.gson.JsonArray) RegistryRole(org.commongeoregistry.adapter.metadata.RegistryRole) JSONObject(org.json.JSONObject) RestResponse(com.runwaysdk.mvc.RestResponse) JSONArray(org.json.JSONArray) Endpoint(com.runwaysdk.mvc.Endpoint)

Aggregations

RestResponse (com.runwaysdk.mvc.RestResponse)13 Endpoint (com.runwaysdk.mvc.Endpoint)8 JSONArray (org.json.JSONArray)7 JSONObject (org.json.JSONObject)5 JsonArray (com.google.gson.JsonArray)4 Date (java.util.Date)4 RegistryRole (org.commongeoregistry.adapter.metadata.RegistryRole)4 Test (org.junit.Test)4 Pair (com.runwaysdk.Pair)3 GeoprismUserDTO (net.geoprism.GeoprismUserDTO)3 HashSet (java.util.HashSet)2 InputStream (java.io.InputStream)1