List of usage examples for java.lang Integer intValue
@HotSpotIntrinsicCandidate public int intValue()
From source file:com.aurel.track.dbase.jobs.DatabaseBackupJob.java
@Override public void execute(JobExecutionContext context) { LOGGER.info("DataBaseBackupJob was triggered at " + new Date()); if (!ClusterBL.getIAmTheMaster()) { return;/*ww w. j ava 2 s . c o m*/ } LOGGER.info("Execute DatabaseBackupJob at " + new Date() + "..."); if (!ApplicationBean.getInstance().getSiteBean().getIsDatabaseBackupJobOn()) { LOGGER.info("Database backup job config is off! Exit DatabaseBackupJob."); return; } JobDetail jobDetail = context.getJobDetail(); JobDataMap jobDataMap = jobDetail.getJobDataMap(); Scheduler scheduler = context.getScheduler(); // Check if a job with the same name is currently running. // If so, skip this one. try { int count = 0; for (JobExecutionContext cont : scheduler.getCurrentlyExecutingJobs()) { JobDetail jd = cont.getJobDetail(); if (jd.getKey().equals(jobDetail.getKey())) { ++count; } } if (count > 1) { return; } } catch (Exception e) { // Scheduler exception LOGGER.error(e.getMessage()); } CronTrigger trigger = (CronTrigger) context.getTrigger(); Date nextFire = trigger.getNextFireTime(); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); LOGGER.info("Backup job next firing time: " + dateFormat.format(nextFire)); LOGGER.debug("Cron-Exp.: " + trigger.getCronExpression()); PropertiesConfiguration tcfg = null; try { tcfg = ApplicationBean.getInstance().getDbConfig(); } catch (Exception e) { LOGGER.error(e.getMessage()); } Date now = new Date(); String backupName = DatabaseBackupBL.formatBackupName(now); Boolean includeAttachments = ApplicationBean.getInstance().getSiteBean().getIncludeAttachments(); if (includeAttachments == null) { includeAttachments = jobDataMap.getBooleanFromString("includeAttachments").booleanValue(); } boolean keepAllBackups = false; Integer backupNumber = ApplicationBean.getInstance().getSiteBean().getNoOfBackups(); if (backupNumber == null || backupNumber.intValue() <= 0) { try { backupNumber = jobDataMap.getIntFromString("backupNumber"); } catch (Exception ex) { backupNumber = 15; } } try { keepAllBackups = jobDataMap.getBooleanFromString("keepAllBackups").booleanValue(); } catch (Exception e) { keepAllBackups = false; } ApplicationBean appBean = ApplicationBean.getInstance(); if (appBean.isBackupInProgress()) { LOGGER.info("Another backup is already in progress..."); return; } appBean.setBackupInProgress(true); try { DatabaseBackupBL.zipDatabase(backupName, includeAttachments, tcfg); LOGGER.info("Backup created succesfully as:" + backupName); if (!keepAllBackups) { DatabaseBackupBL.checkBackupNumber(backupNumber); } } catch (DatabaseBackupBLException e) { LOGGER.error("Can't create backup"); LOGGER.error(e); } appBean.setBackupInProgress(false); LOGGER.info("Done executing DatabaseBackupJob!"); }
From source file:com.android.sdklib.internal.repository.MockDownloadCache.java
/** * Override openCachedUrl to return one of the registered payloads or throw a FNF exception. * This totally ignores the cache's {@link DownloadCache.Strategy}. * It will however throw a FNF if {@link #overrideStrategy(Strategy)} is set to * {@link DownloadCache.Strategy#ONLY_CACHE}. *//* w w w.j a v a2s . c om*/ @Override public InputStream openCachedUrl(String urlString, ITaskMonitor monitor) throws IOException, CanceledByUserException { synchronized (mCachedHits) { Integer count = mCachedHits.get(urlString); mCachedHits.put(urlString, (count == null ? 0 : count.intValue()) + 1); } if (Strategy.ONLY_CACHE.equals(mOverrideStrategy)) { // Override the cache to read only "local cached" data. // In this first phase, we assume there's nothing cached. // TODO register first-pass files later. throw new FileNotFoundException(urlString); } Payload payload = mCachedPayloads.get(urlString); if (payload == null || payload.mHttpCode != HttpStatus.SC_OK) { throw new FileNotFoundException(urlString); } byte[] content = payload.mContent; if (content == null) { content = new byte[0]; } return new ByteArrayInputStream(content); }
From source file:edu.lternet.pasta.portal.search.BrowseCrawlerServlet.java
/** * Initializes the servlet by starting a separate thread in which to * run the BrowseCrawler main program.//w w w .jav a 2 s. c o m * * @param config the ServletConfig object, holding servlet configuration * info * @throws ServletException */ public void init(ServletConfig config) throws ServletException { super.init(config); PropertiesConfiguration options = ConfigurationListener.getOptions(); String browseDirPath = options.getString("browse.dir"); BrowseSearch.setBrowseCacheDir(browseDirPath); Integer crawlPeriodInt; this.servletContext = getServletContext(); crawlPeriodInt = new Integer("24"); this.crawlPeriod = crawlPeriodInt.intValue(); browseCrawlerThread = new Thread(this); browseCrawlerThread.setPriority(Thread.MIN_PRIORITY); // be a good citizen browseCrawlerThread.start(); }
From source file:net.sf.ehcache.distribution.RMICachePeer.java
/** * Construct a new remote peer.//from w w w .j a v a2 s .c o m * * @param cache The cache attached to the peer * @param hostName The host name the peer is running on. * @param rmiRegistryPort The port number on which the RMI Registry listens. Should be an unused port in * the range 1025 - 65536 * @param remoteObjectPort the port number on which the remote objects bound in the registry receive calls. * This defaults to a free port if not specified. * Should be an unused port in the range 1025 - 65536 * @param socketTimeoutMillis * @throws RemoteException */ public RMICachePeer(Ehcache cache, String hostName, Integer rmiRegistryPort, Integer remoteObjectPort, Integer socketTimeoutMillis) throws RemoteException { super(remoteObjectPort.intValue(), new ConfigurableRMIClientSocketFactory(socketTimeoutMillis), RMISocketFactory.getDefaultSocketFactory()); this.remoteObjectPort = remoteObjectPort; this.hostname = hostName; this.rmiRegistryPort = rmiRegistryPort; this.cache = cache; }
From source file:com.aurel.track.fieldType.runtime.matchers.converter.DateMatcherConverter.java
/** * Convert the object value to xml string for save * @param value/*ww w . ja va 2 s . c om*/ * @param matcherRelation * @return */ @Override public String toXMLString(Object value, Integer matcherRelation) { if (value == null || matcherRelation == null) { return null; } switch (matcherRelation.intValue()) { case MatchRelations.MORE_THAN_DAYS_AGO: case MatchRelations.MORE_THAN_EQUAL_DAYS_AGO: case MatchRelations.LESS_THAN_DAYS_AGO: case MatchRelations.LESS_THAN_EQUAL_DAYS_AGO: case MatchRelations.IN_MORE_THAN_DAYS: case MatchRelations.IN_MORE_THAN_EQUAL_DAYS: case MatchRelations.IN_LESS_THAN_DAYS: case MatchRelations.IN_LESS_THAN_EQUAL_DAYS: return value.toString(); case MatchRelations.EQUAL_DATE: case MatchRelations.NOT_EQUAL_DATE: case MatchRelations.GREATHER_THAN_DATE: case MatchRelations.GREATHER_THAN_EQUAL_DATE: case MatchRelations.LESS_THAN_DATE: case MatchRelations.LESS_THAN_EQUAL_DATE: try { Date dateValue = (Date) value; return DateTimeUtils.getInstance().formatISODateTime(dateValue); } catch (Exception e) { LOGGER.warn("Converting the " + value + " to Date for xml string failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } return null; }
From source file:com.ottogroup.bi.streaming.operator.json.aggregate.functions.IntegerContentAggregateFunction.java
/** * @see com.ottogroup.bi.streaming.operator.json.aggregate.functions.JsonContentAggregateFunction#sum(java.io.Serializable, java.io.Serializable) *///from w w w . j a v a 2 s . co m public Integer sum(Integer oldSum, Integer value) throws Exception { if (oldSum == null && value == null) return null; if (oldSum != null && value == null) return oldSum; if (oldSum == null && value != null) return Integer.valueOf(value.intValue()); return Integer.valueOf(oldSum.intValue() + value.intValue()); }
From source file:de.hybris.platform.acceleratorservices.cronjob.SiteMapMediaJob.java
@Override public PerformResult perform(final SiteMapMediaCronJobModel cronJob) { final List<MediaModel> siteMapMedias = new ArrayList<MediaModel>(); final CMSSiteModel contentSite = cronJob.getContentSite(); getCmsSiteService().setCurrentSite(contentSite); // set the catalog version for the current session getActivateBaseSiteInSession().activate(contentSite); final SiteMapConfigModel siteMapConfig = contentSite.getSiteMapConfig(); final Collection<SiteMapPageModel> siteMapPages = siteMapConfig.getSiteMapPages(); for (final SiteMapPageModel siteMapPage : siteMapPages) { final List<File> siteMapFiles = new ArrayList<File>(); final SiteMapPageEnum pageType = siteMapPage.getCode(); final SiteMapGenerator generator = this.getGeneratorForSiteMapPage(pageType); if (BooleanUtils.isTrue(siteMapPage.getActive()) && generator != null) { final List models = generator.getData(contentSite); final Integer MAX_SITEMAP_LIMIT = cronJob.getSiteMapUrlLimitPerFile(); if (models.size() > MAX_SITEMAP_LIMIT.intValue()) { final List<List> modelsList = splitUpTheListIfExceededLimit(models, MAX_SITEMAP_LIMIT); for (int modelIndex = 0; modelIndex < modelsList.size(); modelIndex++) { generateSiteMapFiles(siteMapFiles, contentSite, generator, siteMapConfig, modelsList.get(modelIndex), pageType, Integer.valueOf(modelIndex)); }//from ww w . java 2 s. com } else { generateSiteMapFiles(siteMapFiles, contentSite, generator, siteMapConfig, models, pageType, null); } } else { LOG.warn(String.format("Skipping SiteMap page %s active %s", siteMapPage.getCode(), siteMapPage.getActive())); } if (!siteMapFiles.isEmpty()) { for (final File siteMapFile : siteMapFiles) { siteMapMedias.add(createCatalogUnawareMediaModel(siteMapFile)); } } } if (!siteMapMedias.isEmpty()) { final Collection<MediaModel> existingSiteMaps = contentSite.getSiteMaps(); contentSite.setSiteMaps(siteMapMedias); modelService.save(contentSite); // clean up old sitemap medias if (CollectionUtils.isNotEmpty(existingSiteMaps)) { modelService.removeAll(existingSiteMaps); } } return new PerformResult(CronJobResult.SUCCESS, CronJobStatus.FINISHED); }
From source file:com.cms.base.api.base.query.BasePageQuery.java
public void setCurrentPage(Integer cPage) { if (cPage == null || cPage.intValue() <= 0) { currentPage = defaultFristPage;//from w ww .jav a 2s .co m } else { currentPage = cPage; } }
From source file:com.magnet.android.mms.request.GenericResponseParserPrimitiveTest.java
@SmallTest public void testGenericPrimitiveResponse() throws MobileException, IOException { GenericResponseParser<String> parser = new GenericResponseParser<String>(String.class, null, GenericRestConstants.CONTENT_TYPE_TEXT_PLAIN, null); String response = "\"Whatever is the deal\""; String result = (String) parser.parseResponse(response.getBytes()); assertEquals("Whatever is the deal", result); result = (String) parser.parseResponse((byte[]) null); assertEquals(null, result);// ww w . ja va 2s . c o m GenericResponseParser<Character> cparser = new GenericResponseParser<Character>(char.class, null, GenericRestConstants.CONTENT_TYPE_TEXT_PLAIN, null); char cresponse = 'p'; try { Character cresult = (Character) cparser.parseResponse(String.valueOf(cresponse).getBytes("UTF-8")); assertEquals(Character.valueOf(cresponse), cresult); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } GenericResponseParser<Integer> nparser = new GenericResponseParser<Integer>(Integer.class, null, GenericRestConstants.CONTENT_TYPE_TEXT_PLAIN, null); String strResponse = Integer.toString(Integer.MIN_VALUE); Integer nresult = (Integer) nparser.parseResponse(strResponse.getBytes()); assertEquals(Integer.MIN_VALUE, nresult.intValue()); }