public ServiceList findService(FindService body) throws DispositionReportFaultMessage { long startTime = System.nanoTime(); try { new ValidateInquiry(null).validateFindService(body); } catch (DispositionReportFaultMessage drfm) { long procTime = System.nanoTime() - startTime; serviceCounter.update(InquiryQuery.FIND_SERVICE, QueryStatus.FAILED, procTime); throw drfm; } EntityManager em = PersistenceManager.getEntityManager(); EntityTransaction tx = em.getTransaction(); try { tx.begin(); if (isAuthenticated()) this.getEntityPublisher(em, body.getAuthInfo()); org.apache.juddi.query.util.FindQualifiers findQualifiers = new org.apache.juddi.query.util.FindQualifiers(); findQualifiers.mapApiFindQualifiers(body.getFindQualifiers()); List<?> keysFound = InquiryHelper.findService(body, findQualifiers, em); if (keysFound.size() == 0) { if (body.getBusinessKey() != null) { // Check that we were passed a valid businessKey per // 5.1.12.4 of the UDDI v3 spec String businessKey = body.getBusinessKey(); org.apache.juddi.model.BusinessEntity modelBusinessEntity = null; try { modelBusinessEntity = em.find(org.apache.juddi.model.BusinessEntity.class, businessKey); } catch (ClassCastException e) { } if (modelBusinessEntity == null) { throw new InvalidKeyPassedException( new ErrorMessage("errors.invalidkey.BusinessNotFound", businessKey)); } } } ServiceList result = InquiryHelper.getServiceListFromKeys(body, findQualifiers, em, keysFound); tx.rollback(); long procTime = System.nanoTime() - startTime; serviceCounter.update(InquiryQuery.FIND_SERVICE, QueryStatus.SUCCESS, procTime); return result; } finally { if (tx.isActive()) { tx.rollback(); } em.close(); } }
public static void appendConditions(DynamicQuery qry, FindQualifiers fq, Name name) { String namePredicate = DynamicQuery.PREDICATE_EQUALS; if (fq != null && fq.isApproximateMatch()) { namePredicate = DynamicQuery.PREDICATE_LIKE; } qry.WHERE().pad().openParen().pad(); String nameTerm = ENTITY_ALIAS + ".name"; String nameValue = name.getValue(); if (fq != null && fq.isCaseInsensitiveMatch()) { nameTerm = "upper(" + ENTITY_ALIAS + ".name)"; nameValue = name.getValue().toUpperCase(); } // JUDDI-235: wildcards are provided by user (only commenting in case a new interpretation // arises) // if (fq.isApproximateMatch()) // nameValue = nameValue.endsWith(DynamicQuery.WILDCARD)?nameValue:nameValue + // DynamicQuery.WILDCARD; if (name.getLang() == null || name.getLang().length() == 0) { qry.appendGroupedAnd(new DynamicQuery.Parameter(nameTerm, nameValue, namePredicate)); } else { String langValue = name.getLang().endsWith(DynamicQuery.WILDCARD) ? name.getLang().toUpperCase() : name.getLang().toUpperCase() + DynamicQuery.WILDCARD; qry.appendGroupedAnd( new DynamicQuery.Parameter(nameTerm, nameValue, namePredicate), new DynamicQuery.Parameter( "upper(" + ENTITY_ALIAS + ".langCode)", langValue, DynamicQuery.PREDICATE_LIKE)); } qry.closeParen().pad(); if (fq != null && fq.isSignaturePresent()) { qry.AND() .pad() .openParen() .pad() .append(TModelQuery.SIGNATURE_PRESENT) .pad() .closeParen() .pad(); } }
public RelatedBusinessesList findRelatedBusinesses(FindRelatedBusinesses body) throws DispositionReportFaultMessage { long startTime = System.nanoTime(); try { new ValidateInquiry(null).validateFindRelatedBusinesses(body, false); } catch (DispositionReportFaultMessage drfm) { long procTime = System.nanoTime() - startTime; serviceCounter.update(InquiryQuery.FIND_RELATEDBUSINESSES, QueryStatus.FAILED, procTime); throw drfm; } EntityManager em = PersistenceManager.getEntityManager(); EntityTransaction tx = em.getTransaction(); try { tx.begin(); if (isAuthenticated()) this.getEntityPublisher(em, body.getAuthInfo()); // TODO: findQualifiers aren't really used for this call, except maybe for sorting. Sorting // must be done in Java due to the retrieval method used. Right now // no sorting is performed. org.apache.juddi.query.util.FindQualifiers findQualifiers = new org.apache.juddi.query.util.FindQualifiers(); findQualifiers.mapApiFindQualifiers(body.getFindQualifiers()); RelatedBusinessesList result = InquiryHelper.getRelatedBusinessesList(body, em); tx.rollback(); long procTime = System.nanoTime() - startTime; serviceCounter.update(InquiryQuery.FIND_RELATEDBUSINESSES, QueryStatus.SUCCESS, procTime); return result; } finally { if (tx.isActive()) { tx.rollback(); } em.close(); } }
public BusinessList findBusiness(FindBusiness body) throws DispositionReportFaultMessage { long startTime = System.nanoTime(); try { new ValidateInquiry(null).validateFindBusiness(body); } catch (DispositionReportFaultMessage drfm) { long procTime = System.nanoTime() - startTime; serviceCounter.update(InquiryQuery.FIND_BUSINESS, QueryStatus.FAILED, procTime); throw drfm; } EntityManager em = PersistenceManager.getEntityManager(); EntityTransaction tx = em.getTransaction(); try { tx.begin(); if (isAuthenticated()) this.getEntityPublisher(em, body.getAuthInfo()); org.apache.juddi.query.util.FindQualifiers findQualifiers = new org.apache.juddi.query.util.FindQualifiers(); findQualifiers.mapApiFindQualifiers(body.getFindQualifiers()); List<?> keysFound = InquiryHelper.findBusiness(body, findQualifiers, em); BusinessList result = InquiryHelper.getBusinessListFromKeys(body, findQualifiers, em, keysFound); tx.rollback(); long procTime = System.nanoTime() - startTime; serviceCounter.update(InquiryQuery.FIND_BUSINESS, QueryStatus.SUCCESS, procTime); return result; } finally { if (tx.isActive()) { tx.rollback(); } em.close(); } }