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:ml.shifu.shifu.util.ModelSpecLoaderUtils.java
/** * Load the generic model config and parse it to java object. * Similar as {@link #findModels(ModelConfig, EvalConfig, RawSourceData.SourceType)} * /*from w ww. ja va 2 s . c o m*/ * @param modelConfig * - {@link ModelConfig}, need this, since the model file may exist in HDFS * @param evalConfig * - {@link EvalConfig}, maybe null * @param sourceType * - {@link SourceType}, HDFS or Local? * @return the file status list for generic models * @throws IOException * Exception occurred when finding generic models */ public static List<FileStatus> findGenericModels(ModelConfig modelConfig, EvalConfig evalConfig, RawSourceData.SourceType sourceType) throws IOException { FileSystem fs = ShifuFileUtils.getFileSystemBySourceType(sourceType); PathFinder pathFinder = new PathFinder(modelConfig); // Find generic model config file with suffix .json String modelSuffix = ".json"; List<FileStatus> fileList = new ArrayList<>(); if (null == evalConfig || StringUtils.isBlank(evalConfig.getModelsPath())) { Path path = new Path(pathFinder.getModelsPath(sourceType)); // modelsPath / <ModelName> // + File.separator + modelConfig.getBasic().getName()); fileList.addAll(Arrays.asList(fs.listStatus(path, new FileSuffixPathFilter(modelSuffix)))); } else { String modelsPath = evalConfig.getModelsPath(); FileStatus[] expandedPaths = fs.globStatus(new Path(modelsPath)); // models / <ModelName> // + File.separator + modelConfig.getBasic().getName())); if (ArrayUtils.isNotEmpty(expandedPaths)) { for (FileStatus epath : expandedPaths) { fileList.addAll(Arrays.asList(fs.listStatus(epath.getPath(), // list all files with suffix new FileSuffixPathFilter(modelSuffix)))); } } } return fileList; }
From source file:com.yougou.api.service.impl.ApiKeyServiceImpl.java
@Override @Transactional// w w w. j a va2s . co m public boolean bindingApiKeyCustomers(String[] customers, AppType[] appTypes, String apiKeyId, String userName, String appKey) throws Exception { String sqlselect = "select metadata_val,metadata_key from tbl_merchant_api_key_metadata where key_id = ?"; List<Map<String, Object>> results = JDBCUtils.getInstance().listResultMap(sqlselect, new Object[] { apiKeyId }); boolean exist = false; Map<String, List<Object[]>> sqlBatchs = new LinkedHashMap<String, List<Object[]>>(); // ?API String sql = "delete from tbl_merchant_api_key_metadata where key_id = ? and metadata_val=?"; List<Object[]> sqlParams = null; String sj = ""; for (Map<String, Object> result : results) { if (ArrayUtils.isNotEmpty(customers)) { for (String customer : customers) { if (result.get("metadata_val").toString().equalsIgnoreCase(customer)) { exist = true; break; } } } if (!exist) { sqlParams = new ArrayList<Object[]>(); sqlParams.add(new Object[] { apiKeyId, result.get("metadata_val").toString() }); sqlBatchs.put(sql, sqlParams); if ("MERCHANTS".equalsIgnoreCase(result.get("metadata_key").toString())) { SupplierVo supplierVo = supplierService .getSupplierByMerchantCode(result.get("metadata_val").toString()); sj = supplierVo == null ? result.get("metadata_val").toString() : (supplierVo.getSupplier() + "(" + supplierVo.getSupplierCode() + ")"); } else if ("CHAIN".equalsIgnoreCase(result.get("metadata_key").toString())) { Map<String, String> distributorMap = apiDistributorService.queryAllDistributor(); sj = distributorMap.get(result.get("metadata_val").toString()) + "(" + result.get("metadata_val").toString() + ")"; } else { sj = "?"; } MerchantOperationLog operationLog = new MerchantOperationLog(); operationLog.setId(UUIDUtil.getUUID()); operationLog.setMerchantCode(appKey); operationLog.setOperated(new Date()); operationLog.setOperationNotes("appkey:" + sj); operationLog.setOperationType(OperationType.APPKEY_UNBUND); operationLog.setOperator(userName); merchantOperationLogService.saveMerchantOperationLog(operationLog); } } String sql2 = "insert into tbl_merchant_api_key_metadata(id, key_id, metadata_key, metadata_val) values(?, ?, ?, ?)"; // ???API if (ArrayUtils.isNotEmpty(customers)) { for (String customer : customers) { for (Map<String, Object> result : results) { if (result.get("metadata_val").toString().equalsIgnoreCase(customer)) { exist = true; break; } } if (!exist) { sqlParams = new ArrayList<Object[]>(); for (int i = 0; i < customers.length; i++) { sqlParams.add( new Object[] { UUIDUtil.getUUID(), apiKeyId, appTypes[i].name(), customers[i] }); if ("MERCHANTS".equalsIgnoreCase(appTypes[i].name())) { SupplierVo supplierVo = supplierService.getSupplierByMerchantCode(customer); sj = supplierVo == null ? customer : (supplierVo.getSupplier() + "(" + supplierVo.getSupplierCode() + ")"); } else if ("CHAIN".equalsIgnoreCase(appTypes[i].name())) { Map<String, String> distributorMap = apiDistributorService.queryAllDistributor(); sj = distributorMap.get(customer) + "(" + customer + ")"; } else { sj = "?"; } MerchantOperationLog operationLog = new MerchantOperationLog(); operationLog.setId(UUIDUtil.getUUID()); operationLog.setMerchantCode(appKey); operationLog.setOperated(new Date()); operationLog.setOperationNotes("appkey,:" + sj); operationLog.setOperationType(OperationType.APPKEY_BINDING); operationLog.setOperator(userName); merchantOperationLogService.saveMerchantOperationLog(operationLog); } sqlBatchs.put(sql2, sqlParams); } } } return JDBCUtils.getInstance().executeBatch(sqlBatchs); }
From source file:eu.europa.esig.dss.tsl.TrustedListsCertificateSource.java
/** * Adds all the service entries (current and history) of all the providers of the trusted list to the list of * CertificateSource//from ww w. j ava 2 s .co m * * @param trustStatusList */ private void loadAllCertificatesFromOneTSL(final TrustStatusList trustStatusList) { for (final TrustServiceProvider trustServiceProvider : trustStatusList.getTrustServicesProvider()) { for (final AbstractTrustService trustService : trustServiceProvider.getTrustServiceList()) { if (logger.isTraceEnabled()) { logger.trace("#Service Name: " + trustService.getServiceName()); logger.trace(" ------> " + trustService.getType()); logger.trace(" ------> " + trustService.getStatus()); } for (final Object digitalIdentity : trustService.getDigitalIdentity()) { try { CertificateToken certificateToken = null; if (digitalIdentity instanceof CertificateToken) { certificateToken = (CertificateToken) digitalIdentity; } else if (digitalIdentity instanceof X500Principal) { final X500Principal x500Principal = (X500Principal) digitalIdentity; final List<CertificateToken> certificateTokens = certPool.get(x500Principal); if (certificateTokens.size() > 0) { certificateToken = certificateTokens.get(0); } else { logger.debug( "WARNING: There is currently no certificate with the given X500Principal: '{}' within the certificate pool!", x500Principal); } } if (certificateToken != null) { addCertificate(certificateToken, trustService, trustServiceProvider, trustStatusList.isWellSigned()); } } catch (DSSException e) { // There is a problem when loading the certificate, we continue with the next one. logger.warn(e.getMessage()); } } for (String certificateUri : trustService.getCertificateUrls()) { try { logger.debug("Try to load certificate from URI : " + certificateUri); byte[] certBytes = dataLoader.get(certificateUri); if (ArrayUtils.isNotEmpty(certBytes)) { CertificateToken certificateToken = DSSUtils.loadCertificate(certBytes); if (certificateToken != null) { addCertificate(certificateToken, trustService, trustServiceProvider, trustStatusList.isWellSigned()); } } } catch (DSSException e) { logger.warn("Unable to add certificate '" + certificateUri + "' : " + e.getMessage()); } } } } }
From source file:com.hp.autonomy.frontend.reports.powerpoint.PowerPointServiceImpl.java
/** * Internal implementation to add a sunburst chart (actually a doughnut chart) to a slide, based on a template. * @param template the parsed template information. * @param slide the slide to add to.//ww w . j av a2 s . c o m * @param anchor optional bounding rectangle to draw onto, in PowerPoint coordinates. * If null, we'll use the bounds from the original template chart. * @param data the sunburst data. * @param shapeId the slide shape ID, should be unique within the slide. * @param relId the relation ID to the chart data. * @throws TemplateLoadException if we can't create the sunburst; most likely due to an invalid template. */ private static void addSunburst(final SlideShowTemplate template, final XSLFSlide slide, final Rectangle2D.Double anchor, final SunburstData data, final int shapeId, final String relId) throws TemplateLoadException { final String[] categories = data.getCategories(); final double[] values = data.getValues(); final String title = data.getTitle(); slide.getXmlObject().getCSld().getSpTree().addNewGraphicFrame() .set(template.getDoughnutChartShapeXML(relId, shapeId, "chart" + shapeId, anchor)); final XSSFWorkbook workbook = new XSSFWorkbook(); final XSSFSheet sheet = workbook.createSheet(); final XSLFChart baseChart = template.getDoughnutChart(); final CTChartSpace chartSpace = (CTChartSpace) baseChart.getCTChartSpace().copy(); final CTChart ctChart = chartSpace.getChart(); final CTPlotArea plotArea = ctChart.getPlotArea(); if (StringUtils.isEmpty(title)) { if (ctChart.getAutoTitleDeleted() != null) { ctChart.getAutoTitleDeleted().setVal(true); } ctChart.unsetTitle(); } final CTDoughnutChart donutChart = plotArea.getDoughnutChartArray(0); final CTPieSer series = donutChart.getSerArray(0); final CTStrRef strRef = series.getTx().getStrRef(); strRef.getStrCache().getPtArray(0).setV(title); sheet.createRow(0).createCell(1).setCellValue(title); strRef.setF(new CellReference(sheet.getSheetName(), 0, 1, true, true).formatAsString()); final CTStrRef categoryRef = series.getCat().getStrRef(); final CTStrData categoryData = categoryRef.getStrCache(); final CTNumRef numRef = series.getVal().getNumRef(); final CTNumData numericData = numRef.getNumCache(); final String[] fillColors = data.getColors(); final String[] strokeColors = data.getStrokeColors(); final boolean overrideFill = ArrayUtils.isNotEmpty(fillColors); final boolean overrideStroke = ArrayUtils.isNotEmpty(strokeColors); final boolean overrideColors = overrideFill || overrideStroke; final List<CTDPt> dPtList = series.getDPtList(); final CTDPt templatePt = (CTDPt) dPtList.get(0).copy(); if (overrideColors) { dPtList.clear(); final CTShapeProperties spPr = templatePt.getSpPr(); final CTLineProperties ln = spPr.getLn(); // We need to unset any styles on the existing template if (overrideFill) { unsetSpPrFills(spPr); } if (overrideStroke) { unsetLineFills(ln); } } categoryData.setPtArray(null); numericData.setPtArray(null); CTLegend legend = null; final int[] showInLegend = data.getShowInLegend(); int nextLegendToShow = 0, nextLegendToShowIdx = -1; if (showInLegend != null) { // We need to write legendEntry elements to hide the legend for chart series we don't want. // Note this only works in PowerPoint, and not OpenOffice. legend = ctChart.isSetLegend() ? ctChart.getLegend() : ctChart.addNewLegend(); Arrays.sort(showInLegend); nextLegendToShow = showInLegend[++nextLegendToShowIdx]; } for (int idx = 0; idx < values.length; ++idx) { final CTStrVal categoryPoint = categoryData.addNewPt(); categoryPoint.setIdx(idx); categoryPoint.setV(categories[idx]); final CTNumVal numericPoint = numericData.addNewPt(); numericPoint.setIdx(idx); numericPoint.setV(Double.toString(values[idx])); if (overrideColors) { final CTDPt copiedPt = (CTDPt) templatePt.copy(); copiedPt.getIdx().setVal(idx); if (overrideFill) { final Color color = Color.decode(fillColors[idx % fillColors.length]); final CTSolidColorFillProperties fillClr = copiedPt.getSpPr().addNewSolidFill(); fillClr.addNewSrgbClr().setVal( new byte[] { (byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue() }); } if (overrideStroke) { final Color strokeColor = Color.decode(strokeColors[idx % strokeColors.length]); final CTSolidColorFillProperties strokeClr = copiedPt.getSpPr().getLn().addNewSolidFill(); strokeClr.addNewSrgbClr().setVal(new byte[] { (byte) strokeColor.getRed(), (byte) strokeColor.getGreen(), (byte) strokeColor.getBlue() }); } dPtList.add(copiedPt); } if (legend != null) { // We're hiding some legend elements. Should we show this index? if (nextLegendToShow == idx) { // We show this index, find the next one to show. ++nextLegendToShowIdx; if (nextLegendToShowIdx < showInLegend.length) { nextLegendToShow = showInLegend[nextLegendToShowIdx]; } } else { // We hide this index. If there's already a matching legend entry in the XML, update it, // otherwise we create a new legend entry. boolean found = false; for (int ii = 0, max = legend.sizeOfLegendEntryArray(); ii < max; ++ii) { final CTLegendEntry legendEntry = legend.getLegendEntryArray(ii); final CTUnsignedInt idxLegend = legendEntry.getIdx(); if (idxLegend != null && idxLegend.getVal() == idx) { found = true; if (legendEntry.isSetDelete()) { legendEntry.getDelete().setVal(true); } else { legendEntry.addNewDelete().setVal(true); } } } if (!found) { final CTLegendEntry idxLegend = legend.addNewLegendEntry(); idxLegend.addNewIdx().setVal(idx); idxLegend.addNewDelete().setVal(true); } } } XSSFRow row = sheet.createRow(idx + 1); row.createCell(0).setCellValue(categories[idx]); row.createCell(1).setCellValue(values[idx]); } categoryData.getPtCount().setVal(categories.length); numericData.getPtCount().setVal(values.length); categoryRef.setF(new CellRangeAddress(1, values.length, 0, 0).formatAsString(sheet.getSheetName(), true)); numRef.setF(new CellRangeAddress(1, values.length, 1, 1).formatAsString(sheet.getSheetName(), true)); try { writeChart(template.getSlideShow(), slide, baseChart, chartSpace, workbook, relId); } catch (IOException | InvalidFormatException e) { throw new TemplateLoadException("Error writing chart in loaded template", e); } }
From source file:net.grinder.SingleConsole.java
private void checkExecutionErrors(ProcessReports[] processReports) { if (samplingCount == 0 && ArrayUtils.isNotEmpty(this.processReports) && ArrayUtils.isEmpty(processReports)) { getListeners().apply(new Informer<ConsoleShutdownListener>() { public void inform(ConsoleShutdownListener listener) { listener.readyToStop(StopReason.SCRIPT_ERROR); }//from w w w .j av a 2s .co m }); } }
From source file:com.belle.yitiansystem.merchant.service.impl.MerchantsService.java
/** * /* w ww.ja v a 2s.c om*/ * ? * * @Date 2012-03-07 * @author wang.m * @throws Exception */ @Transactional public Integer updateMerchant(HttpServletRequest req, SupplierSp supplierSp, String bankNameHidden, String catNameHidden, String brandList, String catList) throws Exception { // ? SupplierSp supplierInfo = getSupplierSpById(supplierSp.getId()); //TODO // ???? String[] brandInfos = getSpLimitBrandBysupplierId(supplierSp.getId()); // ??? String[] catInfos = getSpLimitCatBysupplierId(supplierSp.getId()); SystemmgtUser user = GetSessionUtil.getSystemUser(req); String loginUser = ""; if (user != null) { loginUser = user.getUsername(); } SupplierSp supplier = new SupplierSp(); supplier.setId(supplierSp.getId()); // Id supplier.setUpdateTimestamp(System.currentTimeMillis());// supplier.setSupplier(supplierSp.getSupplier());// ?? supplier.setSupplierCode(supplierSp.getSupplierCode());// ? supplier.setContact(supplierSp.getContact());// ?? supplier.setAccount(supplierSp.getAccount());// ? supplier.setSubBank(supplierSp.getSubBank());// ? supplier.setBankLocal(supplierSp.getBankLocal());// supplier.setBusinessLicense(supplierSp.getBusinessLicense());// ?? supplier.setBusinessLocal(supplierSp.getBusinessLocal());// ? supplier.setBusinessValidity(supplierSp.getBusinessValidity());// ? supplier.setTaxpayer(supplierSp.getTaxpayer());// ? supplier.setInstitutional(supplierSp.getInstitutional());// ? supplier.setTallageNo(supplierSp.getTallageNo());// ?? supplier.setTaxRate(supplierSp.getTaxRate());// supplier.setCouponsAllocationProportion(supplierSp.getCouponsAllocationProportion());// supplier.setIsValid(supplierSp.getIsValid());// ? supplier.setSupplierType(supplierSp.getSupplierType());// supplier.setIsInputYougouWarehouse(supplierSp.getIsInputYougouWarehouse());// ? supplier.setSetOfBooksCode(supplierSp.getSetOfBooksCode());// ??? supplier.setSetOfBooksName(supplierSp.getSetOfBooksName());// ???? supplier.setCreator(loginUser);// supplier.setUpdateUser(loginUser);// supplier.setUpdateDate(new Date());// supplier.setDeleteFlag(1);// supplier.setShipmentType(supplierSp.getShipmentType());// ? supplier.setInventoryCode(supplierSp.getInventoryCode());//? if (supplierSp.getTradeCurrency() != null) { supplier.setTradeCurrency(supplierSp.getTradeCurrency()); } supplier.setIsUseYougouWms(supplierSp.getIsUseYougouWms());//?WMS String operationNotes = merchantOperationLogService.buildMerchantBasicDataOperationNotes(supplierInfo, supplier); //supplierDaoImpl.merge(supplier); //TODO // ?Id??? deleteMerchantBankAndCat(supplierSp.getId()); // ??? addMerchantBankAndCat(supplierSp, req, bankNameHidden, catNameHidden, brandList, catList, "2"); if (ArrayUtils.isNotEmpty(brandInfos)) { if (!StringUtils.equals(brandInfos[0], brandList)) { operationNotes += MessageFormat.format("????{0}?{1}", brandInfos[0], brandList); } } if (ArrayUtils.isNotEmpty(catInfos)) { if (!StringUtils.equals(catInfos[0], catList)) { operationNotes += MessageFormat.format("???{0}?{1}", catInfos[0], catList); } } if (StringUtils.isNotBlank(operationNotes)) { /** Modifier by yang.mq **/ MerchantOperationLog operationLog = new MerchantOperationLog(); operationLog.setMerchantCode(supplier.getSupplierCode()); operationLog.setOperator(supplier.getCreator()); operationLog.setOperated(new Date()); operationLog.setOperationType(OperationType.BASIC_DATA); operationLog.setOperationNotes(operationNotes); merchantOperationLogService.saveMerchantOperationLog(operationLog); } return 2; }
From source file:com.belle.yitiansystem.merchant.service.impl.MerchantsService.java
/** * /*from w w w. j a v a 2 s. co m*/ * ? ???????(??) * * @Date 2012-03-07 * @author wang.m */ @Deprecated @Transactional public boolean update_historyMerchants(SupplierSp supplierSp, HttpServletRequest req, String bankNameHidden, String catNameHidden, String brandList, String catList) { boolean bool = false; try { if (supplierSp != null) { // bool = updateSupplierById(supplierSp.getId(), req); // ? MerchantUser merchantUser = new MerchantUser(); merchantUser.setLoginName(supplierSp.getLoginAccount());// ?? // ?MD5 String password = Md5Encrypt.md5(supplierSp.getLoginPassword()); merchantUser.setPassword(password);// ? merchantUser.setMerchantCode(supplierSp.getSupplierCode());// ? merchantUser.setUserName("");// ? merchantUser.setCreateTime(formDate()); merchantUser.setStatus(1);// ? 1? merchantUser.setIsAdministrator(1); // 1? merchantUser.setDeleteFlag(1);// 1? merchantUserDaoImpl.save(merchantUser); String username = GetSessionUtil.getSystemUser(req).getUsername(); /** ? Modifier by yang.mq **/ MerchantOperationLog operationLog = new MerchantOperationLog(); operationLog.setMerchantCode(supplierSp.getSupplierCode()); operationLog.setOperator(username); operationLog.setOperated(new Date()); operationLog.setOperationType(OperationType.ACCOUNT); operationLog.setOperationNotes( merchantOperationLogService.buildMerchantAccountOperationNotes(null, merchantUser)); merchantOperationLogService.saveMerchantOperationLog(operationLog); // ?Id??? deleteMerchantBankAndCat(supplierSp.getId()); // ??? addMerchantBankAndCat(supplierSp, req, bankNameHidden, catNameHidden, brandList, catList, "2"); // ? SupplierSp supplierInfo = getSupplierSpById(supplierSp.getId()); // ???? String[] brandInfos = getSpLimitBrandBysupplierId(supplierSp.getId()); // ??? //String[] catInfos = getSpLimitCatBysupplierId(supplierSp.getId()); String[] catInfos = getSpLimitBrandCatBysupplierId(supplierSp.getId()); StringBuilder operationNotes = new StringBuilder(); if (ArrayUtils.isNotEmpty(brandInfos)) { if (!StringUtils.equals(brandInfos[0], brandList)) { operationNotes.append(MessageFormat.format( "????{0}?{1}", brandList, brandInfos[0])); } } if (ArrayUtils.isNotEmpty(catInfos)) { if (!StringUtils.equals(catInfos[0], catList)) { operationNotes.append(MessageFormat.format( "???{0}?{1}", catList, catInfos[0])); } } if (operationNotes.length() > 0) { /** Modifier by yang.mq **/ operationLog = new MerchantOperationLog(); operationLog.setMerchantCode(supplierInfo.getSupplierCode()); operationLog.setOperator(GetSessionUtil.getSystemUser(req).getUsername()); operationLog.setOperated(new Date()); operationLog.setOperationType(OperationType.BASIC_DATA); operationLog.setOperationNotes(operationNotes.toString()); merchantOperationLogService.saveMerchantOperationLog(operationLog); } bool = true; } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); logger.error("???????(??)!", e); bool = false; } return bool; }
From source file:com.belle.yitiansystem.merchant.service.impl.MerchantsService.java
/** * /* w w w.j ava 2s .c o m*/ * ? ???????(??) * * @Date 2012-03-07 * @author wang.m */ @Deprecated @Transactional public boolean update_merchantsBankAndCat(SupplierSp supplierSp, HttpServletRequest req, String bankNameHidden, String catNameHidden, String brandList, String catList) { boolean bool = false; try { if (supplierSp != null) { // bool = updateSupplierById(supplierSp.getId(), req); // ?Id??? deleteMerchantBankAndCat(supplierSp.getId()); // ??? addMerchantBankAndCat(supplierSp, req, bankNameHidden, catNameHidden, brandList, catList, "2"); // ? SupplierSp supplierInfo = getSupplierSpById(supplierSp.getId()); // ???? String[] brandInfos = getSpLimitBrandBysupplierId(supplierSp.getId()); // ??? //String[] catInfos = getSpLimitCatBysupplierId(supplierSp.getId()); String[] catInfos = this.getSpLimitBrandCatBysupplierId(supplierSp.getId()); StringBuilder operationNotes = new StringBuilder(); if (ArrayUtils.isNotEmpty(brandInfos)) { if (!StringUtils.equals(brandInfos[0], brandList)) { operationNotes.append(MessageFormat.format( "????{0}?{1}", brandList, brandInfos[0])); } } if (ArrayUtils.isNotEmpty(catInfos)) { if (!StringUtils.equals(catInfos[0], catList)) { operationNotes.append(MessageFormat.format( "???{0}?{1}", catList, catInfos[0])); } } if (operationNotes.length() > 0) { /** Modifier by yang.mq **/ MerchantOperationLog operationLog = new MerchantOperationLog(); operationLog.setMerchantCode(supplierInfo.getSupplierCode()); operationLog.setOperator(GetSessionUtil.getSystemUser(req).getUsername()); operationLog.setOperated(new Date()); operationLog.setOperationType(OperationType.BASIC_DATA); operationLog.setOperationNotes(operationNotes.toString()); merchantOperationLogService.saveMerchantOperationLog(operationLog); } bool = true; } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); logger.error("???????(??)!", e); bool = false; } return bool; }
From source file:net.ymate.module.oauth.impl.DefaultOAuthModuleCfg.java
public DefaultOAuthModuleCfg(YMP owner) { IConfigReader _moduleCfg = MapSafeConfigReader.bind(owner.getConfig().getModuleConfigs(IOAuth.MODULE_NAME)); ////w w w. j a v a 2s. c om __accessTokenExpireIn = _moduleCfg.getInt(ACCESS_TOKEN_EXPIRE_IN); if (__accessTokenExpireIn <= 0) { __accessTokenExpireIn = 7200; } // __refreshCountMax = _moduleCfg.getInt(REFRESH_COUNT_MAX); if (__refreshCountMax < 0) { __refreshCountMax = 0; } // __refreshTokenExpireIn = _moduleCfg.getInt(REFRESH_TOKEN_EXPIRE_IN); if (__refreshTokenExpireIn <= 0) { __refreshTokenExpireIn = 30; } // __authorizationCodeExpireIn = _moduleCfg.getInt(AUTHORIZATION_CODE_EXPIRE_IN); if (__authorizationCodeExpireIn <= 0) { __authorizationCodeExpireIn = 5; } // __cacheNamePrefix = StringUtils.trimToEmpty(_moduleCfg.getString(CACHE_NAME_PREFIX)); // __allowGrantTypes = new HashSet<GrantType>(); String _grantTypeStr = _moduleCfg.getString(ALLOW_GRANT_TYPES, "none"); if (!StringUtils.containsIgnoreCase(_grantTypeStr, "none")) { String[] _types = StringUtils.split(_grantTypeStr, "|"); if (ArrayUtils.isNotEmpty(_types)) { for (String _item : _types) { try { GrantType _type = GrantType.valueOf(StringUtils.upperCase(StringUtils.trimToEmpty(_item))); __allowGrantTypes.add(_type); } catch (IllegalArgumentException ignored) { } } } } // if (!__allowGrantTypes.isEmpty()) { __tokenGenerator = _moduleCfg.getClassImpl(TOKEN_GENERATOR_CLASS, IOAuthTokenGenerator.class); if (__tokenGenerator == null) { __tokenGenerator = new DefaultTokenGenerator(); } // __storageAdapter = _moduleCfg.getClassImpl(STORAGE_ADAPTER_CLASS, IOAuthStorageAdapter.class); } // __errorAdapter = _moduleCfg.getClassImpl(ERROR_ADAPTER_CLASS, IOAuthErrorAdapter.class); if (__errorAdapter == null) { __errorAdapter = new DefaultErrorAdapter(); } }
From source file:net.ymate.platform.persistence.base.EntityMeta.java
/** * ?@Indexes@Index/*from w ww . jav a 2s.c o m*/ * * @param targetClass * @param targetMeta ? */ private static void __doParseIndexes(Class<? extends IEntity> targetClass, EntityMeta targetMeta) { List<Index> _indexes = new ArrayList<Index>(); if (ClassUtils.isAnnotationOf(targetClass, Indexes.class)) { _indexes.addAll(Arrays.asList(targetClass.getAnnotation(Indexes.class).value())); } if (ClassUtils.isAnnotationOf(targetClass, Index.class)) { _indexes.add(targetClass.getAnnotation(Index.class)); } for (Index _index : _indexes) { // ???? if (StringUtils.isNotBlank(_index.name()) && ArrayUtils.isNotEmpty(_index.fields())) { // ?????? if (!targetMeta.containsIndex(_index.name())) { // ??? for (String _field : _index.fields()) { if (!targetMeta.containsProperty(_field)) { throw new IllegalArgumentException("Invalid index field '" + _field + "'"); } } targetMeta.__indexes.put(_index.name(), new IndexMeta(_index.name(), _index.unique(), Arrays.asList(_index.fields()))); } } } }