List of usage examples for org.springframework.util Assert notEmpty
public static void notEmpty(@Nullable Map<?, ?> map, Supplier<String> messageSupplier)
From source file:lib.JdbcTemplate.java
@Override public int[] batchUpdate(final String... sql) throws DataAccessException { Assert.notEmpty(sql, "SQL array must not be empty"); if (logger.isDebugEnabled()) { logger.debug("Executing SQL batch update of " + sql.length + " statements"); }// w ww .j a v a2 s . c o m class BatchUpdateStatementCallback implements StatementCallback<int[]>, SqlProvider { private String currSql; @Override public int[] doInStatement(Statement stmt) throws SQLException, DataAccessException { int[] rowsAffected = new int[sql.length]; if (JdbcUtils.supportsBatchUpdates(stmt.getConnection())) { for (String sqlStmt : sql) { this.currSql = appendSql(this.currSql, sqlStmt); stmt.addBatch(sqlStmt); } try { rowsAffected = stmt.executeBatch(); } catch (BatchUpdateException ex) { String batchExceptionSql = null; for (int i = 0; i < ex.getUpdateCounts().length; i++) { if (ex.getUpdateCounts()[i] == Statement.EXECUTE_FAILED) { batchExceptionSql = appendSql(batchExceptionSql, sql[i]); } } if (StringUtils.hasLength(batchExceptionSql)) { this.currSql = batchExceptionSql; } throw ex; } } else { for (int i = 0; i < sql.length; i++) { this.currSql = sql[i]; if (!stmt.execute(sql[i])) { rowsAffected[i] = stmt.getUpdateCount(); } else { throw new InvalidDataAccessApiUsageException("Invalid batch SQL statement: " + sql[i]); } } } return rowsAffected; } private String appendSql(String sql, String statement) { return (StringUtils.isEmpty(sql) ? statement : sql + "; " + statement); } @Override public String getSql() { return this.currSql; } } return execute(new BatchUpdateStatementCallback()); }
From source file:com.epam.catgenome.manager.bam.BamHelper.java
private void parseBam(final SamReader reader) { Assert.notNull(reader, getMessage(RESOURCE_NOT_FOUND)); final SAMFileHeader samFileHeader = reader.getFileHeader(); //check we can read this Bam-file //get list of chromosome final List<SAMSequenceRecord> list = samFileHeader.getSequenceDictionary().getSequences(); Assert.notEmpty(list, getMessage(MessagesConstants.WRONG_HEADER_BAM_FILE_EMPTY_FILE)); //get first chromosome and make a request to the file with this chromosome final SAMSequenceRecord samSequenceRecord = list.get(0); SAMRecordIterator iterator = reader.query(samSequenceRecord.getSequenceName(), Constants.BAM_START_INDEX_TEST, Math.min(Constants.MAX_BAM_END_INDEX_TEST, samSequenceRecord.getSequenceLength()), false); Assert.notNull(iterator);//from w ww . j a va 2 s.c om }
From source file:cc.tooyoung.common.db.JdbcTemplate.java
public int[] batchUpdate(final String[] sql) throws DataAccessException { Assert.notEmpty(sql, "SQL array must not be empty"); if (ApiLogger.isTraceEnabled()) { ApiLogger.trace(new StringBuilder(128).append("Executing SQL batch update of ").append(sql.length) .append(" statements")); }//from www.j a v a 2 s .co m class BatchUpdateStatementCallback implements StatementCallback, SqlProvider { private String currSql; public Object doInStatement(Statement stmt) throws SQLException, DataAccessException { int[] rowsAffected = new int[sql.length]; if (JdbcUtils.supportsBatchUpdates(stmt.getConnection())) { for (int i = 0; i < sql.length; i++) { this.currSql = sql[i]; stmt.addBatch(sql[i]); } rowsAffected = stmt.executeBatch(); } else { for (int i = 0; i < sql.length; i++) { this.currSql = sql[i]; if (!stmt.execute(sql[i])) { rowsAffected[i] = stmt.getUpdateCount(); } else { throw new InvalidDataAccessApiUsageException("Invalid batch SQL statement: " + sql[i]); } } } return rowsAffected; } public String getSql() { return currSql; } } return (int[]) execute(new BatchUpdateStatementCallback(), true); }
From source file:com.epam.cme.storefront.controllers.pages.checkout.MultiStepCheckoutController.java
protected void setupSilentOrderPostPage(final SopPaymentDetailsForm sopPaymentDetailsForm, final Model model, final String clientIpAddress) { try {//from ww w .j a v a 2 s.c o m final SubscriptionPaymentData silentOrderPageData = getSubscriptionFacade().initializeTransaction( clientIpAddress, getSopResponseUrl(true), getSopResponseUrl(true), new HashMap<String, String>()); Assert.notNull(silentOrderPageData.getPostUrl(), "Silent order page post URL may not be null"); Assert.notEmpty(silentOrderPageData.getParameters(), "Silent order page parameters may not be empty"); getSessionService().setAttribute("authorizationRequestId", clientIpAddress); getSessionService().setAttribute("authorizationRequestToken", silentOrderPageData.getParameters().get("sessionTransactionToken")); model.addAttribute("silentOrderPageData", silentOrderPageData); } catch (final SubscriptionFacadeException e) { model.addAttribute("silentOrderPageData", null); LOG.warn("Failed to initialize session for silent order post page", e); GlobalMessages.addErrorMessage(model, "checkout.multi.sop.globalError"); } catch (final IllegalArgumentException e) { model.addAttribute("silentOrderPageData", null); LOG.warn("Failed to set up silent order post page", e); GlobalMessages.addErrorMessage(model, "checkout.multi.sop.globalError"); } final CartData cartData = getCheckoutFacade().getCheckoutCart(); model.addAttribute("cartData", cartData); model.addAttribute("deliveryAddress", cartData.getDeliveryAddress()); model.addAttribute("sopPaymentDetailsForm", sopPaymentDetailsForm); model.addAttribute("paymentInfos", getUserFacade().getCCPaymentInfos(true)); }
From source file:com.kingen.service.account.AccountService.java
/** * ??/*from ww w .j a v a 2 s.c o m*/ * @param userIds * @param status */ @ServiceLogAnnotation(action = "?") public void updateUser(List<String> userIds, String status) { Assert.notEmpty(userIds, "ID?"); for (String id : userIds) { User t = userDao.findByUserid(id); t.setStatus(status); update(t); } }
From source file:com.kingen.service.account.AccountService.java
@ServiceLogAnnotation(action = "??") public void updateUsersPwd(List<String> userIds) { Assert.notEmpty(userIds, "ID?"); for (String id : userIds) { User t = userDao.findByUserid(id); t.setPassword(Global.getConfig("initialPwd"));//?? updatePwd(t);/*from w ww .jav a 2 s . c o m*/ } }
From source file:com.kingen.service.account.AccountService.java
public void delThem(List<String> userIds, Boolean synToActiviti) { Assert.notEmpty(userIds, "ID?"); for (String id : userIds) { userDao.delete(id);/* www . j a va 2s . c o m*/ if (synToActiviti) { // ?Activiti User,membership? identityService.deleteUser(id); } } }
From source file:com.kingen.service.org.OrgService.java
@ServiceLogAnnotation(action = "") public void delOrgUsers(String orgId, List<String> userIds, Boolean synToActiviti) { Assert.hasLength(orgId, "ID?"); Assert.notEmpty(userIds, "ID?"); dao.delOrgUsers(orgId, userIds);// w ww .ja v a2 s .c o m // ??Activiti Identify? if (synToActiviti) { for (String userId : userIds) { identityService.deleteMembership(userId, orgId); } } }
From source file:com.lti.system.MyLogoutFilter.java
public MyLogoutFilter(String logoutSuccessUrl, LogoutHandler[] handlers) { Assert.hasText(logoutSuccessUrl, "LogoutSuccessUrl required"); Assert.notEmpty(handlers, "LogoutHandlers are required"); this.logoutSuccessUrl = logoutSuccessUrl; this.handlers = handlers; }
From source file:de.hybris.platform.commercefacades.storesession.impl.DefaultStoreSessionFacade.java
@Override public Collection<LanguageData> getAllLanguages() { Collection<LanguageModel> languages = getCommerceCommonI18NService().getAllLanguages(); if (languages.isEmpty()) { languages = getCommonI18NService().getAllLanguages(); }/*from ww w . j av a 2 s . c o m*/ Assert.notEmpty(languages, "No supported languages found for the current site."); return Converters.convertAll(languages, getLanguageConverter()); }