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


Java Monitor.stop方法代码示例

本文整理汇总了Java中com.jamonapi.Monitor.stop方法的典型用法代码示例。如果您正苦于以下问题:Java Monitor.stop方法的具体用法?Java Monitor.stop怎么用?Java Monitor.stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jamonapi.Monitor的用法示例。


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

示例1: invokeUnderTrace

import com.jamonapi.Monitor; //导入方法依赖的package包/类
/**
 * Wraps the invocation with a JAMon Monitor and writes the current
 * performance statistics to the log (if enabled).
 * @see com.jamonapi.MonitorFactory#start
 * @see com.jamonapi.Monitor#stop
 */
@Override
protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable {
	String name = createInvocationTraceName(invocation);
	MonKey key = new MonKeyImp(name, name, "ms.");

	Monitor monitor = MonitorFactory.start(key);
	try {
		return invocation.proceed();
	}
	catch (Throwable ex) {
		trackException(key, ex);
		throw ex;
	}
	finally {
		monitor.stop();
		if (!this.trackAllInvocations || isLogEnabled(logger)) {
			logger.trace("JAMon performance statistics for method [" + name + "]:\n" + monitor);
		}
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:27,代码来源:JamonPerformanceMonitorInterceptor.java

示例2: profileInvocation

import com.jamonapi.Monitor; //导入方法依赖的package包/类
public Object profileInvocation(ProceedingJoinPoint pjp) throws Throwable {
    if (logger.isDebugEnabled()) {
        logger.debug("profiling call for method" + pjp.toLongString());
    }
    Monitor mon = MonitorFactory.start(createMonitorName(pjp));
    try {
        return pjp.proceed();
    } finally {
        mon.stop();
        long now = System.currentTimeMillis();
        if (now - lastOutput > outputInterval) {
            lastOutput = now;
            try {
                outputStats();
            } catch (IOException ioe) {
                logger.warn("error writing to '" + getReportOutputLocation() + "'", ioe);
            }
        }
    }
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:21,代码来源:JamonProfilingAspectAdvice.java

示例3: invokeUnderTrace

import com.jamonapi.Monitor; //导入方法依赖的package包/类
/**
 * Wraps the invocation with a JAMon Monitor and writes the current
 * performance statistics to the log (if enabled).
 * @see com.jamonapi.MonitorFactory#start
 * @see com.jamonapi.Monitor#stop
 */
@Override
protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable {
	String name = createInvocationTraceName(invocation);
	Monitor monitor = MonitorFactory.start(name);
	try {
		return invocation.proceed();
	}
	finally {
		monitor.stop();
		if (!this.trackAllInvocations || isLogEnabled(logger)) {
			logger.trace("JAMon performance statistics for method [" + name + "]:\n" + monitor);
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:JamonPerformanceMonitorInterceptor.java

示例4: storeItemWithProfileInternal

import com.jamonapi.Monitor; //导入方法依赖的package包/类
private Response storeItemWithProfileInternal(String apiKey, String tenantID, String itemID, String itemType,
                             String itemDescription, String itemUrl, String itemImageUrl, String profile) {

    Monitor mon = MonitorFactory.start(JAMON_PROFILE_STORE);

    List<Message> errorMessages = new ArrayList<>();
    List<Message> responseObject = new ArrayList<>();

    try {
        Integer coreTenantId = operatorDAO.getTenantId(apiKey, tenantID);
        if (checkParameters(coreTenantId, itemID, itemDescription, itemUrl, errorMessages) && checkParameterProfile(profile, errorMessages)) {

            itemType = checkItemType(itemType, coreTenantId, Item.DEFAULT_STRING_ITEM_TYPE, errorMessages);
            if (itemType != null) {
                itemDAO.insertOrUpdate(coreTenantId, itemID, itemType, itemDescription, itemUrl, itemImageUrl);
        

                if (profileService.storeProfile(coreTenantId, itemID, itemType, profile))
                    responseObject.add(MSG.PROFILE_SAVED);
                else
                    errorMessages.add(MSG.PROFILE_NOT_SAVED);
            }
        
        }
    } catch (IllegalArgumentException illegalArgumentException) {
        if (illegalArgumentException.getMessage().contains("unknown item type")) {
            errorMessages.add(MSG.OPERATION_FAILED.append(
                    String.format(" itemType %s not found for tenant %s", itemType, tenantID)));
        } else
            errorMessages.add(MSG.PROFILE_NOT_SAVED);
    } catch (RuntimeException runtimeException) {
        errorMessages.add(MSG.PROFILE_NOT_SAVED);
    }

    Response response = formatResponse(responseObject, errorMessages,
            WS.PROFILE_STORE, null);
    mon.stop();
    return response;
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:40,代码来源:JSONProfileWebService.java

示例5: pushFieldInternal

import com.jamonapi.Monitor; //导入方法依赖的package包/类
private Response pushFieldInternal(String apiKey, String tenantID, String itemID, String itemType, String path, String value) {
    Monitor mon = MonitorFactory.start(JAMON_PROFILE_FIELD_STORE);

    List<Message> errorMessages = new ArrayList<>();
    List<Message> responseObject = new ArrayList<>();

    try {
        if (checkParameters(apiKey, tenantID, itemID, itemType, errorMessages) &&
                checkParameterValue(value, errorMessages)) {
            Integer coreTenantID = operatorDAO.getTenantId(apiKey, tenantID);
            if (coreTenantID == null)
                errorMessages.add(MSG.TENANT_WRONG_TENANT_APIKEY);
            else {
                if (profileService.pushToArrayField(
                        coreTenantID, itemID, itemType,
                        path, value))
                    responseObject.add(MSG.PROFILE_FIELD_SAVED);
                else
                    errorMessages.add(MSG.PROFILE_FIELD_NOT_SAVED);
            }
        }
    } catch (Exception e) {
        if (e instanceof IllegalArgumentException) {
            if (e.getMessage().contains("unknown item type")) {
            errorMessages.add(MSG.OPERATION_FAILED.append(
                    String.format(" itemType %s not found for tenant %s", itemType, tenantID)));
            } else {
                errorMessages.add(MSG.PROFILE_FIELD_NOT_SAVED.append(e.getMessage()));
            }
        } else {
            errorMessages.add(MSG.OPERATION_FAILED.append(
                "Exception: " + e.getMessage()));
        }

    } 
    Response response = formatResponse(responseObject, errorMessages,
            WS.PROFILE_FIELD_PUSH, null);
    mon.stop();
    return response; 
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:41,代码来源:JSONProfileWebService.java

示例6: stop

import com.jamonapi.Monitor; //导入方法依赖的package包/类
@Override
public void stop(Monitor mon, Throwable throwable) {
    mon.stop();
    put(throwable);
    // note the following 'get' always succeeds because of the above 'put'
    mon.getMonKey().setDetails(get(throwable));
}
 
开发者ID:stevensouza,项目名称:automon,代码行数:8,代码来源:Jamon.java

示例7: actionHistory

import com.jamonapi.Monitor; //导入方法依赖的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:ferronrsmith,项目名称:easyrec,代码行数:34,代码来源:ShopRecommenderServiceImpl.java

示例8: itemsBasedOnViewingHistory

import com.jamonapi.Monitor; //导入方法依赖的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

示例9: itemsBasedOnActionHistory

import com.jamonapi.Monitor; //导入方法依赖的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

示例10: actionHistoryForUser

import com.jamonapi.Monitor; //导入方法依赖的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

示例11: purchaseItem

import com.jamonapi.Monitor; //导入方法依赖的package包/类
/**
 * This procedure tells the ProfilerController that an Item is purchased.
 * Note:
 * A SessionId is always required. In case no userId is given the sessionId
 * is used a the userId instead.
 */
@IOLog
@Profiled
@Override
public Item purchaseItem(RemoteTenant remoteTenant, String userId, String itemId, String itemType,
                         String itemDescription, String itemUrl, String itemImageUrl, Date actionTime,
                         Session session, String actionInfo) {
    Item item = itemDAO.get(remoteTenant, itemId, itemType);

    if (item == null) {
        item = itemDAO.add(remoteTenant.getId(), itemId, itemType, itemDescription, itemUrl, itemImageUrl);

        if (logger.isDebugEnabled()) {
            logger.debug(new StringBuilder().
                    append("<[email protected]").
                    append(remoteTenant.getId()).
                    append("> ").
                    append(itemType).
                    append(" ").
                    append(itemDescription).
                    append(" (id:").
                    append(itemId).
                    append(")").toString());
        }
    }

    if (item != null && item.isActive()) {

        // if userid is empty use sessionid instead of the userid
        userId = Strings.isNullOrEmpty(userId) ? session.getSessionId() : userId;

        Monitor monCore = MonitorFactory.start(JAMON_REST_BUY_CORE);

        if (actionTime == null) {
            domainActionService
                    .purchaseItem(remoteTenant.getId(), idMappingDAO.lookup(userId), session.getSessionId(),
                            session.getIp(),
                            new ItemVO<>(remoteTenant.getId(), idMappingDAO.lookup(itemId),
                                    itemType), actionInfo);
        } else {
            domainActionService
                    .purchaseItem(remoteTenant.getId(), idMappingDAO.lookup(userId), session.getSessionId(),
                            session.getIp(),
                            new ItemVO<>(remoteTenant.getId(), idMappingDAO.lookup(itemId),
                                    itemType), actionInfo, actionTime);
        }


        monCore.stop();
        if (logger.isDebugEnabled()) {
            logger.debug(new StringBuilder().
                    append("<[email protected]").
                    append(remoteTenant.getId()).
                    append("> ").
                    append(userId).
                    append(" view ").
                    append(itemDescription).
                    append(" (id:").
                    append(itemId).
                    append(")").toString());
        }
    }
    return item;

}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:71,代码来源:ShopRecommenderServiceImpl.java

示例12: viewItem

import com.jamonapi.Monitor; //导入方法依赖的package包/类
/**
 * This procedure tells the ProfilerController that an Item is viewed.
 * Note:
 * A SessionId is always required. In case no userId is given the sessionId
 * is used a the userId instead.
 */
@IOLog
@Profiled
@Override
public Item viewItem(RemoteTenant remoteTenant, String userId, String itemId, String itemType,
                     String itemDescription, String itemUrl, String itemImageUrl, Date actionTime,
                     Session session, String actionInfo) {
    Item item = itemDAO.get(remoteTenant, itemId, itemType);

    if (item == null) {
        item = itemDAO.add(remoteTenant.getId(), itemId, itemType, itemDescription, itemUrl, itemImageUrl);

        if (logger.isDebugEnabled()) {
            logger.debug(new StringBuilder().
                    append("<[email protected]").
                    append(remoteTenant.getId()).
                    append("> ").
                    append(itemType).
                    append(" ").
                    append(itemDescription).
                    append(" (id:").
                    append(itemId).
                    append(")").toString());
        }
    }

    if (item != null && item.isActive()) {
        // if userid is empty use sessionid instead of the userid
        userId = Strings.isNullOrEmpty(userId) ? session.getSessionId() : userId;

        Monitor monCore = MonitorFactory.start(JAMON_REST_VIEW_CORE);

        if (actionTime == null) {
            domainActionService.viewItem(remoteTenant.getId(), idMappingDAO.lookup(userId), session.getSessionId(),
                    session.getIp(),
                    new ItemVO<>(remoteTenant.getId(), idMappingDAO.lookup(itemId),
                            itemType), actionInfo);
        } else {
            domainActionService.viewItem(remoteTenant.getId(), idMappingDAO.lookup(userId), session.getSessionId(),
                    session.getIp(),
                    new ItemVO<>(remoteTenant.getId(), idMappingDAO.lookup(itemId),
                            itemType), actionInfo, actionTime);

        }

        monCore.stop();

        if (logger.isDebugEnabled()) {
            logger.debug(new StringBuilder().
                    append("<[email protected]").
                    append(remoteTenant.getId()).
                    append("> ").
                    append(userId).
                    append(" view ").
                    append(itemDescription).
                    append(" (id:").
                    append(itemId).
                    append(")").toString());
        }
    }

    return item;
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:69,代码来源:ShopRecommenderServiceImpl.java

示例13: rateItem

import com.jamonapi.Monitor; //导入方法依赖的package包/类
/**
 * This procedure tells the ProfilerController that an Item is rated
 * with a given value.
 * Note:
 * A SessionId is always required. In case no userId is given the sessionId
 * is used a the userId instead.
 */
@IOLog
@Profiled
@Override
public Item rateItem(RemoteTenant remoteTenant, String userId, String itemId, String itemType,
                     String itemDescription, String itemUrl, String itemImageUrl, Integer ratingValue,
                     Date actionTime, Session session, String actionInfo) {
    Item item = itemDAO.get(remoteTenant, itemId, itemType);

    if (item == null) {
        item = itemDAO.add(remoteTenant.getId(), itemId, itemType, itemDescription, itemUrl, itemImageUrl);

        if (logger.isDebugEnabled()) {
            logger.debug(new StringBuilder().
                    append("<[email protected]").
                    append(remoteTenant.getId()).
                    append("> ").
                    append(itemType).
                    append(" ").
                    append(itemDescription).
                    append(" (id:").
                    append(itemId).
                    append(")").toString());
        }
    }

    if (item != null && item.isActive()) {

        // if userid is empty use sessionid instead of the userid
        userId = Strings.isNullOrEmpty(userId) ? session.getSessionId() : userId;

        Monitor monCore = MonitorFactory.start(JAMON_REST_RATE_CORE);


        if (actionTime == null) {
            domainActionService.rateItem(remoteTenant.getId(), idMappingDAO.lookup(userId), session.getSessionId(),
                    session.getIp(),
                    new ItemVO<>(remoteTenant.getId(), idMappingDAO.lookup(itemId),
                            itemType), ratingValue, actionInfo);
        } else {
            domainActionService.rateItem(remoteTenant.getId(), idMappingDAO.lookup(userId), session.getSessionId(),
                    session.getIp(),
                    new ItemVO<>(remoteTenant.getId(), idMappingDAO.lookup(itemId),
                            itemType), ratingValue, actionInfo, actionTime);
        }

        monCore.stop();
        if (logger.isDebugEnabled()) {
            logger.debug(new StringBuilder().
                    append("<[email protected]").
                    append(remoteTenant.getId()).
                    append("> ").
                    append(userId).
                    append(" view ").
                    append(itemDescription).
                    append(" (id:").
                    append(itemId).
                    append(")").toString());
        }
    }

    return item;

}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:71,代码来源:ShopRecommenderServiceImpl.java

示例14: deleteItemType

import com.jamonapi.Monitor; //导入方法依赖的package包/类
@GET
@Path("/deleteitemtype")
public Response deleteItemType(@PathParam("type") String type,
                          @QueryParam("apikey") String apiKey,
                          @QueryParam("tenantid") String tenantId,
                          @QueryParam("itemtype") String itemType,
                          @QueryParam("callback") String callback,
                          @QueryParam("token") String token)
        throws EasyRecException {
    Monitor mon = MonitorFactory.start(JAMON_REST_DELETEITEMTYPE);

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

    Integer coreTenantId = operatorDAO.getTenantId(apiKey, tenantId);

    if (coreTenantId == null)
        exceptionResponse(WS.ACTION_DELETEITEMTYPE, MSG.TENANT_WRONG_TENANT_APIKEY, type, callback);
    
    String error = tenantService.isValidItemTypeName(itemType);
    
    if (!"".equals(error))
        exceptionResponse(WS.ACTION_DELETEITEMTYPE, new ErrorMessage(998, error), type, callback);
    
    try {
        Integer typeId = typeMappingService.getIdOfItemType(coreTenantId, itemType);    
        tenantService.deleteItemTypeForTenant(coreTenantId, typeId);
    } catch (IllegalArgumentException iae) {
        exceptionResponse(WS.ACTION_DELETEITEMTYPE, new ErrorMessage(998, "Item type does not exist!"), type, callback);
    } catch (Exception e) {
        exceptionResponse(WS.ACTION_DELETEITEMTYPE, new ErrorMessage(998, e.getMessage()), type, callback);
    }
    mon.stop();
    
    if (type.endsWith(WS.RESPONSE_TYPE_PATH_JSON)) {
        if (callback != null) {
            return Response.ok(new JSONPObject(callback, new SuccessMessage(930, "itemType " + itemType + " and all references successfuly removed!")), WS.RESPONSE_TYPE_JSCRIPT).build();
        } else {
            return Response.ok(new SuccessMessage(930, "itemType " + itemType + " and all references successfuly removed!"), WS.RESPONSE_TYPE_JSON).build();
        }
    } else {
        return Response.ok(new SuccessMessage(930, "itemType " + itemType + " and all references successfuly removed!"), WS.RESPONSE_TYPE_XML).build();
    }
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:50,代码来源:EasyRec.java

示例15: deleteProfile

import com.jamonapi.Monitor; //导入方法依赖的package包/类
/**
 * This method deletes the profile of the item defined by the tenantID,
 * itemID and the itemTypeID
 *
 * @param apiKey       the apiKey which admits access to the API
 * @param tenantID     the tenantID of the item whose profile will be deleted
 * @param itemID       the itemID if the item whose profile will be deleted
 * @param itemType     the itemType of the item whose profile will be deleted
 * @return a response object containing information about the success of the operation
 */
@DELETE
@Path("/delete")
public Response deleteProfile(@QueryParam("apikey") String apiKey,
                              @QueryParam("tenantid") String tenantID,
                              @QueryParam("itemid") String itemID,
                              @DefaultValue("ITEM") @QueryParam("itemtype") String itemType) {

    Monitor mon = MonitorFactory.start(JAMON_PROFILE_DELETE);

    List<Message> errorMessages = new ArrayList<>();
    List<Message> responseObject = new ArrayList<>();

    try {
        if (checkParameters(apiKey, tenantID, itemID, itemType, errorMessages)) {
            Integer coreTenantID = operatorDAO.getTenantId(apiKey, tenantID);
            if (coreTenantID == null)
                errorMessages.add(MSG.TENANT_WRONG_TENANT_APIKEY);
            else {
                if (profileService.deleteProfile(coreTenantID, itemID, itemType))
                    responseObject.add(MSG.PROFILE_DELETED);
                else
                    errorMessages.add(MSG.PROFILE_NOT_DELETED);
            }
        }
    } catch (IllegalArgumentException illegalArgumentException) {
        if (illegalArgumentException.getMessage().contains("unknown item type")) {
            errorMessages.add(MSG.OPERATION_FAILED.append(
                    String.format(" itemType %s not found for tenant %s", itemType, tenantID)));
        } else
            errorMessages.add(MSG.PROFILE_NOT_DELETED.append(illegalArgumentException.getMessage()));
    } catch (ItemNotFoundException itemNotFoundException) {
        errorMessages.add(MSG.ITEM_NOT_EXISTS);
    } catch (RuntimeException runtimeException) {
        errorMessages.add(MSG.PROFILE_NOT_DELETED);
    }

    Response response = formatResponse(responseObject, errorMessages,
            WS.PROFILE_DELETE, null);
    mon.stop();
    return response;
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:52,代码来源:JSONProfileWebService.java


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