下面列出了java.nio.file.FileSystemNotFoundException#javax.validation.constraints.NotNull 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* 参加团购
*
* @param grouponId 团购活动ID
* @return 操作结果
*/
@GetMapping("join")
public Object join(@NotNull Integer grouponId) {
LitemallGroupon groupon = grouponService.queryById(grouponId);
if (groupon == null) {
return ResponseUtil.badArgumentValue();
}
LitemallGrouponRules rules = rulesService.queryById(groupon.getRulesId());
if (rules == null) {
return ResponseUtil.badArgumentValue();
}
LitemallGoods goods = goodsService.findById(rules.getGoodsId());
if (goods == null) {
return ResponseUtil.badArgumentValue();
}
Map<String, Object> result = new HashMap<>();
result.put("groupon", groupon);
result.put("goods", goods);
return ResponseUtil.ok(result);
}
/**
* 评论列表
*
* @param type 类型ID。 如果是0,则查询商品评论;如果是1,则查询专题评论。
* @param valueId 商品或专题ID。如果type是0,则是商品ID;如果type是1,则是专题ID。
* @param showType 显示类型。如果是0,则查询全部;如果是1,则查询有图片的评论。
* @param page 分页页数
* @param limit 分页大小
* @return 评论列表
*/
@GetMapping("list")
public Object list(@NotNull Byte type,
@NotNull Integer valueId,
@NotNull Integer showType,
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit) {
List<LitemallComment> commentList = commentService.query(type, valueId, showType, page, limit);
List<Map<String, Object>> commentVoList = new ArrayList<>(commentList.size());
for (LitemallComment comment : commentList) {
Map<String, Object> commentVo = new HashMap<>();
commentVo.put("addTime", comment.getAddTime());
commentVo.put("content", comment.getContent());
commentVo.put("picList", comment.getPicUrls());
UserInfo userInfo = userInfoService.getInfo(comment.getUserId());
commentVo.put("userInfo", userInfo);
String reply = commentService.queryReply(comment.getId());
commentVo.put("reply", reply);
commentVoList.add(commentVo);
}
return ResponseUtil.okList(commentVoList, commentList);
}
/**
* 专题详情
*
* @param id
* 专题ID
* @return 专题详情
*/
@GetMapping("detail")
public Object detail(@NotNull Integer id) {
logger.info("【请求开始】获取专题详情,请求参数,id:{}", id);
Map<String, Object> data = new HashMap<>();
DtsTopic topic = topicService.findById(id);
data.put("topic", topic);
List<DtsGoods> goods = new ArrayList<>();
for (Integer i : topic.getGoods()) {
DtsGoods good = goodsService.findByIdVO(i);
if (null != good)
goods.add(good);
}
data.put("goods", goods);
logger.info("【请求结束】获取专题详情,响应结果:{}", "成功");
return ResponseUtil.ok(data);
}
@ApiOperation(value = "Read transaction list of an account", nickname = "getTransactionList", notes = "Read transaction reports or transaction lists of a given account ddressed by \"account-id\", depending on the steering parameter \"bookingStatus\" together with balances. For a given account, additional parameters are e.g. the attributes \"dateFrom\" and \"dateTo\". The ASPSP might add balance information, if transaction lists without balances are not supported. ", response = TransactionsResponse200Json.class, authorizations = {
@Authorization(value = "BearerAuthOAuth")
}, tags = {})
@ApiResponses(value = {
@ApiResponse(code = 200, message = "OK", response = TransactionsResponse200Json.class),
@ApiResponse(code = 400, message = "Bad Request", response = Error400NGAIS.class),
@ApiResponse(code = 401, message = "Unauthorized", response = Error401NGAIS.class),
@ApiResponse(code = 403, message = "Forbidden", response = Error403NGAIS.class),
@ApiResponse(code = 404, message = "Not found", response = Error404NGAIS.class),
@ApiResponse(code = 405, message = "Method Not Allowed", response = Error405NGAIS.class),
@ApiResponse(code = 406, message = "Not Acceptable", response = Error406NGAIS.class),
@ApiResponse(code = 408, message = "Request Timeout"),
@ApiResponse(code = 415, message = "Unsupported Media Type"),
@ApiResponse(code = 429, message = "Too Many Requests", response = Error429NGAIS.class),
@ApiResponse(code = 500, message = "Internal Server Error"),
@ApiResponse(code = 503, message = "Service Unavailable")})
@RequestMapping(value = "/v1/accounts/{account-id}/transactions/",
produces = {"application/json", "application/xml", "application/text", "application/problem+json"},
method = RequestMethod.GET)
ResponseEntity<TransactionsResponse200Json> _getTransactionList(@ApiParam(value = "This identification is denoting the addressed account. The account-id is retrieved by using a \"Read Account List\" call. The account-id is the \"id\" attribute of the account structure. Its value is constant at least throughout the lifecycle of a given consent. ", required = true) @PathVariable("account-id") String accountId, @NotNull @ApiParam(value = "Permitted codes are * \"booked\", * \"pending\" and * \"both\" \"booked\" shall be supported by the ASPSP. To support the \"pending\" and \"both\" feature is optional for the ASPSP, Error code if not supported in the online banking frontend ", required = true, allowableValues = "booked, pending, both") @Valid @RequestParam(value = "bookingStatus", required = true) String bookingStatus, @ApiParam(value = "ID of the request, unique to the call, as determined by the initiating party.", required = true) @RequestHeader(value = "X-Request-ID", required = true) UUID xRequestID, @ApiParam(value = "This then contains the consentId of the related AIS consent, which was performed prior to this payment initiation. ", required = true) @RequestHeader(value = "Consent-ID", required = true) String consentID, @ApiParam(value = "Conditional: Starting date (inclusive the date dateFrom) of the transaction list, mandated if no delta access is required. For booked transactions, the relevant date is the booking date. For pending transactions, the relevant date is the entry date, which may not be transparent neither in this API nor other channels of the ASPSP. ") @Valid @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) @RequestParam(value = "dateFrom", required = false) LocalDate dateFrom, @ApiParam(value = "End date (inclusive the data dateTo) of the transaction list, is \"now\" if not given. Might be ignored if a delta function is used. For booked transactions, the relevant date is the booking date. For pending transactions, the relevant date is the entry date, which may not be transparent neither in this API nor other channels of the ASPSP. ") @Valid @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) @RequestParam(value = "dateTo", required = false) LocalDate dateTo, @ApiParam(value = "This data attribute is indicating that the AISP is in favour to get all transactions after the transaction with identification entryReferenceFrom alternatively to the above defined period. This is a implementation of a delta access. If this data element is contained, the entries \"dateFrom\" and \"dateTo\" might be ignored by the ASPSP if a delta report is supported. Optional if supported by API provider. ") @Valid @RequestParam(value = "entryReferenceFrom", required = false) String entryReferenceFrom, @ApiParam(value = "This data attribute is indicating that the AISP is in favour to get all transactions after the last report access for this PSU on the addressed account. This is another implementation of a delta access-report. This delta indicator might be rejected by the ASPSP if this function is not supported. Optional if supported by API provider") @Valid @RequestParam(value = "deltaList", required = false) Boolean deltaList, @ApiParam(value = "If contained, this function reads the list of accessible payment accounts including the booking balance, if granted by the PSU in the related consent and available by the ASPSP. This parameter might be ignored by the ASPSP. ") @Valid @RequestParam(value = "withBalance", required = false) Boolean withBalance, @ApiParam(value = "Is contained if and only if the \"Signature\" element is contained in the header of the request.") @RequestHeader(value = "Digest", required = false) String digest, @ApiParam(value = "A signature of the request by the TPP on application level. This might be mandated by ASPSP. ") @RequestHeader(value = "Signature", required = false) String signature, @ApiParam(value = "The certificate used for signing the request, in base64 encoding. Must be contained if a signature is contained. ") @RequestHeader(value = "TPP-Signature-Certificate", required = false) byte[] tpPSignatureCertificate, @ApiParam(value = "The forwarded IP Address header field consists of the corresponding HTTP request IP Address field between PSU and TPP. It shall be contained if and only if this request was actively initiated by the PSU. ") @RequestHeader(value = "PSU-IP-Address", required = false) String psUIPAddress, @ApiParam(value = "The forwarded IP Port header field consists of the corresponding HTTP request IP Port field between PSU and TPP, if available. ") @RequestHeader(value = "PSU-IP-Port", required = false) String psUIPPort, @ApiParam(value = "The forwarded IP Accept header fields consist of the corresponding HTTP request Accept header fields between PSU and TPP, if available. ") @RequestHeader(value = "PSU-Accept", required = false) String psUAccept, @ApiParam(value = "The forwarded IP Accept header fields consist of the corresponding HTTP request Accept header fields between PSU and TPP, if available. ") @RequestHeader(value = "PSU-Accept-Charset", required = false) String psUAcceptCharset, @ApiParam(value = "The forwarded IP Accept header fields consist of the corresponding HTTP request Accept header fields between PSU and TPP, if available. ") @RequestHeader(value = "PSU-Accept-Encoding", required = false) String psUAcceptEncoding, @ApiParam(value = "The forwarded IP Accept header fields consist of the corresponding HTTP request Accept header fields between PSU and TPP, if available. ") @RequestHeader(value = "PSU-Accept-Language", required = false) String psUAcceptLanguage, @ApiParam(value = "The forwarded Agent header field of the HTTP request between PSU and TPP, if available. ") @RequestHeader(value = "PSU-User-Agent", required = false) String psUUserAgent, @ApiParam(value = "HTTP method used at the PSU ? TPP interface, if available. Valid values are: * GET * POST * PUT * PATCH * DELETE ", allowableValues = "GET, POST, PUT, PATCH, DELETE") @RequestHeader(value = "PSU-Http-Method", required = false) String psUHttpMethod, @ApiParam(value = "UUID (Universally Unique Identifier) for a device, which is used by the PSU, if available. UUID identifies either a device or a device dependant application installation. In case of an installation identification this ID need to be unaltered until removal from device. ") @RequestHeader(value = "PSU-Device-ID", required = false) UUID psUDeviceID, @ApiParam(value = "The forwarded Geo Location of the corresponding http request between PSU and TPP if available. ") @RequestHeader(value = "PSU-Geo-Location", required = false) String psUGeoLocation);
/**
* It will upload bytes in range [start,end] to Google drive.
*
* @param start
* starting byte of range
* @param end
* ending byte of range
*/
void uploadPartially(@NotNull byte[] buffer, long start, long end) {
String contentRange = "bytes " + start + "-" + end + "/" + downloadFileInfo.getContentLength();
int statusCode;
try {
HttpURLConnection uploadConnection = (HttpURLConnection) createdFileUrl.openConnection();
uploadConnection.setDoOutput(true);
uploadConnection.setRequestProperty("User-Agent", USER_AGENT);
uploadConnection.setRequestProperty("Content-Range", contentRange);
IOUtils.copy(new ByteArrayInputStream(buffer), uploadConnection.getOutputStream());
uploadConnection.connect();
statusCode = uploadConnection.getResponseCode();
} catch (IOException e) {
throw new RuntimeException("Error While uploading file.", e);
}
// In case of successful upload, status code will be 3** or 2**
if (statusCode < 400)
uploadInformation.setUploadedSize(end + 1);
else if (statusCode == 403) {
throw new RuntimeException(
"Google didn't allow us to create file. Your drive might not have enough space.");
}
}
private Token getAccessToken(@NotNull String code) throws IOException {
// Initialize client
HttpClient httpClient = HttpClientBuilder.create().build();
HttpPost httpPost = new HttpPost(TOKEN_URL);
// add request parameters
List<NameValuePair> parameters = new ArrayList<>();
parameters.add(new BasicNameValuePair("code", code));
parameters.add(new BasicNameValuePair("client_id", CLIENT_ID));
parameters.add(new BasicNameValuePair("client_secret", CLIENT_SECRET));
parameters.add(new BasicNameValuePair("redirect_uri", REDIRECT_URI));
parameters.add(new BasicNameValuePair("grant_type", GRANT_TYPE));
httpPost.setEntity(new UrlEncodedFormEntity(parameters));
// send request
org.apache.http.HttpResponse response = httpClient.execute(httpPost);
int statusCode = response.getStatusLine().getStatusCode();
InputStream inputStream = response.getEntity().getContent();
if (HttpUtilities.success(statusCode))
return gson.fromJson(new InputStreamReader(inputStream), Token.class);
throw new ApiException(HttpStatus.valueOf(statusCode));
}
@Test
public void testSimpleValidation() {
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
validator.afterPropertiesSet();
ValidPerson person = new ValidPerson();
Set<ConstraintViolation<ValidPerson>> result = validator.validate(person);
assertEquals(2, result.size());
for (ConstraintViolation<ValidPerson> cv : result) {
String path = cv.getPropertyPath().toString();
if ("name".equals(path) || "address.street".equals(path)) {
assertTrue(cv.getConstraintDescriptor().getAnnotation() instanceof NotNull);
}
else {
fail("Invalid constraint violation with path '" + path + "'");
}
}
Validator nativeValidator = validator.unwrap(Validator.class);
assertTrue(nativeValidator.getClass().getName().startsWith("org.hibernate"));
assertTrue(validator.unwrap(ValidatorFactory.class) instanceof HibernateValidatorFactory);
assertTrue(validator.unwrap(HibernateValidatorFactory.class) instanceof HibernateValidatorFactory);
validator.destroy();
}
/**
* 商品分类类目
*
* @param id
* 分类类目ID
* @return 商品分类类目
*/
@GetMapping("category")
public Object category(@NotNull Integer id) {
logger.info("【请求开始】商品分类类目,请求参数,id:{}", id);
DtsCategory cur = categoryService.findById(id);
DtsCategory parent = null;
List<DtsCategory> children = null;
if (cur.getPid() == 0) {
parent = cur;
children = categoryService.queryByPid(cur.getId());
cur = children.size() > 0 ? children.get(0) : cur;
} else {
parent = categoryService.findById(cur.getPid());
children = categoryService.queryByPid(cur.getPid());
}
Map<String, Object> data = new HashMap<>();
data.put("currentCategory", cur);
data.put("parentCategory", parent);
data.put("brotherCategory", children);
logger.info("【请求结束】商品分类类目,响应结果:{}", JSONObject.toJSONString(data));
return ResponseUtil.ok(data);
}
@Test
public void testSimpleValidation() {
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
validator.afterPropertiesSet();
ValidPerson person = new ValidPerson();
Set<ConstraintViolation<ValidPerson>> result = validator.validate(person);
assertEquals(2, result.size());
for (ConstraintViolation<ValidPerson> cv : result) {
String path = cv.getPropertyPath().toString();
if ("name".equals(path) || "address.street".equals(path)) {
assertTrue(cv.getConstraintDescriptor().getAnnotation() instanceof NotNull);
}
else {
fail("Invalid constraint violation with path '" + path + "'");
}
}
Validator nativeValidator = validator.unwrap(Validator.class);
assertTrue(nativeValidator.getClass().getName().startsWith("org.hibernate"));
assertTrue(validator.unwrap(ValidatorFactory.class) instanceof HibernateValidatorFactory);
assertTrue(validator.unwrap(HibernateValidatorFactory.class) instanceof HibernateValidatorFactory);
validator.destroy();
}
@Nonnull
@Override
public AlexaSkill<RequestEnvelope, ResponseEnvelope> buildSkill(@Nonnull @NotNull SkillBuilder<?> skillBuilder,
@Nullable AlexaSkillConfiguration alexaSkillConfiguration) {
SkillBeans skillBeans = alexaSkillConfiguration == null ? unqualifiedSkillBeans : this.skillBeans.get(alexaSkillConfiguration.getName());
skillBeans.getRequestHandlers()
.stream()
.sorted(OrderUtil.COMPARATOR)
.forEach(skillBuilder::addRequestHandler);
skillBeans.getExceptionHandlers()
.stream()
.sorted(OrderUtil.COMPARATOR)
.forEach(skillBuilder::addExceptionHandler);
skillBeans.getRequestInterceptors()
.stream()
.sorted(OrderUtil.COMPARATOR)
.forEach(skillBuilder::addRequestInterceptor);
skillBeans.getResponseInterceptors()
.stream()
.sorted(OrderUtil.COMPARATOR)
.forEach(skillBuilder::addResponseInterceptor);
if (alexaSkillConfiguration != null) {
skillBuilder = skillBuilder.withSkillId(alexaSkillConfiguration.getSkillId());
}
return skillBuilder.build();
}
/**
*
**/
@JsonProperty("op")
@NotNull
public OpEnum getOp() {
return op;
}
/**
*
**/
@JsonProperty("value")
@NotNull
public SchemaState getValue() {
return value;
}
/**
* Set to false if the schema is disabled. If the schema is disabled, all the schema versions are disabled.
**/
@JsonProperty("enabled")
@NotNull
public boolean isEnabled() {
return enabled;
}
/**
* The name to give this version of the schema
**/
@JsonProperty("version")
@NotNull
public String getVersion() {
return version;
}
public Food(
@Size(max = 36) @NotNull String key,
@Size(max = 9999) @NotNull int carbohydrates,
@Size(max = 9999) @NotNull int portionGrams,
@Nullable Meal meal) {
this.key = key;
this.carbohydrates = carbohydrates;
this.portionGrams = portionGrams;
this.meal = meal;
}
/**
* 收货地址详情
*
* @param userId 用户ID
* @param id 收货地址ID
* @return 收货地址详情
*/
@GetMapping("detail")
public Object detail(@LoginUser Integer userId, @NotNull Integer id) {
if (userId == null) {
return ResponseUtil.unlogin();
}
LitemallAddress address = addressService.findById(id);
if (address == null) {
return ResponseUtil.badArgumentValue();
}
Map<Object, Object> data = new HashMap<Object, Object>();
data.put("id", address.getId());
data.put("name", address.getName());
data.put("provinceId", address.getProvinceId());
data.put("cityId", address.getCityId());
data.put("areaId", address.getAreaId());
data.put("mobile", address.getMobile());
data.put("address", address.getAddress());
data.put("isDefault", address.getIsDefault());
String pname = regionService.findById(address.getProvinceId()).getName();
data.put("provinceName", pname);
String cname = regionService.findById(address.getCityId()).getName();
data.put("cityName", cname);
String dname = regionService.findById(address.getAreaId()).getName();
data.put("areaName", dname);
return ResponseUtil.ok(data);
}
@RequiresPermissions("admin:coupon:read")
@RequiresPermissionsDesc(menu = { "推广管理", "优惠券管理" }, button = "详情")
@GetMapping("/read")
public Object read(@NotNull Integer id) {
logger.info("【请求开始】推广管理->优惠券管理->详情,请求参数,id:{}", id);
DtsCoupon coupon = couponService.findById(id);
logger.info("【请求结束】推广管理->优惠券管理->详情,响应结果:{}", JSONObject.toJSONString(coupon));
return ResponseUtil.ok(coupon);
}
@RequiresPermissions("admin:category:read")
@RequiresPermissionsDesc(menu={"商场管理" , "类目管理"}, button="详情")
@GetMapping("/read")
public Object read(@NotNull Integer id) {
LitemallCategory category = categoryService.findById(id);
return ResponseUtil.ok(category);
}
@MinDataSize("1B")
@MaxDataSize("1GB")
@NotNull
public DataSize getTextMaxLineLength()
{
return textMaxLineLength;
}
/**
* Helper method to identify the enabled status for new storage plugins config. If this status is absent in the updater
* file, the status is kept from the configs, which are going to be updated
*
* @param oldPluginConfig current storage plugin config from Persistent Store or bootstrap config file
* @param newPluginConfig new storage plugin config
* @return new storage plugin config with updated enabled status
*/
private StoragePluginConfig updatePluginStatus(@Nullable StoragePluginConfig oldPluginConfig,
@NotNull StoragePluginConfig newPluginConfig) {
if (!newPluginConfig.isEnabledStatusPresent()) {
boolean newStatus = oldPluginConfig != null && oldPluginConfig.isEnabled();
newPluginConfig.setEnabled(newStatus);
}
return newPluginConfig;
}
/**
* 品牌详情
*
* @param id 品牌ID
* @return 品牌详情
*/
@GetMapping("detail")
public Object detail(@NotNull Integer id) {
LitemallBrand entity = brandService.findById(id);
if (entity == null) {
return ResponseUtil.badArgumentValue();
}
Map<String, Object> data = new HashMap<String, Object>();
data.put("brand", entity);
return ResponseUtil.ok(data);
}
@DELETE
@Path("/{slug}/comments/{id}")
@Secured({Role.ADMIN, Role.USER})
@Produces(MediaType.APPLICATION_JSON)
public Response deleteComment(
@PathParam("slug") @NotBlank(message = ValidationMessages.SLUG_MUST_BE_NOT_BLANK) String slug,
@PathParam("id") @NotNull(message = ValidationMessages.COMMENT_ID_MUST_BE_NOT_NULL) Long id,
@Context SecurityContext securityContext) {
Long loggedUserId = getLoggedUserId(securityContext);
articlesService.deleteComment(slug, id, loggedUserId);
return Response.ok().build();
}
@NotNull
@MinDuration("1s")
@MaxDuration("1h")
public Duration getTimeout()
{
return timeout;
}
@Override
@Transactional
public void savePluginSettingsRule(@NotNull DeviceLogRule rule) {
PostgresDeviceLogPluginSettings postgresSettings = (PostgresDeviceLogPluginSettings) getPluginSettings();
if (postgresSettings != null) {
PostgresDeviceLogRule postgresRule = (PostgresDeviceLogRule) rule;
postgresRule.setSettingId(postgresSettings.getId());
if (postgresRule.getId() == null) {
this.mapper.insertPluginSettingsRule(postgresRule);
} else {
this.mapper.updatePluginSettingsRule(postgresRule);
}
this.mapper.deletePluginSettingsRuleDevices(postgresRule.getId());
if (postgresRule.getDevices() != null && !postgresRule.getDevices().isEmpty()) {
final List<Integer> deviceIds = postgresRule.getDevices()
.stream()
.map(LookupItem::getId)
.collect(Collectors.toList());
this.mapper.insertPluginSettingsRuleDevices(postgresRule.getId(), deviceIds);
}
} else {
throw new IllegalStateException("Device Log Plugin settings record is required to be created prior " +
"to saving the rule: " + rule);
}
}
/**
* Get photoUrls
*
* @return photoUrls
**/
@JsonProperty("photoUrls")
@NotNull
public List<String> getPhotoUrls() {
return photoUrls;
}
@NotNull
public DataSize getMaxPartialAggregationMemoryUsage()
{
return maxPartialAggregationMemoryUsage;
}
@NotNull
@MinDuration("1s")
public Duration getOrganizationDiscoveryInterval()
{
return organizationDiscoveryInterval;
}
@NotNull
public String getPasswordForUserCredentialName()
{
return passwordForUserCredentialName;
}
@NotNull
public String getSecuritySystem()
{
return securitySystem;
}
@NotNull
@MinDuration("1m")
public Duration getLocalCleanerInterval()
{
return localCleanerInterval;
}