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


Java MyUtils类代码示例

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


MyUtils类属于org.easyrec.utils包,在下文中一共展示了MyUtils类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:24,代码来源:EasyRec.java

示例2: doGet

import org.easyrec.utils.MyUtils; //导入依赖的package包/类
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    initUpdate();
    response.setContentType("text/xml; charset=utf-8");

    String version = request.getParameter("version");
    String token = request.getParameter("token");
    String url = updateURL + "?" + "version=" + version + "&token=" + token;
    String updateXML = MyUtils.loadWebsiteHtmlCode(url, request.getHeader("user-agent"));

    response.getOutputStream().print(updateXML);
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:15,代码来源:UpdateCheck.java

示例3: doGet

import org.easyrec.utils.MyUtils; //导入依赖的package包/类
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    if (blogPath == null) {
        initBlog();
    }
    response.setContentType("text/xml; charset=utf-8");
    response.getOutputStream().print(MyUtils.loadWebsiteHtmlCode(blogPath));
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:11,代码来源:RSSBlog.java

示例4: viewtenants

import org.easyrec.utils.MyUtils; //导入依赖的package包/类
public ModelAndView viewtenants(HttpServletRequest request, HttpServletResponse httpServletResponse) {
    String tenantId = ServletUtils.getSafeParameter(request, "tenantId", "");
    String operatorId = ServletUtils.getSafeParameter(request, "operatorId", "");

    ModelAndView mav = new ModelAndView("page");

    mav.addObject("title", "easyrec :: administration");

    mav.addObject("operatorId", operatorId);
    mav.addObject("tenantId", tenantId);

    if (Security.isDeveloper(request)) {
        List<RemoteTenant> remoteTenants = remoteTenantDAO.getTenantsFromOperator(operatorId);

        List<Integer> runningTenants = logEntryDAO.getRunningTenants();
        Integer runningTenantId = runningTenants.size() > 0 ? runningTenants.get(0) : null;

        mav.setViewName("dev/page");
        mav.addObject("page", "viewtenants");
        mav.addObject("remoteTenants", MyUtils.sizeOf(remoteTenants) > 0 ? remoteTenants : null);
        mav.addObject("dbname", remoteTenantDAO.getDbName());
        mav.addObject("runningTenantId", runningTenantId);

        return mav;
    } else {
        return MessageBlock.createSingle(mav, MSG.NOT_SIGNED_IN, VIEW_TENANTS, MSG.ERROR);
    }
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:29,代码来源:TenantsController.java

示例5: viewalltenants

import org.easyrec.utils.MyUtils; //导入依赖的package包/类
public ModelAndView viewalltenants(HttpServletRequest request, HttpServletResponse httpServletResponse) {
    String tenantId = ServletUtils.getSafeParameter(request, "tenantId", "");
    String operatorId = ServletUtils.getSafeParameter(request, "operatorId", "");
    String searchString = ServletUtils.getSafeParameter(request, "searchString", "");

    int siteNumber = ServletUtils.getSafeParameter(request, "siteNumber", 0);
    boolean filterDemoTenants = (ServletUtils.getSafeParameter(request, "filterDemoTenants", 1) == 1);

    ModelAndView mav = new ModelAndView("page");

    mav.addObject("title", "easyrec :: administration");

    mav.addObject("operatorId", operatorId);
    mav.addObject("tenantId", tenantId);
    mav.addObject("searchString", searchString);
    mav.addObject("url", request.getRequestURL());


    if (Security.isDeveloper(request)) {
        PageStringGenerator psg = new PageStringGenerator(
                request.getRequestURL() + "?" + request.getQueryString());

        List<RemoteTenant> remoteTenants = remoteTenantDAO.getTenants(siteNumber * psg.getNumberOfItemsPerPage(),
                psg.getNumberOfItemsPerPage(), filterDemoTenants, searchString);

        if (remoteTenants.isEmpty()) {
            remoteTenants = remoteTenantDAO.getTenants(siteNumber * psg.getNumberOfItemsPerPage(),
                    psg.getNumberOfItemsPerPage(), false, searchString);
            filterDemoTenants = false;
        }

        List<Integer> runningTenants = logEntryDAO.getRunningTenants();
        Integer runningTenantId = runningTenants.size() > 0 ? runningTenants.get(0) : null;

        mav.addObject("runningTenantId", runningTenantId);

        int remoteTenantsTotal = remoteTenantDAO.count(filterDemoTenants, searchString);
        mav.addObject("filterDemoTenants", filterDemoTenants);
        mav.addObject("remoteTenantsTotal", remoteTenantsTotal);
        mav.addObject("pageMenuString", psg.getPageMenuString(remoteTenantsTotal, siteNumber));

        mav.setViewName("dev/page");
        mav.addObject("page", "viewalltenants");
        mav.addObject("dbname", remoteTenantDAO.getDbName());
        mav.addObject("remoteTenants", MyUtils.sizeOf(remoteTenants) > 0 ? remoteTenants : null);

        return mav;
    } else {
        return MessageBlock.createSingle(mav, MSG.NOT_SIGNED_IN, VIEW_ALL_TENANTS, MSG.ERROR);
    }
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:52,代码来源:TenantsController.java

示例6: LoggedInAspect

import org.easyrec.utils.MyUtils; //导入依赖的package包/类
@Around("allControllers()")
public Object LoggedInAspect(ProceedingJoinPoint pjp) throws Throwable {

    HttpServletRequest request = (HttpServletRequest) pjp.getArgs()[0];
    HttpSession session = request.getSession(false);

    ModelAndView originalModelAndView = (ModelAndView) pjp.proceed();

    if (extendedWebAppPath == null)
        initPath(request);

    boolean signedIn = false;

    try {
        if (session != null && session.getAttribute("signedInOperatorId") != null)
            signedIn = true;

        if (originalModelAndView != null) {
            originalModelAndView.addObject("signedIn", signedIn);
            originalModelAndView.addObject("isDeveloper", Security.isDeveloper(request));
            originalModelAndView.addObject("securityToken", Security.getSecurityToken(request));
            originalModelAndView.addObject("webappPath", webappPath);
            originalModelAndView.addObject("extendedWebappPath", extendedWebAppPath);
            originalModelAndView.addObject("isGenerator", easyrecSettings.isGenerator());
            originalModelAndView.addObject("operationMode", easyrecSettings.getOperationMode());

            originalModelAndView.addObject("currentMonth", MyUtils.getCurrentMonth());
            originalModelAndView.addObject("currentMonthName", MyUtils.getCurrentMonthName());
            originalModelAndView.addObject("currentYear", MyUtils.getCurrentYear());

            if (session != null) {
                originalModelAndView.addObject("signedInOperator", session.getAttribute("signedInOperator"));
                originalModelAndView.addObject("signedInOperatorId", session.getAttribute("signedInOperatorId"));
            }

            originalModelAndView.addObject("easyrecName", easyrecSettings.getName());
            originalModelAndView.addObject("easyrecVersion", easyrecSettings.getVersion());
            originalModelAndView.addObject("easyrecBiz", easyrecSettings.getBiz());
            originalModelAndView.addObject("easyrecReleases", easyrecSettings.getReleases());
            originalModelAndView.addObject("checkUpdateUrl", easyrecSettings.getUpdateURL());
            originalModelAndView.addObject("updateUrl", easyrecSettings.getReleases());
        }
    } catch (IllegalStateException e) {
        logger.debug("User Logged Out and can not get Session atributes.", e);
    }

    String currentPage = request.getRequestURI();
    boolean isPublicSite = PUBLIC_SITES.contains(currentPage);

    if (!signedIn && !isPublicSite)
        return new ModelAndView("redirect:" + webappPath + "/home");

    return originalModelAndView;
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:55,代码来源:LoggedInCheckAspect.java

示例7: 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();
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:68,代码来源:EasyRec.java

示例8: 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();
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:70,代码来源:EasyRec.java

示例9: viewalltenants

import org.easyrec.utils.MyUtils; //导入依赖的package包/类
public ModelAndView viewalltenants(HttpServletRequest request, HttpServletResponse httpServletResponse) {
    String tenantId = ServletUtils.getSafeParameter(request, "tenantId", "");
    String operatorId = ServletUtils.getSafeParameter(request, "operatorId", "");

    int siteNumber = ServletUtils.getSafeParameter(request, "siteNumber", 0);
    boolean filterDemoTenants = (ServletUtils.getSafeParameter(request, "filterDemoTenants", 1) == 1);

    ModelAndView mav = new ModelAndView("page");

    mav.addObject("title", "easyrec :: administration");

    mav.addObject("operatorId", operatorId);
    mav.addObject("tenantId", tenantId);
    mav.addObject("filterDemoTenants", filterDemoTenants);


    if (Security.isDeveloper(request)) {
        PageStringGenerator psg = new PageStringGenerator(
                request.getRequestURL() + "?" + request.getQueryString());

        List<RemoteTenant> remoteTenants = remoteTenantDAO.getTenants(siteNumber * psg.getNumberOfItemsPerPage(),
                psg.getNumberOfItemsPerPage(), filterDemoTenants);

        if (remoteTenants.isEmpty()) {
            remoteTenants = remoteTenantDAO.getTenants(siteNumber * psg.getNumberOfItemsPerPage(),
                    psg.getNumberOfItemsPerPage(), false);
            mav.addObject("filterDemoTenants", false);
        }

        List<Integer> runningTenants = logEntryDAO.getRunningTenants();
        Integer runningTenantId = runningTenants.size() > 0 ? runningTenants.get(0) : null;

        mav.addObject("runningTenantId", runningTenantId);

        int remoteTenantsTotal = remoteTenantDAO.count();
        mav.addObject("remoteTenantsTotal", remoteTenantsTotal);
        mav.addObject("pageMenuString", psg.getPageMenuString(remoteTenantsTotal, siteNumber));

        mav.setViewName("dev/page");
        mav.addObject("page", "viewalltenants");
        mav.addObject("dbname", remoteTenantDAO.getDbName());
        mav.addObject("remoteTenants", MyUtils.sizeOf(remoteTenants) > 0 ? remoteTenants : null);

        return mav;
    } else {
        return MessageBlock.createSingle(mav, MSG.NOT_SIGNED_IN, VIEW_ALL_TENANTS, MSG.ERROR);
    }
}
 
开发者ID:customertimes,项目名称:easyrec-PoC,代码行数:49,代码来源:TenantsController.java

示例10: 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();
}
 
开发者ID:customertimes,项目名称:easyrec-PoC,代码行数:58,代码来源:EasyRec.java

示例11: 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();
    }
}
 
开发者ID:customertimes,项目名称:easyrec-PoC,代码行数:73,代码来源:EasyRec.java

示例12: 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();
}
 
开发者ID:customertimes,项目名称:easyrec-PoC,代码行数:59,代码来源:EasyRec.java


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