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