use of org.codehaus.jackson.JsonGenerationException in project onebusaway-application-modules by camsys.
the class AgencyMetadataResource method updateAgencyMetadata.
@Path("/update/{agencyIndex}")
@GET
@Produces("application/json")
public Response updateAgencyMetadata(@PathParam("agencyIndex") String agencyIndex, @QueryParam("gtfs_id") String gtfs_id, @QueryParam("name") String name, @QueryParam("short_name") String short_name, @QueryParam("legacy_id") String legacy_id, @QueryParam("gtfs_feed_url") String gtfs_feed_url, @QueryParam("gtfs_rt_feed_url") String gtfs_rt_feed_url, @QueryParam("bounding_box") String bounding_box, @QueryParam("ntd_id") String ntd_id, @QueryParam("agency_message") String agency_message) throws JsonGenerationException, JsonMappingException, IOException {
log.info("Starting updateAgencyMetadata with agencyIndex: " + agencyIndex + ", gtfs_id: " + gtfs_id + ", name: " + name + ", short_name: " + short_name + ", legacy_id: " + legacy_id + ", gtfs_feed_url: " + gtfs_feed_url + ", gtfs_rt_feed_url: " + gtfs_rt_feed_url + ", bounding_box: " + bounding_box + ", ntd_id: " + ntd_id + ", agency_message: " + agency_message);
String message = "Agency Metadata updated: " + agencyIndex;
try {
long id = Long.parseLong(agencyIndex);
_agencyMetadataService.updateAgencyMetadata(id, gtfs_id, name, short_name, legacy_id, gtfs_feed_url, gtfs_rt_feed_url, bounding_box, ntd_id, agency_message);
} catch (Exception e) {
log.error(e.getMessage());
message = e.getMessage();
}
Response response = constructResponse(message);
return response;
}
use of org.codehaus.jackson.JsonGenerationException in project onebusaway-application-modules by camsys.
the class AgencyMetadataResource method deleteAgencyMetadata.
@Path("/delete/{agencyIndex}")
@GET
@Produces("application/json")
public Response deleteAgencyMetadata(@PathParam("agencyIndex") String agencyIndex) throws JsonGenerationException, JsonMappingException, IOException {
String message = "Agency Metadata deleted: " + agencyIndex;
try {
long index = Long.parseLong(agencyIndex);
_agencyMetadataService.delete(index);
} catch (Exception e) {
log.error(e.getMessage());
message = "Failed to delete key: " + e.getMessage();
}
Response response = constructResponse(message);
log.info("Returning deleteAgencyMetadata result.");
return response;
}
use of org.codehaus.jackson.JsonGenerationException in project onebusaway-application-modules by camsys.
the class KeysResource method listEmails.
@Path("/list-emails")
@GET
@Produces("application/json")
public Response listEmails() throws JsonGenerationException, JsonMappingException, IOException {
log.info("Starting listEmails");
try {
validateSecurity();
List<String> apiKeys = _userService.getUserIndexKeyValuesForKeyType(UserIndexTypes.API_KEY);
List<String> emails = new ArrayList<String>();
int count = 0;
for (String apiKey : apiKeys) {
UserIndexKey key = new UserIndexKey(UserIndexTypes.API_KEY, apiKey);
UserIndex userIndex = _userService.getUserIndexForId(key);
count++;
if (userIndex != null) {
if (userIndex.getUser() != null) {
if (userIndex.getUser().getProperties() != null) {
Object o = userIndex.getUser().getProperties();
if (o instanceof UserPropertiesV3) {
UserPropertiesV3 v3 = (UserPropertiesV3) o;
if (!StringUtils.isBlank(v3.getContactEmail())) {
emails.add(v3.getContactEmail());
}
}
}
}
}
if (count % 100 == 0)
log.info("processed " + count + " users....");
}
log.info("processing complete of " + count + " users!");
Response response = constructResponse(emails);
log.info("Returning response from listEmails");
return response;
} catch (Exception e) {
log.error(e.getMessage());
throw new WebApplicationException(e, Response.serverError().build());
}
}
use of org.codehaus.jackson.JsonGenerationException in project onebusaway-application-modules by camsys.
the class KeysResource method createKey.
@Path("/create/{keyValue}")
@GET
@Produces("application/json")
public Response createKey(@PathParam("keyValue") String keyValue, @DefaultValue("") @QueryParam("name") String name, @DefaultValue("") @QueryParam("company") String company, @DefaultValue("") @QueryParam("email") String email, @DefaultValue("") @QueryParam("details") String details, @DefaultValue("100") @QueryParam("minApiReqInt") String minApiReqInt) throws JsonGenerationException, JsonMappingException, IOException {
log.info("Starting createKey with keyValue: " + keyValue + ", name: " + name + ", company: " + company + ", email: " + email + ", details: " + details + ", minApiReqInt: " + minApiReqInt);
Long minApiReqIntervalLong = 0L;
try {
minApiReqIntervalLong = Long.parseLong(minApiReqInt);
} catch (NumberFormatException e) {
log.error("Could not parse minApiReqInt: " + minApiReqInt);
}
String message = "API Key created: " + keyValue;
try {
validateSecurity();
saveOrUpdateKey(keyValue, minApiReqIntervalLong, name, company, email, details);
} catch (Exception e) {
log.error(e.getMessage());
message = e.getMessage();
}
Response response = constructResponse(message);
log.info("Returning createKey result.");
return response;
}
use of org.codehaus.jackson.JsonGenerationException in project onebusaway-application-modules by camsys.
the class KeysResource method updateKey.
@Path("/update/{keyValue}")
@GET
@Produces("application/json")
public Response updateKey(@PathParam("keyValue") String keyValue, @QueryParam("name") String name, @QueryParam("company") String company, @QueryParam("email") String email, @QueryParam("details") String details, @QueryParam("minApiReqInt") String minApiReqInt) throws JsonGenerationException, JsonMappingException, IOException {
log.info("Starting updateKey with keyValue: " + keyValue + ", name: " + name + ", company: " + company + ", email: " + email + ", details: " + details + ", minApiReqInt: " + minApiReqInt);
Long minApiReqIntervalLong = 0L;
if (!minApiReqInt.isEmpty()) {
try {
minApiReqIntervalLong = Long.parseLong(minApiReqInt);
} catch (NumberFormatException e) {
log.error("Could not parse minApiReqInt: " + minApiReqInt);
}
}
String message = "API Key updated: " + keyValue;
try {
validateSecurity();
updateKeyContactInfo(keyValue, name, company, email, details, minApiReqIntervalLong);
} catch (Exception e) {
log.error(e.getMessage());
message = e.getMessage();
}
Response response = constructResponse(message);
log.info("Returning updateKey result.");
return response;
}
Aggregations