use of com.runwaysdk.mvc.Endpoint in project geoprism-registry by terraframe.
the class RegistryAccountController method newInstance.
/**
* Returns all roles associated with the given {@link OrganizationDTO} codes.
* If no codes are provided then return all roles defined in the registry.
*
* @param request
* @param organizationCodes
* comma separated list of {@link OrganizationDTO} codes.
* @return
* @throws JSONException
*/
@Endpoint(method = ServletMethod.POST, error = ErrorSerialization.JSON)
public ResponseIF newInstance(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];
}
GeoprismUserDTO user = UserInviteDTO.newUserInst(request);
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;
}
use of com.runwaysdk.mvc.Endpoint in project geoprism-registry by terraframe.
the class RegistryController method getGeoObjectOverTimeByCode.
@Endpoint(method = ServletMethod.GET, error = ErrorSerialization.JSON, url = RegistryUrls.GEO_OBJECT_TIME_GET_CODE)
public ResponseIF getGeoObjectOverTimeByCode(ClientRequestIF request, @RequestParamter(name = RegistryUrls.GEO_OBJECT_TIME_GET_CODE_PARAM_CODE) String code, @RequestParamter(name = RegistryUrls.GEO_OBJECT_TIME_GET_CODE_PARAM_TYPE_CODE) String typeCode) throws JSONException {
GeoObjectOverTime geoObject = this.registryService.getGeoObjectOverTimeByCode(request.getSessionId(), code, typeCode);
CustomSerializer serializer = this.registryService.serializer(request.getSessionId());
return new RestBodyResponse(geoObject.toJSON(serializer));
}
use of com.runwaysdk.mvc.Endpoint in project geoprism-registry by terraframe.
the class RegistryController method createHierarchyType.
/**
* Create the {@link HierarchyType} from the given JSON.
*
* @param sessionId
* @param htJSON
* JSON of the {@link HierarchyType} to be created.
*/
@Endpoint(method = ServletMethod.POST, error = ErrorSerialization.JSON, url = RegistryUrls.HIERARCHY_TYPE_CREATE)
public ResponseIF createHierarchyType(ClientRequestIF request, @RequestParamter(name = "htJSON", required = true) String htJSON) {
HierarchyType hierarchyType = ServiceFactory.getHierarchyService().createHierarchyType(request.getSessionId(), htJSON);
CustomSerializer serializer = this.registryService.serializer(request.getSessionId());
return new RestBodyResponse(hierarchyType.toJSON(serializer));
}
use of com.runwaysdk.mvc.Endpoint in project geoprism-registry by terraframe.
the class RegistryController method getGeoObjectBounds.
@Endpoint(method = ServletMethod.GET, error = ErrorSerialization.JSON, url = "geoobject/get-bounds")
public ResponseIF getGeoObjectBounds(ClientRequestIF request, @RequestParamter(name = RegistryUrls.GEO_OBJECT_GET_CODE_PARAM_CODE) String code, @RequestParamter(name = RegistryUrls.GEO_OBJECT_GET_PARAM_TYPE_CODE) String typeCode) throws JSONException {
GeoObject geoObject = this.registryService.getGeoObjectByCode(request.getSessionId(), code, typeCode, null);
String bounds = this.registryService.getGeoObjectBounds(request.getSessionId(), geoObject);
return new RestBodyResponse(bounds);
}
use of com.runwaysdk.mvc.Endpoint in project geoprism-registry by terraframe.
the class RegistryController method getParentGeoObjects.
/**
* Get parents of the given GeoObject
*
* @pre @post
*
* @param childUid
* UID of the child object for which the call fetches parents. @param
* parentTypes An array of GeoObjectType names of the types of parent
* GeoObjects to fetch. If blank then return parents of all
* types. @param recursive TRUE if recursive parents of the given
* parent with the given types should be returned, FALSE if only
* single level parents should be returned.
* @throws ParseException
*
* @returns @throws
*/
@Endpoint(method = ServletMethod.GET, error = ErrorSerialization.JSON, url = RegistryUrls.GEO_OBJECT_GET_PARENTS)
public ResponseIF getParentGeoObjects(ClientRequestIF request, @RequestParamter(name = RegistryUrls.GEO_OBJECT_GET_PARENTS_PARAM_CHILDCODE, required = true) String childCode, @RequestParamter(name = RegistryUrls.GEO_OBJECT_GET_PARENTS_PARAM_CHILD_TYPE_CODE, required = true) String childTypeCode, @RequestParamter(name = RegistryUrls.GEO_OBJECT_GET_PARENTS_PARAM_DATE, required = true) String date, @RequestParamter(name = RegistryUrls.GEO_OBJECT_GET_PARENTS_PARAM_PARENT_TYPES) String parentTypes, @RequestParamter(name = RegistryUrls.GEO_OBJECT_GET_PARENTS_PARAM_RECURSIVE, required = true) Boolean recursive) throws ParseException {
String[] aParentTypes = null;
if (parentTypes != null) {
JSONArray jaParentTypes = new JSONArray(parentTypes);
aParentTypes = new String[jaParentTypes.length()];
for (int i = 0; i < jaParentTypes.length(); i++) {
aParentTypes[i] = jaParentTypes.getString(i);
}
}
TreeNode tn = this.registryService.getParentGeoObjects(request.getSessionId(), childCode, childTypeCode, aParentTypes, recursive, GeoRegistryUtil.parseDate(date, true));
return new RestBodyResponse(tn.toJSON());
}
Aggregations