use of com.wordnik.swagger.annotations.ApiResponses in project oxTrust by GluuFederation.
the class TrustRelationshipWebService method delete.
@DELETE
@Path("/delete/{inum}")
@Produces(MediaType.TEXT_PLAIN)
@ApiOperation(value = "delete TrustRelationship", notes = "Delete GluuSAMLTrustRelationship.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 500, message = "Server error") })
public void delete(@PathParam("inum") @NotNull String inum, @Context HttpServletResponse response) {
logger.trace("Delete Trust Relationship");
try {
GluuSAMLTrustRelationship trustRelationship = trustService.getRelationshipByInum(inum);
trustService.removeTrustRelationship(trustRelationship);
} catch (Exception e) {
logger.error("delete() Exception", e);
try {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "INTERNAL SERVER ERROR");
} catch (Exception ex) {
}
}
}
use of com.wordnik.swagger.annotations.ApiResponses in project oxTrust by GluuFederation.
the class TrustRelationshipWebService method setCertificate.
@POST
@Path("/set_certificate/{inum}")
@Consumes({ MediaType.TEXT_PLAIN })
@Produces(MediaType.TEXT_PLAIN)
@ApiOperation(value = "set certificate for TrustRelationship", notes = "Find TrustRelationship by inum and set certificate.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 500, message = "Server error") })
public void setCertificate(@PathParam("inum") String trustRelationshipInum, String certificate, @Context HttpServletResponse response) {
try {
GluuSAMLTrustRelationship trustRelationship = trustService.getRelationshipByInum(trustRelationshipInum);
if (StringHelper.isEmpty(certificate)) {
logger.error("Failed to update TR certificate - certificate is empty");
return;
}
updateTRCertificate(trustRelationship, certificate);
} catch (Exception e) {
logger.error("Failed to update certificate", e);
try {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "INTERNAL SERVER ERROR");
} catch (Exception ex) {
}
}
}
use of com.wordnik.swagger.annotations.ApiResponses in project oxTrust by GluuFederation.
the class TrustRelationshipWebService method setMetadataURL.
@POST
@Path("/set_metadata_url/{inum}")
@Consumes({ MediaType.TEXT_PLAIN })
@Produces(MediaType.TEXT_PLAIN)
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 500, message = "Server error") })
public void setMetadataURL(@PathParam("inum") String trustRelationshipInum, String url, @Context HttpServletResponse response) {
try {
GluuSAMLTrustRelationship trustRelationship = trustService.getRelationshipByInum(trustRelationshipInum);
String metadataFileName = trustRelationship.getSpMetaDataFN();
if (StringHelper.isEmpty(metadataFileName)) {
// Generate new file name
metadataFileName = shibboleth3ConfService.getSpNewMetadataFileName(trustRelationshipInum);
}
shibboleth3ConfService.saveSpMetadataFile(url, metadataFileName);
trustRelationship.setSpMetaDataFN(metadataFileName);
trustRelationship.setSpMetaDataSourceType(GluuMetadataSourceType.FILE);
trustService.updateTrustRelationship(trustRelationship);
} catch (Exception e) {
logger.error("addMetadata() Exception", e);
try {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "INTERNAL SERVER ERROR");
} catch (Exception ex) {
}
}
}
use of com.wordnik.swagger.annotations.ApiResponses in project oxTrust by GluuFederation.
the class ScimConfigurationWS method getConfiguration.
@GET
@Produces({ MediaType.APPLICATION_JSON })
@ApiOperation(value = "Provides metadata as json document. It contains options and endpoints supported by the SCIM server.", response = ScimConfiguration.class)
@ApiResponses(value = { @ApiResponse(code = 500, message = "Failed to build SCIM configuration json object.") })
public Response getConfiguration() {
try {
final List<ScimConfiguration> cl = new ArrayList<ScimConfiguration>();
// SCIM 2.0
final ScimConfiguration c2 = new ScimConfiguration();
c2.setVersion("2.0");
c2.setAuthorizationSupported(new String[] { "uma" });
c2.setUserEndpoint(userService.getEndpointUrl());
c2.setUserSearchEndpoint(userService.getEndpointUrl() + "/" + BaseScimWebService.SEARCH_SUFFIX);
c2.setGroupEndpoint(groupService.getEndpointUrl());
c2.setBulkEndpoint(bulkService.getEndpointUrl());
c2.setServiceProviderEndpoint(serviceProviderService.getEndpointUrl());
c2.setResourceTypesEndpoint(resourceTypeService.getEndpointUrl());
cl.add(c2);
// Convert manually to avoid possible conflicts between resteasy providers, e.g. jettison, jackson
final String entity = jsonService.objectToPerttyJson(cl);
log.trace("SCIM configuration: {}", entity);
return Response.ok(entity).build();
} catch (Throwable ex) {
log.error(ex.getMessage(), ex);
throw new WebApplicationException(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("Failed to generate SCIM configuration").build());
}
}
use of com.wordnik.swagger.annotations.ApiResponses in project ma-modules-public by infiniteautomation.
the class UserEventsV2Controller method getTableModel.
@ApiOperation(value = "Get Explaination For Query", notes = "What is Query-able on this model")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Ok"), @ApiResponse(code = 403, message = "User does not have access") })
@RequestMapping(method = RequestMethod.GET, produces = { "application/json" }, value = "/explain-query")
public ResponseEntity<TableModel> getTableModel(HttpServletRequest request) {
Map<String, QueryAttribute> attributeMap = new HashMap<>();
Field[] inherited = EventInstance.class.getFields();
for (Field field : inherited) {
QueryAttribute qa = new QueryAttribute(field.getName(), null, getJdbcTypeCode(field.getGenericType().getTypeName()));
attributeMap.put(field.getName(), qa);
}
Field[] all = EventInstance.class.getDeclaredFields();
for (Field field : all) {
QueryAttribute qa = new QueryAttribute(field.getName(), null, getJdbcTypeCode(field.getGenericType().getTypeName()));
attributeMap.put(field.getName(), qa);
}
return new ResponseEntity<>(new TableModel("EventInstance.class", new ArrayList<>(attributeMap.values())), HttpStatus.OK);
}
Aggregations