Example usage for java.lang Long equals

List of usage examples for java.lang Long equals

Introduction

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

Prototype

public boolean equals(Object obj) 

Source Link

Document

Compares this object to the specified object.

Usage

From source file:data.services.ParseBaseService.java

private void updateMarks() throws SQLException, ClassNotFoundException {
    List<Mark> marksForSaveList = new ArrayList();
    List<Mark> marksForUpdateList = new ArrayList();
    List<Mark> markList = markDao.getAllAsc();
    List<Long> actualQutoIdList = new ArrayList();
    HashMap<Long, Mark> ourOldIdMarkMap = new HashMap();
    for (Mark m : markList) {
        ourOldIdMarkMap.put(m.getQutoId(), m);
    }/*from  ww w  .j a  v a2 s.c o  m*/
    ResultSet resSet = getFromQutoBase(getSelectAll(QUTO_MARK_TABLE));

    while (resSet.next()) {
        Long qutoId = resSet.getLong("id");
        actualQutoIdList.add(qutoId);

        String pop = StringAdapter.getString(resSet.getString("is_popular")).trim();
        String title = StringAdapter.getString(resSet.getString("title")).trim();
        String titleRus = StringAdapter.getString(resSet.getString("title_rus")).trim();
        String url = StringAdapter.getString(resSet.getString("url")).trim();
        String desc = StringAdapter.getString(resSet.getString("description")).trim();
        Long mediaId = resSet.getLong("media_id");

        if (!ourOldIdMarkMap.keySet().contains(qutoId)) {
            Mark mark = new Mark();
            mark.setPop(pop);
            mark.setTitle(title);
            mark.setTitleRus(titleRus);
            mark.setDescription(desc);
            mark.setMediaId(mediaId);
            mark.setUrl(url);
            if (validate(mark, "TroubleQutoId=" + mark.getQutoId() + "; ")) {
                marksForSaveList.add(mark);
            }
        } else {
            Mark mark = ourOldIdMarkMap.get(qutoId);
            if (!pop.equals(mark.getPop()) || !title.equals(mark.getTitle())
                    || !titleRus.equals(mark.getTitleRus()) || !url.equals(mark.getUrl())
                    || !mediaId.equals(mark.getMediaId()) || !desc.equals(mark.getDescription())) {
                mark.setQutoId(qutoId);
                mark.setPop(pop);
                mark.setTitle(title);
                mark.setTitleRus(titleRus);
                mark.setDescription(desc);
                mark.setMediaId(mediaId);
                mark.setUrl(url);
                if (validate(mark, "TroubleQutoId=" + mark.getQutoId() + "; ")) {
                    marksForUpdateList.add(mark);
                }
            }
        }
    }
    int s = 0;
    int u = 0;
    int d = 0;
    for (Mark m : marksForSaveList) {
        markDao.save(m);
        s++;
    }
    for (Mark m : marksForUpdateList) {
        markDao.update(m);
        u++;
    }
    for (Long qutoId : ourOldIdMarkMap.keySet()) {
        if (!actualQutoIdList.contains(qutoId)) {
            d++;
            markDao.delete(ourOldIdMarkMap.get(qutoId));
        }
    }
    addError(": " + s + " ? ?, " + u + " , " + d
            + " .");

}

From source file:es.caib.seycon.ng.servei.PuntEntradaServiceImpl.java

protected boolean handleCopiaEnlacePuntEntrada(PuntEntrada puntEntradaCopiar, PuntEntrada puntEntradaMenuDesti)
        throws Exception {// NOTA: El
                                                                                                                                          // destino
                                                                                                                                          // SIEMPRE es un
                                                                                                                                          // men
                                                                                                                                          // 1) Verifiquem que el dest siga de tipus men
    if (!"S".equals(puntEntradaMenuDesti.getMenu())) //$NON-NLS-1$
        throw new SeyconException(Messages.getString("PuntEntradaServiceImpl.EntryPointTypeError")); //$NON-NLS-1$

    // 2) Verifiquem autoritzacions: origen, desti i pare del dest
    Long idParePuntEntradaCopiar = puntEntradaCopiar.getIdPare();
    Long idPueOrigen = puntEntradaCopiar.getId();
    Long idPueDesti = puntEntradaMenuDesti.getId();
    Long idParePuntEntradaDesti = (!idPueDesti.equals(ROOT_ID)) ? puntEntradaMenuDesti.getIdPare() : ROOT_ID;
    if (idPueOrigen == null || idParePuntEntradaCopiar == null || idPueDesti == null
            || idParePuntEntradaDesti == null)
        throw new SeyconException(Messages.getString("PuntEntradaServiceImpl.CopyEntryPointConfirmChanges")); //$NON-NLS-1$

    // Analitzem l'arbre dels pares del node dest per verificar que no es
    // mou/*from w  w  w  .  j  a  v  a2  s  . c  o  m*/
    // un node origen dintre de la seua branca
    if (isOrigenAncestorDesti(idPueOrigen, idPueDesti))
        throw new SeyconException(Messages.getString("PuntEntradaServiceImpl.NodeCopyError")); //$NON-NLS-1$

    // Tiene que tener permisos en el punto de entrada origen y destino (es
    // men)
    if (!canAdmin(puntEntradaCopiar) || !canAdmin(puntEntradaMenuDesti))
        throw new SeyconException(Messages.getString("PuntEntradaServiceImpl.NoAuthorizedToCopyEntryPoint")); //$NON-NLS-1$

    PuntEntradaEntity pareOrigenE = getPuntEntradaEntityDao().findById(idParePuntEntradaCopiar);
    PuntEntrada pareOrigen = getPuntEntradaEntityDao().toPuntEntrada(pareOrigenE);
    // Si el origen NO es men tiene que tener permisos en el men
    // contenedor padre del origen (para copiar)
    if (!"S".equals(puntEntradaCopiar.getMenu()) && !canAdmin(pareOrigen)) //$NON-NLS-1$
        throw new SeyconException(
                Messages.getString("PuntEntradaServiceImpl.NoAuthorizedToCopyEntryPointNoPermission")); //$NON-NLS-1$

    // Verificamos que no exista ya en el destino una copia del mismo
    Collection<ArbrePuntEntradaEntity> fillsDesti = getArbrePuntEntradaEntityDao().findByPare(idPueDesti);

    if (fillsDesti != null)
        for (Iterator<ArbrePuntEntradaEntity> it = fillsDesti.iterator(); it.hasNext();) {
            ArbrePuntEntradaEntity arbreActual = it.next();
            if (arbreActual.getFill().getId().equals(idPueOrigen))
                throw new SeyconException(Messages.getString("PuntEntradaServiceImpl.EntryPointDuplicated")); //$NON-NLS-1$
        }

    // Obtenim L'ORDRE DE L'ARBRE dest (estan ordenats per ordre ascendent)
    String ordre = "0"; //$NON-NLS-1$
    if (fillsDesti != null) {// Ens quedem en el fill de major ordre
        if (fillsDesti.size() == 0) // Para nodes men sense fills
            ordre = "0"; //$NON-NLS-1$
        else { // Obtenim el seu fill "major" (es de tipus List ordenat)
            ArbrePuntEntradaEntity fill = ((List<ArbrePuntEntradaEntity>) fillsDesti)
                    .get(fillsDesti.size() - 1);
            int ordreFillMajor = fill.getOrdre(); //int ordreFillMajor = Integer.parseInt(fill.getOrdre());
            ordre = "" + (ordreFillMajor + 1); //$NON-NLS-1$
        }
    }

    // Creamos una copia del rbol en el men destino:
    PuntEntradaEntity nouPare = getPuntEntradaEntityDao().findById(idPueDesti);
    PuntEntradaEntity pueCopiat = getPuntEntradaEntityDao().findById(idPueOrigen);

    // Creen la nova entrada a l'arbre dest
    ArbrePuntEntradaEntity nouArbre = getArbrePuntEntradaEntityDao().newArbrePuntEntradaEntity();
    nouArbre.setFill(pueCopiat);
    nouArbre.setOrdre(Integer.parseInt(ordre)); //nouArbre.setOrdre(ordre);
    nouArbre.setPare(nouPare);
    getArbrePuntEntradaEntityDao().create(nouArbre);

    // 1) Creem l'accs a la branca dest
    if (fillsDesti == null) {
        fillsDesti = new HashSet<ArbrePuntEntradaEntity>();
    }
    fillsDesti.add(nouArbre);
    nouPare.setArbrePuntEntradaSocPare(new HashSet<ArbrePuntEntradaEntity>(fillsDesti));

    // 2) Actualitzem el men dest (hem afegit un fill)
    getPuntEntradaEntityDao().update(nouPare);

    return true;
}

From source file:uk.ac.cam.cl.dtg.segue.api.managers.UserAccountManager.java

/**
 * processEmailVerification.//from   www  .  ja  v a2 s .  c  o m
 * @param userid
 *            - the user id
 *
 * @param email
 *            - the email address - may be new or the same
 * 
 * @param token
 *            - token used to verify email address
 * 
 * @return - whether the token is valid or not
 * @throws SegueDatabaseException
 *             - exception if token cannot be validated
 * @throws InvalidTokenException - if something is wrong with the token provided
 * @throws NoUserException - if the user does not exist.
 */
public RegisteredUserDTO processEmailVerification(final Long userid, final String email, final String token)
        throws SegueDatabaseException, InvalidTokenException, NoUserException {
    IPasswordAuthenticator authenticator = (IPasswordAuthenticator) this.registeredAuthProviders
            .get(AuthenticationProvider.SEGUE);

    RegisteredUser user = this.findUserById(userid);

    if (null == user) {
        log.warn(String.format("Recieved an invalid email token request for (%s)", email));
        throw new NoUserException();
    }

    if (!userid.equals(user.getId())) {
        log.warn(String.format("Recieved an invalid email token request for (%s)" + " - provided bad userid",
                email));
        throw new InvalidTokenException();
    }

    EmailVerificationStatus evStatus = user.getEmailVerificationStatus();
    if (evStatus != null && evStatus == EmailVerificationStatus.VERIFIED && user.getEmail().equals(email)) {
        log.warn(String.format("Recieved a duplicate email verification request for (%s) - already verified",
                email));
        return this.convertUserDOToUserDTO(user);
    }

    if (authenticator.isValidEmailVerificationToken(user, email, token)) {
        user.setEmailVerificationStatus(EmailVerificationStatus.VERIFIED);
        user.setEmailVerificationToken(null);

        // Update the email address if different
        if (!user.getEmail().equals(email)) {
            user.setEmail(email);
        }

        // Save user
        RegisteredUser createOrUpdateUser = this.database.createOrUpdateUser(user);
        log.info(String.format("Email verification for user (%s) has completed successfully.",
                createOrUpdateUser.getId()));
        return this.convertUserDOToUserDTO(createOrUpdateUser);
    } else {
        log.warn(String.format("Recieved an invalid email verification token for (%s) - invalid token", email));
        throw new InvalidTokenException();
    }
}

From source file:es.caib.seycon.ng.servei.PuntEntradaServiceImpl.java

protected boolean handleMoureMenusPuntEntrada(PuntEntrada puntEntradaMoure, PuntEntrada puntEntradaMenuDesti)
        throws Exception {// NOTA: El
                                                                                                                                        // destino
                                                                                                                                        // SIEMPRE es un
                                                                                                                                        // men
                                                                                                                                        // 1) Verifiquem que el dest siga de tipus men
    if (!"S".equals(puntEntradaMenuDesti.getMenu())) //$NON-NLS-1$
        throw new SeyconException(Messages.getString("PuntEntradaServiceImpl.EntryPointTypeError")); //$NON-NLS-1$

    // 2) Verifiquem autoritzacions: origen, desti i pare del dest
    Long idParePuntEntradaMoure = puntEntradaMoure.getIdPare();
    Long idPueOrigen = puntEntradaMoure.getId();
    Long idPueDesti = puntEntradaMenuDesti.getId();
    Long idParePuntEntradaDesti = (!idPueDesti.equals(ROOT_ID)) ? puntEntradaMenuDesti.getIdPare() : ROOT_ID;
    if (idPueOrigen == null || idParePuntEntradaMoure == null || idPueDesti == null
            || idParePuntEntradaDesti == null)
        throw new SeyconException(Messages.getString("PuntEntradaServiceImpl.EntryPointConfirmChanges")); //$NON-NLS-1$

    // Analitzem l'arbre dels pares del node dest per verificar que no es
    // mou/*  w  w w. j  a  va2  s.c  o m*/
    // un node origen dintre de la seua branca
    if (isOrigenAncestorDesti(idPueOrigen, idPueDesti))
        throw new SeyconException(Messages.getString("PuntEntradaServiceImpl.NotNodeMoviment")); //$NON-NLS-1$

    PuntEntradaEntity pareOrigenE = getPuntEntradaEntityDao().findById(idParePuntEntradaMoure);
    PuntEntrada pareOrigen = getPuntEntradaEntityDao().toPuntEntrada(pareOrigenE);
    // PuntEntradaEntity pareDestiE =
    // getPuntEntradaEntityDao().findById(idParePuntEntradaDesti);
    // PuntEntrada pareDesti =
    // getPuntEntradaEntityDao().toPuntEntrada(pareDestiE);
    // Tiene que tener permisos en el punto de entrada origen y destino (es
    // men)
    if (!canAdmin(puntEntradaMoure) || !canAdmin(puntEntradaMenuDesti))
        throw new SeyconException(Messages.getString("PuntEntradaServiceImpl.NotAuthorizedToMoveEntryPoint")); //$NON-NLS-1$

    // Si el origen NO es men tiene que tener permisos en el men
    // contenedor padre del origen (para mover)
    if (!"S".equals(puntEntradaMoure.getMenu()) && !canAdmin(pareOrigen)) //$NON-NLS-1$
        throw new SeyconException(
                Messages.getString("PuntEntradaServiceImpl.NotAuthorizedToMoveEntryPointNoPermission")); //$NON-NLS-1$

    // Obtenim l'arbre del punt d'entrada origen i dest
    List<ArbrePuntEntradaEntity> brancaOrigen = getArbrePuntEntradaEntityDao()
            .findByPare(idParePuntEntradaMoure);
    ArbrePuntEntradaEntity arbreAntic = null;
    int pos = 0; // per reindexar elements (ja estn ordenats pel camp
                 // ordre)
    for (Iterator<ArbrePuntEntradaEntity> it = brancaOrigen.iterator(); it.hasNext();) {
        ArbrePuntEntradaEntity a = it.next();
        if (a.getFill().getId().equals(idPueOrigen)) {
            arbreAntic = a;
            it.remove();
        } else {
            a.setOrdre(pos); // Establim nova posici (reindexem tots //$NON-NLS-1$ a.setOrdre("" + pos); 
                             // els elements)
            pos++; // Si el trobem no augmentem la posici origen
        }
    }
    // Creen la nova entrada a l'arbre dest
    PuntEntradaEntity nouPare = getPuntEntradaEntityDao().findById(idPueDesti);
    PuntEntradaEntity pueMogut = getPuntEntradaEntityDao().findById(idPueOrigen);

    // Obtenim L'ORDRE DE L'ARBRE dest
    String ordre = "0"; //$NON-NLS-1$
    Collection<ArbrePuntEntradaEntity> fillsDesti = getArbrePuntEntradaEntityDao().findByPare(idPueDesti);
    if (fillsDesti != null) {// Ens quedem en el fill de major ordre
        if (fillsDesti.size() == 0) // Para nodes men sense fills
            ordre = "0"; //$NON-NLS-1$
        else { // Obtenim el seu fill "major" (de tipus List i estan
               // ordenats per query en ordre ascendent)
            ArbrePuntEntradaEntity fill = ((List<ArbrePuntEntradaEntity>) fillsDesti)
                    .get(fillsDesti.size() - 1);
            int ordreFillMajor = fill.getOrdre(); //int ordreFillMajor = Integer.parseInt(fill.getOrdre());
            ordre = "" + (ordreFillMajor + 1); //$NON-NLS-1$
        }
    }

    // Creem el accs al punt d'entrada mogut
    ArbrePuntEntradaEntity nouArbre = getArbrePuntEntradaEntityDao().newArbrePuntEntradaEntity();
    nouArbre.setOrdre(Integer.parseInt(ordre)); //nouArbre.setOrdre(ordre);
    nouArbre.setFill(pueMogut);
    nouArbre.setPare(nouPare);

    // 1) Esborrem l'arbre antic
    if (arbreAntic != null)
        getArbrePuntEntradaEntityDao().remove(arbreAntic);
    // 2) Creem l'accs a la nova branca
    getArbrePuntEntradaEntityDao().create(nouArbre);
    if (fillsDesti == null) {
        fillsDesti = new HashSet<ArbrePuntEntradaEntity>();
    }
    fillsDesti.add(nouArbre);
    nouPare.setArbrePuntEntradaSocPare(new HashSet<ArbrePuntEntradaEntity>(fillsDesti));
    // 3) Actualitzem la branca dest (hem afegit un fill)
    getPuntEntradaEntityDao().update(nouPare);

    // 4) Actualitzem la branca origen (hem mogut un fill)
    getArbrePuntEntradaEntityDao().update(brancaOrigen);
    return true;
}

From source file:com.square.adherent.noyau.service.implementations.ContratServiceImpl.java

@Override
public List<CoordonneesBancairesDto> getListeCoordonneesBancaires(Long idPersonne) {
    final Long idMoyenPaiementCheque = adherentMappingService.getIdMoyenPaiementCheque();
    final Long idMoyenPaiementEspece = adherentMappingService.getIdMoyenPaiementEspece();

    final CritereRechercheContratDto criteres = new CritereRechercheContratDto();
    criteres.setIdAssure(idPersonne);/*from  w  w  w.j  a  v  a 2s.com*/
    criteres.setHasContratEnCours(true);
    final List<Contrat> listeContrat = contratDao.getContratsByCriteres(criteres);

    final List<CoordonneesBancairesDto> listeCoordonneesBancaires = new ArrayList<CoordonneesBancairesDto>();
    for (Contrat contrat : listeContrat) {
        final CoordonneesBancairesDto coordonneesBancaires = new CoordonneesBancairesDto();
        coordonneesBancaires.setNumeroContrat(contrat.getNumeroContrat());
        if (contrat.getMoyenPaiementCotisation() != null
                && !idMoyenPaiementCheque.equals(contrat.getMoyenPaiementCotisation().getId())
                && !idMoyenPaiementEspece.equals(contrat.getMoyenPaiementCotisation().getId())) {
            coordonneesBancaires.setInfosBanque(
                    (InfosBanqueDto) mapperDozerBean.map(contrat.getBanqueCotisation(), InfosBanqueDto.class));
        }
        final InfosPaiementDto infosPaiement = new InfosPaiementDto();
        infosPaiement.setFrequencePaiement((IdentifiantLibelleDto) mapperDozerBean
                .map(contrat.getFrequencePaiementCotisation(), IdentifiantLibelleDto.class));
        infosPaiement.setMoyenPaiement((IdentifiantLibelleDto) mapperDozerBean
                .map(contrat.getMoyenPaiementCotisation(), IdentifiantLibelleDto.class));
        infosPaiement.setJourPaiement(contrat.getJourPaiementCotisation());
        coordonneesBancaires.setInfosPaiement(infosPaiement);
        listeCoordonneesBancaires.add(coordonneesBancaires);
    }
    return listeCoordonneesBancaires;
}

From source file:com.ibm.asset.trails.service.impl.ReconServiceImpl.java

@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW)
public Long manualReconcileByAlert(Long alertId, InstalledSoftware parentInstalledSoftware, Recon pRecon,
        String remoteUser, String comments, Account account, Map<License, Integer> appliedLicenseQtyMap,
        String psMethod, int owner) {
    AlertUnlicensedSw selectedAlert = getEntityManager().find(AlertUnlicensedSw.class, alertId);
    List<AlertUnlicensedSw> affectedAlertList = new ArrayList<AlertUnlicensedSw>();
    Reconcile reconcile = null;//w w  w  .  j a v a2 s  .co  m
    Iterator<Entry<License, Integer>> liLicenseApplied = null;
    Entry<License, Integer> leTemp = null;

    liLicenseApplied = appliedLicenseQtyMap.entrySet().iterator();

    while (liLicenseApplied.hasNext()) {
        leTemp = liLicenseApplied.next();
        if (leTemp.getValue().intValue() == 0) {
            log.error("ERROR: Attempting to insert a 0 quantity LicenseReconMap for method " + psMethod);
            log.error(selectedAlert);
            log.error(appliedLicenseQtyMap);
            return null;
        }
    }

    if (isAllocateByHardware(pRecon)) {
        affectedAlertList.addAll(findAffectedAlertList(account,
                selectedAlert.getInstalledSoftware().getSoftware().getSoftwareId(),
                selectedAlert.getInstalledSoftware().getSoftwareLpar().getHardwareLpar().getHardware().getId(),
                pRecon.isAutomated(), pRecon.isManual()));
    } else {
        affectedAlertList.add(selectedAlert);
    }

    liLicenseApplied = appliedLicenseQtyMap.entrySet().iterator();
    Set<UsedLicense> usedLicenseSet = new HashSet<UsedLicense>();
    Set<UsedLicenseHistory> usedLicenseHistorieSet = new HashSet<UsedLicenseHistory>();
    int totalUsedLicenses = 0;
    while (affectedAlertList.size() != 0 && liLicenseApplied.hasNext()) {
        leTemp = liLicenseApplied.next();

        UsedLicense ul = new UsedLicense();
        ul.setLicense(leTemp.getKey());
        ul.setUsedQuantity(leTemp.getValue());
        ul.setCapacityType(leTemp.getKey().getCapacityType());
        getEntityManager().persist(ul);
        usedLicenseSet.add(ul);
        totalUsedLicenses += ul.getUsedQuantity();

        UsedLicenseHistory ulh = new UsedLicenseHistory();
        ulh.setLicense(leTemp.getKey());
        ulh.setUsedQuantity(leTemp.getValue());
        ulh.setCapacityType(leTemp.getKey().getCapacityType());
        getEntityManager().persist(ulh);
        usedLicenseHistorieSet.add(ulh);
    }

    // Story 26012
    int hasInvalidAlertcount = 0;
    int alertWithoutScheduleFcounter = 0;
    int alertWithoutMachineLevelScheduleFcounter = 0;
    for (AlertUnlicensedSw affectedAlert : affectedAlertList) {
        boolean bReconcileValidation = reconcileValidate(affectedAlert, pRecon, totalUsedLicenses);

        // User Story - 17236 - Manual License Allocation at HW level
        // can automatically close Alerts on another account on the same
        // Shared HW as requested by users Start
        int alertlistSwOwner = -1;// default init value
        boolean validateScheduleF4WorkingAlertAndCrossAccountAlertFlag = false;// default
        // init
        // value
        boolean crossAccountAlertFlag = isCrossAccountAlert(
                affectedAlert.getInstalledSoftware().getSoftwareLpar().getAccount(), account);
        if (crossAccountAlertFlag == false) {// same account alert

            // AB added
            alertlistSwOwner = validateScheduleFowner(affectedAlert, pRecon);
            boolean isMachineLevel = isAllocateByHardware(pRecon);
            // this only used to export the schedule F defined flag to
            // ReconWorkspaceImpl
            if (alertlistSwOwner == 2) {
                if (isMachineLevel) {
                    ScheduleF hostnameSf = vSwLparDAO.getHostnameLevelScheduleF(
                            affectedAlert.getInstalledSoftware().getSoftwareLpar().getAccount(),
                            affectedAlert.getInstalledSoftware().getSoftware().getSoftwareName(),
                            affectedAlert.getInstalledSoftware().getSoftwareLpar().getName());
                    if (null != hostnameSf) {
                        alertWithoutMachineLevelScheduleFcounter++;
                    } else {
                        alertWithoutScheduleFcounter++;
                    }
                } else {
                    alertWithoutScheduleFcounter++;
                }

            }

        } else {// cross account alert
            validateScheduleF4WorkingAlertAndCrossAccountAlertFlag = validateScheduleF4WorkingAlertAndCrossAccountAlert(
                    selectedAlert, affectedAlert);
        }

        if ((crossAccountAlertFlag == false && alertlistSwOwner == owner && owner != 2)
                || (crossAccountAlertFlag == true
                        && validateScheduleF4WorkingAlertAndCrossAccountAlertFlag == true)) {

            if (!bReconcileValidation) {
                hasInvalidAlertcount++;
                continue;
            }
            if (affectedAlert.isOpen()) {
                reconcile = createReconcile(affectedAlert.getInstalledSoftware(),
                        affectedAlert.getInstalledSoftware(), pRecon, remoteUser, comments, usedLicenseSet,
                        usedLicenseHistorieSet);

                AlertUnlicensedSwH aush = createAlertHistory(affectedAlert);
                aush.setAlertUnlicensedSw(affectedAlert);

                // Close the alert
                affectedAlert.setOpen(false);
                affectedAlert.setComments("Manual Close");
                affectedAlert.setRecordTime(new Date());
                aush = getEntityManager().merge(aush);
            } else {
                reconcile = affectedAlert.getReconcile();
                Long oldReconcileTypeId = reconcile.getReconcileType().getId();
                reconcile.setParentInstalledSoftware(reconcile.getParentInstalledSoftware());
                reconcile.setReconcileType(pRecon.getReconcileType());
                reconcile.setRecordTime(new Date());
                reconcile.setRemoteUser(remoteUser);
                reconcile.setComments(comments);
                reconcile.setMachineLevel(new Integer(isAllocateByHardware(pRecon) ? 1 : 0));
                if (pRecon.getPer() != null) {
                    AllocationMethodology allocationMethodology = allocationMethodologyService
                            .findByCode(pRecon.getPer().toUpperCase());
                    reconcile.setAllocationMethodology(allocationMethodology);
                }

                if (null != pRecon.getReconcileTypeId() && null != oldReconcileTypeId
                        && pRecon.getReconcileTypeId().equals(1L) && oldReconcileTypeId.equals(5L)
                        && pRecon.isAutomated()) {
                    ScarletReconcile scarletReconcile = scarletReconcileDAO.findById(reconcile.getId());

                    if (null != scarletReconcile) {
                        scarletReconcileDAO.remove(scarletReconcile);
                    }
                }

                log.debug("Clearing licenses");
                clearUsedLicenses(reconcile, remoteUser);
                reconcile.setUsedLicenses(usedLicenseSet);
                log.debug("Saving reconcile");
                reconcile = getEntityManager().merge(reconcile);
                createReconcileHistory(reconcile, usedLicenseHistorieSet);
            }
        }
    } // end of for

    if (hasInvalidAlertcount == affectedAlertList.size()) {
        clearUsedLicenses(usedLicenseSet, usedLicenseHistorieSet, remoteUser);
    }

    // Story 26012
    if (alertWithoutScheduleFcounter == affectedAlertList.size()) {
        setScheduleFDefInRecon("Schedule F not defined for all alerts.");

    } else if (alertWithoutScheduleFcounter > 0 && alertWithoutScheduleFcounter < affectedAlertList.size()) {
        setScheduleFDefInRecon(
                "The reconciliation action could not be applied to alerts where Schedule F is not defined.");
    }

    if (alertWithoutMachineLevelScheduleFcounter > 0) {
        AllocationMethodology allocationMethodology = getAllocationMethodology(pRecon.getPer());
        setScheduleFDefInRecon("The Machine Level Allocation Methodology " + allocationMethodology.getName()
                + " could not be applied on alerts with HOSTNAME level scope.");
    }

    return selectedAlert.getInstalledSoftware().getSoftwareLpar().getHardwareLpar().getHardware().getId();

}

From source file:com.cloud.template.TemplateManagerImpl.java

void verifyTemplateId(Long id) {
    // Don't allow to modify system template
    if (id.equals(Long.valueOf(1))) {
        InvalidParameterValueException ex = new InvalidParameterValueException(
                "Unable to update template/iso of specified id");
        ex.addProxyObject(String.valueOf(id), "templateId");
        throw ex;
    }/*from w  w w.java  2s.  co m*/
}

From source file:com.cloud.template.TemplateManagerImpl.java

@Override
public List<String> listTemplatePermissions(BaseListTemplateOrIsoPermissionsCmd cmd) {
    Account caller = CallContext.current().getCallingAccount();
    Long id = cmd.getId();

    if (id.equals(Long.valueOf(1))) {
        throw new PermissionDeniedException(
                "unable to list permissions for " + cmd.getMediaType() + " with id " + id);
    }//from  w w w  .  j a va  2  s  .  c om

    VirtualMachineTemplate template = _tmpltDao.findById(id);
    if (template == null) {
        throw new InvalidParameterValueException("unable to find " + cmd.getMediaType() + " with id " + id);
    }

    if (cmd instanceof ListTemplatePermissionsCmd) {
        if (template.getFormat().equals(ImageFormat.ISO)) {
            throw new InvalidParameterValueException("Please provide a valid template");
        }
    } else if (cmd instanceof ListIsoPermissionsCmd) {
        if (!template.getFormat().equals(ImageFormat.ISO)) {
            throw new InvalidParameterValueException("Please provide a valid iso");
        }
    }

    if (!template.isPublicTemplate()) {
        _accountMgr.checkAccess(caller, null, true, template);
    }

    List<String> accountNames = new ArrayList<String>();
    List<LaunchPermissionVO> permissions = _launchPermissionDao.findByTemplate(id);
    if ((permissions != null) && !permissions.isEmpty()) {
        for (LaunchPermissionVO permission : permissions) {
            Account acct = _accountDao.findById(permission.getAccountId());
            accountNames.add(acct.getAccountName());
        }
    }

    // also add the owner if not public
    if (!template.isPublicTemplate()) {
        Account templateOwner = _accountDao.findById(template.getAccountId());
        accountNames.add(templateOwner.getAccountName());
    }

    return accountNames;
}

From source file:org.sakaiproject.lti.impl.DBLTIService.java

/**
 * /* w  w w .j a  va  2 s .  c o  m*/
 * {@inheritDoc}
 * 
 * @see org.sakaiproject.lti.impl.BaseLTIService#updateContentDao(java.lang.Long, 
 *      java.lang.Object, java.lang.String, boolean)
 */
public Object updateContentDao(Long key, Object newProps, String siteId, boolean isAdminRole,
        boolean isMaintainRole) {
    if (key == null || newProps == null) {
        throw new IllegalArgumentException("both key and newProps must be non-null");
    }
    if (siteId == null && !isAdminRole) {
        throw new IllegalArgumentException("siteId must be non-null for non-admins");
    }

    // Load the content item
    Map<String, Object> content = getContentDao(key, siteId, isAdminRole);
    if (content == null) {
        return rb.getString("error.content.not.found");
    }
    Long oldToolKey = foorm.getLongNull(content.get(LTI_TOOL_ID));

    Object oToolId = (Object) foorm.getField(newProps, LTI_TOOL_ID);
    Long newToolKey = null;
    if (oToolId != null && oToolId instanceof Number) {
        newToolKey = new Long(((Number) oToolId).longValue());
    } else if (oToolId != null) {
        try {
            newToolKey = new Long((String) oToolId);
        } catch (Exception e) {
            return rb.getString("error.invalid.toolid");
        }
    }
    if (newToolKey == null || newToolKey < 0)
        newToolKey = oldToolKey;

    // Load the tool we are aiming for
    Map<String, Object> tool = getToolDao(newToolKey, siteId, isAdminRole);
    if (tool == null) {
        return rb.getString("error.invalid.toolid");
    }

    // If the user is not an admin, they cannot switch to 
    // a tool that is stealthed
    Long visible = foorm.getLongNull(tool.get(LTI_VISIBLE));
    if (visible == null)
        visible = new Long(0);
    if ((!isAdminRole) && (!oldToolKey.equals(newToolKey))) {
        if (visible == 1) {
            return rb.getString("error.invalid.toolid");
        }
    }

    String[] contentModel = getContentModelDao(tool, isAdminRole);
    if (contentModel == null)
        return rb.getString("error.invalid.toolid");

    return updateThingDao("lti_content", contentModel, LTIService.CONTENT_MODEL, key, newProps, siteId,
            isAdminRole, isMaintainRole);
}

From source file:io.snappydata.hydra.cluster.SnappyTest.java

public static void HydraTask_verifyCountQueryResults() {
    ArrayList<String[]> tables = (ArrayList<String[]>) SQLBB.getBB().getSharedMap().get("tableNames");
    for (String[] table1 : tables) {
        String schemaTableName = table1[0] + "." + table1[1];
        String tableName = schemaTableName;
        Long countQueryResultInSnappy = (Long) SnappyBB.getBB().getSharedMap().get(tableName);
        Log.getLogWriter()//from  w w  w . jav a  2  s. co  m
                .info("countQueryResult for table " + tableName + " in Snappy: " + countQueryResultInSnappy);
        Long countQueryResultInGemXD = (Long) SQLBB.getBB().getSharedMap().get(tableName);
        Log.getLogWriter()
                .info("countQueryResult for table " + tableName + " in GemFireXD: " + countQueryResultInGemXD);
        if (!(countQueryResultInSnappy.equals(countQueryResultInGemXD))) {
            String misMatch = "Test Validation failed as countQuery result for table  " + tableName
                    + " in GemFireXD: " + countQueryResultInGemXD
                    + " did not match not match with countQuery result for table " + tableName + " in Snappy: "
                    + countQueryResultInSnappy;
            throw new TestException(misMatch);
        }
    }
}