use of org.springframework.web.bind.annotation.CrossOrigin in project LaRocheChemAssessment by clubberstake.
the class ClassController method saveSyllabus.
@CrossOrigin(origins = "http://localhost:4200")
@PostMapping("/saveSyllabus")
public ResponseEntity<Void> saveSyllabus(@RequestBody String[] syllabus) throws FileNotFoundException {
System.out.println(syllabus[1]);
String[] filepath = syllabus[0].split("/");
String PATH = "src/main/java/laroche/chem/assessment/syllabus";
for (int i = 0; i < filepath.length - 1; i++) {
PATH = PATH + "/" + filepath[i];
File directory = new File(String.valueOf(PATH));
if (!directory.exists()) {
directory.mkdir();
}
}
System.out.println(PATH);
writer = new PrintWriter(PATH + "/" + filepath[filepath.length - 1]);
writer.println(syllabus[1]);
writer.close();
return ResponseEntity.status(HttpStatus.CONFLICT).build();
}
use of org.springframework.web.bind.annotation.CrossOrigin in project Info-Evaluation by TechnionYP5777.
the class InfoevalServiceImp method checkAmbiguities.
@Override
@CrossOrigin
@RequestMapping(path = "Queries/checkAmbiguities", method = RequestMethod.GET)
public synchronized ArrayList<String> checkAmbiguities(String name) throws IOException {
String UpdatedName = updteName(name);
try {
logger.log(Level.INFO, "Checking ambiguities in URL: " + "https://en.wikipedia.org/wiki/" + UpdatedName);
WikiParsing wiki = (new WikiParsing("https://en.wikipedia.org/wiki/" + UpdatedName));
// System.out.print("Trying to fetch from ,
// https://en.wikipedia.org/wiki/" + UpdatedName);
wiki.CheckAmbiguities();
return !wiki.isConflictedName() ? null : wiki.getNames();
} catch (Exception e) {
logger.log(Level.WARNING, "Problem in checking ambiguities");
throw e;
}
}
use of org.springframework.web.bind.annotation.CrossOrigin in project Info-Evaluation by TechnionYP5777.
the class InfoevalServiceImp method getArrested.
@Override
@CrossOrigin
@RequestMapping(path = "Queries/Arrests", method = RequestMethod.GET)
public synchronized LinkedList<String> getArrested(String name) throws Exception {
// Parse user's input:
String UpdatedName = updteName(name);
try {
logger.log(Level.INFO, "Analyzing Arrests query from url: " + "https://en.wikipedia.org/wiki/" + UpdatedName);
WikiParsing wiki = (new WikiParsing("https://en.wikipedia.org/wiki/" + UpdatedName));
wiki.Parse("arrested");
new ArrayList<>();
analyze.setParagraphsArrests(wiki.getParagraphs());
analyze.clearArrestsInformation();
analyze.ArrestsQuery();
return analyze.getArrestsInformation();
} catch (Exception e) {
logger.log(Level.WARNING, "Problem in arrests query");
throw e;
}
}
use of org.springframework.web.bind.annotation.CrossOrigin in project c4sg-services by Code4SocialGood.
the class OrganizationController method createUserOrganization.
@CrossOrigin
@RequestMapping(value = "/{id}/users/{userId}", method = RequestMethod.POST)
@ApiOperation(value = "Create a relation between user and organization")
@ApiResponses(value = { @ApiResponse(code = 404, message = "ID of organization or user invalid") })
public // TODO: Replace explicit user{id} with AuthN user id.
ResponseEntity<?> createUserOrganization(@ApiParam(value = "ID of user", required = true) @PathVariable("userId") Integer userId, @ApiParam(value = "ID of organization", required = true) @PathVariable("id") Integer organizationId) {
System.out.println("************** OrganizationController.createUserOrganization()" + ": userId=" + userId + "; organizationId=" + organizationId + " **************");
try {
organizationService.saveUserOrganization(userId, organizationId);
URI location = ServletUriComponentsBuilder.fromCurrentRequest().path("/{id}/users/{userId}").buildAndExpand(organizationId, userId).toUri();
return ResponseEntity.created(location).build();
} catch (NullPointerException | UserOrganizationException e) {
throw new NotFoundException("ID of organization or user invalid, or relationship already exist");
}
}
use of org.springframework.web.bind.annotation.CrossOrigin in project spring-framework by spring-projects.
the class RequestMappingHandlerMapping method initCorsConfiguration.
@Override
protected CorsConfiguration initCorsConfiguration(Object handler, Method method, RequestMappingInfo mappingInfo) {
HandlerMethod handlerMethod = createHandlerMethod(handler, method);
Class<?> beanType = handlerMethod.getBeanType();
CrossOrigin typeAnnotation = AnnotatedElementUtils.findMergedAnnotation(beanType, CrossOrigin.class);
CrossOrigin methodAnnotation = AnnotatedElementUtils.findMergedAnnotation(method, CrossOrigin.class);
if (typeAnnotation == null && methodAnnotation == null) {
return null;
}
CorsConfiguration config = new CorsConfiguration();
updateCorsConfig(config, typeAnnotation);
updateCorsConfig(config, methodAnnotation);
if (CollectionUtils.isEmpty(config.getAllowedMethods())) {
for (RequestMethod allowedMethod : mappingInfo.getMethodsCondition().getMethods()) {
config.addAllowedMethod(allowedMethod.name());
}
}
return config.applyPermitDefaultValues();
}
Aggregations