List of usage examples for org.apache.commons.lang ArrayUtils isNotEmpty
public static boolean isNotEmpty(boolean[] array)
Checks if an array of primitive booleans is not empty or not null
.
From source file:com.nec.harvest.servlet.interceptor.BackOriginGroupInterceptor.java
@Override @SuppressWarnings("unchecked") public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { final User userPricipal = AuthenticatedUserDetails.getUserPrincipal(); if (userPricipal == null || userPricipal.getOrganization() == null) { if (logger.isDebugEnabled()) { logger.debug("Please login again with right permission"); }// w ww. jav a2 s. c o m logger.info("Sorry, you don't have permission to access this url"); // Sorry, you don't have permission to access this url. Please login again with right permission response.setContentType(HttpServletContentType.PLAN_TEXT); response.sendRedirect(request.getContextPath() + "/logout"); response.flushBuffer(); return false; } final HandlerMethod handlerMethod = (org.springframework.web.method.HandlerMethod) handler; final Object controller = handlerMethod.getBean(); if (controller instanceof MenuController) { return super.preHandle(request, response, handler); } final Map<String, Object> pathVariables = (Map<String, Object>) request .getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE); final String PRO_GROUP_NO = "proGNo"; final String proGroupNo = (String) pathVariables.get(PRO_GROUP_NO); final boolean hasMenuGroups = menuGroupService .hasMenuGroupByUserRoleAndSpecificGroup(userPricipal.getUsrKbn(), proGroupNo); if (!hasMenuGroups) { logger.info("Sorry, you don't have permission to access this url"); // Sorry, you don't have permission to access this url. Please login again with right permission response.setContentType(HttpServletContentType.PLAN_TEXT); response.sendRedirect(request.getContextPath() + "/logout"); response.flushBuffer(); return false; } final String ORG_CODE = "orgCode"; final HttpSession session = request.getSession(); // Get active original code String orgCode = (String) pathVariables.get(ORG_CODE); if (StringUtils.isNotEmpty(orgCode)) { final String userOrgCode = (String) session.getAttribute(Constants.SESS_ORGANIZATION_CODE); if (!userOrgCode.equals(orgCode)) { logger.info("Sorry, you don't have permission to access this url"); // Sorry, you don't have permission to access this url. Please login again with right permission response.setContentType(HttpServletContentType.PLAN_TEXT); response.sendRedirect(request.getContextPath() + "/logout"); response.flushBuffer(); return false; } } // All of original groups String[] processGroupNumbers = null; if (controller instanceof DailyReportingProGroup) { processGroupNumbers = ((DailyReportingProGroup) controller).getProcessGroupNumber(); } else if (controller instanceof MasterManagementProGroup) { processGroupNumbers = ((MasterManagementProGroup) controller).getProcessGroupNumber(); } else if (controller instanceof ProfitAndLossManagementProGroup) { processGroupNumbers = ((ProfitAndLossManagementProGroup) controller).getProcessGroupNumber(); } // If the end-user already logged in into Harvest system, but have an error occurred // when trying to set some information into SESSION then we can reset again that // information into SESSION orgCode = (String) session.getAttribute(Constants.SESS_ORGANIZATION_CODE); if (orgCode == null) { session.setAttribute(Constants.SESS_ORGANIZATION_CODE, userPricipal.getOrganization().getStrCode()); } final Object businessDay = session.getAttribute(Constants.SESS_BUSINESS_DAY); if (businessDay == null) { BusinessDayService businessDayService = ContextAwareContainer.getInstance() .getComponent(BusinessDayService.class); final BusinessDay businessDate = businessDayService.findLatest(); // session.setAttribute(Constants.SESS_BUSINESS_DAY, businessDate.getEigDate()); } // Granted authority of user logged-in final String grantedAuthority = userPricipal.getUsrKbn(); final Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); for (GrantedAuthority authority : authentication.getAuthorities()) { logger.info("User {} was logged-in with granted role {}", authentication.getName(), authority.getAuthority()); } /** * ? * * 1?2?3??4 */ logger.info( "Granted authority of logged user: {}, NOTE: 1?2?3??4", grantedAuthority); // if (StringUtils.isNotEmpty(grantedAuthority)) { if (ArrayUtils.isNotEmpty(processGroupNumbers)) { // Trying to store the original group menu into the REQUEST final String processGroupNumber = processGroupNumbers[Integer.valueOf(grantedAuthority) - 1]; request.setAttribute(Constants.SESS_ORIGINAL_GROUP, processGroupNumber); // logger.info("Were are trying to handle the sub-menu of group {}", processGroupNumber); } } return super.preHandle(request, response, handler); }
From source file:com.adobe.cq.wcm.core.components.models.impl.v1.ListImpl.java
private void populateTagListItems() { listItems = new ArrayList<>(); String[] tags = properties.get(PN_TAGS, new String[0]); boolean matchAny = properties.get(PN_TAGS_MATCH, TAGS_MATCH_ANY_VALUE).equals(TAGS_MATCH_ANY_VALUE); if (ArrayUtils.isNotEmpty(tags)) { Page rootPage = getRootPage(PN_TAGS_PARENT_PAGE); if (rootPage != null) { TagManager tagManager = resourceResolver.adaptTo(TagManager.class); RangeIterator<Resource> resourceRangeIterator = tagManager.find(rootPage.getPath(), tags, matchAny); if (resourceRangeIterator != null) { while (resourceRangeIterator.hasNext()) { Page containingPage = pageManager.getContainingPage(resourceRangeIterator.next()); if (containingPage != null) { listItems.add(containingPage); }/*from w w w . j a va 2 s. c o m*/ } } } } }
From source file:ml.shifu.shifu.core.correlation.CorrelationWritable.java
/** * CorrelationWritable should be initialized in CorrelationMapper. * If Sum array is null, it means CorrelationWritable has not need to be processed in Reducer phase * //from ww w . ja va 2 s . c o m * @return True if it is be initialized, False otherwise */ public boolean isValid() { return (ArrayUtils.isNotEmpty(getXySum()) && ArrayUtils.isNotEmpty(getXxSum()) && ArrayUtils.isNotEmpty(getYySum()) && ArrayUtils.isNotEmpty(getAdjustCount()) && ArrayUtils.isNotEmpty(getAdjustSumX()) && ArrayUtils.isNotEmpty(getAdjustSumY())); }
From source file:com.photon.phresco.service.admin.actions.admin.Videos.java
public String delete() throws PhrescoException { if (s_isDebugEnabled) { LOGGER.debug("Videos.delete : Entry"); }//ww w . j a v a 2 s . c o m try { String[] videoIds = getHttpRequest().getParameterValues("videoId"); if (s_isDebugEnabled) { if (videoIds == null) { LOGGER.warn("Videos.delete", "status=\"Bad Request\"", "message=\"VideoIds is empty\""); return showErrorPopup(new PhrescoException("VideoIds is empty"), getText(VIDEO_DELETED)); } LOGGER.info("Videos.delete", "videoIds=" + "\"" + videoIds); } if (ArrayUtils.isNotEmpty(videoIds)) { for (String videoid : videoIds) { getServiceManager().deleteVideo(videoid); } addActionMessage(getText(VIDEO_DELETED)); } } catch (PhrescoException e) { if (s_isDebugEnabled) { LOGGER.error("Videos.delete", "status=\"Failure\"", "message=\"" + e.getLocalizedMessage() + "\""); } return showErrorPopup(e, getText(EXCEPTION_VIDEO_DELETE)); } if (s_isDebugEnabled) { LOGGER.debug("Videos.delete : Exit"); } return list(); }
From source file:com.photon.phresco.service.admin.actions.components.Component.java
public String delete() throws PhrescoException { if (isDebugEnabled) { S_LOGGER.debug("Entering Method Component.delete()"); }/*from ww w. jav a2 s.co m*/ try { String[] techIds = getHttpRequest().getParameterValues(REST_QUERY_TECHID); String customerId = getCustomerId(); String tech = getTechnology(); String type = getType(); CacheKey key = new CacheKey(customerId, type, tech); if (ArrayUtils.isNotEmpty(techIds)) { for (String techId : techIds) { ClientResponse clientResponse = getServiceManager().deleteFeature(techId); if (clientResponse.getStatus() != RES_CODE_200) { addActionError(getText(COMPONENT_NOT_DELETED)); } } addActionMessage(getText(COMPONENT_DELETED)); } } catch (PhrescoException e) { return showErrorPopup(e, getText(EXCEPTION_COMPONENT_DELETE)); } return technologies(); }
From source file:gr.abiss.calipso.tiers.processor.ModelDrivenBeansGenerator.java
protected void createService(BeanDefinitionRegistry registry, ModelContext modelContext) throws NotFoundException, CannotCompileException { if (modelContext.getServiceDefinition() == null) { String newBeanClassName = modelContext.getGeneratedClassNamePrefix() + "Service"; String newBeanRegistryName = StringUtils.uncapitalize(newBeanClassName); String newBeanPackage = this.serviceBasePackage + '.'; // grab the generic types List<Class<?>> genericTypes = modelContext.getGenericTypes(); // extend the base service interface Class<?> newServiceInterface = JavassistUtil.createInterface(newBeanPackage + newBeanClassName, ModelService.class, genericTypes); ArrayList<Class<?>> interfaces = new ArrayList<Class<?>>(1); interfaces.add(newServiceInterface); // create a service implementation bean CreateClassCommand createServiceCmd = new CreateClassCommand( newBeanPackage + "impl." + newBeanClassName + "Impl", AbstractModelServiceImpl.class); createServiceCmd.setInterfaces(interfaces); createServiceCmd.setGenericTypes(genericTypes); createServiceCmd.addGenericType(modelContext.getRepositoryType()); HashMap<String, Object> named = new HashMap<String, Object>(); named.put("value", newBeanRegistryName); createServiceCmd.addTypeAnnotation(Named.class, named); // create and register a service implementation bean Class<?> serviceClass = JavassistUtil.createClass(createServiceCmd); AbstractBeanDefinition def = BeanDefinitionBuilder.rootBeanDefinition(serviceClass).getBeanDefinition(); registry.registerBeanDefinition(newBeanRegistryName, def); // note in context as a dependency to a controller modelContext.setServiceDefinition(def); modelContext.setServiceInterfaceType(newServiceInterface); modelContext.setServiceImplType(serviceClass); } else {// w ww. j ava 2 s . com Class<?> serviceType = ClassUtils.getClass(modelContext.getServiceDefinition().getBeanClassName()); // grab the service interface if (!serviceType.isInterface()) { Class<?>[] serviceInterfaces = serviceType.getInterfaces(); if (ArrayUtils.isNotEmpty(serviceInterfaces)) { for (Class<?> interfaze : serviceInterfaces) { if (ModelService.class.isAssignableFrom(interfaze)) { modelContext.setServiceInterfaceType(interfaze); break; } } } } Assert.notNull(modelContext.getRepositoryType(), "Found a service bean definition for " + modelContext.getGeneratedClassNamePrefix() + " but failed to figure out the service interface type."); } }
From source file:com.photon.phresco.service.admin.actions.admin.Roles.java
public String delete() throws PhrescoException { if (isDebugEnabled) { LOGGER.debug("Roles.delete : Entry"); }/*from w ww. j av a 2 s . co m*/ try { String[] roleIds = getHttpRequest().getParameterValues(REQ_ROLE_ID); if (isDebugEnabled) { if (roleIds == null) { LOGGER.warn("Roles.delete", "status=\"Bad Request\"", "message=\"RoleIds is empty\""); return showErrorPopup(new PhrescoException("RoleIds is empty"), getText(EXCEPTION_ROLE_DELETE)); } LOGGER.info("Roles.delete", "roleIds=" + "\"" + roleIds); } if (ArrayUtils.isNotEmpty(roleIds)) { for (String roleid : roleIds) { getServiceManager().deleteRole(roleid); } addActionMessage(getText(ROLE_DELETED)); } } catch (PhrescoException e) { if (isDebugEnabled) { LOGGER.error("Roles.delete", "status=\"Failure\"", "message=\"" + e.getLocalizedMessage() + "\""); } return showErrorPopup(e, getText(EXCEPTION_ROLE_DELETE)); } if (isDebugEnabled) { LOGGER.debug("Roles.delete : Exit"); } return list(); }
From source file:com.univocity.app.swing.DataAnalysisWindow.java
private JMenuItem newJMenuItem(String label, final DaoTable table, final String engineName, final boolean enableUpdates, final boolean applyToAll) { JMenuItem item = new JMenuItem(label); item.addActionListener(new ActionListener() { @Override/* w ww .j ava 2 s . com*/ public void actionPerformed(ActionEvent e) { Object[] primaryKey = table.getSelectedPrimaryKey(); if (ArrayUtils.isNotEmpty(primaryKey)) { DataIntegrationEngine engine = Univocity.getEngine(engineName); String entity = table.getDatabaseName() + "." + table.getSelectedTableName(); if (applyToAll) { if (enableUpdates) { engine.enableUpdateOnAllRecords(entity); } else { engine.disableUpdateOnAllRecords(entity); } } else { ModifiableDataset dataset = Univocity.datasetFactory().newDataset(new ArrayList<Object[]>(), table.getPrimaryKeyNames()); dataset.insert(table.getSelectedPrimaryKey()); if (enableUpdates) { engine.enableUpdateOnRecords(entity, dataset); } else { engine.disableUpdateOnRecords(entity, dataset); } } } } }); return item; }
From source file:gr.abiss.calipso.tiers.processor.ModelDrivenBeanGeneratingRegistryPostProcessor.java
protected void createService(BeanDefinitionRegistry registry, ModelContext modelContext) throws NotFoundException, CannotCompileException { if (modelContext.getServiceDefinition() == null) { String newBeanClassName = modelContext.getGeneratedClassNamePrefix() + "Service"; String newBeanRegistryName = StringUtils.uncapitalize(newBeanClassName); String newBeanPackage = modelContext.getBeansBasePackage() + ".service"; // grab the generic types List<Class<?>> genericTypes = modelContext.getGenericTypes(); // extend the base service interface Class<?> newServiceInterface = JavassistUtil.createInterface(newBeanPackage + newBeanClassName, ModelService.class, genericTypes); ArrayList<Class<?>> interfaces = new ArrayList<Class<?>>(1); interfaces.add(newServiceInterface); // create a service implementation bean CreateClassCommand createServiceCmd = new CreateClassCommand( newBeanPackage + "impl." + newBeanClassName + "Impl", AbstractModelServiceImpl.class); createServiceCmd.setInterfaces(interfaces); createServiceCmd.setGenericTypes(genericTypes); createServiceCmd.addGenericType(modelContext.getRepositoryType()); HashMap<String, Object> named = new HashMap<String, Object>(); named.put("value", newBeanRegistryName); createServiceCmd.addTypeAnnotation(Named.class, named); // create and register a service implementation bean Class<?> serviceClass = JavassistUtil.createClass(createServiceCmd); AbstractBeanDefinition def = BeanDefinitionBuilder.rootBeanDefinition(serviceClass).getBeanDefinition(); registry.registerBeanDefinition(newBeanRegistryName, def); // note in context as a dependency to a controller modelContext.setServiceDefinition(def); modelContext.setServiceInterfaceType(newServiceInterface); modelContext.setServiceImplType(serviceClass); } else {//from w w w. ja va 2s.c o m Class<?> serviceType = ClassUtils.getClass(modelContext.getServiceDefinition().getBeanClassName()); // grab the service interface if (!serviceType.isInterface()) { Class<?>[] serviceInterfaces = serviceType.getInterfaces(); if (ArrayUtils.isNotEmpty(serviceInterfaces)) { for (Class<?> interfaze : serviceInterfaces) { if (ModelService.class.isAssignableFrom(interfaze)) { modelContext.setServiceInterfaceType(interfaze); break; } } } } Assert.notNull(modelContext.getRepositoryType(), "Found a service bean definition for " + modelContext.getGeneratedClassNamePrefix() + " but failed to figure out the service interface type."); } }
From source file:com.stoxx.portlet.preregcustomeradmin.delegate.CustomerAdminDelegate.java
private void processEmailAddress(ThemeDisplay themeDisplay, Map<String, List<String>> resultMap, long salesEntryId, String companyName, String emailAddress, UserProfileDetails userProfileDetail, boolean isKeyAccountHolder, List<Long> roleIdsToRemove, List<Long> roleIdsToAdd) throws STOXXException, SystemException, PortalException { log.info("Processing email address:" + emailAddress); long companyId = themeDisplay.getCompanyId(); if (Validator.isNotNull(emailAddress)) { emailAddress = StringUtil.toLowerCase(emailAddress); if (userProfileDetail == null) { log.info("Creating new user as customer with email:" + emailAddress); boolean userCreationSuccess = createNewCustomer(themeDisplay, emailAddress, salesEntryId, companyName, isKeyAccountHolder); if (!userCreationSuccess) { addToSkippedEmails(resultMap, emailAddress); } else if (isKeyAccountHolder) { try { SalesEntryLocalServiceUtil.updateKeyAccountHolderEmail(salesEntryId, emailAddress); } catch (NoSuchSalesEntryException e) { log.error("Sales entry not found with id " + salesEntryId + " while updating key account holder"); }/*from w ww . ja v a2 s.c om*/ } } else if (Validator.equals(userProfileDetail.getStatus(), Integer.valueOf(4))) { boolean deletedUserHandled = handleDeletedUser(userProfileDetail, salesEntryId, companyName, themeDisplay, isKeyAccountHolder); if (!deletedUserHandled) { addToSkippedEmails(resultMap, emailAddress); } else if (isKeyAccountHolder) { try { SalesEntryLocalServiceUtil.updateKeyAccountHolderEmail(salesEntryId, emailAddress); } catch (NoSuchSalesEntryException e) { log.error("Sales entry not found with id " + salesEntryId + " while updating key account holder"); } } } else if (STOXXConstants.STOXX_GENERAL_USER.equals(userProfileDetail.getUserType())) { boolean userTypeChangeSuccess = changeGeneralUserToCustomer(userProfileDetail, salesEntryId, themeDisplay); if (userTypeChangeSuccess) { List<Long> roleIdList = new ArrayList<Long>(); SalesEntry salesEntry = SalesEntryLocalServiceUtil.getSalesEntry(salesEntryId); if (Validator.isNotNull(salesEntry)) { String packageNames = salesEntry.getPackageNames(); String[] roleNames = StringUtils.split(packageNames, StringPool.COMMA); if (ArrayUtils.isNotEmpty(roleNames)) { for (String role : roleNames) { Role liferayRole = RoleLocalServiceUtil.fetchRole(companyId, role.trim()); if (Validator.isNotNull(liferayRole)) { roleIdList.add(liferayRole.getRoleId()); } } } } if (Validator.isNotNull(roleIdList) && roleIdList.size() > 0) { roleIdsToAdd = new ArrayList<Long>(); roleIdsToAdd.addAll(roleIdList); } updateRoleAssignments(themeDisplay, roleIdsToRemove, roleIdsToAdd, userProfileDetail.getEmailAddress()); if (isKeyAccountHolder) { log.info("Updating sales entry with KAH=" + emailAddress); try { SalesEntryLocalServiceUtil.updateKeyAccountHolderEmail(salesEntryId, emailAddress); try { User existingKAHUser = UserLocalServiceUtil .getUserByEmailAddress(themeDisplay.getCompanyId(), emailAddress); Role gatewayUserRole = RoleLocalServiceUtil.getRole(themeDisplay.getCompanyId(), STOXX_KEY_ACCOUNT_HOLDER_ROLE); RoleLocalServiceUtil.addUserRole(existingKAHUser.getUserId(), gatewayUserRole); } catch (NoSuchUserException ex) { log.error("Key acount holder not yet registered. " + ex.getMessage()); } catch (PortalException ex) { log.error("PortalException while adding key account holder role to user.", ex); } } catch (NoSuchSalesEntryException e) { log.error("Sales entry not found with id " + salesEntryId + " while updating key account holder"); } } } else { log.info("Adding emailAddress '" + emailAddress + "' to skipped list because unable to convert it to customer."); addToSkippedEmails(resultMap, emailAddress); } } else if (STOXXConstants.STOXX_STAFF_USER.equals(userProfileDetail.getUserType())) { log.info("Skipping emailaddress '" + emailAddress + "' as it is staff in system."); addToSkippedEmails(resultMap, emailAddress); } else if (STOXXConstants.STOXX_VENDOR_USER.equals(userProfileDetail.getUserType())) { log.info("Skipping emailaddress '" + emailAddress + "' as it is vendor in system."); addToSkippedEmails(resultMap, emailAddress); } else if (GetterUtil.getLong(userProfileDetail.getSalesEntryId()) != salesEntryId) { log.info("Skipping emailaddress '" + emailAddress + "' as it is customer for another sales entry id:" + userProfileDetail.getSalesEntryId()); addToSkippedEmails(resultMap, emailAddress); } else if (Validator.isNotNull(userProfileDetail.getSalesEntryId()) && STOXXConstants.STOXX_REGISTERED_USER.equalsIgnoreCase(userProfileDetail.getUserType()) && GetterUtil.getLong(userProfileDetail.getSalesEntryId()) == salesEntryId) { SalesEntry salesEntry = SalesEntryLocalServiceUtil .getSalesEntry(userProfileDetail.getSalesEntryId()); log.info("salesEntry Id latest is >>> " + salesEntry.getSalesEntryId()); boolean isKeyAccountRole = Boolean.FALSE; String keyEmailAddress = salesEntry.getKeyEmailAddress(); log.info("salesEntry Id latest is >>> " + keyEmailAddress + " and the emailAddress is " + emailAddress); if (StringUtils.isNotBlank(keyEmailAddress) && keyEmailAddress.equalsIgnoreCase(emailAddress)) { isKeyAccountRole = Boolean.TRUE; } log.info("from front end isKeyAccountRole is >>> " + isKeyAccountRole + " and from back end isKeyAccountRole >>> " + isKeyAccountRole); if ((isKeyAccountHolder && isKeyAccountRole) || (!isKeyAccountHolder && !isKeyAccountRole)) { log.info("Skipping emailaddress '" + emailAddress + "' as it is customer for another sales entry id:" + userProfileDetail.getSalesEntryId()); addToSkippedEmails(resultMap, emailAddress); } } } }