Search in sources :

Example 6 with Endpoint

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

the class HierarchyController method setInheritedHierarchy.

/**
 * Modifies a hierarchy to inherit from another hierarchy at the given
 * GeoObjectType
 *
 * @param request
 *          Session Request
 * @param hierarchyTypeCode
 *          code of the {@link HierarchyType} being modified.
 * @param inheritedHierarchyTypeCode
 *          code of the {@link HierarchyType} being inherited.
 * @param geoObjectTypeCode
 *          code of the root {@link GeoObjectType}.
 */
@Endpoint(method = ServletMethod.POST, error = ErrorSerialization.JSON, url = "setInherited")
public ResponseIF setInheritedHierarchy(ClientRequestIF request, @RequestParamter(name = "hierarchyTypeCode", required = true) String hierarchyTypeCode, @RequestParamter(name = "inheritedHierarchyTypeCode", required = true) String inheritedHierarchyTypeCode, @RequestParamter(name = "geoObjectTypeCode", required = true) String geoObjectTypeCode) {
    HierarchyType ht = ServiceFactory.getHierarchyService().setInheritedHierarchy(request.getSessionId(), hierarchyTypeCode, inheritedHierarchyTypeCode, geoObjectTypeCode);
    CustomSerializer serializer = this.registryService.serializer(request.getSessionId());
    return new RestBodyResponse(ht.toJSON(serializer));
}
Also used : HierarchyType(org.commongeoregistry.adapter.metadata.HierarchyType) CustomSerializer(org.commongeoregistry.adapter.metadata.CustomSerializer) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 7 with Endpoint

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

the class ListTypeController method tile.

@Endpoint(error = ErrorSerialization.JSON)
public ResponseIF tile(ClientRequestIF request, @RequestParamter(name = "x", required = true) Integer x, @RequestParamter(name = "y", required = true) Integer y, @RequestParamter(name = "z", required = true) Integer z, @RequestParamter(name = "config", required = true) String config) throws JSONException {
    JSONObject object = new JSONObject(config);
    object.put("x", x);
    object.put("y", y);
    object.put("z", z);
    return new InputStreamResponse(this.service.getTile(request.getSessionId(), object), "application/x-protobuf", null);
}
Also used : JSONObject(org.json.JSONObject) InputStreamResponse(com.runwaysdk.mvc.InputStreamResponse) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 8 with Endpoint

use of com.runwaysdk.mvc.Endpoint 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 9 with Endpoint

use of com.runwaysdk.mvc.Endpoint 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 10 with Endpoint

use of com.runwaysdk.mvc.Endpoint 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

Endpoint (com.runwaysdk.mvc.Endpoint)68 RestBodyResponse (com.runwaysdk.mvc.RestBodyResponse)52 CustomSerializer (org.commongeoregistry.adapter.metadata.CustomSerializer)25 Date (java.util.Date)21 JsonObject (com.google.gson.JsonObject)19 JsonArray (com.google.gson.JsonArray)16 HierarchyType (org.commongeoregistry.adapter.metadata.HierarchyType)11 JSONArray (org.json.JSONArray)11 JSONObject (org.json.JSONObject)11 RestResponse (com.runwaysdk.mvc.RestResponse)8 GeoObject (org.commongeoregistry.adapter.dataaccess.GeoObject)8 SimpleDateFormat (java.text.SimpleDateFormat)6 InputStreamResponse (com.runwaysdk.mvc.InputStreamResponse)5 InputStream (java.io.InputStream)5 RegistryRole (org.commongeoregistry.adapter.metadata.RegistryRole)5 GeoObjectOverTime (org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime)4 OrganizationDTO (org.commongeoregistry.adapter.metadata.OrganizationDTO)4 Locale (java.util.Locale)3 ImportStrategy (net.geoprism.registry.etl.upload.ImportConfiguration.ImportStrategy)3 ParentTreeNode (org.commongeoregistry.adapter.dataaccess.ParentTreeNode)3