Search in sources :

Example 11 with CrossOrigin

use of org.springframework.web.bind.annotation.CrossOrigin in project c4sg-services by Code4SocialGood.

the class OrganizationController method getOrganizationsByUser.

@CrossOrigin
@RequestMapping(value = "/user/{id}", method = RequestMethod.GET)
@ApiOperation(value = "Find organizations by user id", notes = "Returns a collection of organizations")
@ApiResponses(value = { @ApiResponse(code = 404, message = "ID of user invalid") })
public List<OrganizationDTO> getOrganizationsByUser(@ApiParam(value = "userId of organizations to return", required = true) @PathVariable("id") Integer id) {
    System.out.println("************** OrganizationController.getOrganizationsByUser()" + ": id=" + id + " **************");
    List<OrganizationDTO> organizations = null;
    try {
        organizations = organizationService.findByUser(id);
    } catch (Exception e) {
        throw new NotFoundException("ID of user invalid");
    }
    return organizations;
}
Also used : NotFoundException(org.c4sg.exception.NotFoundException) CreateOrganizationDTO(org.c4sg.dto.CreateOrganizationDTO) OrganizationDTO(org.c4sg.dto.OrganizationDTO) NotFoundException(org.c4sg.exception.NotFoundException) UserOrganizationException(org.c4sg.exception.UserOrganizationException) BadRequestException(org.c4sg.exception.BadRequestException) CrossOrigin(org.springframework.web.bind.annotation.CrossOrigin) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 12 with CrossOrigin

use of org.springframework.web.bind.annotation.CrossOrigin in project c4sg-services by Code4SocialGood.

the class OrganizationController method updateOrganization.

@CrossOrigin
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
@ApiOperation(value = "Update an existing organization")
public Map<String, Object> updateOrganization(@ApiParam(value = "Updated organization object", required = true) @PathVariable("id") int id, @RequestBody @Valid OrganizationDTO organizationDTO) {
    System.out.println("************** OrganizationController.updateOrganization()" + ": id=" + id + "; organizationDTO=" + organizationDTO + " **************");
    Map<String, Object> responseData = null;
    try {
        OrganizationDTO updatedOrganization = organizationService.updateOrganization(id, organizationDTO);
        responseData = Collections.synchronizedMap(new HashMap<>());
        responseData.put("organization", updatedOrganization);
    } catch (Exception e) {
        System.err.println(e);
    }
    return responseData;
}
Also used : HashMap(java.util.HashMap) CreateOrganizationDTO(org.c4sg.dto.CreateOrganizationDTO) OrganizationDTO(org.c4sg.dto.OrganizationDTO) NotFoundException(org.c4sg.exception.NotFoundException) UserOrganizationException(org.c4sg.exception.UserOrganizationException) BadRequestException(org.c4sg.exception.BadRequestException) CrossOrigin(org.springframework.web.bind.annotation.CrossOrigin) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 13 with CrossOrigin

use of org.springframework.web.bind.annotation.CrossOrigin in project c4sg-services by Code4SocialGood.

the class OrganizationController method createOrganization.

@CrossOrigin
@RequestMapping(method = RequestMethod.POST)
@ApiOperation(value = "Create organization", notes = "Creates an organization, and returns the organization created.", response = OrganizationDTO.class)
@ApiResponses(value = { @ApiResponse(code = 500, message = "Internal server error") })
public Map<String, Object> createOrganization(@ApiParam(value = "Organization to create", required = true) @RequestBody @Valid CreateOrganizationDTO createOrganizationDTO) {
    System.out.println("************** OrganizationController.createOrganization()" + ": createOrganizationDTO=" + createOrganizationDTO + " **************");
    Map<String, Object> responseData = null;
    // organizationDTO.setLogo(organizationService.getLogoUploadPath(organizationDTO.getId()));
    try {
        OrganizationDTO createdOrganization = organizationService.createOrganization(createOrganizationDTO);
        responseData = Collections.synchronizedMap(new HashMap<>());
        responseData.put("organization", createdOrganization);
    } catch (Exception e) {
        System.err.println(e);
    }
    return responseData;
}
Also used : HashMap(java.util.HashMap) CreateOrganizationDTO(org.c4sg.dto.CreateOrganizationDTO) OrganizationDTO(org.c4sg.dto.OrganizationDTO) NotFoundException(org.c4sg.exception.NotFoundException) UserOrganizationException(org.c4sg.exception.UserOrganizationException) BadRequestException(org.c4sg.exception.BadRequestException) CrossOrigin(org.springframework.web.bind.annotation.CrossOrigin) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 14 with CrossOrigin

use of org.springframework.web.bind.annotation.CrossOrigin in project ORCID-Source by ORCID.

the class OpenIDController method getOpenIDDiscovery.

/**
 * Expose the openid discovery information
 *
 * @param request
 * @return
 * @throws JsonProcessingException
 */
@CrossOrigin
@RequestMapping(value = "/.well-known/openid-configuration", method = RequestMethod.GET, produces = "application/json")
@ResponseBody
public String getOpenIDDiscovery(HttpServletRequest request) throws JsonProcessingException {
    ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
    String json = ow.writeValueAsString(openIDConnectDiscoveryService.getConfig());
    return json;
}
Also used : ObjectWriter(com.fasterxml.jackson.databind.ObjectWriter) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) CrossOrigin(org.springframework.web.bind.annotation.CrossOrigin) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 15 with CrossOrigin

use of org.springframework.web.bind.annotation.CrossOrigin in project sonarQuest by viadee.

the class QuestController method addWorld.

@CrossOrigin
@RequestMapping(value = "/{questId}/addWorld/{worldId}", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
public QuestDto addWorld(@PathVariable(value = "questId") final Long questId, @PathVariable(value = "worldId") final Long worldId) {
    Quest quest = this.questRepository.findOne(questId);
    if (quest != null) {
        final World world = this.worldRepository.findOne(worldId);
        quest.setWorld(world);
        quest = this.questRepository.save(quest);
    }
    return toQuestDto(quest);
}
Also used : World(com.viadee.sonarQuest.entities.World) Quest(com.viadee.sonarQuest.entities.Quest) CrossOrigin(org.springframework.web.bind.annotation.CrossOrigin) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

CrossOrigin (org.springframework.web.bind.annotation.CrossOrigin)27 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)24 Task (com.viadee.sonarQuest.entities.Task)8 SpecialTask (com.viadee.sonarQuest.entities.SpecialTask)7 Quest (com.viadee.sonarQuest.entities.Quest)6 ApiOperation (io.swagger.annotations.ApiOperation)5 IOException (java.io.IOException)5 NotFoundException (org.c4sg.exception.NotFoundException)4 UserOrganizationException (org.c4sg.exception.UserOrganizationException)4 SpecialTaskDto (com.viadee.sonarQuest.dtos.SpecialTaskDto)3 TaskDto (com.viadee.sonarQuest.dtos.TaskDto)3 TaskDto.toTaskDto (com.viadee.sonarQuest.dtos.TaskDto.toTaskDto)3 World (com.viadee.sonarQuest.entities.World)3 WikiParsing (infoeval.main.WikiData.WikiParsing)3 ApiResponses (io.swagger.annotations.ApiResponses)3 ArrayList (java.util.ArrayList)3 CreateOrganizationDTO (org.c4sg.dto.CreateOrganizationDTO)3 OrganizationDTO (org.c4sg.dto.OrganizationDTO)3 BadRequestException (org.c4sg.exception.BadRequestException)3 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)3