/** * Create a new post. The post will be validated using {@link PostValidator}. * * @param post The post to create. * @return The newly created post. */ @ApiOperation("Create a new post") @ResponseStatus(HttpStatus.CREATED) @RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Post> addPost(@Valid @RequestBody Post post) { post.setUuid(null); try { Post saved = postRepository.save(post); return ResponseEntity .created(URI.create("/admin/posts/" + saved.getUuid())) .body(saved); } catch (Exception e) { logger.error("Could not create post.", e); throw new PostCreationException("Could not create post.", e); } }
@ApiOperation(value = "Creates or updates connector configuration for external resource attributes for the given " + "zone.", tags = { "Attribute Connector Management" }) @ApiResponses(value = { @ApiResponse(code = 201, message = "Connector configuration for the given zone is successfully created.") }) @RequestMapping(method = PUT, value = V1 + AcsApiUriTemplates.RESOURCE_CONNECTOR_URL, consumes = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<String> putResourceConnector( @ApiParam(value = "New or updated connector configuration for external resource attributes", required = true) @RequestBody final AttributeConnector connector) { try { boolean connectorCreated = this.service.upsertResourceConnector(connector); if (connectorCreated) { // return 201 with empty response body return created(V1 + AcsApiUriTemplates.RESOURCE_CONNECTOR_URL, false); } // return 200 with empty response body return ok(); } catch (AttributeConnectorException e) { throw new RestApiException(HttpStatus.UNPROCESSABLE_ENTITY, e.getMessage(), e); } }
/** * Retrieves all the of user groups in this NiFi. * * @return a list of all user groups in this NiFi. */ @GET @Consumes(MediaType.WILDCARD) @Produces(MediaType.APPLICATION_JSON) @Path("user-groups") @ApiOperation( value = "Gets all user groups", notes = NON_GUARANTEED_ENDPOINT, response = UserGroup.class, responseContainer = "List" ) @ApiResponses({ @ApiResponse(code = 400, message = HttpStatusMessages.MESSAGE_400), @ApiResponse(code = 401, message = HttpStatusMessages.MESSAGE_401), @ApiResponse(code = 403, message = HttpStatusMessages.MESSAGE_403), @ApiResponse(code = 404, message = HttpStatusMessages.MESSAGE_404), @ApiResponse(code = 409, message = HttpStatusMessages.MESSAGE_409) }) public Response getUserGroups() { verifyAuthorizerIsManaged(); authorizeAccess(RequestAction.READ); final List<UserGroup> userGroups = authorizationService.getUserGroups(); return generateOkResponse(userGroups).build(); }
@ApiOperation(value = "机构管理-编辑接口") @PostMapping("/edit") @ResponseBody public BaseResult edit(SysOffice model){ BaseResult result=new BaseResult(BaseResultCode.SUCCESS,"成功"); SysUser curentUser= UserUtils.getUser(); if(StringUtils.isEmpty(model.getId())){ model.setCreateBy(curentUser.getId()); model.setUpdateBy(curentUser.getId()); service.insert(model); }else { model.setUpdateBy(curentUser.getId()); service.updateByPrimaryKeySelective(model); } return result; }
@ApiOperation(value = "Retrieves the Deployment Specification", notes = "Retrieves a Deployment Specification specified by its owning Virtual System and Deployment Spec Id", response = ApplianceManagerConnectorDto.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation"), @ApiResponse(code = 400, message = "In case of any error", response = ErrorCodeDto.class) }) @Path("/{vsId}/deploymentSpecs/{dsId}") @GET public DeploymentSpecDto getDeploymentSpec(@Context HttpHeaders headers, @ApiParam(value = "The Virtual System Id") @PathParam("vsId") Long vsId, @ApiParam(value = "The Deployment Specification Id") @PathParam("dsId") Long dsId) { logger.info("getting Deployment Spec " + dsId); this.userContext.setUser(OscAuthFilter.getUsername(headers)); GetDtoFromEntityRequest getDtoRequest = new GetDtoFromEntityRequest(); getDtoRequest.setEntityId(dsId); getDtoRequest.setEntityName("DeploymentSpec"); GetDtoFromEntityServiceApi<DeploymentSpecDto> getDtoService = this.getDtoFromEntityServiceFactory.getService(DeploymentSpecDto.class); DeploymentSpecDto dto = this.apiUtil.submitBaseRequestToService(getDtoService, getDtoRequest).getDto(); this.apiUtil.validateParentIdMatches(dto, vsId, "SecurityGroup"); return dto; }
/** * POST /account : update the current user information. * * @param userDTO * the current user information * @return the ResponseEntity with status 200 (OK), or status 400 (Bad * Request) or 500 (Internal Server Error) if the user couldn't be * updated */ @ApiOperation(value = "saveAccount",notes = "save Account") @PostMapping("/account") public ResponseEntity saveAccount(@Valid @RequestBody UserDTO userDTO) { final String userLogin = SecurityUtils.getCurrentUserLogin(); Optional<User> existingUser = userRepository.findOneByEmail(userDTO.getEmail()); if (existingUser.isPresent() && (!existingUser.get() .getLogin() .equalsIgnoreCase(userLogin))) { return ResponseEntity.badRequest() .headers(HeaderUtil.createFailureAlert("user-management", "emailexists", "Email already in use")) .body(null); } return userRepository.findOneByLogin(userLogin) .map(u -> { userService.updateUser(userDTO.getFirstName(), userDTO.getLastName(), userDTO.getEmail(), userDTO.getLangKey(), userDTO.getImageUrl()); return new ResponseEntity(HttpStatus.OK); }) .orElseGet(() -> new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR)); }
@CrossOrigin @RequestMapping(method = RequestMethod.GET, value = "/ola", produces = "text/plain") @ApiOperation("Returns the greeting in Portuguese") public String ola(HttpServletRequest request) { String hostname = System.getenv().getOrDefault("HOSTNAME", "Unknown"); Enumeration<String> headerNames = request.getHeaderNames(); StringBuffer headerMsg = new StringBuffer("{"); while (headerNames.hasMoreElements()) { String headerName = headerNames.nextElement(); String headerValue = request.getHeader(headerName); if (headerValue != null) { headerMsg.append(String.format("{\"%s\":\"%s\"}", headerName, headerValue)); headerMsg.append(","); } } headerMsg.append("}"); log.info("Request Headers:{}", headerMsg); return String.format("Olá de %s", hostname); }
@ApiOperation(value = "菜单管理-编辑接口") @PostMapping("/edit") @ResponseBody public BaseResult edit(SysMenu model){ BaseResult result=new BaseResult(BaseResultCode.SUCCESS,"成功"); SysUser curentUser= UserUtils.getUser(); if(StringUtils.isEmpty(model.getId())){ model.setCreateBy(curentUser.getId()); model.setUpdateBy(curentUser.getId()); service.insert(model); }else { model.setUpdateBy(curentUser.getId()); service.updateByPrimaryKeySelective(model); } return result; }
@ApiOperation(value = "新增权限") @RequiresPermissions("upms:permission:create") @ResponseBody @RequestMapping(value = "/create", method = RequestMethod.POST) public Object create(UpmsPermission upmsPermission) { ComplexResult result = FluentValidator.checkAll() .on(upmsPermission.getName(), new LengthValidator(1, 20, "名称")) .doValidate() .result(ResultCollectors.toComplex()); if (!result.isSuccess()) { return new UpmsResult(UpmsResultConstant.INVALID_LENGTH, result.getErrors()); } long time = System.currentTimeMillis(); upmsPermission.setCtime(time); upmsPermission.setOrders(time); int count = upmsPermissionService.insertSelective(upmsPermission); return new UpmsResult(UpmsResultConstant.SUCCESS, count); }
@ApiOperation("Returns a Claim Issue receipt for a given claim external id") @GetMapping( value = "/claimIssueReceipt/{externalId}", produces = MediaType.APPLICATION_PDF_VALUE ) public ResponseEntity<ByteArrayResource> claimIssueReceipt( @ApiParam("Claim external id") @PathVariable("externalId") @NotBlank String externalId ) { byte[] pdfDocument = documentsService.generateClaimIssueReceipt(externalId); return ResponseEntity .ok() .contentLength(pdfDocument.length) .body(new ByteArrayResource(pdfDocument)); }
@GetMapping(value = "{id}/thumbnail") @ApiOperation("Streams contents of the most recent Document Content Version associated with the Stored Document.") @ApiResponses(value = { @ApiResponse(code = 200, message = "Returns thumbnail of a file") }) @Transactional(readOnly = true) public ResponseEntity<Resource> getPreviewThumbnail(@PathVariable UUID id) { DocumentContentVersion documentContentVersion = documentContentVersionService.findMostRecentDocumentContentVersionByStoredDocumentId(id); if (documentContentVersion == null || documentContentVersion.getStoredDocument().isDeleted()) { return ResponseEntity.notFound().build(); } return ResponseEntity.ok() .contentType(MediaType.IMAGE_JPEG) .body(documentThumbnailService.generateThumbnail(documentContentVersion)); }
@POST @Path("/{file}") @Produces(MediaType.TEXT_PLAIN) @ApiOperation(value = "Replace this file with the file at the given URL") @ApiResponses(value = { @ApiResponse(code = 207, message = "Multiple responses available"), @ApiResponse(code = 400, message = "Request contains invalid parameters")}) public Response setConnectorFileByURL( String url, @PathParam("file") String file, @QueryParam("scope") String scope, @QueryParam("nodeId") List<String> nodeId) { ApiRequester apiRequester = requesterBuilder(ControllerConnectorAPI.class) .pathMethod("setConnectorFileByURL") .httpMethod(POST) .resolveTemplate("file", file) .accept(MediaType.TEXT_PLAIN) .entity(Entity.entity(url, MediaType.TEXT_PLAIN)) .build(); return forwardRequest(scope, apiRequester, nodeId); }
@ApiOperation("添加一道题目的一个测试用例") @RequiresAuthentication @PostMapping("/{pid}/test_cases") public ResponseEntity addProblemTestCase( @PathVariable("pid") int pid, @RequestBody @Valid AddProblemTestCaseFormat format) { ProblemEntity problemEntity = problemService.getProblemByPid(pid); haveProblem(problemEntity); havePermission(problemEntity); // 添加test_case int tid = testCasesService.addTestCase(pid, format.getStdin(), format.getStdout(), format.getStrength()); if (tid == 0) { throw new WebErrorException("添加失败"); } return new ResponseEntity("添加成功", tid); }
@ApiOperation(value = "Deletes an Manager Connector", notes = "Deletes an Appliance Manager Connector if not referenced by any Distributed Appliances", response = BaseJobResponse.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation"), @ApiResponse(code = 400, message = "In case of any error or if the Manager connector is referenced by a Distributed Appliance", response = ErrorCodeDto.class) }) @Path("/{applianceManagerConnectorId}") @DELETE public Response deleteApplianceManagerConnector(@Context HttpHeaders headers, @ApiParam(value = "Id of the Appliance Manager Connector", required = true) @PathParam("applianceManagerConnectorId") Long amcId) { logger.info("Deleting Appliance Manager Connector " + amcId); this.userContext.setUser(OscAuthFilter.getUsername(headers)); return this.apiUtil.getResponseForBaseRequest(this.deleteApplianceManagerConnectorService, new BaseIdRequest(amcId)); }
@ApiOperation( value = "Updates an Manager Connector. If we are unable to connect to the endpoint(IP) using the credentials provided, this call will fail.", notes = "Creates an Manager Connector and sync's it immediately. " + "If we are unable to connect to the manager using the credentials provided, this call will fail." + "To skip validation of IP and credentials 'skipRemoteValidation' flag can be used.", response = BaseJobResponse.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation"), @ApiResponse(code = 400, message = "In case of any error validating the information", response = ErrorCodeDto.class) }) @Path("/{applianceManagerConnectorId}") @PUT public Response updateApplianceManagerConnector(@Context HttpHeaders headers, @ApiParam(value = "Id of the Appliance Manager Connector", required = true) @PathParam("applianceManagerConnectorId") Long amcId, @ApiParam(required = true) ApplianceManagerConnectorRequest amcRequest) { logger.info("Updating Appliance Manager Connector " + amcId); this.userContext.setUser(OscAuthFilter.getUsername(headers)); this.apiUtil.setIdOrThrow(amcRequest, amcId, "Appliance Manager Connector"); Response responseForBaseRequest = this.apiUtil.getResponseForBaseRequest(this.updateService, new DryRunRequest<>(amcRequest, amcRequest.isSkipRemoteValidation())); return responseForBaseRequest; }
@RequestMapping(value = "/v1/dispatch/batch/define/group", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "在批次中添加任务组") public String addGroup(HttpServletResponse response, HttpServletRequest request) { String batchId = request.getParameter("batch_id"); String domainId = request.getParameter("domain_id"); String json = request.getParameter("JSON"); List<BatchGroupDto> list = new GsonBuilder().create().fromJson(json, new TypeToken<List<BatchGroupDto>>() { }.getType()); for (BatchGroupDto m : list) { m.setDomainId(domainId); m.setBatchId(batchId); } RetMsg retMsg = batchGroupService.addGroup(list); if (!retMsg.checkCode()) { response.setStatus(retMsg.getCode()); return Hret.error(retMsg); } return Hret.success(retMsg); }
/** * Returns terms * * @return Response encapsulating TermBeans */ @GET @Path("/{uuid}/term/{termUuid}") @Produces("application/json") @ApiOperation(value = "Get term by UUID") public Response getTermByUuid( @ApiParam(value = "Taxonomy uuid", required = false) @PathParam("uuid") String taxonomyUuid, @ApiParam(value = "term uuid", required = true) @PathParam("termUuid") String termUuid) { final Taxonomy taxonomy = ensureTaxonomy(taxonomyUuid, PrivCheck.VIEW); TermResult term = taxonomyService.getTermResultByUuid(taxonomyUuid, termUuid); TermBean bean = null; if( term != null ) { bean = beanFromTaxonomyTerm(term, taxonomyUuid); return Response.ok(bean).build(); } else { throw new WebException(Status.NOT_FOUND.getStatusCode(), Status.NOT_FOUND.getReasonPhrase(), "termUuid given is not valid"); } }
@ApiOperation(value = "Create and start a new workspace. Stop all other workspaces (only one workspace can be running at a time)") @PostMapping("/workspace/oso") public Workspace createOnOpenShift(@RequestParam String masterUrl, @RequestParam String namespace, @RequestBody WorkspaceCreateParams params, @ApiParam(value = "OpenShift token", required = true) @RequestHeader("Authorization") String openShiftToken) throws IOException, URISyntaxException, RouteNotFoundException, StackNotFoundException, GitHubOAthTokenException, ProjectCreationException, WorkspaceNotFound { return createWorkspace(masterUrl, namespace, openShiftToken, null, null, params); }
/** * 获取所有机构列表 * @return */ @ApiOperation(value = "字典管理-树层级结构接口") @PostMapping("/get_by_parentid") @ResponseBody public BaseResult getByParentId(SysDict model) { BaseResult result=new BaseResult(BaseResultCode.SUCCESS,"成功"); result.setData(tree(model)); return result; }
@ApiOperation(value = "displays hello world after a given amount of seconds seconds") @GET @Path("/suspend/{seconds}") @Produces(MediaType.TEXT_PLAIN) public void suspend(@Suspended final AsyncResponse asyncResponse, @PathParam("seconds") final int seconds) throws InterruptedException { Thread.sleep(seconds * 1000L); asyncResponse.resume(Response.ok("hello").build()); }
@GET @Path("/blue/rest/organizations/{organization}/pipelines/") @Produces({ "application/json" }) @ApiOperation(value = "", tags={ }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successfully retrieved pipelines details", response = Pipelines.class), @ApiResponse(code = 401, message = "Authentication failed - incorrect username and/or password", response = .class), @ApiResponse(code = 403, message = "Jenkins requires authentication - please set username and password", response = .class) }) public Pipelines getPipelines(@PathParam("organization") String organization);
@GET @Path("{flowId}/versions/latest") @Consumes(MediaType.WILDCARD) @Produces(MediaType.APPLICATION_JSON) @ApiOperation( value = "Get the latest version of a flow", response = VersionedFlowSnapshot.class ) @ApiResponses({ @ApiResponse(code = 401, message = HttpStatusMessages.MESSAGE_401), @ApiResponse(code = 403, message = HttpStatusMessages.MESSAGE_403), @ApiResponse(code = 404, message = HttpStatusMessages.MESSAGE_404), @ApiResponse(code = 409, message = HttpStatusMessages.MESSAGE_409) }) public Response getLatestFlowVersion( @PathParam("bucketId") @ApiParam("The bucket identifier") final String bucketId, @PathParam("flowId") @ApiParam("The flow identifier") final String flowId) { authorizeBucketAccess(RequestAction.READ, bucketId); final VersionedFlowSnapshotMetadata latest = registryService.getLatestFlowSnapshotMetadata(bucketId, flowId); if (latest == null) { throw new ResourceNotFoundException("No flow versions found for flow with id " + flowId); } final VersionedFlowSnapshot lastSnapshot = registryService.getFlowSnapshot(bucketId, flowId, latest.getVersion()); populateLinksAndPermissions(lastSnapshot); return Response.status(Response.Status.OK).entity(lastSnapshot).build(); }
@GET @Consumes({ "application/json" }) @Produces({ "application/json" }) @ApiOperation(value = "", notes = "Retrieves all Multi-Target Application files ", response = FileMetadata.class, responseContainer = "List", authorizations = { @Authorization(value = "oauth2", scopes = { }) }, tags = {}) @ApiResponses(value = { @ApiResponse(code = 200, message = "OK", response = FileMetadata.class, responseContainer = "List") }) public Response getMtaFiles() { return delegate.getMtaFiles(securityContext, spaceGuid); }
@ApiOperation("保存模块") @PostMapping(value = "/saveModule") public OperationResult save(@RequestBody ModuleDTO dto){ moduleService.saveModule(dto); return OperationResult.Success("保存成功", null); }
@ApiOperation(value = "删除单页") @RequiresPermissions("cms:page:delete") @RequestMapping(value = "/delete/{ids}",method = RequestMethod.GET) @ResponseBody public Object delete(@PathVariable("ids") String ids) { int count = cmsPageService.deleteByPrimaryKeys(ids); return new CmsResult(CmsResultConstant.SUCCESS, count); }
@ApiOperation(value = "更新单条条目") @PreAuthorize("hasRole('USER')") @RequestMapping(value = "/{id}", method = RequestMethod.PUT) public JsonResult<Entry> updateEntry(@PathVariable @ApiParam(value = "条目id", required = true) String id, @ApiParam(value = "条目对象", required = true) @RequestBody Entry entry) { entry.setId(id); return entryService.save(entry); }
@ApiOperation(value = "Lists Security Group Members", notes = "Lists Security Group Member owned by Security Group and Virtualization Connector provided.", response = SecurityGroupMemberItemDto.class, responseContainer = "Set") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation"), @ApiResponse(code = 400, message = "In case of any error", response = ErrorCodeDto.class) }) @Path("/{vcId}/securityGroups/{sgId}/members") @GET public Set<SecurityGroupMemberItemDto> getSecurityGroupMembers(@Context HttpHeaders headers, @ApiParam(value = "The Virtualization Connector Id") @PathParam("vcId") Long vcId, @ApiParam(value = "The Security Group Id") @PathParam("sgId") Long sgId) { logger.info("Listing Members for Security Group - " + sgId); this.userContext.setUser(OscAuthFilter.getUsername(headers)); GetDtoFromEntityRequest getDtoRequest = new GetDtoFromEntityRequest(); getDtoRequest.setEntityId(sgId); getDtoRequest.setEntityName("SecurityGroup"); GetDtoFromEntityServiceApi<SecurityGroupDto> getDtoService = this.getDtoFromEntityServiceFactory.getService(SecurityGroupDto.class); SecurityGroupDto dto = this.apiUtil.submitBaseRequestToService(getDtoService, getDtoRequest).getDto(); this.apiUtil.validateParentIdMatches(dto, vcId, "SecurityGroup"); @SuppressWarnings("unchecked") SetResponse<SecurityGroupMemberItemDto> memberList = (SetResponse<SecurityGroupMemberItemDto>) this.apiUtil .getSetResponse(this.listSecurityGroupMembersBySgService, new BaseIdRequest(sgId)); return memberList.getSet(); }
@PUT @Path("/{id}/profile/{key}") @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED }) @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED }) @ApiOperation(value = "Get the profile of applicant", response = JSONObject.class) @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns the profile of applicant", response = JSONObject.class), @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class), @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class), @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) }) public Response updateApplicantProfile(@Context HttpServletRequest request, @Context HttpHeaders header, @Context Company company, @Context Locale locale, @Context User user, @Context ServiceContext serviceContext, @PathParam("id") long id, @PathParam("key") String key, @BeanParam ProfileInputModel input);
@RequestMapping(value = "/content/cat/list",method = RequestMethod.GET) @ApiOperation(value = "获得分类列表") public List<ZTreeNode> getContentByCid(@RequestParam(name="id", defaultValue="0") Long parentId){ List<ZTreeNode> list=contentCatService.getContentCatList(parentId); return list; }
@ApiOperation(value = "设备选择链接节点", notes = "设备选择链接节点") @RequestMapping(value = "/select", method = RequestMethod.GET) public ResponseEntity<BaseResp<LoadbanceNode>> selectNode() { Map<String, NodeServerInfo> maps = new HashMap<>(nodeServerDiscoveryService.nodeServerPool()); if (!CollectionUtils.isEmpty(maps)) { NodeServerInfo info = maps.values().stream() .min(Comparator.comparingInt(e -> e.getNodeLoaderInfo().getOnlineDeviceCounter())) .get(); return ResponseEntity.ok( BaseResp.ok( LoadbanceNode.builder() .ip(info.getInternetIp()) .port(info.getDevicePort()) .readInterval(IdleEnum.READ_IDLE.getValue()) .writeInterval(IdleEnum.WRITE_IDLE.getValue()) .allInterval(IdleEnum.ALL_IDLE.getValue()) .build() )); } return ResponseEntity.ok(BaseResp.fail(400, "无可链接节点")); }
@ApiOperation("Delete a sample") @DELETE @Path("{id}") @Timed public Sample delete(@PathParam("id") Long id) { return sampleDao.deleteSample(id); }
@GET @Path("/crumbIssuer/api/json") @Produces({ "application/json" }) @ApiOperation(value = "", tags={ }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successfully retrieved CSRF protection token", response = DefaultCrumbIssuer.class), @ApiResponse(code = 401, message = "Authentication failed - incorrect username and/or password", response = .class), @ApiResponse(code = 403, message = "Jenkins requires authentication - please set username and password", response = .class) }) public DefaultCrumbIssuer getCrumb();
@DELETE @Path("/{id}/parts/{partno}") @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) @ApiOperation(value = "Remove a DossierPart of a DossierTemplate", response = DossierPartInputModel.class) @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns the DossierPart was removed", response = DossierPartInputModel.class), @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class), @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class), @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) }) public Response removeDossierParts(@Context HttpServletRequest request, @Context HttpHeaders header, @Context Company company, @Context Locale locale, @Context User user, @Context ServiceContext serviceContext, @PathParam("id") long id, @PathParam("partno") String partNo);
@ApiOperation(value = "修改密码") @PostMapping(value = "/update/password") public Object updatePassword(ModelMap modelMap, @RequestBody SysUser param) { Assert.isNotBlank(param.getOldPassword(), "OLDPASSWORD"); Assert.isNotBlank(param.getPassword(), "PASSWORD"); Long userId = getCurrUser(); String encryptPassword = SecurityUtil.encryptPassword(param.getOldPassword()); Parameter parameter = new Parameter(getService(), "queryById").setId(userId); logger.info("{} execute queryById start...", parameter.getNo()); SysUser sysUser = (SysUser) provider.execute(parameter).getModel(); logger.info("{} execute queryById end.", parameter.getNo()); Assert.notNull(sysUser, "USER", param.getId()); if (!sysUser.getPassword().equals(encryptPassword)) { throw new UnauthorizedException("原密码错误."); } param.setPassword(encryptPassword); param.setUpdateBy(getCurrUser()); return super.update(modelMap, param); }
@ApiOperation(value = "修改设置") @RequiresPermissions("cms:setting:update") @RequestMapping(value = "/update/{id}", method = RequestMethod.POST) @ResponseBody public Object update(@PathVariable("id") int id, CmsSetting cmsSetting) { ComplexResult result = FluentValidator.checkAll() .on(cmsSetting.getSettingKey(), new LengthValidator(1, 20, "键")) .doValidate() .result(ResultCollectors.toComplex()); if (!result.isSuccess()) { return new CmsResult(CmsResultConstant.INVALID_LENGTH, result.getErrors()); } cmsSetting.setSettingId(id); int count = cmsSettingService.updateByPrimaryKeySelective(cmsSetting); return new CmsResult(CmsResultConstant.SUCCESS, count); }
@Override public void applyExtensions(ReaderContext context, Operation operation, Method method) { final ApiOperation apiOperation = method.getAnnotation(ApiOperation.class); if (apiOperation != null) { operation.getVendorExtensions() .putAll(BaseReaderUtils.parseExtensions(apiOperation.extensions())); } }
@POST @ApiOperation("Updates/Creates keys in the user context") @ApiResponses( @ApiResponse(code = 204, message = "Successful operation")) public void updateContext(UpdateTaskContext taskContext) throws CommsRouterException { taskService.updateContext(taskContext, routerObjectId); }
@POST @ApiOperation( value = "Add new Agent", notes = "Add new Agent and associate it with a Router") @ApiResponses({ @ApiResponse(code = 201, message = "Successful operation", response = ApiObjectRef.class)}) public Response create(CreateAgentArg agentArg) throws CommsRouterException { LOGGER.debug("Creating agent {}", agentArg); ApiObjectRef agent = agentService.create(agentArg, routerRef); return createResponse(agent); }
/** * 方法名: sysOrganizationEdit * 功 能: 修改数据 * 参 数: @param info * 参 数: @return * 返 回: String * 作 者 : Tenghui.Wang * @throws */ @ApiOperation(value = "修改数据", notes = "") @RequestMapping(path = "/sysOrganizationEdit", method = RequestMethod.POST) @ResponseBody public String sysOrganizationEdit(@RequestBody SysOrganizationInfo info) { System.out.println(info.toString()); logger.info("sysOrganizationEdit", SysOrganizationController.class); try { sysOrganizationService.sysOrganizationEdit(info); return "1"; } catch (Exception e) { return "0"; } }
/** * authenticationRequest * Authentication Request to acquire an Access Token, to then in turn use this Token to access a * protected resource within the Your Microservice Eco-System. * * @param authenticationRequest Incoming Authentication Request DTO * @param request Incoming Request * @return ResponseEntity If successful Authentication, Response Entity will Contain the JWT to be used for accessing * subsequent Protected resources within the Your Microservice Eco-System. * @throws AuthenticationException Thrown when Failure Occurs, Handlers will Response Accordingly. */ @ApiOperation(value="Authentication to obtain Access Token using Swagger Console", httpMethod = "POST", hidden = false) @RequestMapping(value="/", method = RequestMethod.POST, consumes = {"application/json", "application/json;charset=UTF8"}) public ResponseEntity<?> swaggerAuthenticationRequest(@RequestBody AuthenticationRequest authenticationRequest, HttpServletRequest request) throws AuthenticationException { /** * Perform Authentication Request for Consumer to Obtain Access Token. */ LOGGER.info("Performing Authentication of '{}' from '{}'", authenticationRequest.getUsername(), "swagger"); Authentication authentication = this.authenticationManager.authenticate( new UsernamePasswordAuthenticationToken( authenticationRequest.getUsername(), authenticationRequest.getPassword() ) ); SecurityContextHolder.getContext().setAuthentication(authentication); // Reload password post-authentication so we can generate token UserDetails userDetails = this.userDetailsService.loadUserByUsername(authenticationRequest.getUsername()); String token = this.yourMicroserviceToken.generateToken(userDetails.getUsername(), "unknown"); /** * Publish Authentication Notification... */ try { publishAuthenticationEvents(request, (YourMicroserviceUserDetails)userDetails, YourEntityEventHistory.EntityEventTagNames.LAST_LOGIN); } catch (Exception e) { LOGGER.warn("Unable to perform Publishing of Personal Event History for Last Login: {}", e.getMessage()); } /** * Persist our new Token Entity to our History. */ saveTokenHistory(token); /** * Return the Successful response with our Generated Access Token. */ return ResponseEntity.ok(new AuthenticationResponse(token, TOKEN_EXPIRATION_IN_SECONDS.intValue())); }