本文整理汇总了Java中com.sun.jersey.api.json.JSONWithPadding类 的典型用法代码示例。如果您正苦于以下问题:Java JSONWithPadding类的具体用法?Java JSONWithPadding怎么用?Java JSONWithPadding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JSONWithPadding类 属于com.sun.jersey.api.json包,在下文中一共展示了JSONWithPadding类 的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setZNode
import com.sun.jersey.api.json.JSONWithPadding; //导入依赖的package包/类
@PUT
@Produces( { MediaType.APPLICATION_JSON, "application/javascript",
MediaType.APPLICATION_XML })
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
public Response setZNode(
@PathParam("path") String path,
@QueryParam("callback") String callback,
@DefaultValue("-1") @QueryParam("version") String versionParam,
@DefaultValue("base64") @QueryParam("dataformat") String dataformat,
@DefaultValue("false") @QueryParam("null") String setNull,
@Context UriInfo ui, byte[] data) throws InterruptedException,
KeeperException {
ensurePathNotNull(path);
int version;
try {
version = Integer.parseInt(versionParam);
} catch (NumberFormatException e) {
throw new WebApplicationException(Response.status(
Response.Status.BAD_REQUEST).entity(
new ZError(ui.getRequestUri().toString(), path
+ " bad version " + versionParam)).build());
}
if (setNull.equals("true")) {
data = null;
}
Stat stat = zk.setData(path, data, version);
ZStat zstat = new ZStat(path, ui.getAbsolutePath().toString(), null,
null, stat.getCzxid(), stat.getMzxid(), stat.getCtime(), stat
.getMtime(), stat.getVersion(), stat.getCversion(),
stat.getAversion(), stat.getEphemeralOwner(), stat
.getDataLength(), stat.getNumChildren(), stat
.getPzxid());
return Response.status(Response.Status.OK).entity(
new JSONWithPadding(zstat, callback)).build();
}
开发者ID:maoling, 项目名称:fuck_zookeeper, 代码行数:41, 代码来源:ZNodeResource.java
示例2: wrapContentIfNeccessary
import com.sun.jersey.api.json.JSONWithPadding; //导入依赖的package包/类
public static Object wrapContentIfNeccessary(String callback,
final String responseType, final Object content) {
if (responseType.equals(MediaTypeHelper.APPLICATION_X_JAVASCRIPT)) {
return new JSONWithPadding(content, callback);
}
return content;
}
开发者ID:andrey-desman, 项目名称:openhab-hdl, 代码行数:8, 代码来源:ResponseHelper.java
示例3: filter
import com.sun.jersey.api.json.JSONWithPadding; //导入依赖的package包/类
@Override
public BroadcastAction filter(String broadcasterId, AtmosphereResource resource, Object originalMessage, Object message) {
final HttpServletRequest request = resource.getRequest();
ResponseTypeHelper responseTypeHelper = new ResponseTypeHelper();
String responseType = responseTypeHelper.getResponseType(request);
try {
Object responseObject = responseType.equals(MediaTypeHelper.APPLICATION_X_JAVASCRIPT) ?
new JSONWithPadding(message, responseTypeHelper.getQueryParam(request, "callback")) : message;
return new BroadcastAction(
ACTION.CONTINUE, Response.ok(responseObject, responseType).build());
} catch (Exception e) {
logger.error(e.getMessage());
return new BroadcastAction(ACTION.ABORT, message);
}
}
开发者ID:andrey-desman, 项目名称:openhab-hdl, 代码行数:16, 代码来源:MessageTypeFilter.java
示例4: EasyRecException
import com.sun.jersey.api.json.JSONWithPadding; //导入依赖的package包/类
public EasyRecException(List<Message> messages, String action, String type, String callback) {
//GenericEntity<List<Message>> entity = new GenericEntity<List<Message>>(messages) {};
super(callback != null ?
Response.ok(new JSONWithPadding(messagesToArray(messages), callback),
WS.RESPONSE_TYPE_JSCRIPT).build() :
Response.ok(messagesToArray(messages), type).build());
}
开发者ID:customertimes, 项目名称:easyrec-PoC, 代码行数:8, 代码来源:EasyRecException.java
示例5: formatResponse
import com.sun.jersey.api.json.JSONWithPadding; //导入依赖的package包/类
/**
* This method takes an object and creates a <code>Response</code> object
* out of it which will be returned. If <code>messages</code> contains error
* messages they will be send back instead.
* The format of the <code>Response</code>
* depends on the <code>responseType</code>.
* Supported types are <code>application/xml</code> and <code>application/json</code>
*
* @param respondData an object which will be returned as a
* <code>Response</code> object
* @param messages a list of <code>Message</code> objects which contain
* error messages of the API request
* @param responseType defines the format of the <code>Response</code> object
* @param callback if set and responseType is jason the result will be returned
* via this javascript callback function (optional)
* @return a <code>Response</code> object containing the <code>responseData</code>
* in the format defined with <code>responseType</code>
*/
private Response formatResponse(Object respondData,
List<Message> messages,
String serviceName,
String responseType,
String callback) {
//handle error messages if existing
if (messages.size() > 0) {
if ((WS.RESPONSE_TYPE_PATH_JSON.equals(responseType)))
throw new EasyRecException(messages, serviceName, WS.RESPONSE_TYPE_JSON, callback);
else
throw new EasyRecException(messages, serviceName);
}
if (respondData instanceof List) {
respondData = new ResponseSuccessMessage(serviceName, (List<SuccessMessage>) respondData);
}
//convert respondData to Respond object
if (WS.RESPONSE_TYPE_PATH_JSON.equals(responseType)) {
if (callback != null) {
return Response.ok(new JSONWithPadding(respondData, callback),
WS.RESPONSE_TYPE_JSCRIPT).build();
} else {
return Response.ok(respondData, WS.RESPONSE_TYPE_JSON).build();
}
} else if (WS.RESPONSE_TYPE_PATH_XML.equals(responseType)) {
return Response.ok(respondData, WS.RESPONSE_TYPE_XML).build();
} else {
return Response.status(Response.Status.UNSUPPORTED_MEDIA_TYPE).build();
}
}
开发者ID:customertimes, 项目名称:easyrec-PoC, 代码行数:51, 代码来源:ProfileWebservice.java
示例6: formatResponse
import com.sun.jersey.api.json.JSONWithPadding; //导入依赖的package包/类
/**
* This method takes an object and creates a <code>Response</code> object
* out of it which will be returned. If <code>messages</code> contains error
* messages they will be send back instead.
* The format of the <code>Response</code>
* depends on the <code>responseType</code>.
* Supported types are <code>application/xml</code> and <code>application/json</code>
*
* @param respondData an object which will be returned as a
* <code>Response</code> object
* @param messages a list of <code>Message</code> objects which contain
* error messages of the API request
* @param responseType defines the format of the <code>Response</code> object
* @param callback if set and responseType is jason the result will be returned
* via this javascript callback function (optional)
* @return a <code>Response</code> object containing the <code>responseData</code>
* in the format defined with <code>responseType</code>
*/
private Response formatResponse(Object respondData,
List<Message> messages,
String serviceName,
String responseType,
String callback) {
//handle error messages if existing
if (messages.size() > 0) {
if ((WS.JSON_PATH.equals(responseType)))
throw new EasyRecException(messages, serviceName, WS.RESPONSE_TYPE_JSON, callback);
else
throw new EasyRecException(messages, serviceName);
}
if (respondData instanceof List) {
respondData = new ResponseSuccessMessage(serviceName, (List<SuccessMessage>) respondData);
}
//convert respondData to Respond object
if (WS.JSON_PATH.equals(responseType)) {
if (callback != null) {
return Response.ok(new JSONWithPadding(respondData, callback),
WS.RESPONSE_TYPE_JSCRIPT).build();
} else {
return Response.ok(respondData, WS.RESPONSE_TYPE_JSON).build();
}
} else if (WS.XML_PATH.equals(responseType)) {
return Response.ok(respondData, WS.RESPONSE_TYPE_XML).build();
} else {
return Response.status(Response.Status.UNSUPPORTED_MEDIA_TYPE).build();
}
}
开发者ID:customertimes, 项目名称:easyrec-PoC, 代码行数:51, 代码来源:EasyRec.java
示例7: createZNode
import com.sun.jersey.api.json.JSONWithPadding; //导入依赖的package包/类
@POST
@Produces( { MediaType.APPLICATION_JSON, "application/javascript",
MediaType.APPLICATION_XML })
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
public Response createZNode(
@PathParam("path") String path,
@QueryParam("callback") String callback,
@DefaultValue("create") @QueryParam("op") String op,
@QueryParam("name") String name,
@DefaultValue("base64") @QueryParam("dataformat") String dataformat,
@DefaultValue("false") @QueryParam("null") String setNull,
@DefaultValue("false") @QueryParam("sequence") String sequence,
@DefaultValue("false") @QueryParam("ephemeral") String ephemeral,
@Context UriInfo ui, byte[] data) throws InterruptedException,
KeeperException {
ensurePathNotNull(path);
if (path.equals("/")) {
path += name;
} else {
path += "/" + name;
}
if (!op.equals("create")) {
throw new WebApplicationException(Response.status(
Response.Status.BAD_REQUEST).entity(
new ZError(ui.getRequestUri().toString(), path
+ " bad operaton " + op)).build());
}
if (setNull.equals("true")) {
data = null;
}
CreateMode createMode;
if (sequence.equals("true")) {
if (ephemeral.equals("false")) {
createMode = CreateMode.PERSISTENT_SEQUENTIAL;
} else {
createMode = CreateMode.EPHEMERAL_SEQUENTIAL;
}
} else if (ephemeral.equals("false")) {
createMode = CreateMode.PERSISTENT;
} else {
createMode = CreateMode.EPHEMERAL;
}
String newPath = zk.create(path, data, Ids.OPEN_ACL_UNSAFE, createMode);
URI uri = ui.getAbsolutePathBuilder().path(newPath).build();
return Response.created(uri).entity(
new JSONWithPadding(new ZPath(newPath, ui.getAbsolutePath()
.toString()))).build();
}
开发者ID:maoling, 项目名称:fuck_zookeeper, 代码行数:56, 代码来源:ZNodeResource.java
示例8: view
import com.sun.jersey.api.json.JSONWithPadding; //导入依赖的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();
}
开发者ID:customertimes, 项目名称:easyrec-PoC, 代码行数:58, 代码来源:EasyRec.java
示例9: rate
import com.sun.jersey.api.json.JSONWithPadding; //导入依赖的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();
}
}
开发者ID:customertimes, 项目名称:easyrec-PoC, 代码行数:73, 代码来源:EasyRec.java
示例10: buy
import com.sun.jersey.api.json.JSONWithPadding; //导入依赖的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();
}
开发者ID:customertimes, 项目名称:easyrec-PoC, 代码行数:59, 代码来源:EasyRec.java
示例11: otherUsersAlsoViewed
import com.sun.jersey.api.json.JSONWithPadding; //导入依赖的package包/类
@GET
@Path("/otherusersalsoviewed")
public Response otherUsersAlsoViewed(@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("numberOfResults") Integer numberOfResults,
@QueryParam("itemtype") String itemType,
@QueryParam("requesteditemtype") String requestedItemType,
@QueryParam("callback") String callback,
@QueryParam("withProfile") @DefaultValue("false") boolean withProfile) throws EasyRecException {
Monitor mon = MonitorFactory.start(JAMON_REST_ALSO_VIEWED);
Recommendation rec = null;
Integer coreTenantId = operatorDAO.getTenantId(apiKey, tenantId);
if (coreTenantId == null)
exceptionResponse(WS.ACTION_OTHER_USERS_ALSO_VIEWED, MSG.TENANT_WRONG_TENANT_APIKEY, type, callback);
RemoteTenant r = remoteTenantDAO.get(coreTenantId);
if (r.isMaxActionLimitExceeded())
exceptionResponse(WS.ACTION_OTHER_USERS_ALSO_VIEWED, MSG.MAXIMUM_ACTIONS_EXCEEDED, type, callback);
itemType = checkItemType(itemType, type, coreTenantId, tenantId, WS.ACTION_OTHER_USERS_ALSO_VIEWED, callback);
requestedItemType = checkItemType(requestedItemType, type, coreTenantId, tenantId, WS.ACTION_OTHER_USERS_ALSO_VIEWED, callback, null);
Session session = new Session(sessionId, request);
try {
if ((numberOfResults == null) || (numberOfResults > WS.DEFAULT_NUMBER_OF_RESULTS))
numberOfResults = WS.DEFAULT_NUMBER_OF_RESULTS;
rec = shopRecommenderService.alsoViewedItems(coreTenantId, userId, itemId, itemType, requestedItemType,
session, numberOfResults);
//added by FK on 2012-12-18 for adding profile data to recommendations.
if (withProfile) {
addProfileDataToItems(rec);
}
} catch (EasyRecRestException sre) {
exceptionResponse(WS.ACTION_OTHER_USERS_ALSO_VIEWED, sre.getMessageObject(), type,
callback);
}
mon.stop();
if (WS.JSON_PATH.equals(type)) {
if (callback != null)
return Response.ok(new JSONWithPadding(rec, callback), WS.RESPONSE_TYPE_JSCRIPT).build();
else
return Response.ok(rec, WS.RESPONSE_TYPE_JSON).build();
} else
return Response.ok(rec, WS.RESPONSE_TYPE_XML).build();
}
开发者ID:customertimes, 项目名称:easyrec-PoC, 代码行数:52, 代码来源:EasyRec.java
示例12: recommendationsForUser
import com.sun.jersey.api.json.JSONWithPadding; //导入依赖的package包/类
@GET
@Path("/recommendationsforuser")
public Response recommendationsForUser(@PathParam("type") String type, @QueryParam("apikey") String apiKey,
@QueryParam("tenantid") String tenantId, @QueryParam("userid") String userId,
@QueryParam("numberOfResults") Integer numberOfResults,
@QueryParam("requesteditemtype") String requestedItemType,
@QueryParam("callback") String callback,
@QueryParam("actiontype") @DefaultValue(TypeMappingService.ACTION_TYPE_VIEW) String actiontype,
@QueryParam("withProfile") @DefaultValue("false") boolean withProfile)
throws EasyRecException {
Monitor mon = MonitorFactory.start(JAMON_REST_RECS_FOR_USER);
Recommendation rec = null;
Session session = new Session(null, request);
Integer coreTenantId = operatorDAO.getTenantId(apiKey, tenantId);
if (coreTenantId == null)
exceptionResponse(WS.ACTION_RECOMMENDATIONS_FOR_USER, MSG.TENANT_WRONG_TENANT_APIKEY, type, callback);
RemoteTenant remoteTenant = remoteTenantDAO.get(coreTenantId);
if (remoteTenant.isMaxActionLimitExceeded())
exceptionResponse(WS.ACTION_RECOMMENDATIONS_FOR_USER, MSG.MAXIMUM_ACTIONS_EXCEEDED, type, callback);
if (Strings.isNullOrEmpty(userId))
exceptionResponse(WS.ACTION_RECOMMENDATIONS_FOR_USER, MSG.USER_NO_ID, type, callback);
requestedItemType = checkItemType(requestedItemType, type, coreTenantId, tenantId, WS.ACTION_RECOMMENDATIONS_FOR_USER, callback, null);
if (typeMappingService.getIdOfActionType(coreTenantId, actiontype) == null) {
exceptionResponse(WS.ACTION_RECOMMENDATIONS_FOR_USER, MSG.OPERATION_FAILED.append(String.format(" actionType %s not found for tenant %s", actiontype, tenantId)), type, callback);
}
if ((numberOfResults == null) || (numberOfResults > WS.DEFAULT_NUMBER_OF_RESULTS))
numberOfResults = WS.DEFAULT_NUMBER_OF_RESULTS;
if (rec == null || rec.getRecommendedItems().isEmpty()) {
try {
rec = shopRecommenderService.itemsBasedOnActionHistory(coreTenantId, userId, session, actiontype, null, WS.ACTION_HISTORY_DEPTH, null,
requestedItemType, numberOfResults);
//added by FK on 2012-12-18 for adding profile data to recommendations.
if (withProfile) {
addProfileDataToItems(rec);
}
} catch (EasyRecRestException sre) {
exceptionResponse(WS.ACTION_RECOMMENDATIONS_FOR_USER, sre.getMessageObject(), type, callback);
}
}
mon.stop();
if (WS.JSON_PATH.equals(type)) {
if (callback != null)
return Response.ok(new JSONWithPadding(rec, callback), WS.RESPONSE_TYPE_JSCRIPT).build();
else
return Response.ok(rec, WS.RESPONSE_TYPE_JSON).build();
} else
return Response.ok(rec, WS.RESPONSE_TYPE_XML).build();
}
开发者ID:customertimes, 项目名称:easyrec-PoC, 代码行数:61, 代码来源:EasyRec.java
示例13: actionHistoryForUser
import com.sun.jersey.api.json.JSONWithPadding; //导入依赖的package包/类
@GET
@Path("/actionhistoryforuser")
public Response actionHistoryForUser(@PathParam("type") String type, @QueryParam("apikey") String apiKey,
@QueryParam("tenantid") String tenantId, @QueryParam("userid") String userId,
@QueryParam("numberOfResults") Integer numberOfResults,
@QueryParam("requesteditemtype") String requestedItemType,
@QueryParam("callback") String callback,
@QueryParam("actiontype") @DefaultValue(TypeMappingService.ACTION_TYPE_VIEW) String actiontype)
throws EasyRecException {
Monitor mon = MonitorFactory.start(JAMON_REST_ACTIONHISTORY);
Recommendation rec = null;
Session session = new Session(null, request);
Integer coreTenantId = operatorDAO.getTenantId(apiKey, tenantId);
if (coreTenantId == null)
exceptionResponse(WS.ACTION_HISTORY, MSG.TENANT_WRONG_TENANT_APIKEY, type, callback);
RemoteTenant remoteTenant = remoteTenantDAO.get(coreTenantId);
if (remoteTenant.isMaxActionLimitExceeded())
exceptionResponse(WS.ACTION_HISTORY, MSG.MAXIMUM_ACTIONS_EXCEEDED, type, callback);
if (Strings.isNullOrEmpty(userId))
exceptionResponse(WS.ACTION_HISTORY, MSG.USER_NO_ID, type, callback);
requestedItemType = checkItemType(requestedItemType, type, coreTenantId, tenantId, WS.ACTION_HISTORY, callback, null);
if (typeMappingService.getIdOfActionType(coreTenantId, actiontype) == null) {
exceptionResponse(WS.ACTION_HISTORY, MSG.OPERATION_FAILED.append(String.format(" actionType %s not found for tenant %s", actiontype, tenantId)), type, callback);
}
if ((numberOfResults == null) || (numberOfResults > WS.DEFAULT_NUMBER_OF_RESULTS))
numberOfResults = WS.DEFAULT_NUMBER_OF_RESULTS;
if (rec == null || rec.getRecommendedItems().isEmpty()) {
try {
rec = shopRecommenderService.actionHistory(coreTenantId, userId, session, actiontype, requestedItemType, numberOfResults + 5, numberOfResults); // +5 to compensate for inactive items
} catch (EasyRecRestException sre) {
exceptionResponse(WS.ACTION_HISTORY, sre.getMessageObject(), type, callback);
}
}
mon.stop();
if (WS.JSON_PATH.equals(type)) {
if (callback != null)
return Response.ok(new JSONWithPadding(rec, callback), WS.RESPONSE_TYPE_JSCRIPT).build();
else
return Response.ok(rec, WS.RESPONSE_TYPE_JSON).build();
} else
return Response.ok(rec, WS.RESPONSE_TYPE_XML).build();
}
开发者ID:customertimes, 项目名称:easyrec-PoC, 代码行数:57, 代码来源:EasyRec.java
示例14: otherUsersAlsoBought
import com.sun.jersey.api.json.JSONWithPadding; //导入依赖的package包/类
@GET
@Path("/otherusersalsobought")
public Response otherUsersAlsoBought(@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("numberOfResults") Integer numberOfResults,
@QueryParam("itemtype") String itemType,
@QueryParam("requesteditemtype") String requestedItemType,
@QueryParam("callback") String callback,
@QueryParam("withProfile") @DefaultValue("false") boolean withProfile)
throws EasyRecException {
Monitor mon = MonitorFactory.start(JAMON_REST_ALSO_BOUGHT);
Recommendation rec = null;
Integer coreTenantId = operatorDAO.getTenantId(apiKey, tenantId);
if (coreTenantId == null)
exceptionResponse(WS.ACTION_OTHER_USERS_ALSO_BOUGHT, MSG.TENANT_WRONG_TENANT_APIKEY, type, callback);
RemoteTenant r = remoteTenantDAO.get(coreTenantId);
if (r.isMaxActionLimitExceeded())
exceptionResponse(WS.ACTION_OTHER_USERS_ALSO_BOUGHT, MSG.MAXIMUM_ACTIONS_EXCEEDED, type, callback);
itemType = checkItemType(itemType, type, coreTenantId, tenantId, WS.ACTION_OTHER_USERS_ALSO_BOUGHT, callback);
requestedItemType = checkItemType(requestedItemType, type, coreTenantId, tenantId, WS.ACTION_OTHER_USERS_ALSO_BOUGHT, callback, null);
Session session = new Session(sessionId, request);
try {
if ((numberOfResults == null) || (numberOfResults > WS.DEFAULT_NUMBER_OF_RESULTS))
numberOfResults = WS.DEFAULT_NUMBER_OF_RESULTS;
rec = shopRecommenderService.alsoBoughtItems(coreTenantId, userId, itemId, itemType, requestedItemType,
session, numberOfResults);
//added by FK on 2012-12-18 for adding profile data to recommendations.
if (withProfile) {
addProfileDataToItems(rec);
}
} catch (EasyRecRestException sre) {
exceptionResponse(WS.ACTION_OTHER_USERS_ALSO_BOUGHT, sre.getMessageObject(), type, callback);
}
mon.stop();
if (WS.JSON_PATH.equals(type)) {
if (callback != null)
return Response.ok(new JSONWithPadding(rec, callback), WS.RESPONSE_TYPE_JSCRIPT).build();
else
return Response.ok(rec, WS.RESPONSE_TYPE_JSON).build();
} else
return Response.ok(rec, WS.RESPONSE_TYPE_XML).build();
}
开发者ID:customertimes, 项目名称:easyrec-PoC, 代码行数:52, 代码来源:EasyRec.java
示例15: itemsRatedGoodByOtherUsers
import com.sun.jersey.api.json.JSONWithPadding; //导入依赖的package包/类
@GET
@Path("/itemsratedgoodbyotherusers")
public Response itemsRatedGoodByOtherUsers(@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("numberOfResults") Integer numberOfResults,
@QueryParam("itemtype") String itemType,
@QueryParam("requesteditemtype") String requestedItemType,
@QueryParam("callback") String callback,
@QueryParam("withProfile") @DefaultValue("false") boolean withProfile) throws EasyRecException {
Monitor mon = MonitorFactory.start(JAMON_REST_ALSO_RATED);
Recommendation rec = null;
Integer coreTenantId = operatorDAO.getTenantId(apiKey, tenantId);
if (coreTenantId == null)
exceptionResponse(WS.ACTION_ITEMS_RATED_GOOD_BY_OTHER_USERS, MSG.TENANT_WRONG_TENANT_APIKEY, type,
callback);
RemoteTenant r = remoteTenantDAO.get(coreTenantId);
if (r.isMaxActionLimitExceeded())
exceptionResponse(WS.ACTION_ITEMS_RATED_GOOD_BY_OTHER_USERS, MSG.MAXIMUM_ACTIONS_EXCEEDED, type, callback);
itemType = checkItemType(itemType, type, coreTenantId, tenantId, WS.ACTION_ITEMS_RATED_GOOD_BY_OTHER_USERS, callback);
requestedItemType = checkItemType(requestedItemType, type, coreTenantId, tenantId, WS.ACTION_ITEMS_RATED_GOOD_BY_OTHER_USERS, callback, null);
Session session = new Session(sessionId, request);
try {
if ((numberOfResults == null) || (numberOfResults > WS.DEFAULT_NUMBER_OF_RESULTS))
numberOfResults = WS.DEFAULT_NUMBER_OF_RESULTS;
rec = shopRecommenderService.alsoGoodRatedItems(coreTenantId, userId, itemId, itemType, requestedItemType,
session, numberOfResults);
//added by FK on 2012-12-18 for adding profile data to recommendations.
if (withProfile) {
addProfileDataToItems(rec);
}
} catch (EasyRecRestException sre) {
exceptionResponse(WS.ACTION_ITEMS_RATED_GOOD_BY_OTHER_USERS, sre.getMessageObject(),
type, callback);
}
mon.stop();
if (WS.JSON_PATH.equals(type)) {
if (callback != null)
return Response.ok(new JSONWithPadding(rec, callback), WS.RESPONSE_TYPE_JSCRIPT).build();
else
return Response.ok(rec, WS.RESPONSE_TYPE_JSON).build();
} else
return Response.ok(rec, WS.RESPONSE_TYPE_XML).build();
}
开发者ID:customertimes, 项目名称:easyrec-PoC, 代码行数:56, 代码来源:EasyRec.java
示例16: relatedItems
import com.sun.jersey.api.json.JSONWithPadding; //导入依赖的package包/类
@GET
@Path("/relateditems")
public Response relatedItems(@PathParam("type") String type, @QueryParam("apikey") String apiKey,
@QueryParam("tenantid") String tenantId,
@QueryParam("assoctype") String assocType, @QueryParam("userid") String userId,
@QueryParam("sessionid") String sessionId, @QueryParam("itemid") String itemId,
@QueryParam("numberOfResults") Integer numberOfResults,
@QueryParam("itemtype") String itemType,
@QueryParam("requesteditemtype") String requestedItemType,
@QueryParam("callback") String callback,
@QueryParam("withProfile") @DefaultValue("false") boolean withProfile)
throws EasyRecException {
Monitor mon = MonitorFactory.start(JAMON_REST_RELATED_ITEMS);
Recommendation rec = null;
Integer coreTenantId = operatorDAO.getTenantId(apiKey, tenantId);
Integer assocTypeId = null;
if (coreTenantId == null)
exceptionResponse(WS.ACTION_RELATED_ITEMS, MSG.TENANT_WRONG_TENANT_APIKEY, type, callback);
RemoteTenant r = remoteTenantDAO.get(coreTenantId);
if (r.isMaxActionLimitExceeded())
exceptionResponse(WS.ACTION_RELATED_ITEMS, MSG.MAXIMUM_ACTIONS_EXCEEDED, type, callback);
if (itemId == null)
exceptionResponse(WS.ACTION_RELATED_ITEMS, MSG.ITEM_NO_ID, type, callback);
if (assocType != null) {
assocTypeId = typeMappingService.getIdOfAssocType(coreTenantId, assocType, Boolean.TRUE); // only visible assocTypes can be queried
if (assocTypeId == null)
exceptionResponse(WS.ACTION_RELATED_ITEMS, MSG.ASSOC_TYPE_DOES_NOT_EXIST, type, callback);
} else {
assocType = AssocTypeDAO.ASSOCTYPE_IS_RELATED;
}
itemType = checkItemType(itemType, type, coreTenantId, tenantId, WS.ACTION_RELATED_ITEMS, callback);
requestedItemType = checkItemType(requestedItemType, type, coreTenantId, tenantId, WS.ACTION_RELATED_ITEMS, callback, null);
Session session = new Session(null, request);
try {
if ((numberOfResults == null) || (numberOfResults > WS.DEFAULT_NUMBER_OF_RESULTS))
numberOfResults = WS.DEFAULT_NUMBER_OF_RESULTS;
rec = shopRecommenderService.relatedItems(coreTenantId, assocType, userId, itemId, itemType, requestedItemType, session,
numberOfResults);
//added by FK on 2012-12-18 for adding profile data to recommendations.
if (withProfile) {
addProfileDataToItems(rec);
}
} catch (EasyRecRestException e) {
exceptionResponse(WS.ACTION_RELATED_ITEMS, e.getMessageObject(), type,
callback);
}
mon.stop();
if (WS.JSON_PATH.equals(type)) {
if (callback != null)
return Response.ok(new JSONWithPadding(rec, callback), WS.RESPONSE_TYPE_JSCRIPT).build();
else
return Response.ok(rec, WS.RESPONSE_TYPE_JSON).build();
} else
return Response.ok(rec, WS.RESPONSE_TYPE_XML).build();
}
开发者ID:customertimes, 项目名称:easyrec-PoC, 代码行数:67, 代码来源:EasyRec.java
示例17: setItemActive
import com.sun.jersey.api.json.JSONWithPadding; //导入依赖的package包/类
@GET
@Path("/setitemactive")
public Response setItemActive(@PathParam("type") String type, @QueryParam("apikey") String apiKey,
@QueryParam("tenantid") String tenantId, @QueryParam("itemid") String itemId,
@QueryParam("active") Boolean active, @QueryParam("itemtype") String itemType,
@QueryParam("callback") String callback) throws EasyRecException {
Monitor mon = MonitorFactory.start(JAMON_REST_ITEM_ACTIVE);
Integer coreTenantId = operatorDAO.getTenantId(apiKey, tenantId);
if (coreTenantId == null)
exceptionResponse(WS.ACTION_SET_ITEM_ACTIVE, MSG.TENANT_WRONG_TENANT_APIKEY, type, callback);
if (itemId == null)
exceptionResponse(WS.ACTION_SET_ITEM_ACTIVE, MSG.ITEM_NO_ID, type, callback);
if (active == null)
exceptionResponse(WS.ACTION_SET_ITEM_ACTIVE, MSG.ITEM_NO_ACTIVE, type, callback);
itemType = checkItemType(itemType, type, coreTenantId, tenantId, WS.ACTION_SET_ITEM_ACTIVE, callback);
RemoteTenant r = remoteTenantDAO.get(coreTenantId);
Item item = itemDAO.get(r, itemId, itemType);
if (item == null)
exceptionResponse(WS.ACTION_SET_ITEM_ACTIVE, MSG.ITEM_NOT_EXISTS, type, callback);
else {
if (item.isActive() && !active)
itemDAO.deactivate(coreTenantId, itemId, itemType);
if (!item.isActive() && active)
itemDAO.activate(coreTenantId, itemId, itemType);
}
ResponseItem respItem = new ResponseItem(tenantId, WS.ACTION_SET_ITEM_ACTIVE + active, null, null, 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();
}
开发者ID:customertimes, 项目名称:easyrec-PoC, 代码行数:45, 代码来源:EasyRec.java
六六分期app的软件客服如何联系?不知道吗?加qq群【895510560】即可!标题:六六分期
阅读:19149| 2023-10-27
今天小编告诉大家如何处理win10系统火狐flash插件总是崩溃的问题,可能很多用户都不知
阅读:9974| 2022-11-06
今天小编告诉大家如何对win10系统删除桌面回收站图标进行设置,可能很多用户都不知道
阅读:8317| 2022-11-06
今天小编告诉大家如何对win10系统电脑设置节能降温的设置方法,想必大家都遇到过需要
阅读:8687| 2022-11-06
我们在使用xp系统的过程中,经常需要对xp系统无线网络安装向导设置进行设置,可能很多
阅读:8628| 2022-11-06
今天小编告诉大家如何处理win7系统玩cf老是与主机连接不稳定的问题,可能很多用户都不
阅读:9643| 2022-11-06
电脑对日常生活的重要性小编就不多说了,可是一旦碰到win7系统设置cf烟雾头的问题,很
阅读:8611| 2022-11-06
我们在日常使用电脑的时候,有的小伙伴们可能在打开应用的时候会遇见提示应用程序无法
阅读:7991| 2022-11-06
今天小编告诉大家如何对win7系统打开vcf文件进行设置,可能很多用户都不知道怎么对win
阅读:8642| 2022-11-06
今天小编告诉大家如何对win10系统s4开启USB调试模式进行设置,可能很多用户都不知道怎
阅读:7527| 2022-11-06
请发表评论