当前位置: 首页>>代码示例>>Java>>正文


Java EasyRecRestException类代码示例

本文整理汇总了Java中org.easyrec.rest.nodomain.exception.EasyRecRestException的典型用法代码示例。如果您正苦于以下问题:Java EasyRecRestException类的具体用法?Java EasyRecRestException怎么用?Java EasyRecRestException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EasyRecRestException类属于org.easyrec.rest.nodomain.exception包,在下文中一共展示了EasyRecRestException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: itemsBasedOnPurchaseHistory

import org.easyrec.rest.nodomain.exception.EasyRecRestException; //导入依赖的package包/类
@IOLog
@Profiled
@Override
public RecommendedItem[] itemsBasedOnPurchaseHistory(Integer tenantId, String userId, String sessionId,
                                                     String consideredItemType,
                                                     Integer numberOfLastActionsConsidered, String assocType,
                                                     String requestedItemType) throws EasyRecRestException {
    RecommendationVO<Integer, String> recommendation = domainRecommenderService
            .itemsBasedOnPurchaseHistory(tenantId, idMappingDAO.lookup(userId), sessionId, consideredItemType,
                    numberOfLastActionsConsidered, assocType, requestedItemType);
    List<RecommendedItem> recommendedItems = idMappingService
            .convertListOfRecommendedItemVOs(recommendation.getRecommendedItems());
    if (recommendedItems != null && recommendedItems.size() > 0) {
        return recommendedItems.toArray(new RecommendedItem[recommendedItems.size()]);
    } else {
        return new RecommendedItem[0];
    }
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:19,代码来源:ShopRecommenderServiceImpl.java

示例2: itemsBasedOnSearchingHistory

import org.easyrec.rest.nodomain.exception.EasyRecRestException; //导入依赖的package包/类
@IOLog
@Profiled
@Override
public RecommendedItem[] itemsBasedOnSearchingHistory(Integer tenantId, String userId, String sessionId,
                                                      String consideredItemType,
                                                      Integer numberOfLastActionsConsidered, String assocType,
                                                      String requestedItemType) throws EasyRecRestException {
    RecommendationVO<Integer, String> recommendation = domainRecommenderService
            .itemsBasedOnSearchingHistory(tenantId, idMappingDAO.lookup(userId), sessionId, consideredItemType,
                    numberOfLastActionsConsidered, assocType, requestedItemType);
    List<RecommendedItem> recommendedItems = idMappingService
            .convertListOfRecommendedItemVOs(recommendation.getRecommendedItems());
    if (recommendedItems != null && recommendedItems.size() > 0) {
        return recommendedItems.toArray(new RecommendedItem[recommendedItems.size()]);
    } else {
        return new RecommendedItem[0];
    }
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:19,代码来源:ShopRecommenderServiceImpl.java

示例3: itemsOfCluster

import org.easyrec.rest.nodomain.exception.EasyRecRestException; //导入依赖的package包/类
@Override
public List<Item> itemsOfCluster(Integer tenant, String clusterName, Integer numberOfResults,Integer offset,
                                 String strategy,
                                 Boolean useFallback, Integer itemType, Session session)
        throws EasyRecRestException {
    List<Item> items;
    RemoteTenant remoteTenant = remoteTenantDAO.get(tenant);
    offset = CollectionUtils.getSafeOffset(offset);
    if (logger.isDebugEnabled())
        logger.debug("<[email protected]" + remoteTenant.getStringId() + "> " + " requesting items of cluster " +
                clusterName);

    logger.info("Use fallback: " + useFallback);

    ClusterVO cluster = clusterService.loadCluster(tenant, clusterName);

    if (cluster != null) {
        List<ItemVO<Integer, Integer>> clusterItems =
                clusterService.getItemsOfCluster(cluster, strategy, useFallback, numberOfResults, itemType);

        items = idMappingService.mapClusterItems(clusterItems, remoteTenant, session,
                WS.MAX_NUMBER_OF_RANKING_RESULTS, 0);

        return CollectionUtils.getSafeSubList(items, offset, numberOfResults);
    } else {
        throw new EasyRecRestException(MSG.CLUSTER_NOT_EXISTS);
    }
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:29,代码来源:ShopRecommenderServiceImpl.java

示例4: getAssocTypes

import org.easyrec.rest.nodomain.exception.EasyRecRestException; //导入依赖的package包/类
@IOLog
@Profiled
@Override
public String[] getAssocTypes(Integer tenantId) throws EasyRecRestException {
    return typeMappingService.getAssocTypes(tenantId)
            .toArray(new String[typeMappingService.getAssocTypes(tenantId).size()]);
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:8,代码来源:ShopRecommenderServiceImpl.java

示例5: itemsOfCluster

import org.easyrec.rest.nodomain.exception.EasyRecRestException; //导入依赖的package包/类
@Override
public List<Item> itemsOfCluster(Integer tenant, String clusterName, Integer numberOfResults, String strategy,
                                 Boolean useFallback, Integer itemType, Session session)
        throws EasyRecRestException {
    List<Item> items;
    RemoteTenant remoteTenant = remoteTenantDAO.get(tenant);

    if (logger.isDebugEnabled())
        logger.debug("<[email protected]" + remoteTenant.getStringId() + "> " + " requesting items of cluster " +
                clusterName);

    logger.info("Use fallback: " + useFallback);

    ClusterVO cluster = clusterService.loadCluster(tenant, clusterName);

    if (cluster != null) {
        List<ItemVO<Integer, Integer>> clusterItems =
                clusterService.getItemsOfCluster(cluster, strategy, useFallback, numberOfResults, itemType);

        items = idMappingService.mapClusterItems(clusterItems, remoteTenant, session,
                WS.MAX_NUMBER_OF_RANKING_RESULTS);

        return items.subList(0, Math.min(items.size(), numberOfResults));
    } else {
        throw new EasyRecRestException(MSG.CLUSTER_NOT_EXISTS);
    }
}
 
开发者ID:customertimes,项目名称:easyrec-PoC,代码行数:28,代码来源:ShopRecommenderServiceImpl.java

示例6: itemsBasedOnViewingHistory

import org.easyrec.rest.nodomain.exception.EasyRecRestException; //导入依赖的package包/类
@IOLog
@Profiled
@Override
public Recommendation itemsBasedOnViewingHistory(Integer tenantId, String userId, Session session,
                                                 String consideredItemType, Integer numberOfLastActionsConsidered,
                                                 String assocType, String requestedItemType,
                                                 Integer numberOfRecommendations) throws EasyRecRestException {
    Recommendation rec;
    RemoteTenant remoteTenant = remoteTenantDAO.get(tenantId);

    Monitor monCore = MonitorFactory.start(JAMON_REST_RECS_FOR_USER);
    RecommendationVO<Integer, String> recommendation =
            domainRecommenderService.itemsBasedOnViewingHistory(
                    tenantId, idMappingDAO.lookup(userId), null, // no sessionId needed
                    consideredItemType, numberOfLastActionsConsidered, assocType, requestedItemType);

    monCore.stop();
    List<Item> items = idMappingService.mapRecommendedItems(recommendation, remoteTenant,
            idMappingDAO.lookup(userId), session,
            numberOfRecommendations);  // session needed for building backtracking url (session.getRequest())


    rec = new Recommendation(remoteTenant.getStringId(), WS.ACTION_RECOMMENDATIONS_FOR_USER, userId, null,
            // no sessionId needed
            null, // no base item needed
            items);
    return rec;
}
 
开发者ID:customertimes,项目名称:easyrec-PoC,代码行数:29,代码来源:ShopRecommenderServiceImpl.java

示例7: actionHistory

import org.easyrec.rest.nodomain.exception.EasyRecRestException; //导入依赖的package包/类
@IOLog
@Profiled
@Override
public Recommendation actionHistory(Integer tenantId, String userId, Session session,
                                                String consideredActionType, String consideredItemType, 
                                                Integer numberOfLastActionsConsidered,
                                                Integer numberOfRecommendations) throws EasyRecRestException {
    Recommendation rec;
    RemoteTenant remoteTenant = remoteTenantDAO.get(tenantId);

    Monitor monCore = MonitorFactory.start(JAMON_REST_ACTION_HISTORY_CORE);
    List<ItemVO<Integer, String>> recommendation =
            domainRecommenderService.getActionHistory(tenantId, 
                                                      idMappingDAO.lookup(userId),
                                                      null, 
                                                      consideredActionType, 
                                                      consideredItemType, 
                                                      null, 
                                                      numberOfLastActionsConsidered);

    monCore.stop();
    List<Item> items = idMappingService.mapListOfItemVOs(recommendation, 
                                                        remoteTenant, 
                                                        idMappingDAO.lookup(userId), 
                                                        session, 
                                                        numberOfRecommendations);

    rec = new Recommendation(remoteTenant.getStringId(), WS.ACTION_HISTORY, userId, 
            null, // no sessionId needed
            null, // no base item needed
            items);
    return rec;
}
 
开发者ID:customertimes,项目名称:easyrec-PoC,代码行数:34,代码来源:ShopRecommenderServiceImpl.java

示例8: itemsBasedOnActionHistory

import org.easyrec.rest.nodomain.exception.EasyRecRestException; //导入依赖的package包/类
@IOLog
@Profiled
@Override
public Recommendation itemsBasedOnActionHistory(Integer tenantId, String userId, Session session,
                                                String consideredActionType, String consideredItemType, 
                                                Integer numberOfLastActionsConsidered,
                                                String assocType, String requestedItemType,
                                                Integer numberOfRecommendations) throws EasyRecRestException {
    Recommendation rec;
    RemoteTenant remoteTenant = remoteTenantDAO.get(tenantId);

    Double ratingThreshold = null;
    if (consideredActionType.equals(TypeMappingService.ACTION_TYPE_RATE)) {
        ratingThreshold = tenantService.getTenantById(tenantId).getRatingRangeNeutral();
    }
    Monitor monCore = MonitorFactory.start(JAMON_REST_RECS_FOR_USER);
    RecommendationVO<Integer, String> recommendation =
            domainRecommenderService.getItemsBasedOnActionHistory(
                    tenantId, idMappingDAO.lookup(userId), null, // no sessionId needed
                    consideredActionType, consideredItemType, ratingThreshold, numberOfLastActionsConsidered, assocType, requestedItemType);

    monCore.stop();
    List<Item> items = idMappingService.mapRecommendedItems(recommendation, remoteTenant,
            idMappingDAO.lookup(userId), session,
            numberOfRecommendations);  // session needed for building backtracking url (session.getRequest())


    rec = new Recommendation(remoteTenant.getStringId(), WS.ACTION_RECOMMENDATIONS_FOR_USER, userId, null,
            // no sessionId needed
            null, // no base item needed
            items);
    return rec;
}
 
开发者ID:customertimes,项目名称:easyrec-PoC,代码行数:34,代码来源:ShopRecommenderServiceImpl.java

示例9: itemsForUser

import org.easyrec.rest.nodomain.exception.EasyRecRestException; //导入依赖的package包/类
@IOLog
@Profiled
@Override
public Recommendation itemsForUser(Integer tenantId, String userId, Session session,
                                   String consideredActionType, String consideredItemType, Integer numberOfLastActionsConsidered,
                                   String assocType, String requestedItemType,
                                   Integer numberOfRecommendations) throws EasyRecRestException {

    Recommendation rec = null;
    RemoteTenant remoteTenant = remoteTenantDAO.get(tenantId);

    // double check: should have been checked before
    if (remoteTenant.getPluginsEnabled()) {
        //TODO: add sourceType to query!!! (dm: copy paste from relatedItems - refactor shared code ?)
        RecommendationVO<Integer, String> recommendation =
                domainRecommenderService
                        .getAlsoActedItems(tenantId, idMappingDAO.lookup(userId), session.getSessionId(),
                                AssocTypeDAO.ASSOCTYPE_USER_TO_ITEM,
                                new ItemVO<Integer, String>(tenantId, idMappingDAO.lookup(userId),
                                        TypeMappingService.ITEM_TYPE_USER), null,
                                requestedItemType);

        List<Item> items = idMappingService
                .mapRecommendedItems(recommendation, remoteTenant, idMappingDAO.lookup(userId), session,
                        numberOfRecommendations);

        rec = new Recommendation(remoteTenant.getStringId(), WS.ACTION_RECOMMENDATIONS_FOR_USER, userId, null, null, items);

    }
    return rec;

}
 
开发者ID:customertimes,项目名称:easyrec-PoC,代码行数:33,代码来源:ShopRecommenderServiceImpl.java

示例10: getItemTypes

import org.easyrec.rest.nodomain.exception.EasyRecRestException; //导入依赖的package包/类
@IOLog
@Profiled
@Override
public Set<String> getItemTypes(Integer tenantId) throws EasyRecRestException {
    return typeMappingService.getItemTypes(tenantId, true);
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:7,代码来源:ShopRecommenderServiceImpl.java

示例11: getClusters

import org.easyrec.rest.nodomain.exception.EasyRecRestException; //导入依赖的package包/类
@IOLog
@Profiled
@Override
public List<ClusterVO> getClusters(Integer tenantId) throws EasyRecRestException {
    return Lists.newArrayList(clusterService.getClustersForTenant(tenantId).getVertices());
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:7,代码来源:ShopRecommenderServiceImpl.java

示例12: otherUsersAlsoViewed

import org.easyrec.rest.nodomain.exception.EasyRecRestException; //导入依赖的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("offset") @DefaultValue("0") Integer offset,
                                     @QueryParam("itemtype") String itemType,
                                     @QueryParam("requesteditemtype") String requestedItemType,
                                     @QueryParam("callback") String callback,
                                     @QueryParam("withProfile") @DefaultValue("false") boolean withProfile,
                                     @QueryParam("token") String token) throws EasyRecException {

    Monitor mon = MonitorFactory.start(JAMON_REST_ALSO_VIEWED);

    if (easyrecSettings.getSecuredAPIMethods().contains("otherusersalsoviewed")) {
        Operator o = operatorDAO.getOperatorFromToken(token);
        if (o == null)
            exceptionResponse(WS.ACTION_OTHER_USERS_ALSO_VIEWED, MSG.WRONG_TOKEN, type, callback);
        else
            apiKey = o.getApiKey();
    }

    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, offset);
        //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 (type.endsWith(WS.RESPONSE_TYPE_PATH_JSON)) {
        if (callback != null)
            return Response.ok(new JSONPObject(callback, rec), 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:major2015,项目名称:easyrec_major,代码行数:64,代码来源:EasyRec.java

示例13: actionHistoryForUser

import org.easyrec.rest.nodomain.exception.EasyRecRestException; //导入依赖的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("offset") @DefaultValue("0") Integer offset,
                                     @QueryParam("requesteditemtype") String requestedItemType,
                                     @QueryParam("callback") String callback,
                                     @QueryParam("actiontype") @DefaultValue(TypeMappingService.ACTION_TYPE_VIEW) String actiontype,
                                     @QueryParam("withProfile") @DefaultValue("false") boolean withProfile,
                                     @QueryParam("token") String token)
        throws EasyRecException {

    Monitor mon = MonitorFactory.start(JAMON_REST_ACTIONHISTORY);

    if (easyrecSettings.getSecuredAPIMethods().contains("actionhistoryforuser")) {
        Operator o = operatorDAO.getOperatorFromToken(token);
        if (o == null)
            exceptionResponse(WS.ACTION_HISTORY, MSG.WRONG_TOKEN, type, callback);
        else
            apiKey = o.getApiKey();
    }

    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,
                                                       offset); // +5 to compensate for inactive items

            if (withProfile) {
                addProfileDataToItems(rec);
            }
        } catch (EasyRecRestException sre) {
            exceptionResponse(WS.ACTION_HISTORY, sre.getMessageObject(), type, callback);
        }
    }

    mon.stop();

    if (type.endsWith(WS.RESPONSE_TYPE_PATH_JSON)) {
        if (callback != null)
            return Response.ok(new JSONPObject(callback, rec), 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:major2015,项目名称:easyrec_major,代码行数:74,代码来源:EasyRec.java

示例14: otherUsersAlsoBought

import org.easyrec.rest.nodomain.exception.EasyRecRestException; //导入依赖的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("offset") @DefaultValue("0") Integer offset,
                                     @QueryParam("itemtype") String itemType,
                                     @QueryParam("requesteditemtype") String requestedItemType,
                                     @QueryParam("callback") String callback,
                                     @QueryParam("withProfile") @DefaultValue("false") boolean withProfile,
                                     @QueryParam("token") String token)
        throws EasyRecException {

    Monitor mon = MonitorFactory.start(JAMON_REST_ALSO_BOUGHT);

    if (easyrecSettings.getSecuredAPIMethods().contains("otherusersalsobought")) {
        Operator o = operatorDAO.getOperatorFromToken(token);
        if (o == null)
            exceptionResponse(WS.ACTION_OTHER_USERS_ALSO_BOUGHT, MSG.WRONG_TOKEN, type, callback);
        else
            apiKey = o.getApiKey();
    }

    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, offset);
        //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 (type.endsWith(WS.RESPONSE_TYPE_PATH_JSON)) {
        if (callback != null)
            return Response.ok(new JSONPObject(callback, rec), 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:major2015,项目名称:easyrec_major,代码行数:64,代码来源:EasyRec.java

示例15: itemsRatedGoodByOtherUsers

import org.easyrec.rest.nodomain.exception.EasyRecRestException; //导入依赖的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("offset") @DefaultValue("0") Integer offset,
                                           @QueryParam("itemtype") String itemType,
                                           @QueryParam("requesteditemtype") String requestedItemType,
                                           @QueryParam("callback") String callback,
                                           @QueryParam("withProfile") @DefaultValue("false") boolean withProfile,
                                           @QueryParam("token") String token) throws EasyRecException {

    Monitor mon = MonitorFactory.start(JAMON_REST_ALSO_RATED);

    if (easyrecSettings.getSecuredAPIMethods().contains("itemsratedgoodbyotherusers")) {
        Operator o = operatorDAO.getOperatorFromToken(token);
        if (o == null)
            exceptionResponse(WS.ACTION_ITEMS_RATED_GOOD_BY_OTHER_USERS, MSG.WRONG_TOKEN, type, callback);
        else
            apiKey = o.getApiKey();
    }

    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, offset);
        //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 (type.endsWith(WS.RESPONSE_TYPE_PATH_JSON)) {
        if (callback != null)
            return Response.ok(new JSONPObject(callback, rec), 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:major2015,项目名称:easyrec_major,代码行数:67,代码来源:EasyRec.java


注:本文中的org.easyrec.rest.nodomain.exception.EasyRecRestException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。