List of usage examples for java.lang Long equals
public boolean equals(Object obj)
From source file:com.gst.portfolio.loanaccount.domain.Loan.java
public LoanDisbursementDetails fetchLoanDisbursementsById(Long id) { LoanDisbursementDetails loanDisbursementDetail = null; for (LoanDisbursementDetails disbursementDetail : this.disbursementDetails) { if (id.equals(disbursementDetail.getId())) { loanDisbursementDetail = disbursementDetail; break; }//w w w . j a v a 2 s . c om } return loanDisbursementDetail; }
From source file:com.gst.portfolio.loanaccount.domain.Loan.java
private void removeChargesByDisbursementID(Long id) { List<LoanCharge> tempCharges = new ArrayList<>(); for (LoanCharge charge : this.charges) { LoanTrancheDisbursementCharge transCharge = charge.getTrancheDisbursementCharge(); if (transCharge != null && id.equals(transCharge.getloanDisbursementDetails().getId())) { tempCharges.add(charge);/*from www .j ava 2 s. co m*/ } } for (LoanCharge charge : tempCharges) { removeLoanCharge(charge); } }
From source file:ome.formats.OMEROMetadataStoreClient.java
private void resetPixelsId(Long pixId) throws ServerError { if (pixId != null && !pixId.equals(currentPixId)) { rawPixelStore.setPixelsId(pixId, true); currentPixId = pixId;//from w w w . j a v a2 s . com } }
From source file:br.gov.jfrj.siga.ex.bl.ExBL.java
public String assinarDocumento(final DpPessoa cadastrante, final DpLotacao lotaCadastrante, final ExDocumento doc, final Date dtMov, final byte[] pkcs7, final byte[] certificado, long tpMovAssinatura) throws AplicacaoException { String sNome;//from w w w. j av a 2s . c o m Long lCPF = null; if (doc.isCancelado()) throw new AplicacaoException("No possvel assinar um documento cancelado."); boolean fPreviamenteAssinado = doc.isAssinado(); if (!fPreviamenteAssinado) { try { processarComandosEmTag(doc, "pre_assinatura"); } catch (AplicacaoException e) { throw e; } catch (Exception e) { throw new Error(e); } } final byte[] cms; try { final byte[] data = doc.getConteudoBlobPdf(); CdService client = Service.getCdService(); String s; if (certificado != null) { cms = client.validarECompletarPacoteAssinavel(certificado, data, pkcs7, true, (dtMov != null) ? dtMov : dao().consultarDataEHoraDoServidor()); } else { // s = client.validarAssinatura(pkcs7, data, dao().dt(), // VALIDAR_LCR); // Service.throwExceptionIfError(s); // // if (BUSCAR_CARIMBO_DE_TEMPO) { cms = client.validarECompletarAssinatura(pkcs7, data, true, dtMov); } sNome = client.validarAssinatura(cms, data, dao().dt(), VALIDAR_LCR); // cms = client // .converterPkcs7EmCMSComCertificadosLCRsECarimboDeTempo(pkcs7); // Service.throwExceptionIfError(cms); // // sNome = client.validarAssinaturaCMS( // MessageDigest.getInstance("SHA1").digest(data), SHA1, // cms, dao().dt()); Service.throwExceptionIfError(sNome); String sCPF = client.recuperarCPF(cms); Service.throwExceptionIfError(sCPF); lCPF = Long.valueOf(sCPF); // } else { // sNome = s; // String sCPF = client.recuperarCPF(pkcs7); // Service.throwExceptionIfError(sCPF); // lCPF = Long.valueOf(sCPF); // } // writeB64File("c:/trabalhos/java/cd_teste_doc.b64", data); // writeB64File("c:/trabalhos/java/cd_teste_hash.b64", // MessageDigest // .getInstance("SHA1").digest(data)); // writeB64File("c:/trabalhos/java/cd_teste_pkcs7.b64", pkcs7); // writeB64File("c:/trabalhos/java/cd_teste_cms.b64", cms); } catch (final Exception e) { throw new AplicacaoException( "Erro na assinatura de um documento: " + e.getMessage() == null ? "" : e.getMessage(), 0, e); } boolean fValido = false; Long lMatricula = null; DpPessoa usuarioDoToken = null; // Obtem a matricula do assinante try { if (sNome == null) throw new AplicacaoException("No foi possvel acessar o nome do assinante"); String sMatricula = sNome.split(":")[1]; lMatricula = Long.valueOf(sMatricula); } catch (final Exception e) { // throw new AplicacaoException( // "No foi possvel obter a matrcula do assinante", 0, e); } // Verifica se a matrcula confere com o subscritor titular ou com um // cossignatario try { if (lMatricula != null) { if (doc.getSubscritor() != null && lMatricula.equals(doc.getSubscritor().getMatricula())) { fValido = true; usuarioDoToken = doc.getSubscritor(); } if (!fValido) { fValido = (lMatricula.equals(doc.getCadastrante().getMatricula())) && (doc.getExTipoDocumento().getIdTpDoc() == ExTipoDocumento.TIPO_DOCUMENTO_EXTERNO); } if (!fValido) for (ExMovimentacao m : doc.getMobilGeral().getExMovimentacaoSet()) { if (m.getExTipoMovimentacao() .getIdTpMov() == ExTipoMovimentacao.TIPO_MOVIMENTACAO_INCLUSAO_DE_COSIGNATARIO && m.getExMovimentacaoCanceladora() == null && lMatricula.equals(m.getSubscritor().getMatricula())) { fValido = true; usuarioDoToken = m.getSubscritor(); continue; } } if (!fValido && tpMovAssinatura == ExTipoMovimentacao.TIPO_MOVIMENTACAO_CONFERENCIA_COPIA_DOCUMENTO && Ex.getInstance().getComp().podeAutenticarDocumento(cadastrante, lotaCadastrante, doc)) { fValido = true; } } if (!fValido && lCPF != null) { if (doc.getSubscritor() != null && lCPF.equals(doc.getSubscritor().getCpfPessoa())) { fValido = true; usuarioDoToken = doc.getSubscritor(); } if (!fValido) { fValido = (lCPF.equals(doc.getCadastrante().getCpfPessoa())) && (doc.getExTipoDocumento().getIdTpDoc() == ExTipoDocumento.TIPO_DOCUMENTO_EXTERNO); } if (!fValido) for (ExMovimentacao m : doc.getMobilGeral().getExMovimentacaoSet()) { if (m.getExTipoMovimentacao() .getIdTpMov() == ExTipoMovimentacao.TIPO_MOVIMENTACAO_INCLUSAO_DE_COSIGNATARIO && m.getExMovimentacaoCanceladora() == null && lCPF.equals(m.getSubscritor().getCpfPessoa())) { fValido = true; usuarioDoToken = m.getSubscritor(); continue; } } if (!fValido && tpMovAssinatura == ExTipoMovimentacao.TIPO_MOVIMENTACAO_CONFERENCIA_COPIA_DOCUMENTO && Ex.getInstance().getComp().podeAutenticarDocumento(cadastrante, lotaCadastrante, doc)) { fValido = true; } } if (lMatricula == null && lCPF == null) throw new AplicacaoException("No foi possvel recuperar nem a matrcula nem o CPF do assinante"); if (fValido == false) throw new AplicacaoException("Assinante no subscritor nem cossignatario"); } catch (final Exception e) { throw new AplicacaoException( "S permitida a assinatura digital do subscritor e dos cossignatrios do documento", 0, e); } String s = null; try { iniciarAlteracao(); if (usuarioDoToken != null && usuarioDoToken.equivale(cadastrante)) usuarioDoToken = cadastrante; final ExMovimentacao mov = criarNovaMovimentacao(tpMovAssinatura, cadastrante, lotaCadastrante, doc.getMobilGeral(), dtMov, usuarioDoToken, null, null, null, null); // if (BUSCAR_CARIMBO_DE_TEMPO) { // mov.setConteudoTpMov(CdService.MIME_TYPE_CMS); mov.setConteudoBlobMov2(cms); // } else { mov.setConteudoTpMov(CdService.MIME_TYPE_PKCS7); // mov.setConteudoBlobMov2(pkcs7); // } mov.setDescrMov(sNome); gravarMovimentacao(mov); concluirAlteracao(mov.getExDocumento()); // Verifica se o documento possui documento pai e faz a juntada // automtica. Caso o pai seja um volume de um processo, primeiro // verifica se o volume est encerrado, se estiver procura o ltimo // volume para juntar. if (doc.getExMobilPai() != null) { if (doc.getExMobilPai().getDoc().isProcesso() && doc.getExMobilPai().isVolumeEncerrado()) { doc.setExMobilPai(doc.getExMobilPai().doc().getUltimoVolume()); gravar(cadastrante, lotaCadastrante, doc, null); } juntarAoDocumentoPai(cadastrante, lotaCadastrante, doc, dtMov, cadastrante, cadastrante, mov); } if (doc.getExMobilAutuado() != null) { juntarAoDocumentoAutuado(cadastrante, lotaCadastrante, doc, dtMov, cadastrante, cadastrante, mov); } if (!fPreviamenteAssinado && doc.isAssinado()) { processarComandosEmTag(doc, "assinatura"); } } catch (final Exception e) { cancelarAlteracao(); if (e.getMessage().contains("junta")) throw new AplicacaoException( "O documento foi assinado com sucesso mas no foi possvel juntar este documento ao documento pai. O erro da juntada foi - " + e.getMessage(), 0, e); throw new AplicacaoException("Erro ao assinar documento.", 0, e); } alimentaFilaIndexacao(doc, true); return s; }
From source file:jp.primecloud.auto.service.impl.InstanceServiceImpl.java
/** * {@inheritDoc}/*w ww . ja v a2 s . c o m*/ */ @Override public void updateCloudstackInstance(Long instanceNo, String instanceName, String comment, String keyName, String instanceType, String securityGroupName, String zoneid, Long addressNo) { // ? updateInstance(instanceNo, instanceName, comment); // ? if (instanceNo == null) { throw new AutoApplicationException("ECOMMON-000003", "instanceNo"); } // ?? Instance instance = instanceDao.read(instanceNo); if (instance == null) { throw new AutoApplicationException("ESERVICE-000403", instanceNo); } // ?? Platform platform = platformDao.read(instance.getPlatformNo()); if (PCCConstant.PLATFORM_TYPE_CLOUDSTACK.equals(platform.getPlatformType()) == false) { throw new AutoApplicationException("ESERVICE-000404", instance.getInstanceName()); } // ?????? CloudstackInstance cloudstackInstance = cloudstackInstanceDao.read(instanceNo); if (InstanceStatus.fromStatus(instance.getStatus()) != InstanceStatus.STOPPED) { // ?????????????????? if (!StringUtils.equals(cloudstackInstance.getKeyName(), keyName)) { throw new AutoApplicationException("ESERVICE-000407", instance.getInstanceName()); } if (!StringUtils.equals(cloudstackInstance.getInstanceType(), instanceType)) { throw new AutoApplicationException("ESERVICE-000407", instance.getInstanceName()); } if (StringUtils.isEmpty(cloudstackInstance.getSecuritygroup()) ? StringUtils.isNotEmpty(securityGroupName) : !StringUtils.equals(cloudstackInstance.getSecuritygroup(), securityGroupName)) { throw new AutoApplicationException("ESERVICE-000407", instance.getInstanceName()); } if (StringUtils.isEmpty(cloudstackInstance.getZoneid()) ? StringUtils.isNotEmpty(zoneid) : !StringUtils.equals(cloudstackInstance.getZoneid(), zoneid)) { throw new AutoApplicationException("ESERVICE-000407", instance.getInstanceName()); } } // ?? if (StringUtils.isEmpty(cloudstackInstance.getZoneid()) ? StringUtils.isNotEmpty(zoneid) : !StringUtils.equals(cloudstackInstance.getZoneid(), zoneid)) { if (cloudstackVolumeDao.countByInstanceNo(instanceNo) > 0) { // EBS??????? throw new AutoApplicationException("ESERVICE-000412", instance.getInstanceName()); } } //?? CloudstackAddress cloudstackAddress = null; if (addressNo != null) { // ?? cloudstackAddress = cloudstackAddressDao.read(addressNo); if (cloudstackAddress == null) { throw new AutoApplicationException("ESERVICE-000415", addressNo); } // ???????????? if (cloudstackAddress.getInstanceNo() != null && !instanceNo.equals(cloudstackAddress.getInstanceNo())) { // ?????? throw new AutoApplicationException("ESERVICE-000416", cloudstackAddress.getIpaddress()); } } // ? cloudstackInstance.setKeyName(keyName); cloudstackInstance.setInstanceType(instanceType); cloudstackInstance.setSecuritygroup(securityGroupName); cloudstackInstance.setZoneid(zoneid); cloudstackInstanceDao.update(cloudstackInstance); // ????????? List<CloudstackAddress> cloudstackAddresses = cloudstackAddressDao.readByInstanceNo(instanceNo); for (CloudstackAddress address : cloudstackAddresses) { if (address.getAddressNo().equals(addressNo)) { continue; } address.setInstanceNo(null); cloudstackAddressDao.update(address); } // ?? if (addressNo != null && !instanceNo.equals(cloudstackAddress.getInstanceNo())) { cloudstackAddress.setInstanceNo(instanceNo); cloudstackAddressDao.update(cloudstackAddress); } // Farm farm = farmDao.read(instance.getFarmNo()); eventLogger.log(EventLogLevel.INFO, farm.getFarmNo(), farm.getFarmName(), null, null, instanceNo, instanceName, "InstanceUpdate", instanceType, instance.getPlatformNo(), null); }
From source file:com.gst.portfolio.loanaccount.domain.Loan.java
public LoanTransaction handlePayDisbursementTransaction(final Long chargeId, final LoanTransaction chargesPayment, final List<Long> existingTransactionIds, final List<Long> existingReversedTransactionIds) { existingTransactionIds.addAll(findExistingTransactionIds()); existingReversedTransactionIds.addAll(findExistingReversedTransactionIds()); LoanCharge charge = null;/*from w w w .j a va 2 s. c o m*/ for (final LoanCharge loanCharge : this.charges) { if (loanCharge.isActive() && chargeId.equals(loanCharge.getId())) { charge = loanCharge; } } @SuppressWarnings("null") final LoanChargePaidBy loanChargePaidBy = new LoanChargePaidBy(chargesPayment, charge, charge.amount(), null); chargesPayment.getLoanChargesPaid().add(loanChargePaidBy); final Money zero = Money.zero(getCurrency()); chargesPayment.updateComponents(zero, zero, charge.getAmount(getCurrency()), zero); chargesPayment.updateLoan(this); addLoanTransaction(chargesPayment); updateLoanOutstandingBalaces(); charge.markAsFullyPaid(); return chargesPayment; }
From source file:com.square.core.service.implementations.PersonneServiceImplementation.java
private Telephone creerOuMettreAJourTelephone(Set<Personne> personnes, TelephoneDto telephoneDto, Boolean impacterFamille) { // Vrification des dpendances final NatureTelephone natureTelephone = natureTelephoneDao .rechercherNatureTelephoneParId(telephoneDto.getNature().getIdentifiant()); if (natureTelephone == null) { throw new BusinessException(messageSourceUtil .get(PersonnePhysiqueKeyUtil.MESSAGE_ERREUR_NATURE_TELEPHONE_INEXISTENT_EN_BD)); }/*from ww w . ja va 2s .c o m*/ final Pays paysTelephone = paysDao.rechercherPaysParId(telephoneDto.getPays().getId()); if (paysTelephone == null) { throw new BusinessException( messageSourceUtil.get(PersonnePhysiqueKeyUtil.MESSAGE_ERREUR_PAYS_INEXISTENT_EN_BD)); } // On construit la liste des identifiants des persones de la famille final Set<Long> idsPersonnes = new LinkedHashSet<Long>(); for (Personne personne : personnes) { idsPersonnes.add(personne.getId()); } // On construit la liste des personnes associes au tlphone en cas de restauration final Set<Personne> nouvellesPersonnes = new LinkedHashSet<Personne>(); Long idPersonneModifie = null; for (Personne personne : personnes) { if (idPersonneModifie == null) { idPersonneModifie = personne.getId(); } nouvellesPersonnes.add(personne); if (BooleanUtils.isFalse(impacterFamille)) { break; } } // On supprime le formatage du numro de tlphone pour stocker les donnes brutes seulement final String numeroTelephone = formatUtil.supprimerFormatNumTel(telephoneDto.getNumero()); Telephone telephone; final Calendar maintenant = Calendar.getInstance(); if (telephoneDto.getId() != null) { // si le tlphone est supprimer if (BooleanUtils.isTrue(telephoneDto.getSupprime())) { final Telephone tel = telephoneDao.rechercherTelephoneParId(telephoneDto.getId()); supprimerTelephone(tel, maintenant); return tel; } else { // MODE MISE A JOUR // On rcupre le tlphone mettre jour telephone = telephoneDao.rechercherTelephoneParId(telephoneDto.getId()); if (telephone == null) { throw new BusinessException(messageSourceUtil .get(PersonnePhysiqueKeyUtil.MESSAGE_ERREUR_TELEPHONE_INEXISTENT_EN_BD)); } // On vrifie que le tlphone n'existe pas dj dans la liste des tlphones de la personne final CritereRechercheTelephone critereTel = new CritereRechercheTelephone(); critereTel.setIdsPersonnes(idsPersonnes); critereTel.getIdsTelExclus().add(telephoneDto.getId()); critereTel.setNumeroTelephone(numeroTelephone); critereTel.setIsSupprime(null); final List<Telephone> listeTelephones = telephoneDao.rechercherTelephoneParCritere(critereTel); if (listeTelephones != null && listeTelephones.size() > 0) { // Ce tlphone existe dj, on le rcupre final Telephone telExistant = listeTelephones.get(0); // On le restaure restaurerTelephone(telExistant, nouvellesPersonnes, maintenant); // On supprime l'ancien tlphone supprimerTelephone(telephone, maintenant); return telExistant; } else { // MISE A JOUR DU TELEPHONE telephone.setDateModification(maintenant); telephone.setNumTelephone(numeroTelephone); telephone.setPays(paysTelephone); telephone.setNatureTelephone(natureTelephone); return telephone; } } } else { // MODE CREATION // On vrifie que le tlphone n'existe pas dj dans la liste des tlphones de la personne final CritereRechercheTelephone critereTel = new CritereRechercheTelephone(); critereTel.setIdsPersonnes(idsPersonnes); critereTel.setNumeroTelephone(numeroTelephone); critereTel.setIsSupprime(null); final List<Telephone> listeTelephones = telephoneDao.rechercherTelephoneParCritere(critereTel); if (listeTelephones != null && listeTelephones.size() > 0) { // Le tlphone existe dj, on le rcupre telephone = listeTelephones.get(0); // si le tlphone est de diffrente nature on lui change sa nature if (telephoneDto.getNature() != null && (telephone.getNatureTelephone() == null || !telephone .getNatureTelephone().getId().equals(telephoneDto.getNature().getIdentifiant()))) { telephone.setNatureTelephone(natureTelephone); return telephone; } // Mantis 8288 On vrifie que la liste des personnes rataches au numro ne contient // que la personne sur laquelle on veux changer le numro final List<String> listeNumerosPersonneFamilleConcernees = new ArrayList<String>(); for (Personne personneTel : telephone.getPersonnes()) { if (!idPersonneModifie.equals(personneTel.getId())) { listeNumerosPersonneFamilleConcernees.add(personneTel.getNum()); } } if (listeNumerosPersonneFamilleConcernees.size() > 0 && !telephone.isSupprime()) { String messageErreur = "Certains membres de la famille possdent dj le numro de tlphone " + telephone.getNumTelephone() + ", veuillez d'abord leur supprimer ou bien ne pas demander les impacter. Les numros des personnes concernes sont : "; final int nbNum = listeNumerosPersonneFamilleConcernees.size(); int compteur = 0; for (String num : listeNumerosPersonneFamilleConcernees) { compteur++; messageErreur = messageErreur + num + (compteur == nbNum ? "." : ", "); } throw new BusinessException(messageErreur); } // On restaure le tlphone restaurerTelephone(telephone, nouvellesPersonnes, maintenant); return telephone; } else { // CREATION D'UN NOUVEAU TELEPHONE telephone = new Telephone(); telephone.setDateCreation(maintenant); telephone.setNumTelephone(numeroTelephone); telephone.setPays(paysTelephone); telephone.setNatureTelephone(natureTelephone); if (telephoneDto.getIdext() != null) { telephone.setIdentifiantExterieur(telephoneDto.getIdext()); } return telephone; } } }
From source file:com.cloud.configuration.ConfigurationManagerImpl.java
@Override public void checkPodCidrSubnets(final long dcId, final Long podIdToBeSkipped, final String cidr) { // For each pod, return an error if any of the following is true: // The pod's CIDR subnet conflicts with the CIDR subnet of any other pod // Check if the CIDR conflicts with the Guest Network or other pods long skipPod = 0; if (podIdToBeSkipped != null) { skipPod = podIdToBeSkipped;/*from w ww . j a v a 2 s.com*/ } final HashMap<Long, List<Object>> currentPodCidrSubnets = _podDao.getCurrentPodCidrSubnets(dcId, skipPod); final List<Object> newCidrPair = new ArrayList<Object>(); newCidrPair.add(0, getCidrAddress(cidr)); newCidrPair.add(1, (long) getCidrSize(cidr)); currentPodCidrSubnets.put(new Long(-1), newCidrPair); final DataCenterVO dcVo = _zoneDao.findById(dcId); final String guestNetworkCidr = dcVo.getGuestNetworkCidr(); // Guest cidr can be null for Basic zone String guestIpNetwork = null; Long guestCidrSize = null; if (guestNetworkCidr != null) { final String[] cidrTuple = guestNetworkCidr.split("\\/"); guestIpNetwork = NetUtils.getIpRangeStartIpFromCidr(cidrTuple[0], Long.parseLong(cidrTuple[1])); guestCidrSize = Long.parseLong(cidrTuple[1]); } final String zoneName = getZoneName(dcId); // Iterate through all pods in this zone for (final Long podId : currentPodCidrSubnets.keySet()) { String podName; if (podId.longValue() == -1) { podName = "newPod"; } else { podName = getPodName(podId.longValue()); } final List<Object> cidrPair = currentPodCidrSubnets.get(podId); final String cidrAddress = (String) cidrPair.get(0); final long cidrSize = ((Long) cidrPair.get(1)).longValue(); long cidrSizeToUse = -1; if (guestCidrSize == null || cidrSize < guestCidrSize) { cidrSizeToUse = cidrSize; } else { cidrSizeToUse = guestCidrSize; } String cidrSubnet = NetUtils.getCidrSubNet(cidrAddress, cidrSizeToUse); if (guestNetworkCidr != null) { final String guestSubnet = NetUtils.getCidrSubNet(guestIpNetwork, cidrSizeToUse); // Check that cidrSubnet does not equal guestSubnet if (cidrSubnet.equals(guestSubnet)) { if (podName.equals("newPod")) { throw new InvalidParameterValueException( "The subnet of the pod you are adding conflicts with the subnet of the Guest IP Network. Please specify a different CIDR."); } else { throw new InvalidParameterValueException("Warning: The subnet of pod " + podName + " in zone " + zoneName + " conflicts with the subnet of the Guest IP Network. Please change either the pod's CIDR or the Guest IP Network's subnet, and re-run install-vmops-management."); } } } // Iterate through the rest of the pods for (final Long otherPodId : currentPodCidrSubnets.keySet()) { if (podId.equals(otherPodId)) { continue; } // Check that cidrSubnet does not equal otherCidrSubnet final List<Object> otherCidrPair = currentPodCidrSubnets.get(otherPodId); final String otherCidrAddress = (String) otherCidrPair.get(0); final long otherCidrSize = ((Long) otherCidrPair.get(1)).longValue(); if (cidrSize < otherCidrSize) { cidrSizeToUse = cidrSize; } else { cidrSizeToUse = otherCidrSize; } cidrSubnet = NetUtils.getCidrSubNet(cidrAddress, cidrSizeToUse); final String otherCidrSubnet = NetUtils.getCidrSubNet(otherCidrAddress, cidrSizeToUse); if (cidrSubnet.equals(otherCidrSubnet)) { final String otherPodName = getPodName(otherPodId.longValue()); if (podName.equals("newPod")) { throw new InvalidParameterValueException( "The subnet of the pod you are adding conflicts with the subnet of pod " + otherPodName + " in zone " + zoneName + ". Please specify a different CIDR."); } else { throw new InvalidParameterValueException("Warning: The pods " + podName + " and " + otherPodName + " in zone " + zoneName + " have conflicting CIDR subnets. Please change the CIDR of one of these pods."); } } } } }
From source file:br.gov.jfrj.siga.ex.bl.ExBL.java
public void assinarMovimentacao(DpPessoa cadastrante, DpLotacao lotaCadastrante, ExMovimentacao movAlvo, final Date dtMov, final byte[] pkcs7, final byte[] certificado, long tpMovAssinatura) throws AplicacaoException { if (movAlvo != null) { log.info(//from w w w . ja va2 s . co m "Assinando movimentacao: " + movAlvo.toString() + " Id da movimentao: " + movAlvo.getIdMov()); } else { log.warn("A movimentacao a ser assinada nao pode ser nula"); throw new AplicacaoException("No possvel assinar uma movimentao cancelada."); } if (movAlvo.isCancelada()) { log.warn("A movimentacao a ser assinada est cancelada"); throw new AplicacaoException("No possvel assinar uma movimentao cancelada."); } String sNome; Long lCPF = null; final byte[] cms; try { final byte[] data = movAlvo.getConteudoBlobpdf(); CdService client = Service.getCdService(); String s; if (certificado != null) { cms = client.validarECompletarPacoteAssinavel(certificado, data, pkcs7, true, (dtMov != null) ? dtMov : dao().consultarDataEHoraDoServidor()); } else { // s = client.validarAssinatura(pkcs7, data, dao().dt(), // VALIDAR_LCR); // Service.throwExceptionIfError(s); // // if (BUSCAR_CARIMBO_DE_TEMPO) { cms = client.validarECompletarAssinatura(pkcs7, data, true, dtMov); } if (cms == null) throw new Exception("Assinatura invlida!"); if (data == null) throw new Exception("Contedo invlido na validao da assinatura!"); sNome = client.validarAssinatura(cms, data, dao().dt(), VALIDAR_LCR); Service.throwExceptionIfError(sNome); String sCPF = client.recuperarCPF(cms); Service.throwExceptionIfError(sCPF); lCPF = Long.valueOf(sCPF); boolean fValido = false; Long lMatricula = null; try { if (sNome == null) throw new AplicacaoException("No foi possvel acessar o nome do assinante"); String sMatricula = sNome.split(":")[1]; lMatricula = Long.valueOf(sMatricula.replace("-", "")); } catch (final Exception e) { // throw new AplicacaoException( // "No foi possvel obter a matrcula do assinante", 0, e); } // Verifica se a matrcula confere com o subscritor do Despacho ou // do // desentranhamento no caso de assinatura de despacho if (tpMovAssinatura == ExTipoMovimentacao.TIPO_MOVIMENTACAO_ASSINATURA_DIGITAL_MOVIMENTACAO && (movAlvo .getIdTpMov() == ExTipoMovimentacao.TIPO_MOVIMENTACAO_DESPACHO || movAlvo.getIdTpMov() == ExTipoMovimentacao.TIPO_MOVIMENTACAO_DESPACHO_TRANSFERENCIA || movAlvo.getIdTpMov() == ExTipoMovimentacao.TIPO_MOVIMENTACAO_DESPACHO_TRANSFERENCIA_EXTERNA || movAlvo.getIdTpMov() == ExTipoMovimentacao.TIPO_MOVIMENTACAO_CANCELAMENTO_JUNTADA)) { try { if (lMatricula != null) { fValido = movAlvo.getSubscritor() != null && lMatricula.equals(movAlvo.getSubscritor().getMatricula()); } if (!fValido && lCPF != null) { fValido = movAlvo.getSubscritor() != null && lCPF.equals(movAlvo.getSubscritor().getCpfPessoa()); } if (lMatricula == null && lCPF == null) { log.warn("No foi possvel recuperar nem a matrcula nem o CPF do assinante"); throw new AplicacaoException( "No foi possvel recuperar nem a matrcula nem o CPF do assinante"); } if (fValido == false && movAlvo.getIdTpMov() == ExTipoMovimentacao.TIPO_MOVIMENTACAO_CANCELAMENTO_JUNTADA) { log.warn("Assinante no subscritor do desentranhamento"); throw new AplicacaoException("Assinante no subscritor do desentranhamento"); } if (fValido == false) { log.warn("Assinante no subscritor do despacho"); throw new AplicacaoException("Assinante no subscritor do despacho"); } } catch (final Exception e) { if (fValido == false && movAlvo.getIdTpMov() == ExTipoMovimentacao.TIPO_MOVIMENTACAO_CANCELAMENTO_JUNTADA) { log.warn("S permitida a assinatura digital do subscritor do desentranhamento"); throw new AplicacaoException( "S permitida a assinatura digital do subscritor do desentranhamento", 0, e); } log.warn("S permitida a assinatura digital do subscritor do despacho"); throw new AplicacaoException("S permitida a assinatura digital do subscritor do despacho", 0, e); } } log.info("Iniciando alterao da movimentao " + movAlvo.toString() + " Id da movimentao: " + movAlvo.getIdMov()); iniciarAlteracao(); // Nato: isso esta errado. Deveriamos estar recebendo o cadastrante // e sua lotacao. final ExMovimentacao mov = criarNovaMovimentacao(tpMovAssinatura, cadastrante, lotaCadastrante, movAlvo.getExMobil(), null, null, null, null, null, null); mov.setExMovimentacaoRef(movAlvo); // if (BUSCAR_CARIMBO_DE_TEMPO) { // mov.setConteudoTpMov(CdService.MIME_TYPE_CMS); mov.setConteudoBlobMov2(cms); // } else { mov.setConteudoTpMov(CdService.MIME_TYPE_PKCS7); // mov.setConteudoBlobMov2(pkcs7); // } mov.setDescrMov(sNome); gravarMovimentacao(mov); concluirAlteracao(mov.getExDocumento()); } catch (final AplicacaoException e) { cancelarAlteracao(); throw e; } catch (final Exception e) { log.error("Erro ao assinar movimentao.", e); cancelarAlteracao(); throw new AplicacaoException("Erro ao assinar movimentao.", 0, e); } }
From source file:com.viettel.hqmc.DAOHE.FilesDAOHE.java
private boolean checkProductTargetIsModify(ProductTarget target, List<ProductTarget> lstItem, Long status) { if (status.equals(Constants.FILE_STATUS.EVALUATED_TO_ADD)) { return false; }//from ww w. ja va 2s. co m if (target.getProductTargetId() == null || target.getProductTargetId() <= 0l) { return true; } if (lstItem == null) { return false; } if (lstItem.isEmpty()) { return false; } for (ProductTarget item : lstItem) { if (target.getProductTargetId().equals(item.getProductTargetId()) || target.getProductTargetId().equals(item.getOriginalId())) { if (item.getMaxLevel() != null && target.getMaxLevel() != null) { if (!item.getMaxLevel().equals(target.getMaxLevel())) { return true; } } if (item.getTargetName() != null && target.getTargetName() != null) { if (!item.getTargetName().equals(target.getTargetName())) { return true; } } if (item.getUnitId() != null && target.getUnitId() != null) { if (!item.getUnitId().equals(target.getUnitId())) { return true; } } } } return false; }