@CrossOrigin @RequestMapping(value = "/detectMeaningLanguageSpecific", method = RequestMethod.GET) HttpEntity<Object> detectMeaningLanguageSpecific(@RequestParam("inputAsJson") String inputAsJson) { try { Logger.getAnonymousLogger().log(Level.INFO, "Invoke: detectMeaningLanguageSpecific: " + inputAsJson); Gson gson = new Gson(); InputParameterdetectMeaningLanguageSpecific inputParameterdetectMeaningLanguageSpecific = gson .fromJson(inputAsJson, InputParameterdetectMeaningLanguageSpecific.class); List<Entity> concepts = sparqlDerivation.detectPossibleConceptsLanguageSpecific( inputParameterdetectMeaningLanguageSpecific.getKeyword(), inputParameterdetectMeaningLanguageSpecific.getLanguage()); MeaningResult meaningResult = new MeaningResult(); meaningResult.setConceptOverview(concepts); meaningResult.setSearchTyp("ExplorativeSearch"); Gson output = new Gson(); String result = ""; result = output.toJson(meaningResult); return new ResponseEntity<Object>(result, HttpStatus.OK); } catch (Exception e) { return new ResponseEntity<Object>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); } }
@CrossOrigin @RequestMapping(value = "/invokechaincode", method = RequestMethod.POST) @ResponseBody public String invokeMethod(@RequestBody String[] chaincodeParameters) throws CryptoException, InvalidArgumentException, TransactionException, IOException, InterruptedException, ExecutionException, TimeoutException, ProposalException, IllegalAccessException, InstantiationException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException { String ops = "transfer"; String org = "druginc"; String channelName = "drugchan"; String chainCode = "bbb"; //String[] params = new String[] { "Bob", "Alice", "20" }; String[] params = chaincodeParameters; String peerName = "peer0.druginc.drug.com"; User user = new UserFileSystem("Admin", "druginc.drug.com"); TransactionEvent event = new InvokeChaincode().invoke(ops, params, org, peerName, channelName, chainCode, user); if (event != null) { // event.getTransactionID(). } return "Success!"; }
/** * ChangeDetails post method. Receives the new information of the user, * checks it and updates it on the heroku server. * * @param name * @param phone * @param newCar * @param email * @param type * @param oldCar * @return A JSONized string of the success/error value. */ @CrossOrigin(origins = "*") @RequestMapping(value = "/User/ChangeDetails", method = RequestMethod.POST, produces = "application/json") @ResponseBody public String changeDetails(@RequestParam("name") String name, @RequestParam("phone") String phone, @RequestParam("newCar") String newCar, @RequestParam("email") String email, @RequestParam("type") String type, @RequestParam("oldCar") String oldCar) { boolean retVal = false; // LoginManager login = new LoginManager(); try { retVal = login.userUpdate(oldCar, name, phone, email, newCar, SCStringToSC(type)); System.out.println("in UC.changeDetails.POST retVal=" + retVal); if (!retVal) System.out.println("in UC.changeDetails.POST changeDetails failed!"); else { setUserData(name, newCar, email, phone, SCStringToSC(type)); System.out.println("in UC.changeDetails.POST changeDetails success!"); } } catch (LoginException e) { System.out.println("in UC.changeDetails.POST Exception thrown: " + e); e.printStackTrace(); } detailsChanged = true; return JSONize("val", retVal ? "true" : "false"); }
@ApiResponses({ @ApiResponse(code = 200, response = String.class, message = "success"), @ApiResponse(code = 400, response = String.class, message = "illegal request content"), }) @CrossOrigin @RequestMapping(value = "requests", method = GET) public ResponseEntity<SagaExecutionQueryResult> queryExecutions( @RequestParam(name = "pageIndex") String pageIndex, @RequestParam(name = "pageSize") String pageSize, @RequestParam(name = "startTime") String startTime, @RequestParam(name = "endTime") String endTime) { if (isRequestParamValid(pageIndex, pageSize, startTime, endTime)) { try { return ResponseEntity.ok(queryService.querySagaExecution(pageIndex, pageSize, startTime, endTime)); } catch (ParseException ignored) { throw new InvocationException(BAD_REQUEST, "illegal request content"); } } else { throw new InvocationException(BAD_REQUEST, "illegal request content"); } }
/** * New Login get method * @return the user object */ @CrossOrigin(origins = "*") @RequestMapping(value = "/User/LoginDemo/{key}", produces = "application/json") @ResponseBody public ServerUser loginDemo(@PathVariable String key) { if (users.get(key) != null) { final ParseQuery<ParseObject> query = ParseQuery.getQuery("PMUser"); try { ParseObject o = query.get(users.get(key).getUserId()); return (o == null) ? new ServerUser() : new ServerUser(new User(o)); } catch (final Exception e) { return null; } } return new ServerUser(); }
@ApiOperation(value = "Get users", notes = "", response = User.class, responseContainer = "List", authorizations = { @Authorization(value = "Bearer") }, tags={ "admin", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Get User list ok", response = User.class), @ApiResponse(code = 500, message = "An unexpected error occured.", response = User.class) }) @RequestMapping(value = "/users", produces = { "application/json" }, method = RequestMethod.GET) @CrossOrigin ResponseEntity<Object> usersGet( @ApiParam(value = "Request pagination page") @RequestParam(value = "page", required = false) String page, @ApiParam(value = "Request pagination size / num of users") @RequestParam(value = "size", required = false) String size, @ApiParam(value = "Request orderBy filter") @RequestParam(value = "orderBy", required = false) String orderBy, @ApiParam(value = "Request orderBy filter") @RequestParam(value = "orderDirection", required = false) String orderDirection, @ApiParam(value = "Request search term") @RequestParam(value = "lastName", required = false) String lastName) throws ApiException, Exception;
@ApiOperation(value = "", notes = "Change approve status of user", response = Void.class, authorizations = { @Authorization(value = "Bearer") }, tags={ "admin", }) @ApiResponses(value = { @ApiResponse(code = 204, message = "no content", response = Void.class), @ApiResponse(code = 400, message = "Bad request", response = Void.class), @ApiResponse(code = 404, message = "not found", response = Void.class), @ApiResponse(code = 409, message = "Non-final orders found", response = Void.class), @ApiResponse(code = 500, message = "An unexpected error occured.", response = Void.class) }) @RequestMapping(value = "/users/{id}/approve", produces = { "application/json" }, method = RequestMethod.PUT) @CrossOrigin ResponseEntity<Object> usersIdApprovePut(@ApiParam(value = "",required=true ) @PathVariable("id") Long id, @NotNull @ApiParam(value = "Approve or disapprove", required = true) @RequestParam(value = "approve", required = true) Boolean approve, @ApiParam(value = "Force disapprove user") @RequestParam(value = "force", required = false) Boolean force) throws ApiException, Exception;
@ApiOperation(value = "Deletes an existing user", notes = " ", response = Void.class, authorizations = { @Authorization(value = "Bearer") }, tags={ "admin", }) @ApiResponses(value = { @ApiResponse(code = 204, message = "User successfully deleted", response = Void.class), @ApiResponse(code = 400, message = "User couldn't be deleted", response = Void.class), @ApiResponse(code = 402, message = "Mix final orders", response = Void.class), @ApiResponse(code = 404, message = "User not found", response = Void.class), @ApiResponse(code = 409, message = "Only not final orders", response = Void.class), @ApiResponse(code = 412, message = "Only final orders", response = Void.class) }) @RequestMapping(value = "/users/{id}", produces = { "application/json" }, method = RequestMethod.DELETE) @CrossOrigin ResponseEntity<Object> usersIdDelete(@ApiParam(value = "",required=true ) @PathVariable("id") Long id, @ApiParam(value = "") @RequestParam(value = "force", required = false) Boolean force) throws ApiException, Exception;
@ApiOperation(value = "Updates an existing food", notes = "Chef can update food name, type, description or price", response = Message.class, authorizations = { @Authorization(value = "Bearer") }, tags={ "chef", }) @ApiResponses(value = { @ApiResponse(code = 204, message = "A custom message.", response = Message.class), @ApiResponse(code = 400, message = "An unexpected error occured.", response = Message.class), @ApiResponse(code = 404, message = "Food not found", response = Message.class), @ApiResponse(code = 409, message = "Concurrent modification error", response = Message.class), @ApiResponse(code = 412, message = "Food name already exists", response = Message.class), @ApiResponse(code = 500, message = "An unexpected error occured.", response = Message.class) }) @RequestMapping(value = "/foods/{foodId}", produces = { "application/json" }, method = RequestMethod.PUT) @CrossOrigin ResponseEntity<Message> foodsFoodIdPut(@ApiParam(value = "",required=true ) @PathVariable("foodId") Long foodId, @ApiParam(value = "The food to be updated" ,required=true ) @Valid @RequestBody EditedFood food, @ApiParam(value = "") @RequestParam(value = "clone", required = false) Boolean clone)throws ApiException, Exception;
@ApiOperation(value = "Gets all foods, optionally return stats per food", notes = "Return a list of all foods", response = FoodWithStats.class, responseContainer = "List", authorizations = { @Authorization(value = "Bearer") }, tags={ "chef", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "A list of foods", response = FoodWithStats.class), @ApiResponse(code = 500, message = "An unexpected error occured.", response = FoodWithStats.class) }) @RequestMapping(value = "/foods", produces = { "application/json" }, method = RequestMethod.GET) @CrossOrigin ResponseEntity<FoodsPage> foodsGet( @ApiParam(value = "") @RequestParam(value = "stats", required = false) Boolean stats, @ApiParam(value = "Request pagination page") @RequestParam(value = "page", required = false) String page, @ApiParam(value = "Request pagination size / num of foods") @RequestParam(value = "size", required = false) String size, @ApiParam(value = "Request foodType filter") @RequestParam(value = "foodType", required = false) String foodType, @ApiParam(value = "Request archived filter") @RequestParam(value = "archived", required = false) String archived, @ApiParam(value = "Request orderBy filter") @RequestParam(value = "orderBy", required = false) String orderBy, @ApiParam(value = "Request foods version") @RequestParam(value = "foods_version", required = false) @Valid @Digits( integer=9, fraction=0 )Integer foods_version, @ApiParam(value = "Request orderBy filter") @RequestParam(value = "orderDirection", required = false) String orderDirection) throws ApiException, Exception;
/** * Login post method. logs the user into the heroku server. * * @param name * : the unique user id. * @param pass * : the user password. */ @CrossOrigin(origins = "*") @RequestMapping(value = "/User/Login", method = RequestMethod.POST, produces = "application/json") @ResponseBody public void login(@RequestParam("name") String name, @RequestParam("pass") String pass) { System.out.println("Login.POST: name:" + name + "pass:" + pass); if (name != null) if (!"".equals(name)) { if (login.userLogin(name, pass)) setUserData(login.getUserName(), login.getCarNumber(), login.getEmail(), login.getPhoneNumber(), login.getSticker()); } else { System.out.println("Logging out"); setUserData("", "", "", "", StickersColor.WHITE); lastRegVal = ""; detailsChanged = false; } }
/** * New Login post method. logs the user into the heroku server. * * @param name * : the unique user id. * @param pass * : the user password. */ @CrossOrigin(origins = "*") @RequestMapping(value = "/User/LoginDemo/{key}", method = RequestMethod.POST, produces = "application/json") @ResponseBody public String loginDemo(@PathVariable("key") String key, @RequestParam("name") String name, @RequestParam("pass") String pass) { if (name == null) return statusToString(UCStatus.BAD_PARAMS); if (!"".equals(name)) { System.out.println("Logging in " + name); UserState us = new UserState(); if ((users.get(key) != null && users.get(key).getStatus() == UCStatus.SUCCESS) || !us.UserLogin(name, pass)) return statusToString(UCStatus.ALREADY_CONNECTED); if (users.get(key) != null) users.remove(key); us.setStatus(UCStatus.SUCCESS); users.put(key, us); return statusToString(users.get(key).getStatus()); } if (users.get(key) == null) return statusToString(UCStatus.NOT_CONNECTED); System.out.println("Logging out"); users.remove(key); return statusToString(UCStatus.SUCCESS); }
@ApiOperation(value = "Put Food/Foods in a dailyMenu", notes = "", response = LastEdit.class, authorizations = { @Authorization(value = "Bearer") }, tags={ "chef", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "daily menu updated ok", response = LastEdit.class), @ApiResponse(code = 204, message = "daily Menu deleted", response = LastEdit.class), @ApiResponse(code = 400, message = "Bad Request for daily menu", response = LastEdit.class), @ApiResponse(code = 404, message = "daily menu not found", response = LastEdit.class), @ApiResponse(code = 409, message = "Concurrent modification error", response = LastEdit.class), @ApiResponse(code = 412, message = "can't modify menus older than yesterday", response = LastEdit.class), @ApiResponse(code = 417, message = "The request is failed because there are orders on the food", response = LastEdit.class), @ApiResponse(code = 500, message = "An unexpected error occured.", response = LastEdit.class) }) @RequestMapping(value = "/dailyMenus/{id}", produces = { "application/json" }, method = RequestMethod.PUT) @CrossOrigin ResponseEntity<Object> dailyMenusIdPut(@ApiParam(value = "",required=true ) @PathVariable("id") String id, @ApiParam(value = "The daily menu to be updated" ,required=true ) @RequestBody DailyMenuEdit dailyMenu) throws ApiException;
@ApiOperation(value = "Modifies order for the specified day", notes = "Modify the order", response = DailyOrder.class, authorizations = { @Authorization(value = "Bearer") }, tags={ "hungry", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Order succesfully retrieved", response = DailyOrder.class), @ApiResponse(code = 404, message = "Order not found", response = DailyOrder.class), @ApiResponse(code = 410, message = "Concurrent Order Deletion", response = DailyOrder.class), @ApiResponse(code = 500, message = "An unexpected error occured.", response = DailyOrder.class) }) @RequestMapping(value = "/orders/{id}", produces = { "application/json" }, method = RequestMethod.GET) @CrossOrigin ResponseEntity<DailyOrder> ordersIdGet(@ApiParam(value = "",required=true ) @PathVariable("id") Long id, @NotNull @ApiParam(value = "", required = true) @RequestParam(value = "dailyMenuId", required = true) Long dailyMenuId, @NotNull @ApiParam(value = "", required = true) @RequestParam(value = "dailyMenuVersion", required = true) int dailyMenuVersion, @NotNull @ApiParam(value = "", required = true) @RequestParam(value = "dailyMenuDate", required = true) LocalDate dailyMenuDate,@ApiParam(value = "") @RequestParam(value = "userid", required = false) Long userid) throws ApiException;
@ApiOperation(value = "Modifies order for the specified day", notes = "Modify the order", response = OrderUpdate.class, authorizations = { @Authorization(value = "Bearer") }, tags={ "hungry", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Order succesfully modified", response = OrderUpdate.class), @ApiResponse(code = 304, message = "Unmodified data", response = Void.class), @ApiResponse(code = 400, message = "Order couldn't be modified.", response = Void.class), @ApiResponse(code = 402, message = "Not enough balance.", response = Void.class), @ApiResponse(code = 404, message = "Order not found (id)", response = Void.class), @ApiResponse(code = 409, message = "Concurrent modification error", response = DailyOrder.class), @ApiResponse(code = 410, message = "Concurrent Order Deletion", response = ConcurrentOrderDeletion.class), @ApiResponse(code = 412, message = "Deadline for orders passed", response = Void.class), @ApiResponse(code = 500, message = "An unexpected error occured.", response = Error.class) }) @RequestMapping(value = "/orders/{id}", produces = { "application/json" }, method = RequestMethod.PUT) @CrossOrigin ResponseEntity<Object> ordersIdPut(@ApiParam(value = "",required=true ) @PathVariable("id") Long id,@ApiParam(value = "") @RequestParam(value = "userid", required = false) Long userid, @ApiParam(value = "The order items to modify" ) @RequestBody UpdateOrderItems updateOrderItems, Errors errors) throws ApiException;
@ApiOperation(value = "Place a new order", notes = "A new order for the specified daily menu", response = DailyMenu.class, authorizations = { @Authorization(value = "Bearer") }, tags={ "hungry", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Order succesfully placed", response = DailyMenu.class), @ApiResponse(code = 400, message = "Order couldn't have been placed.", response = DailyMenu.class), @ApiResponse(code = 402, message = "Not enough balance.", response = Void.class), @ApiResponse(code = 409, message = "Order already placed", response = DailyMenu.class), @ApiResponse(code = 410, message = "Concurrent Order Deletion", response = DailyMenu.class), @ApiResponse(code = 412, message = "Deadline for orders passed", response = DailyMenu.class), @ApiResponse(code = 500, message = "An unexpected error occured.", response = DailyMenu.class) }) @RequestMapping(value = "/orders", produces = { "application/json" }, method = RequestMethod.POST) @CrossOrigin ResponseEntity<Object> ordersPost(@ApiParam(value = "The order to place" ) @RequestBody Order order,@ApiParam(value = "") @RequestParam(value = "userid", required = false) Long userid, Errors errors) throws ApiException;
/** * Returns from a given concept the data properties and obejctproperties and * to each objecproperty a concept in the case the step range is greater 1 * * @param concept * @param step * range * @param * @return */ @CrossOrigin @RequestMapping(value = "/getPropertyValuesDiscretised", method = RequestMethod.GET) HttpEntity<Object> getPropertyValuesDiscretised(@RequestParam("inputAsJson") String inputAsJson) { try { Logger.getAnonymousLogger().log(Level.INFO, "Invoke: getPropertyValuesDiscretised: " + inputAsJson); Gson gson = new Gson(); InputParameterForgetPropertyValuesDiscretised paramterForGetLogicalView = gson.fromJson(inputAsJson, InputParameterForgetPropertyValuesDiscretised.class); Map<String, List<Group>> mapOfPropertyGroups = sparqlDerivation.generateGroup( paramterForGetLogicalView.getAmountOfGroups(), paramterForGetLogicalView.getConcept(), paramterForGetLogicalView.getProperty()); String result = ""; result = gson.toJson(mapOfPropertyGroups); return new ResponseEntity<Object>(result, HttpStatus.OK); } catch (Exception e) { return new ResponseEntity<Object>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); } }
/** * Returns from a given concept the data properties and obejctproperties and * to each objecproperty a concept in the case the step range is greater 1 * * @param concept * @param step * range * @param * @return */ @CrossOrigin @RequestMapping(value = "/executeSPARQLSelect", method = RequestMethod.GET) HttpEntity<Object> executeSPARQLSelect(@RequestParam("inputAsJson") String inputAsJson) { Logger.getAnonymousLogger().log(Level.INFO, "Invoke: executeSPARQLSelect: " + inputAsJson); OutputForExecuteSelect outputForExecuteSelect = new OutputForExecuteSelect(); try { Gson gson = new Gson(); InputParamaterForExecuteSelect inputParamaterForExecuteSelect = gson.fromJson(inputAsJson, InputParamaterForExecuteSelect.class); outputForExecuteSelect = sparqlDerivation.createSPARQLAndExecuteIT(inputParamaterForExecuteSelect); String result = ""; result = gson.toJson(outputForExecuteSelect); return new ResponseEntity<Object>(result, HttpStatus.OK); } catch (Exception e) { return new ResponseEntity<Object>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); } }
@CrossOrigin @RequestMapping(value = "/getSupportedLanguages", method = RequestMethod.GET) public HttpEntity<Object> getSupportedLanguages() { try { List<String> languages = sparqlDerivation.getSupportedLanguages(); Gson output = new Gson(); String result = ""; OutoutForGetSupportedLanguages supportedLanguages = new OutoutForGetSupportedLanguages(); supportedLanguages.getLanguages().addAll(languages); result = output.toJson(supportedLanguages); return new ResponseEntity<Object>(result, HttpStatus.OK); } catch (Exception e) { return new ResponseEntity<Object>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); } }
@RequestMapping("/register") @CrossOrigin public String register(@RequestParam(value="un", defaultValue="guestUser") String un, HttpServletRequest request) { String response = ""; String sessionKey; Map<String, String> responseMap = new HashMap<String, String> (); session = request.getSession(); sessionKey = session.getId(); PLPUserDB.getInstance().registerNewUser(un, session, sessionKey ); responseMap.put("status", "success"); responseMap.put("session_key", sessionKey); try { response = new ObjectMapper().writeValueAsString(responseMap); } catch (JsonProcessingException e) { System.out.println("JSON parsing Error."); e.printStackTrace(); } //response += "\"status\":\"successs\",\"session_key\":\"" + sessionKey + "\""; System.out.println(response); return response; }
@CrossOrigin @RequestMapping(method = RequestMethod.GET, value = "/memory", produces = "text/plain") public String memory() { System.out.println("Starting to allocate memory..."); Runtime rt = Runtime.getRuntime(); StringBuilder sb = new StringBuilder(); long maxMemory = rt.maxMemory(); long usedMemory = 0; while (((float) usedMemory / maxMemory) < 0.80) { sb.append(System.nanoTime() + sb.toString()); usedMemory = rt.totalMemory(); } String msg = "Allocated more than 80% (" + humanReadableByteCount(usedMemory, false) + ") of the max allowed JVM memory size (" + humanReadableByteCount(maxMemory, false) + ")"; System.out.println(msg); return msg; }
@RequestMapping(value = "/StepSim" , method = RequestMethod.GET) @CrossOrigin public String StepSim(HttpServletRequest request, HttpSession session) throws IOException { String response = ""; try { EventRegistry.getGlobalRegistry().post( new SimulatorControlEvent("step", null)); } catch (Exception exception) { throw new IllegalStateException("No simulator is active!", exception); } response = "{\"status\":\"ok\"}"; return response; }
@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; }
@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; }
@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; }
@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") }) // TODO: Replace explicit user{id} with AuthN user id. public 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"); } }
@ApiResponses({ @ApiResponse(code = 400, response = String.class, message = "illegal request content"), }) @RequestMapping(path = "/{name}", method = RequestMethod.GET) @CrossOrigin @Override public HealthCheckResult healthWithName(@PathVariable(name = "name") String name) { return manager.check(name); }
@CrossOrigin @ApiOperation(value = "创建用户", notes = "根据User对象创建用户") @ApiImplicitParam(name = "user", value = "用户详细实体user", required = true, dataType = "User") @RequestMapping(value = "", method = RequestMethod.POST) public String postUser(@RequestBody User user) { // users.put(user.getId(), user); userService.insertUser(user); return "success"; }
@ApiResponses({ @ApiResponse(code = 200, response = String.class, message = "success"), }) @CrossOrigin @RequestMapping(value = "requests/{sagaId}", method = GET) public ResponseEntity<SagaExecutionDetail> queryExecutionDetail(@PathVariable String sagaId) { return ResponseEntity.ok(queryService.querySagaExecutionDetail(sagaId)); }
@ApiOperation(value = "", notes = "Remind password", response = Void.class, tags={ "auth", }) @ApiResponses(value = { @ApiResponse(code = 204, message = "Reset password email sent", response = Void.class), @ApiResponse(code = 400, message = "Bad email", response = Void.class), @ApiResponse(code = 500, message = "An unexpected error occured.", response = Void.class) }) @RequestMapping(value = "/auth/forgotpwd", produces = { "application/json" }, method = RequestMethod.POST) @CrossOrigin ResponseEntity<Void> authForgotpwdPost(@ApiParam(value = "The email" ,required=true ) @RequestBody String email) throws ApiException;
@ApiOperation(value = "", notes = "Allow users to log in, and to receive a Token", response = Token.class, tags={ "auth", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Login Success.", response = Token.class), @ApiResponse(code = 403, message = "User can not login (not approved).", response = Token.class), @ApiResponse(code = 404, message = "User not found (bad credentials).", response = Token.class), @ApiResponse(code = 500, message = "An unexpected error occured.", response = Token.class) }) @RequestMapping(value = "/auth/login", produces = { "application/json" }, method = RequestMethod.POST) @CrossOrigin ResponseEntity<Token> authLoginPost(@ApiParam(value = "The email/password" ,required=true ) @RequestBody Login body) throws ApiException;
@ApiOperation(value = "", notes = "Allow users to register", response = Void.class, tags={ "auth", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Registration Success", response = Void.class), @ApiResponse(code = 400, message = "Bad registration data", response = Void.class), @ApiResponse(code = 412, message = "user already exists", response = Void.class), @ApiResponse(code = 500, message = "An unexpected error occured.", response = Void.class) }) @RequestMapping(value = "/auth/register", produces = { "application/json" }, method = RequestMethod.POST) @CrossOrigin ResponseEntity<Error> authRegisterPost(@ApiParam(value = "The email/password" ,required=true ) @Valid @RequestBody UserReg body, Errors errors) throws ApiException;
@ApiOperation(value = "", notes = "Allow users to reset password", response = Void.class, authorizations = { @Authorization(value = "Bearer") }, tags={ "auth", }) @ApiResponses(value = { @ApiResponse(code = 204, message = "Password change Success", response = Void.class), @ApiResponse(code = 400, message = "Bad reset password data", response = Void.class), @ApiResponse(code = 500, message = "An unexpected error occured.", response = Void.class) }) @RequestMapping(value = "/auth/changepwd", produces = { "application/json" }, method = RequestMethod.PUT) @CrossOrigin ResponseEntity<Error> authChangepwdPut(@ApiParam(value = "token/password" ,required=true ) @RequestBody ResetPwd body, Errors errors) throws ApiException;
@ApiOperation(value = "", notes = "get yum info", response = Info.class, tags={ "auth", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "ok", response = Info.class), @ApiResponse(code = 500, message = "An unexpected error occured.", response = Info.class) }) @RequestMapping(value = "/auth/privacy", produces = { "application/json" }, method = RequestMethod.GET) @CrossOrigin ResponseEntity<PrivacyInfo> authPrivacyGet() throws ApiException;
@ApiOperation(value = "", notes = "get yum authentication method", response = String.class, tags={ "auth", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "ok", response = String.class), @ApiResponse(code = 500, message = "An unexpected error occured.", response = Error.class) }) @RequestMapping(value = "/auth/method", produces = { "text/plain" }, method = RequestMethod.GET) @CrossOrigin ResponseEntity<String> authMethodGet();
@ApiOperation(value = "Gets monthly menus.", notes = "Return a list containing all menus of the month.", response = DailyMenu.class, responseContainer = "List", authorizations = { @Authorization(value = "Bearer") }, tags={ "hungry", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "A list of daily menus.", response = DailyMenu.class), @ApiResponse(code = 500, message = "An unexpected error occured.", response = DailyMenu.class) }) @RequestMapping(value = "/menus/monthly", produces = { "application/json" }, method = RequestMethod.GET) @CrossOrigin ResponseEntity<Object> menusMonthlyGet(@ApiParam(value = "") @RequestParam(value = "userid", required = false) Long userid) throws ApiException, Exception;
@ApiOperation(value = "Gets monthly menus of the specified month.", notes = "Returns a list containing all menus of the month.", response = DailyMenu.class, responseContainer = "List", authorizations = { @Authorization(value = "Bearer") }, tags={ "hungry", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "A list of daily menus.", response = DailyMenu.class), @ApiResponse(code = 400, message = "Monthly menu not found.", response = DailyMenu.class), @ApiResponse(code = 500, message = "An unexpected error occured.", response = DailyMenu.class) }) @RequestMapping(value = "/menus/monthly/{monthyear}", produces = { "application/json" }, method = RequestMethod.GET) @CrossOrigin ResponseEntity<Object> menusMonthlyMonthyearGet(@ApiParam(value = "ex. 12-2016",required=true ) @PathVariable("monthyear") String monthyear,@ApiParam(value = "") @RequestParam(value = "userid", required = false) Long userid) throws ApiException, Exception;
@ApiOperation(value = "Gets weekly menus", notes = "Returns a list containing all menus of the week.", response = DailyMenu.class, responseContainer = "List", authorizations = { @Authorization(value = "Bearer") }, tags={ "hungry", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "A list of daily menus", response = DailyMenu.class), @ApiResponse(code = 500, message = "An unexpected error occured.", response = DailyMenu.class) }) @RequestMapping(value = "/menus/weekly", produces = { "application/json" }, method = RequestMethod.GET) @CrossOrigin ResponseEntity<Object> menusWeeklyGet(@ApiParam(value = "") @RequestParam(value = "userid", required = false) Long userid) throws ApiException, Exception;
@ApiOperation(value = "Gets weekly menu of the specified week", notes = "Returns a list containing all menus of the week.", response = DailyMenu.class, responseContainer = "List", authorizations = { @Authorization(value = "Bearer") }, tags={ "hungry", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "A list of daily menus", response = DailyMenu.class), @ApiResponse(code = 400, message = "Weekly menu not found.", response = DailyMenu.class), @ApiResponse(code = 500, message = "An unexpected error occured.", response = DailyMenu.class) }) @RequestMapping(value = "/menus/weekly/{week}", produces = { "application/json" }, method = RequestMethod.GET) @CrossOrigin ResponseEntity<Object> menusWeeklyWeekGet(@ApiParam(value = "ex. 02-2017",required=true ) @PathVariable("week") String week, @ApiParam(value = "") @RequestParam(value = "userid", required = false) Long userid) throws ApiException, Exception;
@ApiOperation(value = "", notes = "get user settings", response = User.class, authorizations = { @Authorization(value = "Bearer") }, tags={ "hungry", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "User data", response = User.class), @ApiResponse(code = 500, message = "An unexpected error occured.", response = User.class) }) @RequestMapping(value = "/settings", produces = { "application/json" }, method = RequestMethod.GET) @CrossOrigin ResponseEntity<Object> settingsGet() throws ApiException;