List of usage examples for java.lang StringBuffer delete
@Override public synchronized StringBuffer delete(int start, int end)
From source file:com.allinfinance.common.select.LoadRecordMethod.java
/** * ?/* w w w. jav a2 s . c o m*/ * * @param src * @return 2011-6-22?01:43:30 */ public String getMessage(String[] srcs) { StringBuffer sb = new StringBuffer("{\"data\":[{"); for (String src : srcs) { src = src.substring(2).trim(); sb.append(src); sb.delete(sb.length() - 2, sb.length()); sb.append(","); } sb.deleteCharAt(sb.length() - 1); sb.append("}]}"); return sb.toString(); }
From source file:com.glaf.activiti.web.springmvc.ActivitiProcessViewController.java
@RequestMapping @Transactional(readOnly = true)//from www. java 2 s. c o m public String showImage(HttpServletRequest request, Model model) { String processInstanceId = request.getParameter("processInstanceId"); ProcessDefinition processDefinition = null; if (StringUtils.isNotEmpty(processInstanceId)) { processDefinition = activitiProcessQueryService .getProcessDefinitionByProcessInstanceId(processInstanceId); model.addAttribute("processDefinition", processDefinition); if (processDefinition != null) { model.addAttribute("processDefinitionId", processDefinition.getId()); } List<Task> tasks = activitiTaskQueryService.getAssigneeTasks(processInstanceId); List<HistoricTaskInstance> historyTasks = activitiTaskQueryService .getHistoricTaskInstances(processInstanceId); model.addAttribute("tasks", tasks); model.addAttribute("historyTasks", historyTasks); ProcessInstanceInfo processInstanceInfo = activitiProcessQueryService .getProcessInstanceInfo(processInstanceId); if (processInstanceInfo != null) { model.addAttribute("activeActivityInfos", processInstanceInfo.getActiveActivityInfos()); model.addAttribute("processedActivityInfos", processInstanceInfo.getProcessedActivityInfos()); model.addAttribute("processInstance", processInstanceInfo.getProcessInstance()); model.addAttribute("historyProcessInstance", processInstanceInfo.getHistoricProcessInstance()); StringBuffer positionBuffer = new StringBuffer(); StringBuffer position = new StringBuffer(); StringBuffer buffer = new StringBuffer(); StringBuffer text = new StringBuffer(); int id = 0; List<ActivityInfo> processedActivityInfos = processInstanceInfo.getProcessedActivityInfos(); List<ActivityInfo> activeActivityInfos = processInstanceInfo.getActiveActivityInfos(); ActivityCoordinates coordinates = null; HistoricActivityInstance activityInstance = null; if (processedActivityInfos != null && !processedActivityInfos.isEmpty()) { for (ActivityInfo info : processedActivityInfos) { coordinates = info.getCoordinates(); activityInstance = info.getActivityInstance(); if (activityInstance == null) { continue; } position.delete(0, position.length()); text.delete(0, text.length()); String elId = "_pai_" + (++id); String title = activityInstance.getActivityName(); position.append("left:").append(coordinates.getX() - 2).append("px;"); position.append("top:").append(coordinates.getY() - 2).append("px;"); position.append("height:").append(coordinates.getHeight() - 2).append("px;"); position.append("width:").append(coordinates.getWidth() - 2).append("px;"); buffer.append("\n <div class=\"tip processed\" id=\"").append(elId) .append("\" style=\"").append(position).append("\"></div>"); Date startDate = activityInstance.getStartTime(); Date endDate = activityInstance.getEndTime(); buffer.append("\n <script>$('").append(elId).append("').store('tip:title', '") .append(title).append('\'').append(").store('tip:text', '") .append("<br/><b>:</b> ").append(DateUtils.getDateTime(startDate)) .append("<br/><b>?:</b> ").append(DateUtils.getDateTime(endDate)); if (activityInstance.getAssignee() != null) { buffer.append("<br/><b>:</b> ").append(activityInstance.getAssignee()); } buffer.append("');</script>"); } } if (activeActivityInfos != null && !activeActivityInfos.isEmpty()) { id = 0; for (ActivityInfo activityInfo : activeActivityInfos) { coordinates = activityInfo.getCoordinates(); String elId = "_aai_" + (++id); positionBuffer.delete(0, positionBuffer.length()); positionBuffer.append("left:").append(coordinates.getX() - 2).append("px;"); positionBuffer.append("top:").append(coordinates.getY() - 2).append("px;"); positionBuffer.append("height:").append(coordinates.getHeight() - 2).append("px;"); positionBuffer.append("width:").append(coordinates.getWidth() - 2).append("px;"); buffer.append("\n <div class=\"tip active\" id=\"").append(elId) .append("\" style=\"").append(positionBuffer.toString()).append("\"></div>"); activityInstance = activityInfo.getActivityInstance(); if (activityInstance != null) { String title = activityInstance.getActivityName(); Date startDate = activityInstance.getStartTime(); buffer.append("\n <script>$('").append(elId).append("').store('tip:title', '") .append(title).append('\'').append(").store('tip:text', '") .append("<br/><b>:</b> ").append(DateUtils.getDateTime(startDate)); if (activityInstance.getAssignee() != null) { buffer.append("<br/><b>:</b> ").append(activityInstance.getAssignee()); } buffer.append("');</script>"); } } } model.addAttribute("x_script", buffer.toString()); request.setAttribute("x_script", buffer.toString()); // logger.debug(buffer.toString()); } } String jx_view = request.getParameter("jx_view"); if (StringUtils.isNotEmpty(jx_view)) { return jx_view; } String view = ViewProperties.getString("activiti.view"); if (StringUtils.isNotEmpty(view)) { return view; } return "/activiti/view/view"; }
From source file:dao.CollModeratorDaoDb.java
/** * Unblock a member from collabrums/*from www. j ava 2 s . c o m*/ * @param colIdList the list of the collabrumid's * @param member member who is to be unblocked * @param userId admin of collabrum * @param userLogin login of the admin of collabrum * @throws BaseDaoException If we have a problem interpreting the data or the data is missing or incorrect */ public void unBlockMemberFromCollabrums(ArrayList colIdList, String member, String userId, String userLogin) throws BaseDaoException { if ((colIdList == null) || RegexStrUtil.isNull(userId) || RegexStrUtil.isNull(member) || RegexStrUtil.isNull(userLogin)) { throw new BaseDaoException("params are null"); } Hdlogin hdlogin = getLoginid(member); String memberId = hdlogin.getValue(DbConstants.LOGIN_ID); if (RegexStrUtil.isNull(memberId)) { throw new BaseDaoException("memberId is null"); } /** * check if this user has the permission to add the moderator - isDairyAdmin or Organizer */ for (int i = 0; i < colIdList.size(); i++) { if (!isOrganizer((String) colIdList.get(i), userLogin, userId)) { throw new BaseDaoException("User does not have permission to add moderators, collabrumId =" + colIdList.get(i) + " userId = " + userId); } } /** * Get scalability datasource for collabrum, colladmin (not partitioned) */ String sourceName = scalabilityManager.getWriteZeroScalability(); ds = scalabilityManager.getSource(sourceName); if (ds == null) { throw new BaseDaoException("ds null, unBlockMember() " + sourceName + " userId = " + userId); } Connection conn = null; try { conn = ds.getConnection(); conn.setAutoCommit(false); for (int i = 0; i < colIdList.size(); i++) { if (!isMember((String) colIdList.get(i), memberId)) { deleteBlockedMember.run(conn, (String) colIdList.get(i), memberId); } } } catch (Exception e) { try { conn.rollback(); } catch (Exception e1) { try { if (conn != null) { conn.close(); } } catch (Exception e2) { throw new BaseDaoException("conn.close() error, unBlockMember, memberid = " + memberId, e2); } throw new BaseDaoException("error occured while addModertor, memberId = " + memberId, e1); } } // connection commit try { conn.commit(); } catch (Exception e3) { throw new BaseDaoException(" commit() exception, for unBlockMember() " + "memberId = " + memberId, e3); } try { if (conn != null) { conn.setAutoCommit(true); conn.close(); } } catch (Exception e4) { throw new BaseDaoException(" conn.close() exception, for commit(), unBlockMember() " + "memberId = " + memberId + " userId = " + userId, e4); } /** Jboss methods * fqn - full qualified name * check if the userpage already set in the cache * If it exists, return the userpage from the cache. */ Fqn fqn = cacheUtil.fqn(DbConstants.MEM_AS_MODERATOR_LIST); if (treeCache.exists(fqn, member)) { treeCache.remove(fqn, member); } fqn = cacheUtil.fqn(DbConstants.MEM_AS_ORGANIZER_LIST); if (treeCache.exists(fqn, member)) { treeCache.remove(fqn, member); } fqn = cacheUtil.fqn(DbConstants.USER_PAGE); if (treeCache.exists(fqn, member)) { treeCache.remove(fqn, member); } /** * remove this from the userlogin also */ fqn = cacheUtil.fqn(DbConstants.MEM_AS_MODERATOR_LIST); if (treeCache.exists(fqn, userLogin)) { treeCache.remove(fqn, userLogin); } StringBuffer sb = new StringBuffer(); for (int i = 0; i < colIdList.size(); i++) { sb.append(colIdList.get(i)); sb.append("-"); sb.append(memberId); fqn = cacheUtil.fqn(DbConstants.ORGANIZER); if (treeCache.exists(fqn, sb.toString())) { treeCache.remove(fqn, sb.toString()); } sb.delete(0, sb.length()); fqn = cacheUtil.fqn(DbConstants.COLLABRUM); if (treeCache.exists(fqn, colIdList.get(i))) { treeCache.remove(fqn, colIdList.get(i)); } } fqn = cacheUtil.fqn(DbConstants.BLOCKED_COLLABRUM_LIST); Object obj = treeCache.get(fqn, memberId); if (treeCache.exists(fqn, memberId)) { treeCache.remove(fqn, memberId); } }
From source file:dao.CollModeratorDaoDb.java
/** * Add a member to the collabrum moderator list * @param colIdList the list of the collabrumid's * @param member member who is to be added as moderator * @param userId admin of collabrum/* w w w .ja v a 2 s . c om*/ * @param userLogin login of the admin of collabrum * @throws BaseDaoException If we have a problem interpreting the data or the data is missing or incorrect */ public void addModerator(ArrayList colIdList, String member, String userId, String userLogin) throws BaseDaoException { if ((colIdList == null) || RegexStrUtil.isNull(userId) || RegexStrUtil.isNull(member) || RegexStrUtil.isNull(userLogin)) { throw new BaseDaoException("params are null"); } Hdlogin hdlogin = getLoginid(member); String memberId = hdlogin.getValue(DbConstants.LOGIN_ID); if (RegexStrUtil.isNull(memberId)) { throw new BaseDaoException("memberId is null"); } /** * check if this user has the permission to add the moderator - diaryAdmin or Organizer */ for (int i = 0; i < colIdList.size(); i++) { if (!isOrganizer((String) colIdList.get(i), userLogin, userId)) { throw new BaseDaoException("User does not have permission to add moderators, collabrumId =" + colIdList.get(i) + " userId = " + userId); } } /** * Get scalability datasource for collabrum, colladmin (not partitioned) */ String sourceName = scalabilityManager.getWriteZeroScalability(); ds = scalabilityManager.getSource(sourceName); if (ds == null) { throw new BaseDaoException("ds null, addModerator() " + sourceName + " userId = " + userId); } Connection conn = null; try { conn = ds.getConnection(); conn.setAutoCommit(false); addModeratorQuery.run(conn, colIdList, memberId); for (int i = 0; i < colIdList.size(); i++) { if (!isMember((String) colIdList.get(i), memberId)) { deleteBlockedMember.run(conn, (String) colIdList.get(i), memberId); addMemberQuery.run(conn, (String) colIdList.get(i), memberId); } } } catch (Exception e) { try { conn.rollback(); } catch (Exception e1) { try { if (conn != null) { conn.close(); } } catch (Exception e2) { throw new BaseDaoException("conn.close() error, addModerator, memberid = " + memberId, e2); } throw new BaseDaoException("error occured while addModertor, memberId = " + memberId, e1); } } // connection commit try { conn.commit(); } catch (Exception e3) { throw new BaseDaoException(" commit() exception, for addModerator() " + "memberId = " + memberId, e3); } try { if (conn != null) { conn.setAutoCommit(true); conn.close(); } } catch (Exception e4) { throw new BaseDaoException(" conn.close() exception, for commit(), addModerator() " + "memberId = " + memberId + " userId = " + userId, e4); } /** Jboss methods * fqn - full qualified name * check if the userpage already set in the cache * If it exists, return the userpage from the cache. */ Fqn fqn = cacheUtil.fqn(DbConstants.MEM_AS_MODERATOR_LIST); if (treeCache.exists(fqn, member)) { treeCache.remove(fqn, member); } fqn = cacheUtil.fqn(DbConstants.MEM_AS_ORGANIZER_LIST); if (treeCache.exists(fqn, member)) { treeCache.remove(fqn, member); } fqn = cacheUtil.fqn(DbConstants.USER_PAGE); if (treeCache.exists(fqn, member)) { treeCache.remove(fqn, member); } /** * remove this from the userlogin also */ fqn = cacheUtil.fqn(DbConstants.MEM_AS_MODERATOR_LIST); if (treeCache.exists(fqn, userLogin)) { treeCache.remove(fqn, userLogin); } StringBuffer sb = new StringBuffer(); for (int i = 0; i < colIdList.size(); i++) { sb.append(colIdList.get(i)); sb.append("-"); sb.append(memberId); fqn = cacheUtil.fqn(DbConstants.ORGANIZER); if (treeCache.exists(fqn, sb.toString())) { treeCache.remove(fqn, sb.toString()); } sb.delete(0, sb.length()); fqn = cacheUtil.fqn(DbConstants.COLLABRUM); if (treeCache.exists(fqn, colIdList.get(i))) { treeCache.remove(fqn, colIdList.get(i)); } } fqn = cacheUtil.fqn(DbConstants.BLOCKED_COLLABRUM_LIST); Object obj = treeCache.get(fqn, memberId); if (treeCache.exists(fqn, memberId)) { treeCache.remove(fqn, memberId); } }
From source file:org.apache.roller.weblogger.business.jpa.JPARefererManagerImpl.java
/** * Generates a JPQL query of form/* w w w . j a v a 2s . c o m*/ * SELECT r FROM WeblogReferrer r WHERE * ( refererUrl like %blacklist[1] ..... OR refererUrl like %blacklist[n]) * @param blacklist * @return */ private StringBuffer getQueryStringForBlackList(String[] blacklist) { assert blacklist.length > 0; StringBuffer queryString = new StringBuffer("SELECT r FROM WeblogReferrer r WHERE ("); //Search for any matching entry from blacklist[] final String OR = " OR "; for (int i = 0; i < blacklist.length; i++) { String ignoreWord = blacklist[i]; //TODO: DataMapper port: original code use "like ignore case" as follows // or.add(Expression.ilike("refererUrl","%"+ignoreWord+"%")); // There is no equivalent for it in JPA queryString.append("r.refererUrl like '%").append(ignoreWord.trim()).append("%'").append(OR); } // Get rid of last OR queryString.delete(queryString.length() - OR.length(), queryString.length()); queryString.append(" ) "); return queryString; }
From source file:org.rapidcontext.core.proc.CallContext.java
/** * Logs the specified message to the call log with indentation. * * @param indent the indentation level * @param message the message text *///from w ww. ja va2s .co m private void logInternal(int indent, String message) { StringBuffer buffer = (StringBuffer) attributes.get(ATTRIBUTE_LOG_BUFFER); if (buffer == null) { buffer = new StringBuffer(); attributes.put(ATTRIBUTE_LOG_BUFFER, buffer); } String prefix = DateUtil.formatIsoTime(new Date()) + ": "; buffer.append(prefix); buffer.append(StringUtils.repeat(" ", indent)); buffer.append(logIndent(prefix.length() + indent, message)); buffer.append("\n"); if (buffer.length() > MAX_LOG_LENGTH) { buffer.delete(0, buffer.length() - MAX_LOG_LENGTH); } }
From source file:com.odoo.support.provider.OContentProvider.java
private Cursor createQuery(Uri uri, String[] projection, String selection, String[] selectionArgs, String sort) {//w w w. j a v a 2s. c o m reInitModel(); SQLiteQueryBuilder query = new SQLiteQueryBuilder(); boolean withAlias = (projection.length < model.projection().length); StringBuffer joins = new StringBuffer(); String base_table = model.getTableName(); String base_alias = base_table + "_base"; HashMap<String, String> projectionMap = new HashMap<String, String>(); List<String> mJoinTables = new ArrayList<String>(); for (String col_name : projection) { String col = col_name; if (col_name.contains(".")) { col = col_name.split("\\.")[0]; } OColumn column = model.getColumn(col); String display_col = col; if (withAlias) { display_col = base_alias + "." + col + " AS " + col; boolean many2oneJoin = col_name.contains("."); if (column.getRelationType() != null && many2oneJoin) { OModel rel_model = model.createInstance(column.getType()); String table = rel_model.getTableName(); String alias = table; alias = table + "_self"; table += " AS " + alias; if (!mJoinTables.contains(alias)) { mJoinTables.add(alias); joins.append(" JOIN "); joins.append(table); joins.append(" ON "); joins.append(base_alias + "." + column.getName()); joins.append(" = "); joins.append(alias + "." + OColumn.ROW_ID); joins.append(" "); } String rel_col = col; String rel_col_name = ""; if (col_name.contains(".")) { rel_col += "_" + col_name.split("\\.")[1]; rel_col_name = col_name.split("\\.")[1]; } projectionMap.put(rel_col, alias + "." + rel_col_name + " AS " + rel_col); } } projectionMap.put(col, display_col); } StringBuffer tables = new StringBuffer(); tables.append(base_table + ((withAlias) ? " AS " + base_alias : " ")); tables.append(joins.toString()); query.setTables(tables.toString()); query.setProjectionMap(projectionMap); StringBuffer whr = new StringBuffer(); String where = null; if (selection != null && selectionArgs != null) { if (withAlias) { // Check for and Pattern pattern = Pattern.compile(" and | AND "); String[] data = pattern.split(selection); StringBuffer or_string = new StringBuffer(); for (String token : data) { if (token.contains("OR") || token.contains("or")) { or_string.append(token.trim()); or_string.append(" OR "); } else { whr.append(base_alias + "." + token.trim()); whr.append(" AND "); } } if (whr.length() > 0) whr.delete(whr.length() - 5, whr.length()); // Check for or if (or_string.length() > 0) { if (whr.length() > 0) whr.append(" AND "); pattern = Pattern.compile(" or | OR "); data = pattern.split(or_string.toString()); for (String token : data) { if (!token.contains(base_alias)) { if (token.contains("(")) { whr.append("("); token = token.replaceAll("\\(", ""); whr.append(base_alias + "." + token.trim()); } else if (token.contains(")")) { token = token.replaceAll("\\)", ""); whr.append(base_alias + "." + token.trim()); whr.append(")"); } else { whr.append(base_alias + "." + token.trim()); } } else { whr.append(token.trim()); } whr.append(" OR "); } if (whr.length() > 0) whr.delete(whr.length() - 4, whr.length()); } } else { whr.append(selection); } where = whr.toString(); } Cursor c = null; int uriMatch = matcher.match(uri); switch (uriMatch) { case SINGLE_ROW: // Return a single entry, by ID. String id = uri.getLastPathSegment(); query.appendWhere(base_alias + "." + OColumn.ROW_ID + " = " + id); case COLLECTION: c = query.query(model.getReadableDatabase(), null, where, selectionArgs, null, null, sort); return c; default: throw new UnsupportedOperationException("Unknown uri: " + uri); } }
From source file:dao.DirectoryAbstractDao.java
/** * Add a new blob to a directory of blobs * Adds an empty tag entry into tag directory * Adds an entry in the images directory that is not split * (used for searching)//from w w w .j av a 2 s.c o m * User permissions are checked before the user is allowed to add it. * If the user is the author of this directory or diaryadmin, allow this user to add it. * @param List - files list * @param directoryId - directoryId * @param userLogin - userLogin * @param userId - userId * @throws BaseDaoException If we have a problem interpreting the data or * the data is missing or incorrect */ public void addStreamBlobs(List files, String directoryId, String userLogin, String userId) throws BaseDaoException { // String usertags, if ((files == null) || (RegexStrUtil.isNull(directoryId)) || (userLogin == null) || (userId == null)) { throw new BaseDaoException("params are null"); } /** * Get scalability datasource for dirblob - partitioned on directoryId */ String sourceName = scalabilityManager.getWriteBlobScalability(directoryId); ds = scalabilityManager.getSource(sourceName); if (ds == null) { throw new BaseDaoException("ds null, addStreamBlob " + sourceName); } if (!isAuthor(directoryId, userId) && !diaryAdmin.isDiaryAdmin(userLogin)) { throw new BaseDaoException("user does not have permission to add streamblobs in directory " + directoryId + " userId " + userId); } Connection conn = null; String entryId = null; for (int i = 0; i < files.size(); i++) { if (files.get(i) == null) { logger.info("files.get(" + i + ") is null"); continue; } logger.info("photo file is not null, i=" + i); long bsize = 0; int blobtype = 0; int zoom = 0; String bsizeStr = ((Photo) files.get(i)).getValue(DbConstants.BSIZE); if (!RegexStrUtil.isNull(bsizeStr)) { bsize = new Long(bsizeStr).longValue(); } String blobtypeStr = ((Photo) files.get(i)).getValue(DbConstants.BLOBTYPE); if (!RegexStrUtil.isNull(blobtypeStr)) { blobtype = new Integer(blobtypeStr).intValue(); } String mtype = ((Photo) files.get(i)).getValue(DbConstants.MIMETYPE); String btitle = ((Photo) files.get(i)).getValue(DbConstants.BTITLE); byte[] blob = ((Photo) files.get(i)).getBlob(); String zoomStr = ((Photo) files.get(i)).getValue(DbConstants.ZOOM); if (!RegexStrUtil.isNull(zoomStr)) { zoom = new Integer(zoomStr).intValue(); } String caption = ((Photo) files.get(i)).getValue(DbConstants.CAPTION); if ((bsize <= 0) || RegexStrUtil.isNull(mtype) || RegexStrUtil.isNull(btitle)) { throw new BaseDaoException("params are null"); } logger.info("bsize=" + bsize + " mtype=" + mtype + " btitle=" + btitle); if (RegexStrUtil.isNull(caption)) { caption = btitle; } try { conn = ds.getConnection(); if (conn == null) { throw new BaseDaoException("conn is null"); } conn.setAutoCommit(false); if (WebUtil.isSanEnabled()) { byte[] noBlobData = { ' ' }; logger.info("noblobdata " + directoryId + " userId=" + userId); addStreamBlobQuery.run(conn, noBlobData, blobtype, mtype, btitle, bsize, zoom, directoryId, userId, caption); } else { logger.info("blobdata"); addStreamBlobQuery.run(conn, blob, blobtype, mtype, btitle, bsize, zoom, directoryId, userId, caption); } logger.info("came here addTagQuery"); addTagQuery.run(conn, directoryId, "", "LAST_INSERT_ID()"); logger.info("completed addTagQuery"); boolean convertEntryId = false; addImageQuery.run(conn, "", blobtype, mtype, btitle, bsize, zoom, directoryId, userId, caption, convertEntryId); logger.info("completed addImageQuery"); } catch (Exception e) { logger.info("errorMsg=" + e.getMessage()); try { conn.rollback(); } catch (Exception e1) { logger.info("errorMsg e1=" + e1.getMessage()); try { if (conn != null) { conn.setAutoCommit(true); conn.close(); } } catch (Exception e2) { throw new BaseDaoException( "conn.close() error, addStreamBlob()/addTagQuery/addImageQuery, userId=" + userId + " ErrorMsg=" + e2.getMessage(), e2); } throw new BaseDaoException( " rollback() exception, for addStreamBlob()/addTagQuery()/addImageQuery(), userId = " + userId + " ErrorMsg=" + e1.getMessage(), e1); } throw new BaseDaoException("addStreamBlob()/addTagQuery()/addImageQuery exception, userId = " + userId + " ErrorMsg=" + e.getMessage(), e); } /* * connection commit */ try { conn.commit(); } catch (Exception e3) { throw new BaseDaoException( " commit() exception, for addStreamBlob()/addImageQuery/addTagQuery, userId = " + userId + " ErrorMsg = " + e3.getMessage(), e3); } try { if (conn != null) { conn.setAutoCommit(true); conn.close(); } } catch (Exception e4) { throw new BaseDaoException( " conn.close() exception, for commit(), addStreamBlob()/addTagQuery/addImageQuery userId = " + userId + " ErrorMsg = " + e4.getMessage(), e4); } /** * get stream blobs for a directory from cache, if it exists */ Fqn fqn = cacheUtil.fqn(DbConstants.DIRECTORY_STREAM_BLOBS); if (treeCache.exists(fqn, directoryId)) { treeCache.remove(fqn, directoryId); } fqn = cacheUtil.fqn(DbConstants.RECENT_DIR_IMAGES); if (treeCache.exists(fqn, DbConstants.RECENT_DIR_IMAGES)) { treeCache.remove(fqn, DbConstants.RECENT_DIR_IMAGES); } fqn = cacheUtil.fqn(DbConstants.DIR_CAT); StringBuffer sb = new StringBuffer(directoryId); sb.append("-"); sb.append(DbConstants.PHOTO_CATEGORY); if (treeCache.exists(fqn, sb.toString())) { treeCache.remove(fqn, sb.toString()); } sb.delete(0, sb.length()); sb.append(directoryId); sb.append("-"); sb.append(DbConstants.FILE_CATEGORY); fqn = cacheUtil.fqn(DbConstants.DIR_CAT); if (treeCache.exists(fqn, sb.toString())) { treeCache.remove(fqn, sb.toString()); } fqn = cacheUtil.fqn(DbConstants.DIRECTORY); if (treeCache.exists(fqn, directoryId)) { treeCache.remove(fqn, directoryId); } } }
From source file:org.mifosplatform.organisation.dsa.service.DsaReadPlatformServiceImpl.java
private String getDsaCriteria(final String sqlSearch, final Long officeId, final boolean activeOnly, final String status) { final StringBuffer extraCriteria = new StringBuffer(200); if (sqlSearch != null) { extraCriteria.append(" and (").append(sqlSearch).append(")"); }//from w w w . j av a 2 s . co m if (officeId != null) { extraCriteria.append(" and office_id = ").append(officeId).append(" "); } if (activeOnly) { extraCriteria.append(" and s.is_active is true "); } // Passing status parameter to get ACTIVE (By Default), INACTIVE or ALL // (Both active and Inactive) employees if (status.equalsIgnoreCase("active")) { extraCriteria.append(" and is_active = 1 "); } else if (status.equalsIgnoreCase("inActive")) { extraCriteria.append(" and is_active = 0 "); } else if (status.equalsIgnoreCase("all")) { } else { throw new UnrecognizedQueryParamException("status", status, new Object[] { "all", "active", "inactive" }); } if (StringUtils.isNotBlank(extraCriteria.toString())) { extraCriteria.delete(0, 4); } // remove begin four letter including a space from the string. return extraCriteria.toString(); }
From source file:stg.pr.engine.startstop.CStartEngine.java
/** * Command builder./*w w w. java 2 s . c o m*/ * * @param extraCommands * if any * @param args * Program arguments for PRE. * @return Command */ public String[] buildCommand(ArrayList<String> extraCommands, String[] args) { long lCurrentTimestamp = System.currentTimeMillis(); ArrayList<String> commandBuilder = new ArrayList<String>(); if (logger_.isEnabledFor(LogLevel.FINER)) { logger_.log(LogLevel.FINER, "Building command."); } commandBuilder.add(System.getProperty("java.home") + FILE_SEPARATOR + "bin" + FILE_SEPARATOR + "java"); if (CSettings.get("pr.javaruntimevmargs", null) != null) { // following code is to handle the space delimiter within double // quotes. Example value for this property // can be =-Xms128M -Xmx128M -D.pre.home="/u0201/apps/stg pre" StringCharacterIterator sci = new java.text.StringCharacterIterator( CSettings.get("pr.javaruntimevmargs")); boolean bEscapeCharacter = false; boolean bQuoted = false; StringBuffer cmdBuffer = new StringBuffer(); for (char c = sci.first(); c != CharacterIterator.DONE; c = sci.next()) { switch (c) { case '\\': if (bEscapeCharacter) { cmdBuffer.append(c + "" + c); bEscapeCharacter = false; } else { bEscapeCharacter = true; } break; case ' ': if (!bQuoted) { commandBuilder.add(cmdBuffer.toString()); cmdBuffer.delete(0, cmdBuffer.length()); } else { cmdBuffer.append(c); } bEscapeCharacter = false; break; case '"': if (!bEscapeCharacter) { if (!bQuoted) { bQuoted = true; } else { bQuoted = false; } } bEscapeCharacter = false; break; default: cmdBuffer.append(c); break; } // end of switch case. } // end for string character iterator if (cmdBuffer.length() > 0) { commandBuilder.add(cmdBuffer.toString()); } } // pr.javaruntimevmarg != null if (extraCommands != null) { if (logger_.isEnabledFor(LogLevel.FINEST)) { logger_.log(LogLevel.FINEST, "Adding extra commands if any."); } commandBuilder.addAll(extraCommands); } if (logger_.isEnabledFor(LogLevel.FINER)) { logger_.log(LogLevel.FINER, "Adding constants."); } commandBuilder.add("-classpath"); String classpath = ""; // if (CSettings.get("pr.reportService","OFF").equalsIgnoreCase("ON")) { // File directory = new File(CSettings.get("pr.birt.home") + "/lib"); // if (!directory.exists()) { // throw new IllegalArgumentException("Directory is non-existant. Check property birt.home " + CSettings.getInstance().getSource("pr").getConfigFile().getAbsolutePath()); // } // ArrayList<String> list = new ArrayList<String>(); // list.add(".jar"); // list.add(".zip"); // classpath = getExtraClasspath(directory, list); // System.out.println(classpath); // } if (CSettings.get("pr.javaextraclasspath", null) != null) { commandBuilder.add(System.getProperty("java.class.path") + File.pathSeparatorChar + CSettings.get("pr.javaextraclasspath") + File.pathSeparatorChar + classpath); } else { commandBuilder.add(System.getProperty("java.class.path") + File.pathSeparatorChar + classpath); } commandBuilder.add("stg.pr.engine.CProcessRequestEngine"); commandBuilder.add(args[0]); commandBuilder.add(args[1]); String[] cmd = new String[commandBuilder.size()]; commandBuilder.toArray(cmd); if (logger_.isEnabledFor(LogLevel.FINEST)) { logger_.log(LogLevel.FINEST, "Command " + commandBuilder); logger_.log(LogLevel.FINEST, "Elapsed Time taken to build command " + (System.currentTimeMillis() - lCurrentTimestamp) + " ms."); } return cmd; }