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();
}
}
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();
}
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;
}
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;
}
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;
}
Aggregations