Example usage for java.lang Long longValue

List of usage examples for java.lang Long longValue

Introduction

In this page you can find the example usage for java.lang Long longValue.

Prototype

@HotSpotIntrinsicCandidate
public long longValue() 

Source Link

Document

Returns the value of this Long as a long value.

Usage

From source file:com.oneops.transistor.service.ManifestRfcBulkProcessor.java

private void processEntryPoint(CmsCI templatePlatform, CmsRfcCI manifestPlatform,
        Map<Long, List<Long>> ciIdsMap, Map<Long, List<CmsRfcCI>> newRfcsMap, DesignPullContext context,
        ManifestRfcContainer platformRfcs) {
    List<CmsCIRelation> entryPointRels = cmProcessor.getFromCIRelationsNaked(templatePlatform.getCiId(),
            "mgmt.Entrypoint", null);
    for (CmsCIRelation entryPointRel : entryPointRels) {
        long entryPointTemplateCiId = entryPointRel.getToCiId();
        if (ciIdsMap.containsKey(entryPointTemplateCiId)) {
            for (Long manifestCiId : ciIdsMap.get(entryPointTemplateCiId)) {
                CmsRfcRelation manifestEntryPointRel = bootstrapRelationRfc(manifestPlatform.getCiId(),
                        manifestCiId.longValue(), "manifest.Entrypoint", context.platNsPath, context.envNsPath);
                manifestEntryPointRel.setCreatedBy(context.userId);
                manifestEntryPointRel.setUpdatedBy(context.userId);

                CmsCIRelation existingCIRel = context.existingManifestPlatRels
                        .get(manifestEntryPointRel.getRelationName()) != null
                                ? context.existingManifestPlatRels.get(manifestEntryPointRel.getRelationName())
                                        .get(manifestEntryPointRel.getFromCiId() + ":"
                                                + manifestEntryPointRel.getToCiId())
                                : null;//from ww  w  .j a va 2  s. co  m
                CmsRfcRelation newRfcRel = needUpdateRfcRel(manifestEntryPointRel, existingCIRel);
                if (newRfcRel != null) {
                    platformRfcs.getRfcRelationList().add(newRfcRel);
                    //CmsRfcRelation newManifestEntryPointRel = cmRfcMrgProcessor.upsertRelationRfc(manifestEntryPointRel, userId);
                    logger.debug("new EntryPoint relation rfc id = " + newRfcRel.getRfcId());
                }
            }
        } else if (newRfcsMap.containsKey(entryPointTemplateCiId)) {
            for (CmsRfcCI manifestRfcCI : newRfcsMap.get(entryPointTemplateCiId)) {
                CmsRfcRelation manifestEntryPointRel = bootstrapRelationRfc(0, 0, "manifest.Entrypoint",
                        context.platNsPath, context.envNsPath);
                manifestEntryPointRel.setCreatedBy(context.userId);
                manifestEntryPointRel.setUpdatedBy(context.userId);

                ManifestRfcRelationTriplet entryPointRfcRel = new ManifestRfcRelationTriplet();
                //entryPointRfcRel.setFromRfcCI(platformRfcs.getRootRfcRelTouple().getRfcCI());
                entryPointRfcRel.setToRfcCI(manifestRfcCI);
                entryPointRfcRel.setRfcRelation(manifestEntryPointRel);
                platformRfcs.getRfcRelTripletList().add(entryPointRfcRel);

            }
        }
    }
}

From source file:com.oodlemud.appengine.counter.service.ShardedCounterServiceImpl.java

@Override
public Counter increment(final String counterName, final long amount, boolean isolated) {
    // ///////////
    // Precondition Checks
    Preconditions.checkArgument(!StringUtils.isBlank(counterName));
    Preconditions.checkArgument(amount > 0, "CounterData increments must be positive numbers!");

    // Create the Work to be done for this increment, which will be done
    // inside of a TX. See
    // https://developers.google.com/appengine/docs/java/datastore/transactions#Java_Isolation_and_consistency
    final Work<Long> atomicIncrementShardWork = new Work<Long>() {
        // NOTE: In order for this to work properly, the CounterShardData
        // must be gotten, created, and updated all in the same transaction
        // in order to remain consistent (in other words, it must be
        // atomic).

        @Override// ww  w . j  a v a2s .  com
        public Long run() {
            CounterData counterData = getOrCreateCounterData(counterName);
            if (counterData.getCounterStatus() == CounterStatus.DELETING) {
                throw new RuntimeException("Can't increment counter \"" + counterName
                        + "\" because it is currently being deleted!");
            }

            // Find how many shards are in this counter.
            final int currentNumShards = counterData.getNumShards();

            // Choose the shard randomly from the available shards.
            final int shardNumber = generator.nextInt(currentNumShards);

            Key<CounterShardData> counterShardDataKey = CounterShardData.key(counterName, shardNumber);

            // Load the Shard from the DS.
            CounterShardData counterShardData = ObjectifyService.ofy().load().key(counterShardDataKey).now();
            if (counterShardData == null) {
                // Create it in the Datastore
                counterShardData = new CounterShardData(counterName, shardNumber);
                ObjectifyService.ofy().save().entity(counterShardData).now();
            }

            // Increment the count by {amount}
            counterShardData.setCount(counterShardData.getCount() + amount);

            if (getLogger().isLoggable(Level.FINE)) {
                getLogger().log(Level.FINE, "Saving CounterShardData" + shardNumber + " for CounterData \""
                        + counterName + "\" with count " + counterShardData.getCount());
            }

            // Persist the updated value.
            ObjectifyService.ofy().save().entity(counterShardData).now();
            return new Long(amount);
        }
    };

    // ///////////
    // Take Off!

    Long amountIncrementedInTx = new Long(0L);
    // Perform the increment inside of its own, isolated transaction.
    if (isolated) {
        amountIncrementedInTx = ObjectifyService.ofy().transactNew(atomicIncrementShardWork);
    }
    // Perform the increment inside of the existing transaction, if any.
    else {
        amountIncrementedInTx = ObjectifyService.ofy().transact(atomicIncrementShardWork);
    }

    // We use the "amountIncrementedInTx" to pause this thread until the
    // work inside of "atomicIncrementShardWork" completes. This is because
    // we don't want to increment memcache (below) until after that point.

    // /////////////////
    // Increment this counter in memcache atomically, with retry until it
    // succeeds (with some governor). If this fails, it's ok
    // because memcache is merely a cache of the actual count data, and will
    // eventually become accurate when the cache is reloaded.
    // /////////////////
    incrementMemcacheAtomic(counterName, amountIncrementedInTx.longValue());

    // return #getCount because this will either return the memcache value
    // or get the actual count from the Datastore, which will do the same
    // thing.
    return getCounter(counterName);

}

From source file:com.netpace.aims.controller.application.WapApplicationHelper.java

public static boolean sendDCRToInfoSpace(AimsApp aimsApp, AimsWapApp aimsWapApp, Long aimsLifecyclePhaseId,
        String theRealXSDPath, String hostName) {
    boolean success = true;
    WapInfoSpaceSubmitDCRBean submitDCRBean = new WapInfoSpaceSubmitDCRBean();
    StringBuffer xmlSubmitted = new StringBuffer();
    AimsEventObject aimsEventObject = null;
    AimsAllianc aimsAllianceOfApplication = null;
    AimsEventLite aimsEvent = null;// ww  w .  j a  v  a2 s .c  o  m
    Object[] objHostName = { hostName };
    SubmitDocumentResponse res = null;

    try {
        //If the DCR has been submitted successfully before, skip the entire function.
        if (!InfoSpaceManager.hasAlreadyBeenSubmittedSuccessfully(aimsApp.getAppsId(),
                aimsLifecyclePhaseId.toString())) {
            ArrayList userProfile = new ArrayList();
            ArrayList initialPortalPlacementCategory = new ArrayList();
            ArrayList initialPortalPlacementSubCategory = new ArrayList();
            ArrayList initialPortalPlacementPosition = new ArrayList();

            AimsUser aimsUser = null;
            AimsContact aimsContact = null;
            aimsAllianceOfApplication = (AimsAllianc) DBHelper.getInstance().load(AimsAllianc.class,
                    aimsApp.getAimsAllianceId().toString());

            //Setting Action
            if (aimsLifecyclePhaseId.longValue() == AimsConstants.PHASE_SUBMITTED_DCR_ID.longValue())
                submitDCRBean.setAction("Update");
            else if (aimsLifecyclePhaseId.longValue() == AimsConstants.SUNSET_ID.longValue())
                submitDCRBean.setAction("Remove");
            else
                return false;

            //Vendor Info
            submitDCRBean.setVendorName(aimsAllianceOfApplication.getCompanyName());
            submitDCRBean.setVendorId(aimsAllianceOfApplication.getVendorId().toString());
            submitDCRBean.setEscalationInstructions(aimsAllianceOfApplication.getEscalationInstructions());

            submitDCRBean.setVendorLogoURL(AimsConstants.INFOSPACE_RESOURCE_URL.format(objHostName)
                    + "?app_res=WapVendorLogo&app_id=" + aimsApp.getAppsId().toString() + "&other_info="
                    + URLEncoder.encode(MiscUtils.getBase64Digest(
                            InfospaceUtils.utf8decode(AimsConstants.INFOSPACE_KEY_DIGEST_FOR_URLS),
                            InfospaceUtils.utf8decode(aimsApp.getAppsId().toString()),
                            InfospaceUtils.utf8decode("WapVendorLogo")), "UTF-8"));

            //Vendor Contact Info
            if (aimsAllianceOfApplication.getVzwBusinessContact() != null) {
                aimsContact = (AimsContact) DBHelper.getInstance().load(
                        com.netpace.aims.model.core.AimsContact.class,
                        aimsAllianceOfApplication.getVzwBusinessContact().toString());
                submitDCRBean
                        .setBusinessContactName(aimsContact.getFirstName() + " " + aimsContact.getLastName());
                submitDCRBean.setBusinessContactEmail(aimsContact.getEmailAddress());
                submitDCRBean.setBusinessContactTitle(aimsContact.getTitle());
                submitDCRBean.setBusinessContactMobilePhone(aimsContact.getMobile());
                submitDCRBean.setBusinessContactOfficePhone(aimsContact.getPhone());
            }

            if (aimsAllianceOfApplication.getTechContact() != null) {
                aimsContact = (AimsContact) DBHelper.getInstance().load(
                        com.netpace.aims.model.core.AimsContact.class,
                        aimsAllianceOfApplication.getTechContact().toString());
                submitDCRBean
                        .setEscalationContactName(aimsContact.getFirstName() + " " + aimsContact.getLastName());
                submitDCRBean
                        .setTechnicalContactName(aimsContact.getFirstName() + " " + aimsContact.getLastName());
                submitDCRBean.setEscalationContactEmail(aimsContact.getEmailAddress());
                submitDCRBean.setTechnicalContactEmail(aimsContact.getEmailAddress());
                submitDCRBean.setEscalationContactTitle(aimsContact.getTitle());
                submitDCRBean.setTechnicalContactTitle(aimsContact.getTitle());
                submitDCRBean.setEscalationContactMobilePhone(aimsContact.getMobile());
                submitDCRBean.setTechnicalContactMobilePhone(aimsContact.getMobile());
                submitDCRBean.setEscalationContactOfficePhone(aimsContact.getPhone());
                submitDCRBean.setTechnicalContactOfficePhone(aimsContact.getPhone());
            }

            if (aimsAllianceOfApplication.getVzwAccountManager() != null) {
                aimsUser = (AimsUser) DBHelper.getInstance().load(com.netpace.aims.model.core.AimsUser.class,
                        aimsAllianceOfApplication.getVzwAccountManager().toString());

                submitDCRBean.setCustomerContactName(aimsUser.getAimsContact().getFirstName() + " "
                        + aimsUser.getAimsContact().getLastName());
                submitDCRBean.setCustomerContactEmail(aimsUser.getAimsContact().getEmailAddress());
            }

            //Product Info
            submitDCRBean.setVendorProductCode(aimsWapApp.getVendorProductCode());
            submitDCRBean.setVendorProductVersion(aimsApp.getVersion());
            submitDCRBean.setProductPresentationNameSmallScreens(aimsApp.getTitle());
            submitDCRBean.setProductPresentationNameLargeScreens(aimsWapApp.getLongProductName());
            submitDCRBean.setLongDescription(aimsApp.getLongDesc());
            submitDCRBean.setShortDescription(aimsApp.getShortDesc());
            submitDCRBean.setDemoUrl(aimsWapApp.getDemoUrl());
            submitDCRBean.setTestUrl(aimsWapApp.getTestUrl());
            submitDCRBean.setProductionUrl(aimsWapApp.getProductionUrl());
            submitDCRBean.setDesktopUrl(aimsWapApp.getWebsiteUrl());
            if (aimsWapApp.getLaunchDate() != null)
                submitDCRBean.setAvailabilityDateForProductionURL(Utility
                        .convertToString(aimsWapApp.getLaunchDate(), AimsConstants.DATE_FORMAT_INFOSPACE));
            if (aimsWapApp.getTestEffectiveDate() != null)
                submitDCRBean.setAvailabilityDateForTestURL(Utility.convertToString(
                        aimsWapApp.getTestEffectiveDate(), AimsConstants.DATE_FORMAT_INFOSPACE));

            if (aimsWapApp.getContentType().equals(AimsConstants.WAP_APP_CONTENT_TYPE_PREMIUM[0]))
                submitDCRBean.setPremiumIndicator("true");
            else
                submitDCRBean.setPremiumIndicator("false");

            submitDCRBean.setProductIconURL(AimsConstants.INFOSPACE_RESOURCE_URL.format(objHostName)
                    + "?app_res=WapProductIcon&app_id=" + aimsApp.getAppsId().toString() + "&other_info="
                    + URLEncoder.encode(MiscUtils.getBase64Digest(
                            InfospaceUtils.utf8decode(AimsConstants.INFOSPACE_KEY_DIGEST_FOR_URLS),
                            InfospaceUtils.utf8decode(aimsApp.getAppsId().toString()),
                            InfospaceUtils.utf8decode("WapProductIcon")), "UTF-8"));

            submitDCRBean.setProductImageURL(AimsConstants.INFOSPACE_RESOURCE_URL.format(objHostName)
                    + "?app_res=WapProductLogo&app_id=" + aimsApp.getAppsId().toString() + "&other_info="
                    + URLEncoder.encode(MiscUtils.getBase64Digest(
                            InfospaceUtils.utf8decode(AimsConstants.INFOSPACE_KEY_DIGEST_FOR_URLS),
                            InfospaceUtils.utf8decode(aimsApp.getAppsId().toString()),
                            InfospaceUtils.utf8decode("WapProductLogo")), "UTF-8"));

            if (aimsWapApp.getSubCategoryId1() != null) {
                AimsAppSubCategory subCategory = (AimsAppSubCategory) DBHelper.getInstance()
                        .load(AimsAppSubCategory.class, aimsWapApp.getSubCategoryId1().toString());
                AimsAppCategory category = (AimsAppCategory) DBHelper.getInstance().load(AimsAppCategory.class,
                        subCategory.getAimsAppCategoryId().toString());

                initialPortalPlacementCategory.add(category.getCategoryName());
                initialPortalPlacementSubCategory.add(subCategory.getSubCategoryName());
                initialPortalPlacementPosition.add(aimsWapApp.getLinkOrder1());
            }

            if (aimsWapApp.getSubCategoryId2() != null) {
                AimsAppSubCategory subCategory = (AimsAppSubCategory) DBHelper.getInstance()
                        .load(AimsAppSubCategory.class, aimsWapApp.getSubCategoryId2().toString());
                AimsAppCategory category = (AimsAppCategory) DBHelper.getInstance().load(AimsAppCategory.class,
                        subCategory.getAimsAppCategoryId().toString());

                initialPortalPlacementCategory.add(category.getCategoryName());
                initialPortalPlacementSubCategory.add(subCategory.getSubCategoryName());
                initialPortalPlacementPosition.add(aimsWapApp.getLinkOrder2());
            }

            if (aimsWapApp.getSubCategoryId3() != null) {
                AimsAppSubCategory subCategory = (AimsAppSubCategory) DBHelper.getInstance()
                        .load(AimsAppSubCategory.class, aimsWapApp.getSubCategoryId3().toString());
                AimsAppCategory category = (AimsAppCategory) DBHelper.getInstance().load(AimsAppCategory.class,
                        subCategory.getAimsAppCategoryId().toString());

                initialPortalPlacementCategory.add(category.getCategoryName());
                initialPortalPlacementSubCategory.add(subCategory.getSubCategoryName());
                initialPortalPlacementPosition.add(aimsWapApp.getLinkOrder3());
            }

            submitDCRBean.setUserProfile(userProfile);
            submitDCRBean.setInitialPortalPlacementCategory(initialPortalPlacementCategory);
            submitDCRBean.setInitialPortalPlacementSubCategory(initialPortalPlacementSubCategory);
            submitDCRBean.setInitialPortalPlacementPosition(initialPortalPlacementPosition);

            VZWHandlerStub stub = new VZWHandlerStub();
            res = stub.SubmitDocument(submitDCRBean, theRealXSDPath, xmlSubmitted);

            System.out.println("\n\nResponse from Infospace: " + res.getErrorMsg());

            if (!res.getErrorMsg().equalsIgnoreCase("SUCCESS")) {
                throw new Exception("Error in XML. Please check table AIMS_INFOSPACE_LOG");
            } else {
                InfoSpaceManager.submitInfoSpaceLog(aimsApp.getAppsId(), aimsLifecyclePhaseId.toString(), "Y",
                        res.getErrorMsg());

                if (aimsLifecyclePhaseId.longValue() == AimsConstants.PHASE_SUBMITTED_DCR_ID.longValue()) {
                    AimsApplicationsManager.saveJournalEntry(aimsApp.getAppsId(),
                            "Contents were successfully pushed to Infospace",
                            AimsConstants.JOURNAL_TYPE_PRIVATE, "system");
                }

                aimsEvent = null;
                aimsEvent = EventManagerFactory.getInstance()
                        .getEvent(AimsNotificationConstants.EVENT_WAP_APP_SUCCESS_SENDING_DCR_TO_INFOSPACE);
                if (aimsEvent != null) {
                    aimsEventObject = aimsEvent.getNewEventObject();
                    aimsEventObject.setProperty(AimsNotificationConstants.HANDLER_PROPERTY_ALLIANCE_ID,
                            aimsApp.getAimsAllianceId().toString());
                    aimsEventObject.setProperty(AimsNotificationConstants.HANDLER_PROPERTY_APPS_ID,
                            aimsApp.getAppsId().toString());
                    aimsAllianceOfApplication = (AimsAllianc) DBHelper.getInstance().load(AimsAllianc.class,
                            aimsApp.getAimsAllianceId().toString());
                    aimsEventObject.setProperty(AimsNotificationConstants.PLACE_HOLDER_ALLIANCE_NAME,
                            aimsAllianceOfApplication.getCompanyName());
                    aimsEventObject.setProperty(AimsNotificationConstants.PLACE_HOLDER_DATE_OF_EVENT,
                            (new Date()).toString());
                    aimsEventObject.setProperty(AimsNotificationConstants.PLACE_HOLDER_APP_TITLE,
                            aimsApp.getTitle());
                    aimsEventObject.setProperty(AimsNotificationConstants.PLACE_HOLDER_CONTENT_TYPE,
                            MiscUtils.getWapAppContentType(aimsWapApp.getContentType()));
                    aimsEventObject.setProperty(AimsNotificationConstants.PLACE_HOLDER_APP_STATUS_NEW,
                            ((AimsLifecyclePhase) DBHelper.getInstance().load(
                                    com.netpace.aims.model.application.AimsLifecyclePhase.class,
                                    aimsLifecyclePhaseId.toString())).getPhaseName());
                    aimsEvent.raiseEvent(aimsEventObject);
                }
                //ftp images
                try {
                    log.debug("Infospace DCR success, sending Wap Images via FTP");
                    WapApplicationHelper.processWapFTPTransfer(aimsWapApp.getWapAppsId(), null, aimsApp,
                            aimsWapApp);
                } catch (AimsException aimsException) {
                    System.out.println("Problem while sending ftp images (Success DCR)");
                    aimsException.printStackTrace();
                }
            }
        }
    } catch (Exception ex) {
        try {
            System.out.println("\n\nEXCEPTION FOR INFOSPACE");
            String infoSpaceLogString = null;

            if (res != null)
                infoSpaceLogString = res.getErrorMsg();
            else
                infoSpaceLogString = "LOCAL ERROR: Could not connect to the Infospace Web Service";

            System.out.println("\n\naimsApp.getAppsId(): " + aimsApp.getAppsId());
            System.out.println("aimsLifecyclePhaseId.toString(): " + aimsLifecyclePhaseId.toString());
            System.out.println("infoSpaceLogString: " + infoSpaceLogString);

            System.out.println("\n\nSending out emails related to Infospace");

            StringBuffer emailSubject = new StringBuffer(
                    "Exception in WapApplicationHelper.sendSubmittedDCRToInfoSpace(), on .... ");
            if (hostName != null)
                emailSubject.append(hostName);

            MailUtils.sendMail(AimsConstants.EMAIL_EXCEPTION_ADMIN, "exceptions@netpace.com",
                    emailSubject.toString(), null,
                    "Exception Message:\n" + StringFuncs.NullValueReplacement(ex.getMessage())
                            + "\n\nInfospace Message:\n" + StringFuncs.NullValueReplacement(infoSpaceLogString)
                            + "\n\nException Trace:\n" + MiscUtils.getExceptionStackTraceInfo(ex)
                            + "\n\nXML Submitted:\n" + xmlSubmitted.toString());

            aimsEvent = null;
            aimsEvent = EventManagerFactory.getInstance()
                    .getEvent(AimsNotificationConstants.EVENT_WAP_APP_ERROR_SENDING_DCR_TO_INFOSPACE);
            if (aimsEvent != null) {
                aimsEventObject = aimsEvent.getNewEventObject();
                aimsEventObject.setProperty(AimsNotificationConstants.HANDLER_PROPERTY_ALLIANCE_ID,
                        aimsApp.getAimsAllianceId().toString());
                aimsEventObject.setProperty(AimsNotificationConstants.HANDLER_PROPERTY_APPS_ID,
                        aimsApp.getAppsId().toString());
                aimsAllianceOfApplication = (AimsAllianc) DBHelper.getInstance().load(AimsAllianc.class,
                        aimsApp.getAimsAllianceId().toString());
                aimsEventObject.setProperty(AimsNotificationConstants.PLACE_HOLDER_ALLIANCE_NAME,
                        aimsAllianceOfApplication.getCompanyName());
                aimsEventObject.setProperty(AimsNotificationConstants.PLACE_HOLDER_DATE_OF_EVENT,
                        (new Date()).toString());
                aimsEventObject.setProperty(AimsNotificationConstants.PLACE_HOLDER_APP_TITLE,
                        aimsApp.getTitle());
                aimsEventObject.setProperty(AimsNotificationConstants.PLACE_HOLDER_CONTENT_TYPE,
                        MiscUtils.getWapAppContentType(aimsWapApp.getContentType()));
                aimsEventObject.setProperty(AimsNotificationConstants.PLACE_HOLDER_APP_STATUS_NEW,
                        ((AimsLifecyclePhase) DBHelper.getInstance().load(
                                com.netpace.aims.model.application.AimsLifecyclePhase.class,
                                aimsLifecyclePhaseId.toString())).getPhaseName());
                log.debug("\n1111");
                aimsEventObject.setProperty(AimsNotificationConstants.PLACE_HOLDER_RESEND_INFOSPACE_URL,
                        AimsConstants.INFOSPACE_RESUBMIT_URL.format(objHostName) + "?p_id="
                                + aimsLifecyclePhaseId.toString() + "&app_id=" + aimsApp.getAppsId().toString()
                                + "&other_info="
                                + URLEncoder.encode(
                                        MiscUtils.getBase64Digest(
                                                InfospaceUtils.utf8decode(
                                                        AimsConstants.INFOSPACE_KEY_DIGEST_FOR_URLS),
                                                InfospaceUtils.utf8decode(aimsApp.getAppsId().toString()),
                                                InfospaceUtils.utf8decode(aimsLifecyclePhaseId.toString())),
                                        "UTF-8"));
                log.debug("\n2222\n\n");
                log.debug(aimsEventObject
                        .getProperty(AimsNotificationConstants.PLACE_HOLDER_RESEND_INFOSPACE_URL));
                aimsEvent.raiseEvent(aimsEventObject);
            }

            System.out.println("\n\nLogging error information into DB");
            InfoSpaceManager.submitInfoSpaceLog(aimsApp.getAppsId(), aimsLifecyclePhaseId.toString(), "N",
                    infoSpaceLogString);

        } catch (Exception xyz) {
            try {
                MailUtils.sendMail(AimsConstants.EMAIL_EXCEPTION_ADMIN, "exceptions@netpace.com",
                        AimsConstants.EMAIL_SUBJECT_RARE_EXCEPTION + " .... on " + hostName, null,
                        MiscUtils.getExceptionStackTraceInfo(xyz));
            } catch (Exception mailEx) {
                System.out.println("Exception in WAPApplicationHelper while sending email");
                mailEx.printStackTrace();
            }
        }
        success = false;
    }

    return success;
}

From source file:er.extensions.foundation.ERXProperties.java

/**
 * <div class="en">//w w  w.  ja va 2 s  . co  m
 * Cover method for returning a long for a
 * given system property with a default value.
 * </div>
 * 
 * <div class="ja">
 * ?? long ????
 * </div>
 * 
 * @param s <div class="en">system property</div>
 *          <div class="ja"></div>
 * @param defaultValue <div class="en">default value</div>
 *                     <div class="ja"></div>
 * 
 * @return <div class="en">long value of the system property or the default value</div>
 *         <div class="ja">long ???</div>
 */
public static long longForKeyWithDefault(final String s, final long defaultValue) {
    final String propertyName = getApplicationSpecificPropertyName(s);
    long value;
    Object cachedValue = _cache.get(propertyName);
    if (UndefinedMarker.equals(cachedValue)) {
        value = defaultValue;
    } else if (cachedValue instanceof Long) {
        value = ((Long) cachedValue).longValue();
    } else {
        Long objValue = ERXValueUtilities.LongValueWithDefault(ERXSystem.getProperty(propertyName), null);
        _cache.put(s, objValue == null ? (Object) UndefinedMarker : objValue);
        if (objValue == null) {
            value = defaultValue;
        } else {
            value = objValue.longValue();
        }
        if (retainDefaultsEnabled() && objValue == null) {
            System.setProperty(propertyName, Long.toString(defaultValue));
        }
    }
    return value;
}

From source file:org.openmeetings.app.data.user.Usermanagement.java

public List<Userdata> getUserdataDashBoard(Long user_id) {
    if (user_id.longValue() > 0) {
        try {//from   w  w  w .  j a va 2 s  .c o m
            TypedQuery<Userdata> query = em.createQuery(
                    "select c from Userdata as c where c.user_id = :user_id AND c.deleted <> :deleted",
                    Userdata.class);
            query.setParameter("user_id", user_id.longValue());
            query.setParameter("deleted", "true");
            List<Userdata> ll = query.getResultList();
            return ll;
        } catch (Exception ex2) {
            log.error("getUserdataDashBoard", ex2);
        }
    }
    return null;
}

From source file:com.runwaysdk.dataaccess.database.general.MySQL.java

/**
 * @see com.runwaysdk.dataaccess.database.relationship.AbstractDatabase#getChildCountForParent(java.lang.String,
 *      java.lang.String)//from  www.j  a v  a  2 s.  co m
 */
public long getChildCountForParent(String parent_id, String relationshipTableName) {
    String query = " SELECT COUNT(*) AS CT \n" + " FROM " + relationshipTableName + " \n" + " WHERE "
            + RelationshipDAOIF.PARENT_ID_COLUMN + " = '" + parent_id + "' \n" + " AND "
            + RelationshipDAOIF.CHILD_ID_COLUMN + " IN " + "   (SELECT DISTINCT "
            + RelationshipDAOIF.CHILD_ID_COLUMN + " \n" + "    FROM " + relationshipTableName + " \n"
            + "    WHERE " + RelationshipDAOIF.PARENT_ID_COLUMN + " = '" + parent_id + "')";

    ResultSet resultSet = this.query(query);

    long returnValue = 0;

    try {
        if (resultSet.next()) {
            Long number = (Long) resultSet.getLong("ct");
            returnValue = number.longValue();
        }
    } catch (SQLException sqlEx1) {
        Database.throwDatabaseException(sqlEx1);
    } finally {
        try {
            java.sql.Statement statement = resultSet.getStatement();
            resultSet.close();
            statement.close();
        } catch (SQLException sqlEx2) {
            Database.throwDatabaseException(sqlEx2);
        }
    }

    return returnValue;
}

From source file:com.runwaysdk.dataaccess.database.general.MySQL.java

/**
 * @see com.runwaysdk.dataaccess.database.relationship.AbstractDatabase#getParentCountForChild(java.lang.String,
 *      java.lang.String)/* w  w  w . j  a  v a  2s  .  co  m*/
 */
public long getParentCountForChild(String child_id, String relationshipTableName) {
    String query = " SELECT COUNT(*) AS CT \n" + " FROM " + relationshipTableName + " \n" + " WHERE "
            + RelationshipDAOIF.CHILD_ID_COLUMN + " = '" + child_id + "' \n" + " AND "
            + RelationshipDAOIF.PARENT_ID_COLUMN + " IN " + "   (SELECT DISTINCT "
            + RelationshipDAOIF.PARENT_ID_COLUMN + " \n" + "    FROM " + relationshipTableName + " \n"
            + "    WHERE " + RelationshipDAOIF.CHILD_ID_COLUMN + " = '" + child_id + "')";

    ResultSet resultSet = this.query(query);

    long returnValue = 0;

    try {
        if (resultSet.next()) {
            Long number = (Long) resultSet.getLong("ct");
            returnValue = number.longValue();
        }
    } catch (SQLException sqlEx1) {
        Database.throwDatabaseException(sqlEx1);
    } finally {
        try {
            java.sql.Statement statement = resultSet.getStatement();
            resultSet.close();
            statement.close();
        } catch (SQLException sqlEx2) {
            Database.throwDatabaseException(sqlEx2);
        }
    }

    return returnValue;

}

From source file:org.squale.squaleweb.applicationlayer.action.results.project.ProjectResultsAction.java

/**
 * @param pRequest la requete/*from w  w  w  .ja va 2 s . c  o  m*/
 * @param pParamParent le parent (peut etre null)
 * @param pPracticeName le nom de la pratique
 * @param pPracticeId l'id de la pratique
 */
private void manageTrackerFromPractice(HttpServletRequest pRequest, String pParamParent, String pPracticeName,
        Long pPracticeId) {
    // Mise en place du traceur historique
    String displayName = WebMessages.getString(pRequest, pPracticeName);
    String url = "project.do?action=practice&which=" + pPracticeId.longValue();
    if (null != pParamParent) {
        url += "&whichParent=" + pParamParent;
    }
    updateHistTracker(displayName, url, TrackerStructure.FACTOR_VIEW, pRequest, false);
    // Indique que l'on vient d'une vue synthse et pas d'une vue composant
    changeWay(pRequest, "false");
    // On ne doit pas effacer completement le traceur
    needToReset(pRequest, "false");

}

From source file:com.comcast.cqs.persistence.RedisCachedCassandraPersistence.java

/**
 * Add message to in-memory-queue. creationTS is now
 * @param queueUrl//  w ww .ja  va 2 s . c  o  m
 * @param message
 */
private void addMessageToCache(String queueUrl, int shard, CQSMessage message, ShardedJedis jedis) {
    long ts1 = System.currentTimeMillis();
    Long newLen = jedis.rpush(queueUrl + "-" + shard + "-Q", getMemQueueMessage(message.getMessageId())); //TODO: currently initialDelay is always 0
    if (newLen.longValue() == 0) {
        throw new IllegalStateException("Could not add memId to queue");
    }
    long ts2 = System.currentTimeMillis();
    CQSControllerServlet.valueAccumulator.addToCounter(AccumulatorName.RedisTime, (ts2 - ts1));
}