/** * display flag is used to control the display of the resource only to the end user. It doesnt affect Root Admin. * @return display flag */ public boolean isDisplay(){ CallContext context = CallContext.current(); Map<Object, Object> contextMap = context.getContextParameters(); boolean isDisplay = true; // Iterate over all the first class entities in context and check their display property. for(Map.Entry<Object, Object> entry : contextMap.entrySet()){ try{ Object key = entry.getKey(); Class clz = Class.forName((String)key); if(Displayable.class.isAssignableFrom(clz)){ final Object objVO = getEntityVO(clz, entry.getValue()); isDisplay = ((Displayable) objVO).isDisplay(); } // If the flag is false break immediately if(!isDisplay) break; } catch (Exception e){ s_logger.trace("Caught exception while checking first class entities for display property, continuing on", e); } } context.setEventDisplayEnabled(isDisplay); return isDisplay; }
@Override public void handle(final DispatchTask task) { final BaseCmd cmd = task.getCmd(); if (cmd instanceof BaseAsyncCreateCmd) { try { CallContext.current().setEventDisplayEnabled(cmd.isDisplay()); ((BaseAsyncCreateCmd)cmd).create(); } catch (final ResourceAllocationException e) { throw new ServerApiException(ApiErrorCode.RESOURCE_ALLOCATION_ERROR, e.getMessage(), e); } } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ATTEMP_TO_CREATE_NON_CREATION_CMD); } }
ctx.setEventDisplayEnabled(cmd.isDisplay()); if(params.get(ApiConstants.PROJECT_ID) != null) { Project project = _entityMgr.findByUuidIncludingRemoved(Project.class, params.get(ApiConstants.PROJECT_ID));