Search in sources :

Example 31 with ApiResponses

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) {
        }
    }
}
Also used : GluuSAMLTrustRelationship(org.gluu.oxtrust.model.GluuSAMLTrustRelationship) CertificateEncodingException(java.security.cert.CertificateEncodingException) BaseMappingException(org.gluu.persist.exception.mapping.BaseMappingException) IOException(java.io.IOException) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Produces(javax.ws.rs.Produces) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) ApiResponses(com.wordnik.swagger.annotations.ApiResponses)

Example 32 with ApiResponses

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) {
        }
    }
}
Also used : GluuSAMLTrustRelationship(org.gluu.oxtrust.model.GluuSAMLTrustRelationship) CertificateEncodingException(java.security.cert.CertificateEncodingException) BaseMappingException(org.gluu.persist.exception.mapping.BaseMappingException) IOException(java.io.IOException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) ApiResponses(com.wordnik.swagger.annotations.ApiResponses)

Example 33 with ApiResponses

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) {
        }
    }
}
Also used : GluuSAMLTrustRelationship(org.gluu.oxtrust.model.GluuSAMLTrustRelationship) CertificateEncodingException(java.security.cert.CertificateEncodingException) BaseMappingException(org.gluu.persist.exception.mapping.BaseMappingException) IOException(java.io.IOException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) ApiResponses(com.wordnik.swagger.annotations.ApiResponses)

Example 34 with ApiResponses

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());
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) ArrayList(java.util.ArrayList) ScimConfiguration(org.gluu.oxtrust.model.scim.ScimConfiguration) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) ApiResponses(com.wordnik.swagger.annotations.ApiResponses)

Example 35 with ApiResponses

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);
}
Also used : Field(java.lang.reflect.Field) ResponseEntity(org.springframework.http.ResponseEntity) HashMap(java.util.HashMap) QueryAttribute(com.infiniteautomation.mango.db.query.QueryAttribute) ArrayList(java.util.ArrayList) TableModel(com.infiniteautomation.mango.db.query.TableModel) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) ApiResponses(com.wordnik.swagger.annotations.ApiResponses) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ApiResponses (com.wordnik.swagger.annotations.ApiResponses)47 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)44 Path (javax.ws.rs.Path)21 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)19 Produces (javax.ws.rs.Produces)17 POST (javax.ws.rs.POST)14 RestProcessResult (com.serotonin.m2m2.web.mvc.rest.v1.message.RestProcessResult)13 IOException (java.io.IOException)10 User (com.serotonin.m2m2.vo.User)9 Consumes (javax.ws.rs.Consumes)9 GET (javax.ws.rs.GET)9 ArrayList (java.util.ArrayList)8 WebApplicationException (javax.ws.rs.WebApplicationException)8 CertificateEncodingException (java.security.cert.CertificateEncodingException)6 GluuSAMLTrustRelationship (org.gluu.oxtrust.model.GluuSAMLTrustRelationship)6 BaseMappingException (org.gluu.persist.exception.mapping.BaseMappingException)6 TranslatableMessage (com.serotonin.m2m2.i18n.TranslatableMessage)5 ResponseEntity (org.springframework.http.ResponseEntity)5 SingularityRequestWithState (com.hubspot.singularity.SingularityRequestWithState)4 InvalidRQLRestException (com.infiniteautomation.mango.rest.v2.exception.InvalidRQLRestException)4