org.springframework.web.bind.annotation.RequestParam Java Examples

The following examples show how to use org.springframework.web.bind.annotation.RequestParam. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ReferenceFileController.java    From qconfig with MIT License 6 votes vote down vote up
@RequestMapping("/list")
@ResponseBody
public Object referenceList(@RequestParam String group, @RequestParam String profile,
                            @RequestParam(required = false) String groupLike,
                            @RequestParam(required = false) String dataIdLike,
                            @RequestParam(required = false, defaultValue = "1") int page,
                            @RequestParam(required = false, defaultValue = "15") int pageSize) {
    checkLegalGroup(group);
    checkLegalProfile(profile);
    try {
        return JsonV2.successOf(
                referenceService.getReferenceInfo(
                        group, profile, groupLike, dataIdLike, page, pageSize, true));
    } catch (RuntimeException e) {
        logger.error("get reference list error, group={}, profile={}", group, profile, e);
        throw e;
    }
}
 
Example #2
Source File: QywxMenuController.java    From jeewx with Apache License 2.0 6 votes vote down vote up
/**
 * 删除
 * @return
 */
@RequestMapping(params="doDelete",method = RequestMethod.GET)
@ResponseBody
public AjaxJson doDelete(@RequestParam(required = true, value = "id" ) String id){
		AjaxJson j = new AjaxJson();
		try {
		    QywxMenu qywxMenu = new QywxMenu();
			qywxMenu.setId(id);
			qywxMenuDao.delete(qywxMenu);
			j.setMsg("删除成功");
		} catch (Exception e) {
		    log.info(e.getMessage());
			j.setSuccess(false);
			j.setMsg("删除失败");
		}
		return j;
}
 
Example #3
Source File: RegController.java    From push with Apache License 2.0 6 votes vote down vote up
@PostMapping("keep")
public ServerNode keep(@RequestParam String id, @RequestParam(required = false) String ip, @RequestParam String port, HttpServletRequest request) {
    BoundHashOperations imKeep = getNodes();
    ServerNode serverNode = null;
    if (!imKeep.hasKey(id)) {
        serverNode = new ServerNode();
        serverNode.setId(id);
        if (StringUtils.isEmpty(ip))
            ip = IpUtil.getIpAddr(request);
        serverNode.setUrl(ip + ":" + port);
        serverNode.setLastCheckTime(System.currentTimeMillis());
    } else {
        serverNode = (ServerNode) imKeep.get(id);
        serverNode.setLastCheckTime(System.currentTimeMillis());
    }
    logger.debug("keep:{} {} {}", id, ip, port);
    imKeep.put(id, serverNode);
    return serverNode;
}
 
Example #4
Source File: RelationshipController.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@PostMapping( value = "", consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE )
public void postRelationshipJson(
    @RequestParam( defaultValue = "CREATE_AND_UPDATE" ) ImportStrategy strategy,
    ImportOptions importOptions,
    HttpServletRequest request, HttpServletResponse response
)
    throws IOException
{
    importOptions.setStrategy( strategy );
    InputStream inputStream = StreamUtils.wrapAndCheckCompressionFormat( request.getInputStream() );
    ImportSummaries importSummaries = relationshipService.addRelationshipsJson( inputStream, importOptions );

    importSummaries.getImportSummaries().stream()
        .filter( filterImportSummary( importOptions ) )
        .forEach( setImportSummaryHref( request ) );

    webMessageService.send( WebMessageUtils.importSummaries( importSummaries ), response, request );
}
 
Example #5
Source File: UserController.java    From maven-framework-project with MIT License 6 votes vote down vote up
@RequestMapping(value="/update", method=RequestMethod.POST)
public @ResponseBody User update(
		@RequestParam String username,
		@RequestParam String firstName,
		@RequestParam String lastName,
		@RequestParam Integer role) {

	Role existingRole = new Role();
	existingRole.setRole(role);
	
	User existingUser = new User();
	existingUser.setUsername(username);
	existingUser.setFirstName(firstName);
	existingUser.setLastName(lastName);
	existingUser.setRole(existingRole);
	
	return service.update(existingUser);
}
 
Example #6
Source File: LoginController.java    From Spring-Security-Third-Edition with MIT License 6 votes vote down vote up
@GetMapping(value = "/login")
public ModelAndView login(
        @RequestParam(value = "error", required = false) String error,
        @RequestParam(value = "logout", required = false) String logout) {

    logger.info("******login(error): {} ***************************************", error);
    logger.info("******login(logout): {} ***************************************", logout);

    ModelAndView model = new ModelAndView();
    if (error != null) {
        model.addObject("error", "Invalid username and password!");
    }

    if (logout != null) {
        model.addObject("message", "You've been logged out successfully.");
    }
    model.setViewName("login");

    return model;

}
 
Example #7
Source File: TaggerController.java    From AIDR with GNU Affero General Public License v3.0 6 votes vote down vote up
@RequestMapping(value = "/removeAttributeFromCrises.action", method = {RequestMethod.GET})
@ResponseBody
public Map<String, Object> removeAttributeFromCrises(@RequestParam Integer id) {
	//logger.info("Remove classifier from crises by modelFamilyID");
	try {
		boolean success = taggerService.removeAttributeFromCrises(id);
		if (success){
			return getUIWrapper(true, "Classifier was successful removed from crisis");
		} else {
			return getUIWrapper(false, "Error while remove classifier from crises in Tagger");
		}
	} catch (Exception e) {
		logger.error("Error while removing classifier from crises by modelFamilyID: "+id, e);
		return getUIWrapper(false, e.getMessage());
	}
}
 
Example #8
Source File: RestLogController.java    From Guns with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 查询操作日志列表
 *
 * @author fengshuonan
 * @Date 2018/12/23 5:34 PM
 */
@RequestMapping("/list")
public LayuiPageInfo list(@RequestParam(required = false) String beginTime,
                          @RequestParam(required = false) String endTime,
                          @RequestParam(required = false) String logName,
                          @RequestParam(required = false) Integer logType) {

    //获取分页参数
    Page page = LayuiPageFactory.defaultPage();

    //根据条件查询操作日志
    List<Map<String, Object>> result = restOperationLogService.getOperationLogs(page, beginTime, endTime, logName, BizLogType.valueOf(logType));

    page.setRecords(new LogWrapper(result).wrap());

    return LayuiPageFactory.createPageInfo(page);
}
 
Example #9
Source File: BpmConfNoticeController.java    From lemon with Apache License 2.0 6 votes vote down vote up
@RequestMapping("bpm-conf-notice-list")
public String list(@RequestParam("bpmConfNodeId") Long bpmConfNodeId,
        Model model) {
    BpmConfNode bpmConfNode = bpmConfNodeManager.get(bpmConfNodeId);
    Long bpmConfBaseId = bpmConfNode.getBpmConfBase().getId();
    List<BpmConfNotice> bpmConfNotices = bpmConfNoticeManager.findBy(
            "bpmConfNode", bpmConfNode);
    List<BpmMailTemplate> bpmMailTemplates = bpmMailTemplateManager
            .getAll();

    model.addAttribute("bpmConfBaseId", bpmConfBaseId);
    model.addAttribute("bpmConfNotices", bpmConfNotices);
    model.addAttribute("bpmMailTemplates", bpmMailTemplates);

    return "bpm/bpm-conf-notice-list";
}
 
Example #10
Source File: SysDepartController.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
/**
 * <p>
 * 部门搜索功能方法,根据关键字模糊搜索相关部门
 * </p>
 * 
 * @param keyWord
 * @return
 */
@RequestMapping(value = "/searchBy", method = RequestMethod.GET)
public Result<List<SysDepartTreeModel>> searchBy(@RequestParam(name = "keyWord", required = true) String keyWord) {
	Result<List<SysDepartTreeModel>> result = new Result<List<SysDepartTreeModel>>();
	try {
		List<SysDepartTreeModel> treeList = this.sysDepartService.searhBy(keyWord);
		if (treeList.size() == 0 || treeList == null) {
			throw new Exception();
		}
		result.setSuccess(true);
		result.setResult(treeList);
		return result;
	} catch (Exception e) {
		e.fillInStackTrace();
		result.setSuccess(false);
		result.setMessage("查询失败或没有您想要的任何数据!");
		return result;
	}
}
 
Example #11
Source File: SystemController.java    From hunt-admin with Apache License 2.0 6 votes vote down vote up
/**
 * 登录
 *
 * @param loginName 登录名
 * @param password  密码
 * @param platform  终端类型
 * @return
 */
@ApiOperation(value = "登录", httpMethod = "POST", produces = "application/json", response = Result.class)
@ResponseBody
@RequestMapping(value = "login", method = RequestMethod.POST)
public Result login(@RequestParam String loginName,
                    @RequestParam String password,
                    @RequestParam int platform,
                    HttpServletRequest request) throws Exception {
    //极限验证二次服务验证
    if (!verifyCaptcha(request)) {
        return Result.instance(ResponseCode.verify_captcha_error.getCode(), ResponseCode.verify_captcha_error.getMsg());
    }
    SysUser user = sysUserService.selectByLoginName(loginName);
    if (user == null) {
        return Result.instance(ResponseCode.unknown_account.getCode(), ResponseCode.unknown_account.getMsg());
    }
    if (user.getStatus() == 3) {
        return Result.instance(ResponseCode.forbidden_account.getCode(), ResponseCode.forbidden_account.getMsg());
    }
    Subject subject = SecurityUtils.getSubject();
    subject.login(new UsernamePasswordToken(loginName, password));
    LoginInfo loginInfo = sysUserService.login(user, subject.getSession().getId(), platform);
    subject.getSession().setAttribute("loginInfo", loginInfo);
    log.debug("登录成功");
    return Result.success(loginInfo);
}
 
Example #12
Source File: FoodController.java    From java_server with MIT License 6 votes vote down vote up
/**
 * 对应校区
 *
 * @param foodId
 * @return
 */
@RequestMapping("cancelRecommend")
public @ResponseBody
Map<String, Object> cancelRecommend(@RequestParam Long foodId,
                                    @RequestParam Integer campusId) {
    Map<String, Object> responseMap = new HashMap<String, Object>();
    Map<String, Object> paramMap = new HashMap<String, Object>();

    paramMap.put("foodId", foodId);
    paramMap.put("toHome", 0);
    paramMap.put("campusId", campusId);
    Integer cancel = foodService.cancelRecommend(paramMap);
    if (cancel == -1 || cancel == 0) {
        responseMap.put(Constants.STATUS, Constants.FAILURE);
        responseMap.put(Constants.MESSAGE, "取消推荐失败!");
    } else {
        responseMap.put(Constants.STATUS, Constants.SUCCESS);
        responseMap.put(Constants.MESSAGE, "取消推荐成功!");
    }
    return responseMap;
}
 
Example #13
Source File: ComplianceController.java    From pacbot with Apache License 2.0 6 votes vote down vote up
/**
 * API returns details of the given ruleId.
 *
 * @param ruleId the rule id
 * @return ResponseEntity<Object>
 */

@RequestMapping(path = "/v1/policydescription", method = RequestMethod.GET)

public ResponseEntity<Object> getPolicyDescription(@RequestParam("ruleId") String ruleId) {

    if (Strings.isNullOrEmpty(ruleId)) {
        return ResponseUtils.buildFailureResponse(new Exception("ruleId Mandatory"));
    }
    PolicyDescription response = null;
    try {
        response = new PolicyDescription(complianceService.getRuleDescription(ruleId));

    } catch (ServiceException e) {
       return complianceService.formatException(e);
    }
    return ResponseUtils.buildSucessResponse(response);
}
 
Example #14
Source File: SimplePostController.java    From tutorials with MIT License 6 votes vote down vote up
@RequestMapping(value = "/users/upload", method = RequestMethod.POST)
public String postMultipart(@RequestParam("file") final MultipartFile file) {
    if (!file.isEmpty()) {
        try {
            final DateFormat dateFormat = new SimpleDateFormat("yyyy_MM_dd_HH.mm.ss");
            final String fileName = dateFormat.format(new Date());
            final File fileServer = new File(fileName);
            fileServer.createNewFile();
            final byte[] bytes = file.getBytes();
            final BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(fileServer));
            stream.write(bytes);
            stream.close();
            return "You successfully uploaded ";
        } catch (final Exception e) {
            return "You failed to upload " + e.getMessage();
        }
    } else {
        return "You failed to upload because the file was empty.";
    }
}
 
Example #15
Source File: SortaController.java    From molgenis with GNU Lesser General Public License v3.0 6 votes vote down vote up
@PostMapping(value = "/match/upload", headers = "Content-Type=multipart/form-data")
public String upload(
    @RequestParam(value = "taskName") String jobName,
    @RequestParam(value = "selectOntologies") String ontologyIri,
    @RequestParam(value = "file") MultipartFile file,
    Model model,
    HttpServletRequest httpServletRequest)
    throws IOException {
  if (isEmpty(ontologyIri) || file == null) {
    return init(model);
  }
  validateJobName(jobName);
  try (InputStream inputStream = file.getInputStream()) {
    return startMatchJob(jobName, ontologyIri, model, httpServletRequest, inputStream);
  }
}
 
Example #16
Source File: InterpretationController.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@RequestMapping( value = "/eventReport/{uid}", method = RequestMethod.POST, consumes = { "text/html", "text/plain" } )
public void writeEventReportInterpretation( @PathVariable( "uid" ) String uid,
    @RequestParam( value = "ou", required = false ) String orgUnitUid, @RequestBody String text,
    HttpServletResponse response, HttpServletRequest request )
    throws WebMessageException
{
    EventReport eventReport = idObjectManager.get( EventReport.class, uid );

    if ( eventReport == null )
    {
        throw new WebMessageException(
            WebMessageUtils.conflict( "Event report does not exist or is not accessible: " + uid ) );
    }

    OrganisationUnit orgUnit = getUserOrganisationUnit( orgUnitUid, eventReport,
        currentUserService.getCurrentUser() );

    createIntepretation( new Interpretation( eventReport, orgUnit, text ), request, response );
}
 
Example #17
Source File: RequestMappingHandlerAdapterIntegrationTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
String handleInInterface(
@CookieValue("cookie") int cookieV,
@PathVariable("pathvar") String pathvarV,
@RequestHeader("header") String headerV,
@RequestHeader(defaultValue = "#{systemProperties.systemHeader}") String systemHeader,
@RequestHeader Map<String, Object> headerMap,
@RequestParam("dateParam") Date dateParam,
@RequestParam Map<String, Object> paramMap,
String paramByConvention,
@Value("#{request.contextPath}") String value,
@ModelAttribute("modelAttr") @Valid TestBean modelAttr,
Errors errors,
TestBean modelAttrByConvention,
Color customArg,
HttpServletRequest request,
HttpServletResponse response,
@SessionAttribute TestBean sessionAttribute,
@RequestAttribute TestBean requestAttribute,
User user,
@ModelAttribute OtherUser otherUser,
Model model,
UriComponentsBuilder builder);
 
Example #18
Source File: ProductController.java    From geode-demo-application with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "/listSpecificProducts", method = RequestMethod.GET)
public String listSpecificProducts(
		@RequestParam(value = "brand", required = true) String brand,
		@RequestParam(value = "type", required = true) String type,
		@RequestParam(value = "gender", required = true) String gender,
		@RequestParam(value = "inStock", required = false) boolean inStock,
		Model model) {
	Collection<Product> products;
	if (inStock) {
		products = productRepository.findAllWithStockByBrandTypeGender(brand, type, gender);
	}
	else {
		products = productRepository.findAllByBrandTypeGender(brand, type, gender);
	}
	model.addAttribute("products", products);
	return "listProducts";
}
 
Example #19
Source File: AccountingController.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
@RequestMapping(value = "{event}/depositAdvancement", method = RequestMethod.POST)
public String depositAdvancement(final @PathVariable Event event, final User user, final Model model,
        @RequestParam final Event eventToRefund) {
    accessControlService.checkEventOwnerOrPaymentManager(eventToRefund, user);

    try {
        accountingManagementService.depositAdvancement(event, eventToRefund, user);
    }
    catch (DomainException e) {
        e.printStackTrace();
        model.addAttribute("error", e.getLocalizedMessage());
        return depositAdvancementInput(event, user, model);
    }

    return redirectToEventDetails(event);
}
 
Example #20
Source File: IndexController.java    From ApiManager with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * @param code 需要显示的pick code
 * @param key 可选参数:根据具体情况定义,如当为模块是,key代表父id
 * @param radio 是否为单选
 * @param def 默认值
 * @param tag 保存选中结果的id
 * @param tagName 显示名称的输入框id
 * @param notNull 是否可以为空:当为单选,且notNull=false是,则可以选着为空
 * @return
 * @throws Exception
 */
@RequestMapping(value = "newPick.do")
@AuthPassport
public String newPick(String code,
					  @RequestParam(defaultValue = "")  String key,
					  @RequestParam(defaultValue = "true") String radio,
					  String def,
					  String tag,
					  String tagName,
					  String notNull) throws Exception {
	String pickContent = customMenuService.pick(radio, code, key, def, notNull);
	HttpServletRequest request = ThreadContext.request();
	request.setAttribute("radio", radio);
	request.setAttribute("tag", tag);
	request.setAttribute("def", def);
	request.setAttribute("iCallBack", getParam("iCallBack", "voidFunction"));
	request.setAttribute("iCallBackParam", getParam("iCallBackParam", ""));
	request.setAttribute("tagName", tagName);
	request.setAttribute("pickContent", pickContent);
	return "WEB-INF/views/newPick.jsp";
}
 
Example #21
Source File: OrganizationController.java    From hunt-admin with Apache License 2.0 6 votes vote down vote up
/**
 * 新增机构
 *
 * @param name        名称
 * @param description 描述
 * @param fullName    全称
 * @param parentId    父级id
 * @param isFinal     是否可修改
 * @return
 */
@ApiOperation(value = "新增机构", httpMethod = "POST", produces = "application/json", response = Result.class)
@RequiresPermissions("organization:insert")
@ResponseBody
@RequestMapping(value = "insert", method = RequestMethod.POST)
public Result insert(@RequestParam String name,
                     @RequestParam String description,
                     @RequestParam String fullName,
                     @RequestParam long parentId,
                     @RequestParam(defaultValue = "1") int isFinal) {
    boolean isExistFullName = sysOrganizationService.isExistFullName(fullName);
    if (isExistFullName) {
        return Result.error(ResponseCode.fullname_already_exist.getMsg());
    }
    SysOrganization organization = new SysOrganization();
    organization.setFullName(fullName);
    organization.setName(name);
    organization.setDescription(description);
    organization.setParentId(parentId);
    organization.setIsFinal(isFinal);
    long i = sysOrganizationService.insertOrganization(organization);
    return Result.success();
}
 
Example #22
Source File: PublicController.java    From AIDR with GNU Affero General Public License v3.0 6 votes vote down vote up
@RequestMapping(value = "/findAll.action", method = RequestMethod.GET)
@ResponseBody
public Map<String,Object>  findAll(@RequestParam Integer start, @RequestParam Integer limit,  @RequestParam Enum statusValue,
		@DefaultValue("no") @QueryParam("trashed") String trashed) throws Exception {
	start = (start != null) ? start : 0;
	limit = (limit != null) ? limit : 50;

	try {

		List<Collection> data = collectionService.findAllForPublic(start, limit, statusValue);
		logger.info("[findAll] fetched data size: " + ((data != null) ? data.size() : 0));
		return getUIWrapper(data, true);

	} catch (Exception e) {
		logger.error("Error in find All collection for public",e);
		return getUIWrapper(false);
	}

	//return getUIWrapper(false);
}
 
Example #23
Source File: DTSController.java    From dtsopensource with Apache License 2.0 6 votes vote down vote up
/**
 * 申购
 * 
 * @param productName
 * @param orderAmount
 * @param currentAmount
 * @param response
 */
@RequestMapping(value = "/purchase", method = RequestMethod.GET)
public void puchase(@RequestParam String productName, @RequestParam BigDecimal orderAmount,
                    @RequestParam BigDecimal currentAmount, HttpServletResponse response) {
    response.setHeader("Content-type", "text/html;charset=UTF-8");
    try {
        this.sysout(response, "购买商品:[" + new String(productName.getBytes("iso8859-1"), "utf-8") + "],订单金额:["
                + orderAmount + "],账户余额:[" + currentAmount + "]");
        PurchaseContext context = new PurchaseContext();
        context.setCurrentAmount(currentAmount);
        context.setOrderAmount(orderAmount);
        context.setProductName(new String(productName.getBytes("iso8859-1"), "utf-8"));
        log.info(context.toString());
        String activityId = purchaseService.puchase(context);
        this.sysout(response, "业务活动ID:" + activityId);
        List<String> list = tradeLog.getNewLog(activityId);
        for (String an : list) {
            this.sysout(response, an);
        }
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
 
Example #24
Source File: PayWayController.java    From roncoo-pay with Apache License 2.0 5 votes vote down vote up
/**
 * 函数功能说明 :跳转添加
 * 
 * @参数: @return
 * @return String
 * @throws
 */
@RequiresPermissions("pay:way:add")
@RequestMapping(value = "/addUI", method = RequestMethod.GET)
public String addUI(Model model, @RequestParam("payProductCode") String payProductCode) {
	model.addAttribute("PayWayEnums", PayWayEnum.toList());
	model.addAttribute("PayTypeEnums", PayTypeEnum.toList());
	model.addAttribute("payProductCode", payProductCode);
	return "pay/way/add";
}
 
Example #25
Source File: TwitterController.java    From tutorials with MIT License 5 votes vote down vote up
@GetMapping(value = "/callback", produces = "text/plain")
@ResponseBody
public String callback(HttpServletRequest servletReq, @RequestParam("oauth_verifier") String oauthV) throws InterruptedException, ExecutionException, IOException {
    OAuth10aService twitterService = createService();
    OAuth1RequestToken requestToken = (OAuth1RequestToken) servletReq.getSession().getAttribute("requestToken");
    OAuth1AccessToken accessToken = twitterService.getAccessToken(requestToken, oauthV);

    OAuthRequest request = new OAuthRequest(Verb.GET, "https://api.twitter.com/1.1/account/verify_credentials.json");
    twitterService.signRequest(accessToken, request);
    Response response = twitterService.execute(request);

    return response.getBody();
}
 
Example #26
Source File: GuestbookController.java    From Shop-for-JavaWeb with MIT License 5 votes vote down vote up
@ModelAttribute
public Guestbook get(@RequestParam(required=false) String id) {
	if (StringUtils.isNotBlank(id)){
		return guestbookService.get(id);
	}else{
		return new Guestbook();
	}
}
 
Example #27
Source File: RequestPartMethodArgumentResolver.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Whether the given {@linkplain MethodParameter method parameter} is a multi-part
 * supported. Supports the following:
 * <ul>
 * <li>annotated with {@code @RequestPart}
 * <li>of type {@link MultipartFile} unless annotated with {@code @RequestParam}
 * <li>of type {@code javax.servlet.http.Part} unless annotated with
 * {@code @RequestParam}
 * </ul>
 */
@Override
public boolean supportsParameter(MethodParameter parameter) {
	if (parameter.hasParameterAnnotation(RequestPart.class)) {
		return true;
	}
	else {
		if (parameter.hasParameterAnnotation(RequestParam.class)) {
			return false;
		}
		return MultipartResolutionDelegate.isMultipartArgument(parameter.nestedIfOptional());
	}
}
 
Example #28
Source File: FileMgrController.java    From flash-waimai with MIT License 5 votes vote down vote up
@RequestMapping(value = "/list", method = RequestMethod.GET)
@RequiresPermissions(value = {Permission.FILE})
public Object list(@RequestParam(required = false) String originalFileName
) {
    Page<FileInfo> page = new PageFactory<FileInfo>().defaultPage();
    if (StringUtils.isNotEmpty(originalFileName)) {
        page.addFilter(SearchFilter.build("originalFileName", SearchFilter.Operator.LIKE, originalFileName));
    }
    page = fileService.queryPage(page);
    return Rets.success(page);
}
 
Example #29
Source File: GreetingController.java    From spring-security-fundamentals with Apache License 2.0 5 votes vote down vote up
/**
 * Web service endpoint to fetch a single Greeting entity by primary key
 * identifier and send it as an email.
 * 
 * If found, the Greeting is returned as JSON with HTTP status 200 and sent
 * via Email.
 * 
 * If not found, the service returns an empty response body with HTTP status
 * 404.
 * 
 * @param id A Long URL path variable containing the Greeting primary key
 *        identifier.
 * @param waitForAsyncResult A boolean indicating if the web service should
 *        wait for the asynchronous email transmission.
 * @return A ResponseEntity containing a single Greeting object, if found,
 *         and a HTTP status code as described in the method comment.
 */
@RequestMapping(
        value = "/api/greetings/{id}/send",
        method = RequestMethod.POST,
        produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Greeting> sendGreeting(@PathVariable("id") Long id,
        @RequestParam(
                value = "wait",
                defaultValue = "false") boolean waitForAsyncResult) {

    logger.info("> sendGreeting id:{}", id);

    Greeting greeting = null;

    try {
        greeting = greetingService.findOne(id);
        if (greeting == null) {
            logger.info("< sendGreeting id:{}", id);
            return new ResponseEntity<Greeting>(HttpStatus.NOT_FOUND);
        }

        if (waitForAsyncResult) {
            Future<Boolean> asyncResponse = emailService
                    .sendAsyncWithResult(greeting);
            boolean emailSent = asyncResponse.get();
            logger.info("- greeting email sent? {}", emailSent);
        } else {
            emailService.sendAsync(greeting);
        }
    } catch (Exception e) {
        logger.error("A problem occurred sending the Greeting.", e);
        return new ResponseEntity<Greeting>(
                HttpStatus.INTERNAL_SERVER_ERROR);
    }

    logger.info("< sendGreeting id:{}", id);
    return new ResponseEntity<Greeting>(greeting, HttpStatus.OK);
}
 
Example #30
Source File: CmRestController.java    From oneops with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value="/cm/ops/procedures/{procedureId}", method = RequestMethod.GET)
@ResponseBody
public CmsOpsProcedure getOpsProcedureExt(@PathVariable long procedureId, 
		@RequestParam(value="definition", required = false) Boolean includeDef){
	boolean incd = false;
	if (includeDef != null) {
		incd = includeDef.booleanValue();
	}
    return opsManager.getCmsOpsProcedure(procedureId,incd);
}