本文整理汇总了Java中org.easyrec.utils.MyUtils.dateFormatCheck方法的典型用法代码示例。如果您正苦于以下问题:Java MyUtils.dateFormatCheck方法的具体用法?Java MyUtils.dateFormatCheck怎么用?Java MyUtils.dateFormatCheck使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.easyrec.utils.MyUtils
的用法示例。
在下文中一共展示了MyUtils.dateFormatCheck方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkTimeConstraints
import org.easyrec.utils.MyUtils; //导入方法依赖的package包/类
private TimeConstraintVO checkTimeConstraints(String startTime, String endTime) {
Date startDate = null;
Date endDate;
SimpleDateFormat dateFormatter = new SimpleDateFormat(dateFormat);
if (startTime != null) {
startDate = MyUtils.dateFormatCheck(startTime, dateFormatter);
if (startDate == null)
return null;
}
if (endTime == null)
endDate = new Date(System.currentTimeMillis());
else {
endDate = MyUtils.dateFormatCheck(endTime, dateFormatter);
if (endDate == null)
return null;
}
return new TimeConstraintVO(startDate, endDate);
}
示例2: view
import org.easyrec.utils.MyUtils; //导入方法依赖的package包/类
@GET
@Path("/view")
public Response view(@PathParam("type") String type, @QueryParam("apikey") String apiKey,
@QueryParam("tenantid") String tenantId, @QueryParam("userid") String userId,
@QueryParam("sessionid") String sessionId, @QueryParam("itemid") String itemId,
@QueryParam("itemdescription") String itemDescription, @QueryParam("itemurl") String itemUrl,
@QueryParam("itemimageurl") String itemImageUrl, @QueryParam("actiontime") String actionTime,
@QueryParam("itemtype") String itemType, @QueryParam("callback") String callback,
@QueryParam("token") String token, @QueryParam("actioninfo") String actionInfo)
throws EasyRecException {
Monitor mon = MonitorFactory.start(JAMON_REST_VIEW);
if (easyrecSettings.getSecuredAPIMethods().contains("view")) {
Operator o = operatorDAO.getOperatorFromToken(token);
if (o == null)
exceptionResponse(WS.ACTION_VIEW, MSG.WRONG_TOKEN, type, callback);
else
apiKey = o.getApiKey();
}
// Collect a List of messages for the user to understand,
// what went wrong (e.g. Wrong API key).
List<Message> messages = new ArrayList<>();
Integer coreTenantId = operatorDAO.getTenantId(apiKey, tenantId);
// if (r.isMaxActionLimitExceeded()) {
// messages.add(Message.MAXIMUM_ACTIONS_EXCEEDED);
// }
checkParams(coreTenantId, itemId, itemDescription, itemUrl, sessionId, actionInfo, messages);
Date actionDate = null;
if (actionTime != null) {
SimpleDateFormat dateFormatter = new SimpleDateFormat(dateFormat);
actionDate = MyUtils.dateFormatCheck(actionTime, dateFormatter);
if (actionDate == null)
messages.add(MSG.DATE_PARSE);
}
if (messages.size() > 0) {
if (type.endsWith(WS.RESPONSE_TYPE_PATH_JSON))
throw new EasyRecException(messages, WS.ACTION_VIEW, WS.RESPONSE_TYPE_JSON, callback);
else
throw new EasyRecException(messages, WS.ACTION_VIEW);
}
RemoteTenant r = remoteTenantDAO.get(coreTenantId);
itemType = checkItemType(itemType, type, coreTenantId, tenantId, WS.ACTION_VIEW, callback);
Session session = new Session(sessionId, request.getRemoteAddr());
Item item = shopRecommenderService.viewItem(r, userId, itemId, itemType, itemDescription,
itemUrl, itemImageUrl, actionDate, session, actionInfo);
ResponseItem respItem = new ResponseItem(tenantId, WS.ACTION_VIEW, userId, sessionId, null, item);
mon.stop();
if (type.endsWith(WS.RESPONSE_TYPE_PATH_JSON)) {
if (callback != null)
return Response.ok(new JSONPObject(callback, respItem), WS.RESPONSE_TYPE_JSCRIPT)
.build();
else
return Response.ok(respItem, WS.RESPONSE_TYPE_JSON).build();
} else
return Response.ok(respItem, WS.RESPONSE_TYPE_XML).build();
}
示例3: buy
import org.easyrec.utils.MyUtils; //导入方法依赖的package包/类
@GET
@Path("/buy")
public Response buy(@PathParam("type") String type, @QueryParam("apikey") String apiKey,
@QueryParam("tenantid") String tenantId, @QueryParam("userid") String userId,
@QueryParam("sessionid") String sessionId, @QueryParam("itemid") String itemId,
@QueryParam("itemdescription") String itemDescription, @QueryParam("itemurl") String itemUrl,
@QueryParam("itemimageurl") String itemImageUrl, @QueryParam("actiontime") String actionTime,
@QueryParam("itemtype") String itemType, @QueryParam("callback") String callback,
@QueryParam("token") String token, @QueryParam("actioninfo") String actionInfo)
throws EasyRecException {
Monitor mon = MonitorFactory.start(JAMON_REST_BUY);
if (easyrecSettings.getSecuredAPIMethods().contains("buy")) {
Operator o = operatorDAO.getOperatorFromToken(token);
if (o == null)
exceptionResponse(WS.ACTION_BUY, MSG.WRONG_TOKEN, type, callback);
else
apiKey = o.getApiKey();
}
// Collect a List of messages for the user to understand,
// what went wrong (e.g. Wrong API key).
List<Message> messages = new ArrayList<>();
Integer coreTenantId = operatorDAO.getTenantId(apiKey, tenantId);
checkParams(coreTenantId, itemId, itemDescription, itemUrl, sessionId, actionInfo, messages);
Date actionDate = null;
if (actionTime != null) {
SimpleDateFormat dateFormatter = new SimpleDateFormat(dateFormat);
actionDate = MyUtils.dateFormatCheck(actionTime, dateFormatter);
if (actionDate == null)
messages.add(MSG.DATE_PARSE);
}
if (messages.size() > 0) {
if (type.endsWith(WS.RESPONSE_TYPE_PATH_JSON))
throw new EasyRecException(messages, WS.ACTION_BUY, WS.RESPONSE_TYPE_JSON, callback);
else
throw new EasyRecException(messages, WS.ACTION_BUY);
}
RemoteTenant r = remoteTenantDAO.get(coreTenantId);
// if (r.isMaxActionLimitExceeded()) {
// messages.add(Message.MAXIMUM_ACTIONS_EXCEEDED);
// }
itemType = checkItemType(itemType, type, coreTenantId, tenantId, WS.ACTION_BUY, callback);
Session session = new Session(sessionId, request.getRemoteAddr());
Item item = shopRecommenderService.purchaseItem(r, userId, itemId, itemType, itemDescription,
itemUrl, itemImageUrl, actionDate, session, actionInfo);
ResponseItem respItem = new ResponseItem(tenantId, WS.ACTION_BUY, userId, sessionId, null, item);
mon.stop();
if (type.endsWith(WS.RESPONSE_TYPE_PATH_JSON)) {
if (callback != null)
return Response.ok(new JSONPObject(callback, respItem), WS.RESPONSE_TYPE_JSCRIPT).build();
else
return Response.ok(respItem, WS.RESPONSE_TYPE_JSON).build();
} else
return Response.ok(respItem, WS.RESPONSE_TYPE_XML).build();
}
示例4: view
import org.easyrec.utils.MyUtils; //导入方法依赖的package包/类
@GET
@Path("/view")
public Response view(@PathParam("type") String type, @QueryParam("apikey") String apiKey,
@QueryParam("tenantid") String tenantId, @QueryParam("userid") String userId,
@QueryParam("sessionid") String sessionId, @QueryParam("itemid") String itemId,
@QueryParam("itemdescription") String itemDescription, @QueryParam("itemurl") String itemUrl,
@QueryParam("itemimageurl") String itemImageUrl, @QueryParam("actiontime") String actionTime,
@QueryParam("itemtype") String itemType, @QueryParam("callback") String callback)
throws EasyRecException {
Monitor mon = MonitorFactory.start(JAMON_REST_VIEW);
// Collect a List of messages for the user to understand,
// what went wrong (e.g. Wrong API key).
List<Message> messages = new ArrayList<Message>();
Integer coreTenantId = operatorDAO.getTenantId(apiKey, tenantId);
RemoteTenant r = remoteTenantDAO.get(coreTenantId);
// if (r.isMaxActionLimitExceeded()) {
// messages.add(Message.MAXIMUM_ACTIONS_EXCEEDED);
// }
checkParams(coreTenantId, itemId, itemDescription, itemUrl, sessionId, messages);
Date actionDate = null;
if (actionTime != null) {
SimpleDateFormat dateFormatter = new SimpleDateFormat(dateFormat);
actionDate = MyUtils.dateFormatCheck(actionTime, dateFormatter);
if (actionDate == null)
messages.add(MSG.DATE_PARSE);
}
if (messages.size() > 0) {
if ((WS.JSON_PATH.equals(type)))
throw new EasyRecException(messages, WS.ACTION_VIEW, WS.RESPONSE_TYPE_JSON, callback);
else
throw new EasyRecException(messages, WS.ACTION_VIEW);
}
itemType = checkItemType(itemType, type, coreTenantId, tenantId, WS.ACTION_VIEW, callback);
Session session = new Session(sessionId, request.getRemoteAddr());
Item item = shopRecommenderService.viewItem(r, userId, itemId, itemType, itemDescription,
itemUrl, itemImageUrl, actionDate, session);
ResponseItem respItem = new ResponseItem(tenantId, WS.ACTION_VIEW, userId, sessionId, null, item);
mon.stop();
if (WS.JSON_PATH.equals(type)) {
if (callback != null)
return Response.ok(new JSONWithPadding(respItem, callback), WS.RESPONSE_TYPE_JSCRIPT)
.build();
else
return Response.ok(respItem, WS.RESPONSE_TYPE_JSON).build();
} else
return Response.ok(respItem, WS.RESPONSE_TYPE_XML).build();
}
示例5: rate
import org.easyrec.utils.MyUtils; //导入方法依赖的package包/类
@GET
@Path("/rate")
public Response rate(@PathParam("type") String type, @QueryParam("apikey") String apiKey,
@QueryParam("tenantid") String tenantId, @QueryParam("userid") String userId,
@QueryParam("sessionid") String sessionId, @QueryParam("itemid") String itemId,
@QueryParam("ratingvalue") String ratingValue,
@QueryParam("itemdescription") String itemDescription, @QueryParam("itemurl") String itemUrl,
@QueryParam("itemimageurl") String itemImageUrl, @QueryParam("actiontime") String actionTime,
@QueryParam("itemtype") String itemType, @QueryParam("callback") String callback)
throws EasyRecException {
Monitor mon = MonitorFactory.start(JAMON_REST_RATE);
// Collect a List of messages for the user to understand,
// what went wrong (e.g. Wrong API key).
List<Message> messages = new ArrayList<Message>();
Integer coreTenantId = operatorDAO.getTenantId(apiKey, tenantId);
RemoteTenant r = remoteTenantDAO.get(coreTenantId);
// if (r.isMaxActionLimitExceeded()) {
// messages.add(Message.MAXIMUM_ACTIONS_EXCEEDED);
// }
checkParams(coreTenantId, itemId, itemDescription, itemUrl, sessionId, messages);
Date actionDate = null;
if (actionTime != null) {
SimpleDateFormat dateFormatter = new SimpleDateFormat(dateFormat);
actionDate = MyUtils.dateFormatCheck(actionTime, dateFormatter);
if (actionDate == null)
messages.add(MSG.DATE_PARSE);
}
Integer rateValue = -1;
try {
rateValue = Integer.valueOf(ratingValue);
if (coreTenantId != null && (rateValue < tenantService.getTenantById(coreTenantId).getRatingRangeMin() ||
rateValue > tenantService.getTenantById(coreTenantId).getRatingRangeMax()))
throw new Exception();
} catch (Exception e) {
messages.add(MSG.ITEM_INVALID_RATING_VALUE);
}
if (messages.size() > 0) {
if ((WS.JSON_PATH.equals(type)))
throw new EasyRecException(messages, WS.ACTION_RATE, WS.RESPONSE_TYPE_JSON, callback);
else
throw new EasyRecException(messages, WS.ACTION_RATE);
}
itemType = checkItemType(itemType, type, coreTenantId, tenantId, WS.ACTION_RATE, callback);
Session session = new Session(sessionId, request.getRemoteAddr());
Item item = shopRecommenderService.rateItem(r, userId, itemId, itemType, itemDescription,
itemUrl, itemImageUrl, rateValue, actionDate, session);
ResponseItem respItem = new ResponseItem(tenantId, WS.ACTION_RATE, userId, sessionId, ratingValue, item);
mon.stop();
if (WS.JSON_PATH.equals(type)) {
if (callback != null)
return Response.ok(new JSONWithPadding(respItem, callback), WS.RESPONSE_TYPE_JSCRIPT).build();
else
return Response.ok(respItem, WS.RESPONSE_TYPE_JSON).build();
} else {
return Response.ok(respItem, WS.RESPONSE_TYPE_XML).build();
}
}
示例6: buy
import org.easyrec.utils.MyUtils; //导入方法依赖的package包/类
@GET
@Path("/buy")
public Response buy(@PathParam("type") String type, @QueryParam("apikey") String apiKey,
@QueryParam("tenantid") String tenantId, @QueryParam("userid") String userId,
@QueryParam("sessionid") String sessionId, @QueryParam("itemid") String itemId,
@QueryParam("itemdescription") String itemDescription, @QueryParam("itemurl") String itemUrl,
@QueryParam("itemimageurl") String itemImageUrl, @QueryParam("actiontime") String actionTime,
@QueryParam("itemtype") String itemType, @QueryParam("callback") String callback)
throws EasyRecException {
Monitor mon = MonitorFactory.start(JAMON_REST_BUY);
// Collect a List of messages for the user to understand,
// what went wrong (e.g. Wrong API key).
List<Message> messages = new ArrayList<Message>();
Integer coreTenantId = operatorDAO.getTenantId(apiKey, tenantId);
RemoteTenant r = remoteTenantDAO.get(coreTenantId);
// if (r.isMaxActionLimitExceeded()) {
// messages.add(Message.MAXIMUM_ACTIONS_EXCEEDED);
// }
checkParams(coreTenantId, itemId, itemDescription, itemUrl, sessionId, messages);
Date actionDate = null;
if (actionTime != null) {
SimpleDateFormat dateFormatter = new SimpleDateFormat(dateFormat);
actionDate = MyUtils.dateFormatCheck(actionTime, dateFormatter);
if (actionDate == null)
messages.add(MSG.DATE_PARSE);
}
if (messages.size() > 0) {
if ((WS.JSON_PATH.equals(type)))
throw new EasyRecException(messages, WS.ACTION_BUY, WS.RESPONSE_TYPE_JSON, callback);
else
throw new EasyRecException(messages, WS.ACTION_BUY);
}
itemType = checkItemType(itemType, type, coreTenantId, tenantId, WS.ACTION_BUY, callback);
Session session = new Session(sessionId, request.getRemoteAddr());
Item item = shopRecommenderService.purchaseItem(r, userId, itemId, itemType, itemDescription,
itemUrl, itemImageUrl, actionDate, session);
ResponseItem respItem = new ResponseItem(tenantId, WS.ACTION_BUY, userId, sessionId, null, item);
mon.stop();
if (WS.JSON_PATH.equals(type)) {
if (callback != null)
return Response.ok(new JSONWithPadding(respItem, callback), WS.RESPONSE_TYPE_JSCRIPT).build();
else
return Response.ok(respItem, WS.RESPONSE_TYPE_JSON).build();
} else
return Response.ok(respItem, WS.RESPONSE_TYPE_XML).build();
}