List of usage examples for java.lang NumberFormatException getMessage
public String getMessage()
From source file:com.sfs.whichdoctor.search.sql.ReimbursementSqlHandler.java
/** * Construct the SQL string, description and parameters. * * @param objCriteria Object containing search criteria values * @param objConstraints Object containing search constraint values * * @return Map containing a String[] { sql, description } => * Collection< Object > parameters * * @throws IllegalArgumentException the illegal argument exception */// w w w.j a v a2 s . c o m public final Map<String[], Collection<Object>> construct(final Object objCriteria, final Object objConstraints) throws IllegalArgumentException { ReimbursementBean searchCriteria = null; ReimbursementBean searchConstraints = null; if (objCriteria instanceof ReimbursementBean) { searchCriteria = (ReimbursementBean) objCriteria; } if (objConstraints instanceof ReimbursementBean) { searchConstraints = (ReimbursementBean) objConstraints; } if (searchCriteria == null) { throw new IllegalArgumentException("The search criteria must be a " + "valid ReimbursementBean"); } if (searchConstraints == null) { throw new IllegalArgumentException("The search constraints must be " + "a valid ReimbursementBean"); } StringBuffer sqlWHERE = new StringBuffer(); StringBuffer description = new StringBuffer(); Collection<Object> parameters = new ArrayList<Object>(); if (searchCriteria.getTags() != null) { try { for (TagBean tag : searchCriteria.getTags()) { Map<String[], Collection<Object>> results = this.tagSearchDAO.construct(tag, new TagBean()); for (String[] index : results.keySet()) { String tagWHERE = index[0]; String tagDescription = index[1]; Collection<Object> tagParameters = results.get(index); if (tagWHERE.compareTo("") != 0) { /* A WHERE condition is defined */ sqlWHERE.append(" " + this.getSQL().getValue("reimbursement/searchTags") + " WHERE " + tagWHERE + ")"); /* Add to the description and process the arrays */ description.append(tagDescription); if (tagParameters != null) { parameters.addAll(tagParameters); } } } } } catch (Exception e) { dataLogger.error("Error setting tag search options: " + e.getMessage()); } } if (searchCriteria.getBasicSearch() != null) { if (searchCriteria.getBasicSearch().compareTo("") != 0) { String searchString = searchCriteria.getBasicSearch().trim(); int basicSearch = 0; try { basicSearch = Integer.parseInt(searchCriteria.getBasicSearch()); } catch (NumberFormatException nfe) { dataLogger.debug("Error parsing BasicSearch: " + nfe.getMessage()); } if (basicSearch == 0) { // If the search string has : in the first ten characters // the financial // abbreviation is probably included - strip it out for // search purposes if (searchString.indexOf(": ") > 3 && searchString.indexOf(": ") < 10) { searchString = searchString.substring(3, searchString.length()); } String field = "%" + searchString + "%"; sqlWHERE.append(" AND (concat(reimbursement.ReimbursementNo, ': ', " + "reimbursement.Description) LIKE ?)"); description.append( " and a reimbursement description like '" + searchCriteria.getBasicSearch() + "'"); parameters.add(field); } else { sqlWHERE.append(" AND (reimbursement.ReimbursementNo LIKE ?)"); description.append(" and a reimbursement number of '" + searchCriteria.getBasicSearch() + "'"); parameters.add("%" + searchCriteria.getBasicSearch()); } } } if (searchCriteria.getNumber() != null) { boolean SearchConstraints = false; if (searchCriteria.getNumber().compareTo("") != 0) { if (searchConstraints.getNumber() != null) { if (searchConstraints.getNumber().compareTo("") != 0) { SearchConstraints = true; } } if (SearchConstraints) { if (searchConstraints.getNumber().compareTo("-") == 0) { // Less than Reimbursement specified sqlWHERE.append(" AND reimbursment.ReimbursementNo <= ?"); description.append( " and a reimbursement number less than '" + searchCriteria.getNumber() + "'"); parameters.add(searchCriteria.getNumber()); } else if (searchConstraints.getNumber().compareTo("+") == 0) { // Greater then Reimbursement specified sqlWHERE.append(" AND reimbursement.ReimbursementNo >= ?"); description.append( " and a reimbursement number greater than '" + searchCriteria.getNumber() + "'"); parameters.add(searchCriteria.getNumber()); } else { // Range between a and b - find whether greater than or // less than. int intA = 0; int intB = 0; try { intA = Integer.parseInt(searchCriteria.getNumber()); } catch (NumberFormatException nfe) { dataLogger.debug("Error parsing ReimbursementNo: " + nfe.getMessage()); } try { intB = Integer.parseInt(searchConstraints.getNumber()); } catch (NumberFormatException nfe) { dataLogger.debug("Error parsing ReimbursementNo: " + nfe.getMessage()); } if (intA == intB) { // criteria A and B are the same sqlWHERE.append(" AND reimbursement.ReimbursementNo LIKE ?"); description .append(" and a reimbursement number of '" + searchCriteria.getNumber() + "'"); parameters.add("%" + searchCriteria.getNumber()); } if (intA < intB) { // criteria A is less than B sqlWHERE.append(" AND reimbursement.ReimbursementNo BETWEEN ? AND ?"); description.append(" and a reimbursement number between '" + searchCriteria.getNumber() + "' and '" + searchConstraints.getNumber() + "'"); parameters.add(searchCriteria.getNumber()); parameters.add(searchConstraints.getNumber()); } if (intA > intB) { // Criteria A is greater than B sqlWHERE.append(" AND reimbursement.ReimbursementNo BETWEEN ? AND ?"); description.append(" and a reimbursement number between '" + searchConstraints.getNumber() + "' and '" + searchCriteria.getNumber() + "'"); parameters.add(searchConstraints.getNumber()); parameters.add(searchCriteria.getNumber()); } } } else { sqlWHERE.append(" AND reimbursement.ReimbursementNo LIKE ?"); description.append(" and a reimbursement number of '" + searchCriteria.getNumber() + "'"); parameters.add("%" + searchCriteria.getNumber()); } } } if (searchCriteria.getGUIDList() != null) { final StringBuffer guidWHERE = new StringBuffer(); for (String guid : searchCriteria.getGUIDList()) { if (StringUtils.isNotBlank(guid)) { guidWHERE.append(" OR reimbursement.GUID = ?"); parameters.add(guid); } } if (guidWHERE.length() > 0) { // Append the guidWHERE buffer to the sqlWHERE buffer sqlWHERE.append(" AND ("); // Append the guidWHERE but strip the first OR statement sqlWHERE.append(guidWHERE.toString().substring(4)); sqlWHERE.append(")"); description.append(" and has a GUID in the supplied list"); } } if (searchCriteria.getIdentifierList() != null) { final StringBuffer identifierWHERE = new StringBuffer(); for (String identifier : searchCriteria.getIdentifierList()) { if (StringUtils.isNotBlank(identifier)) { identifierWHERE.append(" OR reimbursement.ReimbursementNo LIKE ?"); parameters.add("%" + identifier); } } if (identifierWHERE.length() > 0) { // Append the identifierWHERE buffer to the sqlWHERE buffer sqlWHERE.append(" AND ("); // Append the identifierWHERE but strip the first OR statement sqlWHERE.append(identifierWHERE.toString().substring(4)); sqlWHERE.append(")"); description.append(" and has a reimbursement number " + "in the supplied list"); } } if (searchCriteria.getPersonId() > 0) { sqlWHERE.append(" AND reimbursement.PersonId = ?"); description.append(" and person GUID equal to '" + searchCriteria.getPersonId() + "'"); parameters.add(searchCriteria.getPersonId()); } if (searchCriteria.getOrganisationId() > 0) { sqlWHERE.append(" AND reimbursement.OrganisationId = ?"); description.append(" and organisation GUID equal to '" + searchCriteria.getOrganisationId() + "'"); parameters.add(searchCriteria.getOrganisationId()); } if (searchCriteria.getCancelled()) { if (searchConstraints.getCancelled()) { // Only cancelled sqlWHERE.append(" AND reimbursement.Cancelled = true"); description.append(" and the reimbursement is cancelled"); } } else { if (!searchConstraints.getCancelled()) { // Only active sqlWHERE.append(" AND reimbursement.Cancelled = false"); description.append(" and the reimbursement is not cancelled"); } } if (searchCriteria.getClassName() != null) { if (searchCriteria.getClassName().compareTo("") != 0) { sqlWHERE.append(" AND financialtype.Class LIKE ?"); description.append(" and a reimbursement class like '" + searchCriteria.getClassName() + "'"); parameters.add("%" + searchCriteria.getClassName() + "%"); } } if (searchCriteria.getTypeName() != null) { if (searchCriteria.getTypeName().compareTo("") != 0) { sqlWHERE.append(" AND financialtype.Name LIKE ?"); description.append(" and a reimbursement type like '" + searchCriteria.getTypeName() + "'"); parameters.add("%" + searchCriteria.getTypeName() + "%"); } } if (searchCriteria.getDescription() != null) { if (searchCriteria.getDescription().compareTo("") != 0) { if (searchCriteria.getDescription().indexOf("\"") > -1) { // Description contains "" so treat as a specific search sqlWHERE.append(" AND reimbursement.Description LIKE ?"); description.append( " and a reimbursement description like '" + searchCriteria.getDescription() + "'"); parameters.add(StringUtils.replace(searchCriteria.getDescription(), "\"", "")); } else { sqlWHERE.append(" AND reimbursement.Description LIKE ?"); description.append( " and a reimbursement description like '" + searchCriteria.getDescription() + "'"); parameters.add("%" + searchCriteria.getDescription() + "%"); } } } if (searchCriteria.getLocation() != null) { if (searchCriteria.getLocation().compareTo("") != 0) { if (searchCriteria.getLocation().indexOf("\"") > -1) { // Location contains "" so treat as a specific search sqlWHERE.append(" AND reimbursement.Location LIKE ?"); description.append(" and a location like '" + searchCriteria.getLocation() + "'"); parameters.add(StringUtils.replace(searchCriteria.getLocation(), "\"", "")); } else { sqlWHERE.append(" AND reimbursement.Location LIKE ?"); description.append(" and a location like '" + searchCriteria.getLocation() + "'"); parameters.add("%" + searchCriteria.getLocation() + "%"); } } } if (searchCriteria.getSecurity() != null) { if (searchCriteria.getSecurity().compareTo("") != 0) { sqlWHERE.append(" AND financialtype.Security = ?"); description.append(" and a security setting of '" + searchCriteria.getSecurity() + "'"); parameters.add(searchCriteria.getSecurity()); } } // Other searches: cancelled, date issued. if (searchCriteria.getIssued() != null) { if (searchConstraints.getIssued() != null) { int larger = searchCriteria.getIssued().compareTo(searchConstraints.getIssued()); if (larger > 0) { // SearchCriteria date after SearchConstraint date String fieldA = this.getDf().format(searchCriteria.getIssued()); String fieldB = this.getDf().format(searchConstraints.getIssued()); sqlWHERE.append(" AND reimbursement.Issued BETWEEN ? AND ?"); description.append(" and issued between '" + fieldB + "' and '" + fieldA + "'"); parameters.add(fieldB); parameters.add(fieldA); } if (larger < 0) { // SearchCriteria date before SearchConstraint date String fieldA = this.getDf().format(searchCriteria.getIssued()); String fieldB = this.getDf().format(searchConstraints.getIssued()); sqlWHERE.append(" AND reimbursement.Issued BETWEEN ? AND ?"); description.append(" and issued between '" + fieldA + "' and '" + fieldB + "'"); parameters.add(fieldA); parameters.add(fieldB); } if (larger == 0) { // SearchCritier and SearchConstraint are equal String field = this.getDf().format(searchCriteria.getIssued()); sqlWHERE.append(" AND reimbursement.Issued = ?"); description.append(" and issued on '" + field + "'"); parameters.add(field); } } else { String field = this.getDf().format(searchCriteria.getIssued()); sqlWHERE.append(" AND reimbursement.Issued = ?"); description.append(" and issued on '" + field + "'"); parameters.add(field); } } if (searchCriteria.getMeetingDate() != null) { if (searchConstraints.getMeetingDate() != null) { int larger = searchCriteria.getMeetingDate().compareTo(searchConstraints.getMeetingDate()); if (larger > 0) { // SearchCriteria date after SearchConstraint date String fieldA = this.getDf().format(searchCriteria.getMeetingDate()); String fieldB = this.getDf().format(searchConstraints.getMeetingDate()); sqlWHERE.append(" AND reimbursement.MeetingDate BETWEEN ? AND ?"); description.append(" and a meeting between '" + fieldB + "' and '" + fieldA + "'"); parameters.add(fieldB); parameters.add(fieldA); } if (larger < 0) { // SearchCriteria date before SearchConstraint date String fieldA = this.getDf().format(searchCriteria.getMeetingDate()); String fieldB = this.getDf().format(searchConstraints.getMeetingDate()); sqlWHERE.append(" AND reimbursement.MeetingDate BETWEEN ? AND ?"); description.append(" and a meeting between '" + fieldA + "' and '" + fieldB + "'"); parameters.add(fieldA); parameters.add(fieldB); } if (larger == 0) { // SearchCritier and SearchConstraint are equal String field = this.getDf().format(searchCriteria.getMeetingDate()); sqlWHERE.append(" AND reimbursement.MeetingDate = ?"); description.append(" and a meeting on '" + field + "'"); parameters.add(field); } } else { String field = this.getDf().format(searchCriteria.getMeetingDate()); sqlWHERE.append(" AND reimbursement.MeetingDate = ?"); description.append(" and a meeting on '" + field + "'"); parameters.add(field); } } if (searchCriteria.getCreatedDate() != null) { if (searchConstraints.getCreatedDate() != null) { int larger = searchCriteria.getCreatedDate().compareTo(searchConstraints.getCreatedDate()); if (larger > 0) { // SearchCriteria date after SearchConstraint date String fieldA = this.getDf().format(searchCriteria.getCreatedDate()); String fieldB = this.getDf().format(searchConstraints.getCreatedDate()); sqlWHERE.append(" AND guid.CreatedDate BETWEEN ? AND ?"); description.append(" and created between '" + fieldB + "' and '" + fieldA + "'"); parameters.add(fieldB); parameters.add(fieldA); } if (larger < 0) { // SearchCriteria date before SearchConstraint date String fieldA = this.getDf().format(searchCriteria.getCreatedDate()); String fieldB = this.getDf().format(searchConstraints.getCreatedDate()); sqlWHERE.append(" AND guid.CreatedDate BETWEEN ? AND ?"); description.append(" and created between '" + fieldB + "' and '" + fieldA + "'"); parameters.add(fieldA); parameters.add(fieldB); } if (larger == 0) { // SearchCritier and SearchConstraint are equal String field = this.getDf().format(searchCriteria.getCreatedDate()); sqlWHERE.append(" AND guid.CreatedDate = ?"); description.append(" and created on '" + field + "'"); parameters.add(field); } } else { String field = this.getDf().format(searchCriteria.getCreatedDate()); sqlWHERE.append(" AND guid.CreatedDate = ?"); description.append(" and created on '" + field + "'"); parameters.add(field); } } if (searchCriteria.getModifiedDate() != null) { if (searchConstraints.getModifiedDate() != null) { int larger = searchCriteria.getModifiedDate().compareTo(searchConstraints.getModifiedDate()); if (larger > 0) { // SearchCriteria date after SearchConstraint date String fieldA = this.getDf().format(searchCriteria.getModifiedDate()); String fieldB = this.getDf().format(searchConstraints.getModifiedDate()); sqlWHERE.append(" AND guid.ModifiedDate BETWEEN ? AND ?"); description.append(" and modified between '" + fieldB + "' and '" + fieldA + "'"); parameters.add(fieldB); parameters.add(fieldA); } if (larger < 0) { // SearchCriteria date before SearchConstraint date String fieldA = this.getDf().format(searchCriteria.getModifiedDate()); String fieldB = this.getDf().format(searchConstraints.getModifiedDate()); sqlWHERE.append(" AND guid.ModifiedDate BETWEEN ? AND ?"); description.append(" and modified between '" + fieldB + "' and '" + fieldA + "'"); parameters.add(fieldA); parameters.add(fieldB); } if (larger == 0) { // SearchCritier and SearchConstraint are equal String field = this.getDf().format(searchCriteria.getModifiedDate()); sqlWHERE.append(" AND guid.ModifiedDate = ?"); description.append(" and modified on '" + field + "'"); parameters.add(field); } } else { String field = this.getDf().format(searchCriteria.getModifiedDate()); sqlWHERE.append(" AND guid.ModifiedDate = ?"); description.append(" and modified on '" + field + "'"); parameters.add(field); } } if (searchCriteria.getIncludeGUIDList() != null) { final StringBuffer guidWHERE = new StringBuffer(); for (String guid : searchCriteria.getIncludeGUIDList()) { if (StringUtils.isNotBlank(guid)) { guidWHERE.append(" OR reimbursement.GUID = ?"); parameters.add(guid); } } if (guidWHERE.length() > 0) { // Append the guidWHERE buffer to the sqlWHERE buffer sqlWHERE.append(" OR ("); // Append the guidWHERE but strip the first OR statement sqlWHERE.append(guidWHERE.toString().substring(4)); sqlWHERE.append(")"); description.append(" and has a GUID in the supplied list"); } } String[] index = new String[] { sqlWHERE.toString(), DataFilter.getHtml(description.toString()) }; Map<String[], Collection<Object>> results = new HashMap<String[], Collection<Object>>(); results.put(index, parameters); return results; }
From source file:de.interactive_instruments.ShapeChange.Target.ReplicationSchema.ReplicationXmlSchema.java
/** Process a single property. */ protected Element addProperty(PropertyInfo pi) { ClassInfo inClass = pi.inClass();//from w w w . ja v a 2 s.co m Element e1 = document.createElementNS(Options.W3C_XML_SCHEMA, "element"); addGlobalIdentifierAnnotation(e1, pi); String piName = pi.name(); if (pi.categoryOfValue() == Options.FEATURE) { piName = pi.name() + suffixForPropWithFeatureValueType; } else if (pi.categoryOfValue() == Options.OBJECT) { piName = pi.name() + suffixForPropWithObjectValueType; } addAttribute(e1, "name", piName); mapPropertyType(pi, e1); addMinMaxOccurs(e1, pi); // add maxLength restriction if applicable ProcessMapEntry pme = mapEntryByType.get(pi.typeInfo().name); if (pme != null && pme.hasParam() && pme.getParam().trim().equals(MAP_ENTRY_PARAM_MAXLENGTHFROMSIZE)) { int size = -1; if (pi.taggedValue(TV_SIZE) != null && pi.taggedValue(TV_SIZE).trim().length() > 0) { try { size = Integer.parseInt(pi.taggedValue(TV_SIZE).trim()); } catch (NumberFormatException e) { result.addWarning(this, 14, TV_SIZE, pi.name(), inClass.name(), e.getMessage()); } } if (size <= 0 && this.defaultSize != null) { size = this.defaultSize; } if (size > 0) { Element simpleType = document.createElementNS(Options.W3C_XML_SCHEMA, "simpleType"); e1.appendChild(simpleType); Element restriction = document.createElementNS(Options.W3C_XML_SCHEMA, "restriction"); addAttribute(restriction, "base", "string"); e1.removeAttribute("type"); simpleType.appendChild(restriction); Element concreteRestriction = document.createElementNS(Options.W3C_XML_SCHEMA, "maxLength"); addAttribute(concreteRestriction, "value", "" + size); restriction.appendChild(concreteRestriction); } } return e1; }
From source file:org.apache.manifoldcf.authorities.authorities.sharepoint.SharePointADAuthority.java
/** Get parameters needed for caching. */// w w w . jav a 2s .c o m protected void getSessionParameters() throws ManifoldCFException { if (!hasSessionParameters) { try { responseLifetime = Long.parseLong(this.cacheLifetime) * 60L * 1000L; LRUsize = Integer.parseInt(this.cacheLRUsize); } catch (NumberFormatException e) { throw new ManifoldCFException( "Cache lifetime or Cache LRU size must be an integer: " + e.getMessage(), e); } hasSessionParameters = true; } }
From source file:com.hdfs.concat.crush.CrushTest.java
@Test public void backwardsCompatibleInvocationBadNumberOfTasks() throws Exception { try {//from w w w . ja v a 2 s. c o m run(tmp.newFolder("in").getAbsolutePath(), tmp.newFolder("out").getAbsolutePath(), "not a number"); fail(); } catch (NumberFormatException e) { if (!e.getMessage().contains("not a number")) { throw e; } } }
From source file:com.hdfs.concat.crush.CrushTest.java
@Test public void backwardsCompatibleInvocationBadNumberOfTasksWithType() throws Exception { try {//from w ww . j a v a2 s .co m run(tmp.newFolder("in").getAbsolutePath(), tmp.newFolder("out").getAbsolutePath(), "not a number", "TEXT"); fail(); } catch (NumberFormatException e) { if (!e.getMessage().contains("not a number")) { throw e; } } }
From source file:com.hotstar.player.adplayer.feeds.ReferencePlayerFeedItemAdapter.java
protected VideoAnalyticsMetadata parseVideoAnalyticsMetadata(JSONObject jsonObject) throws JSONException { VideoAnalyticsMetadata videoAnalyticsMetadata = new VideoAnalyticsMetadata(); if (jsonObject != null) { if (jsonObject.has(NODE_NAME_VA_VIDEO_ID)) { videoAnalyticsMetadata.setVideoId(jsonObject.getString(NODE_NAME_VA_VIDEO_ID)); }/*from w w w .ja v a2 s. c o m*/ if (jsonObject.has(NODE_NAME_VA_VIDEO_NAME)) { videoAnalyticsMetadata.setVideoName(jsonObject.getString(NODE_NAME_VA_VIDEO_NAME)); } if (jsonObject.has(NODE_NAME_VA_VIDEO_CHAPTERS)) { JSONArray chapters = jsonObject.getJSONArray(NODE_NAME_VA_VIDEO_CHAPTERS); if (chapters.length() > 0) { List<VideoAnalyticsChapterData> va_chapters = new ArrayList<VideoAnalyticsChapterData>(); for (int i = 0; i < chapters.length(); i++) { JSONObject chapter = chapters.getJSONObject(i); if (chapter.has(NODE_NAME_VA_VIDEO_CHAPTER_START) && chapter.has(NODE_NAME_VA_VIDEO_CHAPTER_END)) { try { Long startTime = Long .parseLong(chapter.getString(NODE_NAME_VA_VIDEO_CHAPTER_START)); Long endTime = Long.parseLong(chapter.getString(NODE_NAME_VA_VIDEO_CHAPTER_END)); VideoAnalyticsChapterData va_chapter = new VideoAnalyticsChapterData(startTime, endTime); if (chapter.has(NODE_NAME_VA_VIDEO_CHAPTER_NAME)) { String name = chapter.getString(NODE_NAME_VA_VIDEO_CHAPTER_NAME); va_chapter.setName(name); } va_chapters.add(va_chapter); } catch (NumberFormatException e) { AdVideoApplication.logger.e(LOG_TAG + "::parseVideoAnalyticsMetadata", e.getMessage()); } } } if (!va_chapters.isEmpty()) { videoAnalyticsMetadata.setChapters(va_chapters); } } } if (jsonObject.has(NODE_NAME_VA_PLAY_NAME)) { videoAnalyticsMetadata.setPlayName(jsonObject.getString(NODE_NAME_VA_PLAY_NAME)); } if (jsonObject.has(NODE_NAME_VA_ENABLE_CHAPTER_TRACKING)) { videoAnalyticsMetadata.setEnableChapterTracking( NumberUtils.parseBoolean(jsonObject.getString(NODE_NAME_VA_ENABLE_CHAPTER_TRACKING))); } } return videoAnalyticsMetadata; }
From source file:com.sfs.whichdoctor.webservice.RotationServiceImpl.java
/** * Parses the person identifiers.//from w w w . j a va 2 s. com * * @param personIdentifiers the person identifiers * @return the list */ private List<Integer> parseIdentifiers(final String personIdentifiers) { List<Integer> identifiers = new ArrayList<Integer>(); StringTokenizer tk = new StringTokenizer(personIdentifiers, ","); while (tk.hasMoreTokens()) { String token = tk.nextToken(); int identifier = 0; try { String value = StringUtils.replace(token, "\"", ""); value = StringUtils.replace(value, "'", ""); identifier = Integer.parseInt(value.trim()); } catch (NumberFormatException nfe) { logger.info("Error parsing person identifier: " + nfe.getMessage()); } if (identifier > 0) { identifiers.add(identifier); } } return identifiers; }
From source file:fr.paris.lutece.plugins.rss.web.RssJspBean.java
/** * Modification of a push RSS file/*w w w . ja v a2s. co m*/ * * @return The Jsp URL of the process result * @param request requete Http */ public String doModifyRssFilePortlet(HttpServletRequest request) { // Recovery of parameters processing if (request.getParameter(PARAMETER_CANCEL) != null) { return getHomeUrl(request); } String strRssFileId = request.getParameter(PARAMETER_PUSH_RSS_ID); String strWorkgroup = request.getParameter(PARAMETER_WORKGROUP_KEY); String strMaxItems = request.getParameter(PARAMETER_PUSH_RSS_MAX_ITEMS); String strEncoding = request.getParameter(PARAMETER_PUSH_RSS_ENCODING); String strFeedType = request.getParameter(PARAMETER_PUSH_RSS_FEED_TYPE); int nRssFileId = Integer.parseInt(strRssFileId); String strPortletId = request.getParameter(PARAMETER_PUSH_RSS_PORTLET_ID); if ((strPortletId == null) || !strPortletId.matches(REGEX_ID)) { return AdminMessageService.getMessageUrl(request, MESSAGE_NO_DOCUMENT_PORTLET, AdminMessage.TYPE_STOP); } if (StringUtils.isBlank(strFeedType)) { return AdminMessageService.getMessageUrl(request, MESSAGE_NO_FEED_TYPE, AdminMessage.TYPE_STOP); } if (!getFeedTypes().contains(strFeedType)) { return AdminMessageService.getMessageUrl(request, MESSAGE_NO_FEED_TYPE, AdminMessage.TYPE_STOP); } if (StringUtils.isBlank(strEncoding)) { return AdminMessageService.getMessageUrl(request, MESSAGE_NO_ENCODING, AdminMessage.TYPE_STOP); } int nMaxItems; if (StringUtils.isBlank(strMaxItems)) { nMaxItems = 0; } else { try { nMaxItems = Integer.parseInt(strMaxItems); } catch (NumberFormatException nfe) { AppLogService.error(nfe.getMessage(), nfe); return AdminMessageService.getMessageUrl(request, MESSAGE_MAX_ITEMS, AdminMessage.TYPE_STOP); } } int nPortletId = Integer.parseInt(strPortletId); String strRssFileName = request.getParameter(PARAMETER_PUSH_RSS_NAME); String strRssFileDescription = request.getParameter(PARAMETER_PUSH_RSS_DESCRIPTION); RssGeneratedFile rssFile = new RssGeneratedFile(); rssFile.setPortletId(nPortletId); rssFile.setId(nRssFileId); rssFile.setName(strRssFileName); rssFile.setState(STATE_OK); rssFile.setWorkgroup(strWorkgroup); rssFile.setDescription(strRssFileDescription); rssFile.setMaxItems(nMaxItems); rssFile.setFeedType(strFeedType); rssFile.setEncoding(strEncoding); // Update the database with the new push RSS file RssGeneratedFileHome.update(rssFile); // Check if the portlet does exist if (!RssGeneratedFileHome.checkRssFilePortlet(nPortletId)) { rssFile.setState(STATE_PORTLET_MISSING); } // Format the new file name strRssFileName = UploadUtil.cleanFileName(strRssFileName); // Call the create xml document method String strRssDocument = RssGeneratorService.createRssDocument(nPortletId, rssFile.getDescription(), rssFile.getEncoding(), rssFile.getFeedType(), rssFile.getMaxItems(), request); // Call the create file method RssGeneratorService.createFileRss(strRssFileName, strRssDocument); // Update the push Rss object in the database RssGeneratedFileHome.update(rssFile); // Display the page of publishing return getHomeUrl(request); }
From source file:edu.gsgp.experiment.config.PropertiesManager.java
/** * Load a boolean property from the file. * * @param key The name of the property// w ww . j a va 2s. c o m * @param defaultValue The default value for this property * @return The value loaded from the file or the default value, if it is not * specified in the file. * @throws NumberFormatException The loaded value can not be converted to * boolean * @throws NullPointerException The parameter file was not initialized * @throws MissingOptionException The parameter is mandatory and it was not * found in the parameter file. */ private boolean getBooleanProperty(ParameterList key, boolean defaultValue) throws NumberFormatException, NullPointerException, MissingOptionException { try { boolean keyPresent = fileParameters.containsKey(key.name); String strValue = keyPresent ? fileParameters.getProperty(key.name).replaceAll("\\s", "") : null; if (!keyPresent && key.mandatory) { throw new MissingOptionException("The input parameter (" + key.name + ") was not found"); } else if (!keyPresent || strValue.equals("")) { loadedParametersLog.append(key.name).append("=").append(defaultValue).append(" (DEFAULT)\n"); return defaultValue; } loadedParametersLog.append(key.name).append("=").append(strValue).append("\n"); return Boolean.parseBoolean(strValue); } catch (NumberFormatException e) { throw new NumberFormatException( e.getMessage() + "\nThe input parameter (" + key.name + ") could not be converted to boolean."); } catch (NullPointerException e) { throw new NullPointerException(e.getMessage() + "\nThe parameter file was not initialized."); } }
From source file:edu.gsgp.experiment.config.PropertiesManager.java
/** * Load an int property from the file.//from w ww . j a v a 2 s . c o m * * @param key The name of the property * @param defaultValue The default value for this property * @return The value loaded from the file or the default value, if it is not * specified in the file. * @throws NumberFormatException The loaded value can not be converted to * int * @throws NullPointerException The parameter file was not initialized * @throws MissingOptionException The parameter is mandatory and it was not * found in the parameter file. */ private int getIntegerProperty(ParameterList key, int defaultValue) throws NumberFormatException, NullPointerException, MissingOptionException { try { boolean keyPresent = fileParameters.containsKey(key.name); String strValue = keyPresent ? fileParameters.getProperty(key.name).replaceAll("\\s", "") : null; if (!keyPresent && key.mandatory) { throw new MissingOptionException("The input parameter (" + key.name + ") was not found"); } else if (!keyPresent || strValue.equals("")) { loadedParametersLog.append(key.name).append("=").append(defaultValue).append(" (DEFAULT)\n"); return defaultValue; } loadedParametersLog.append(key.name).append("=").append(strValue).append("\n"); return Integer.parseInt(strValue); } catch (NumberFormatException e) { throw new NumberFormatException( e.getMessage() + "\nThe input parameter (" + key.name + ") could not be converted to int."); } catch (NullPointerException e) { throw new NullPointerException(e.getMessage() + "\nThe parameter file was not initialized."); } }