Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' into feature/JUDDI-991
Browse files Browse the repository at this point in the history
  • Loading branch information
spyhunter99 committed Nov 23, 2018
2 parents e411229 + bc3d6b9 commit 8016bf3
Show file tree
Hide file tree
Showing 33 changed files with 276 additions and 103 deletions.
33 changes: 33 additions & 0 deletions KEYS
Expand Up @@ -1732,3 +1732,36 @@ wmcS4vGJ6xCH3CjErHYntz8PK6Pz0ITDTi7RWjaaFFS2VI+72Jb0x9O3qJ6LQuIa
zqXNuW+b9q0QrxX3GNTRP+gtES6qXuZvUIHDa6fBmtE6qi7w/CM=
=BRII
-----END PGP PUBLIC KEY BLOCK-----

pub rsa4096 2018-11-23 [SC] [expires: 2023-11-22]
3A1AAFA9B89A1D1DDD5F3A4B98AD2E19BFF4106D
uid [ultimate] Alex O'Ree <alexoree@apache.org>
-----BEGIN PGP PUBLIC KEY BLOCK-----

mQINBFv3+7oBEADXMQXwYMxs45ePjno3XcOouM5NMCYsKk6qmrCBr2ffLLTPER6M
9KtyYAqCqe1DQmB0BRau1GuBRN6mydzILjVaJ6B1S+SsDGHOTDpTVyKUKSkQ292X
KzGq3w5xqvQ1ZP1Iob38XvGQDR2vKnqDeZhVcCsDrbMPBpO3bxCCwrztwHogGZiA
wejypOGlYz3stRY7SKvFkuuH75An6KGx/C9VDh8EH0tUT3hQ09On1/m6+I/8X3YR
WUhCj5WuUg9oaI0MCd9CjgKRH7PEnemFhb1iXBxcOn8vC8hRmYqsl54gIhfF9T8P
HdyTfqji7AKNu3zz3yiiaqlteZewxFyjhwnjvmJMQ+D5Mt9ZfexuDIMY7319psiY
w8x8CuDb1NPq3vR/P0oo5baldIk2r3K0uOdXBGOls1bbqUTv2V+fFdAzk7qC+kxU
PrEpkFKMKd2jtkcO/0Qfgn5r5r7aU1AyGRbXT7fySMT2/6GFu4XSrVWBtjFP9u7F
5ELb19dFaQk6eUCr+ZMTwz5TP6pajDp3NSBX+lXZipY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List;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.persistence.EntityManager;
import javax.xml.ws.Holder;
Expand All @@ -31,6 +30,7 @@
import org.apache.juddi.config.AppConfig;
import org.apache.juddi.config.Property;
import org.apache.juddi.mapping.MappingModelToApi;
import org.apache.juddi.model.BindingTemplate;
import org.apache.juddi.query.FetchBindingTemplatesQuery;
import org.apache.juddi.query.FetchBusinessEntitiesQuery;
import org.apache.juddi.query.FetchBusinessServicesQuery;
Expand Down Expand Up @@ -82,15 +82,17 @@ public class InquiryHelper {

private static Log logger = LogFactory.getLog(InquiryHelper.class);

public static List<?> findBinding(FindBinding body, FindQualifiers findQualifiers, EntityManager em) throws DispositionReportFaultMessage {
public static List<Object> findBinding(FindBinding body, FindQualifiers findQualifiers, EntityManager em) throws DispositionReportFaultMessage {

List<?> keysFound = null;

// First perform the embedded FindTModel search which will augment the tModel bag with any resulting tModel keys.
List<Object> keysFound = new LinkedList<Object>();
if (body.getServiceKey()!=null && body.getServiceKey().length() > 0) {
keysFound = findBindingsByServiceKey(em, body.getServiceKey(), keysFound);
}

if (body.getTModelBag() == null)
body.setTModelBag(new TModelBag());
// First perform the embedded FindTModel search which will augment the tModel bag with any resulting tModel keys.
doFindTModelEmbeddedSearch(em, body.getFindQualifiers(), body.getFindTModel(), body.getTModelBag());

keysFound = FindBindingByTModelKeyQuery.select(em, findQualifiers, body.getTModelBag(), body.getServiceKey(), keysFound);
keysFound = FindBindingByCategoryQuery.select(em, findQualifiers, body.getCategoryBag(), body.getServiceKey(), keysFound);
keysFound = FindBindingByCategoryGroupQuery.select(em, findQualifiers, body.getCategoryBag(), body.getServiceKey(), keysFound);
Expand Down Expand Up @@ -168,9 +170,9 @@ public static BindingDetail getBindingDetailFromKeys(FindBinding body, FindQuali
return result;
}

public static List<?> findBusiness(FindBusiness body, FindQualifiers findQualifiers, EntityManager em) throws DispositionReportFaultMessage {
public static List<Object> findBusiness(FindBusiness body, FindQualifiers findQualifiers, EntityManager em) throws DispositionReportFaultMessage {

List<?> keysFound = null;
List<Object> keysFound = null;

// First perform the embedded FindTModel search which will augment the tModel bag with any resulting tModel keys.
if (body.getTModelBag() == null)
Expand All @@ -192,7 +194,7 @@ else if (body.getFindRelatedBusinesses().getFromKey() != null)
else if (body.getFindRelatedBusinesses().getToKey() != null)
getRelatedBusinesses(em, Direction.TO_KEY, frb.getToKey(), frb.getKeyedReference(), relatedBusinessInfos);

List<String> relatedBusinessKeys = new ArrayList<String>(0);
List<Object> relatedBusinessKeys = new ArrayList<Object>(0);
for (org.uddi.api_v3.RelatedBusinessInfo rbi : relatedBusinessInfos.getRelatedBusinessInfo())
relatedBusinessKeys.add(rbi.getBusinessKey());

Expand Down Expand Up @@ -322,7 +324,7 @@ public static BusinessList getBusinessListFromKeys(FindBusiness body, FindQualif

public static List<?> findService(FindService body, FindQualifiers findQualifiers, EntityManager em) throws DispositionReportFaultMessage {

List<?> keysFound = null;
List<Object> keysFound = null;

// First perform the embedded FindTModel search which will augment the tModel bag with any resulting tModel keys.
if (body.getTModelBag() == null)
Expand Down Expand Up @@ -419,8 +421,8 @@ public static ServiceList getServiceListFromKeys(FindService body, FindQualifier
return result;
}

public static List<?> findTModel(FindTModel body, FindQualifiers findQualifiers, EntityManager em) throws DispositionReportFaultMessage {
List<?> keysFound = null;
public static List<Object> findTModel(FindTModel body, FindQualifiers findQualifiers, EntityManager em) throws DispositionReportFaultMessage {
List<Object> keysFound = null;

keysFound = FindTModelByIdentifierQuery.select(em, findQualifiers, body.getIdentifierBag(), keysFound);
keysFound = FindTModelByCategoryQuery.select(em, findQualifiers, body.getCategoryBag(), keysFound);
Expand Down Expand Up @@ -608,7 +610,7 @@ else if (body.getFromKey() != null) {
return result;
}

/*
/**
* Performs the necessary queries for the find_tModel search and adds resulting tModel keys to the tModelBag provided.
*/
private static void doFindTModelEmbeddedSearch(EntityManager em,
Expand All @@ -623,7 +625,7 @@ private static void doFindTModelEmbeddedSearch(EntityManager em,
findQualifiers.mapApiFindQualifiers(findTmodel.getFindQualifiers());


List<?> tmodelKeysFound = null;
List<Object> tmodelKeysFound = null;
tmodelKeysFound = FindTModelByIdentifierQuery.select(em, findQualifiers, findTmodel.getIdentifierBag(), tmodelKeysFound);
tmodelKeysFound = FindTModelByCategoryQuery.select(em, findQualifiers, findTmodel.getCategoryBag(), tmodelKeysFound);
tmodelKeysFound = FindTModelByCategoryGroupQuery.select(em, findQualifiers, findTmodel.getCategoryBag(), tmodelKeysFound);
Expand All @@ -635,6 +637,14 @@ private static void doFindTModelEmbeddedSearch(EntityManager em,
}
}
}

private static List<Object> findBindingsByServiceKey(EntityManager em, String serviceKey, List<Object> keysFound) {
org.apache.juddi.model.BusinessService modelBusinessService=em.find(org.apache.juddi.model.BusinessService.class, serviceKey);
for (BindingTemplate bt : modelBusinessService.getBindingTemplates()){
keysFound.add(bt.getEntityKey());
}
return keysFound;
}


}
Expand Up @@ -134,7 +134,7 @@ public BindingDetail findBinding(FindBinding body)
serviceCounter.update(InquiryQuery.FIND_BINDING, QueryStatus.FAILED, procTime);
throw drfm;
}

EntityManager em = PersistenceManager.getEntityManager();
EntityTransaction tx = em.getTransaction();
try {
Expand All @@ -144,27 +144,25 @@ public BindingDetail findBinding(FindBinding body)
this.getEntityPublisher(em, body.getAuthInfo());

LogFindBindingRequest(body);
if (body.getServiceKey() != null && body.getServiceKey().length() > 0) {
// Check that we were passed a valid serviceKey per
// 5.1.12.4 of the UDDI v3 spec
String serviceKey = body.getServiceKey();
org.apache.juddi.model.BusinessService modelBusinessService = null;
try {
modelBusinessService=em.find(org.apache.juddi.model.BusinessService.class, serviceKey);
} catch (Exception e) {
log.debug(e.getMessage(), e);
}
if (modelBusinessService == null)
throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.ServiceNotFound", serviceKey));
}

org.apache.juddi.query.util.FindQualifiers findQualifiers = new org.apache.juddi.query.util.FindQualifiers();
findQualifiers.mapApiFindQualifiers(body.getFindQualifiers());

List<?> keysFound = InquiryHelper.findBinding(body, findQualifiers, em);

if (keysFound!=null && keysFound.size() == 0) {
if (body.getServiceKey() != null) {
// Check that we were passed a valid serviceKey per
// 5.1.12.4 of the UDDI v3 spec
String serviceKey = body.getServiceKey();
org.apache.juddi.model.BusinessService modelBusinessService = null;
try {
modelBusinessService=em.find(org.apache.juddi.model.BusinessService.class, serviceKey);
} catch (Exception e) {
log.debug(e.getMessage(), e);
}
if (modelBusinessService == null)
throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.ServiceNotFound", serviceKey));

}
}
BindingDetail result = InquiryHelper.getBindingDetailFromKeys(body, findQualifiers, em, keysFound);
tx.rollback();
long procTime = System.currentTimeMillis() - startTime;
Expand Down
47 changes: 26 additions & 21 deletions juddi-core/src/main/java/org/apache/juddi/query/EntityQuery.java
Expand Up @@ -124,7 +124,7 @@ public static List<?> getPagedResult(EntityManager em, DynamicQuery dynamicQry,
* Used for all the find operation sub-queries. Restricts size of the IN clause based on global parameter
*/
@SuppressWarnings("unchecked")
public static List<?> getQueryResult(EntityManager em, DynamicQuery dynamicQry, List<?> keysIn, String inListTerm) {
public static List<Object> getQueryResult(EntityManager em, DynamicQuery dynamicQry, List<?> keysIn, String inListTerm) {

List<Object> result = new ArrayList<Object>(0);
// If keysIn is null, then no IN list is applied to the query - we simply need to run the query. Otherwise, the IN list is chunked based on
Expand All @@ -142,26 +142,31 @@ public static List<?> getQueryResult(EntityManager em, DynamicQuery dynamicQry,
catch(ConfigurationException ce) {
log.error("Configuration exception occurred retrieving: " + Property.JUDDI_MAX_IN_CLAUSE);
}

int inParamsLeft = keysIn.size();
int startIndex = 0;
while(inParamsLeft > 0) {
int endIndex = startIndex + Math.min(inParamsLeft, maxInClause);

List<Object> subKeysIn = new ArrayList<Object>(endIndex);
for (int i=startIndex; i< endIndex; i++) {
subKeysIn.add(keysIn.get(i));
}
dynamicQry.appendInListWithAnd(inListTerm, subKeysIn);
log.debug(dynamicQry);

Query qry = dynamicQry.buildJPAQuery(em);
List<Object> resultChunk = qry.getResultList();
result.addAll(resultChunk);

inParamsLeft = inParamsLeft - (endIndex - startIndex);
startIndex = endIndex;
}
if (keysIn.isEmpty()) {
Query qry = dynamicQry.buildJPAQuery(em);
List<Object> resultChunk = qry.getResultList();
result.addAll(resultChunk);
} else {
int inParamsLeft = keysIn.size();
int startIndex = 0;
while(inParamsLeft > 0) {
int endIndex = startIndex + Math.min(inParamsLeft, maxInClause);

List<Object> subKeysIn = new ArrayList<Object>(endIndex);
for (int i=startIndex; i< endIndex; i++) {
subKeysIn.add(keysIn.get(i));
}
dynamicQry.appendInListWithAnd(inListTerm, subKeysIn);
log.debug(dynamicQry);

Query qry = dynamicQry.buildJPAQuery(em);
List<Object> resultChunk = qry.getResultList();
result.addAll(resultChunk);

inParamsLeft = inParamsLeft - (endIndex - startIndex);
startIndex = endIndex;
}
}
}

return result;
Expand Down
Expand Up @@ -58,7 +58,7 @@ public class FindBindingByCategoryGroupQuery {
BindingTemplateQuery.SIGNATURE_PRESENT);
}

public static List<?> select(EntityManager em, FindQualifiers fq, CategoryBag categoryBag, String parentKey, List<?> keysIn) {
public static List<Object> select(EntityManager em, FindQualifiers fq, CategoryBag categoryBag, String parentKey, List<Object> keysIn) {
if (parentKey != null && parentKey.length() > 0) {
DynamicQuery.Parameter param = new DynamicQuery.Parameter(BindingTemplateQuery.ENTITY_ALIAS + "." + BindingTemplateQuery.KEY_NAME_PARENT, parentKey, DynamicQuery.PREDICATE_EQUALS);
return findQuery.select(em, fq, categoryBag, keysIn, param);
Expand Down
Expand Up @@ -52,7 +52,7 @@ public class FindBindingByCategoryQuery {
BindingTemplateQuery.SIGNATURE_PRESENT);
}

public static List<?> select(EntityManager em, FindQualifiers fq, CategoryBag categoryBag, String parentKey, List<?> keysIn) {
public static List<Object> select(EntityManager em, FindQualifiers fq, CategoryBag categoryBag, String parentKey, List<Object> keysIn) {
if (parentKey != null && parentKey.length() > 0) {
DynamicQuery.Parameter param = new DynamicQuery.Parameter(BindingTemplateQuery.ENTITY_ALIAS + "." + BindingTemplateQuery.KEY_NAME_PARENT, parentKey, DynamicQuery.PREDICATE_EQUALS);
return findQuery.select(em, fq, categoryBag, keysIn, param);
Expand Down
Expand Up @@ -60,11 +60,11 @@ public class FindBindingByTModelKeyQuery extends BindingTemplateQuery {
entityAliasChild = buildAlias(ENTITY_NAME_CHILD);
}

public static List<?> select(EntityManager em, FindQualifiers fq, TModelBag tModels, String parentKey,
List<?> keysIn, DynamicQuery.Parameter... restrictions) {
public static List<Object> select(EntityManager em, FindQualifiers fq, TModelBag tModels, String parentKey,
List<Object> keysIn, DynamicQuery.Parameter... restrictions) {
// If keysIn is not null and empty, then search is over.
if ((keysIn != null) && (keysIn.size() == 0))
return keysIn;
//if ((keysIn != null) && (keysIn.size() == 0))
// return keysIn;

if (tModels == null)
return keysIn;
Expand Down
Expand Up @@ -57,7 +57,7 @@ public class FindBusinessByCategoryGroupQuery {
BusinessEntityQuery.SIGNATURE_PRESENT);
}

public static List<?> select(EntityManager em, FindQualifiers fq, CategoryBag categoryBag, List<?> keysIn) {
public static List<Object> select(EntityManager em, FindQualifiers fq, CategoryBag categoryBag, List<Object> keysIn) {
return findQuery.select(em, fq, categoryBag, keysIn);
}
}
Expand Up @@ -51,7 +51,7 @@ public class FindBusinessByCategoryQuery {
BusinessEntityQuery.SIGNATURE_PRESENT);
}

public static List<?> select(EntityManager em, FindQualifiers fq, CategoryBag categoryBag, List<?> keysIn) {
public static List<Object> select(EntityManager em, FindQualifiers fq, CategoryBag categoryBag, List<Object> keysIn) {
return findQuery.select(em, fq, categoryBag, keysIn);
}
}
Expand Up @@ -71,7 +71,7 @@ public class FindBusinessByCombinedCategoryQuery {
BusinessEntityQuery.SIGNATURE_PRESENT);
}

public static List<?> select(EntityManager em, FindQualifiers fq, CategoryBag categoryBag, List<?> keysIn) {
public static List<Object> select(EntityManager em, FindQualifiers fq, CategoryBag categoryBag, List<Object> keysIn) {
return findQuery.select(em, fq, categoryBag, keysIn);
}
}
Expand Up @@ -54,8 +54,8 @@ public class FindBusinessByDiscoveryURLQuery extends BusinessEntityQuery {
entityAliasChild = buildAlias(ENTITY_NAME_CHILD);
}

public static List<?> select(EntityManager em, FindQualifiers fq, DiscoveryURLs discURLs,
List<?> keysIn, DynamicQuery.Parameter... restrictions) {
public static List<Object> select(EntityManager em, FindQualifiers fq, DiscoveryURLs discURLs,
List<Object> keysIn, DynamicQuery.Parameter... restrictions) {
// If keysIn is not null and empty, then search is over.
if ((keysIn != null) && (keysIn.size() == 0))
return keysIn;
Expand Down
Expand Up @@ -50,7 +50,7 @@ public class FindBusinessByIdentifierQuery {
BusinessEntityQuery.SIGNATURE_PRESENT);
}

public static List<?> select(EntityManager em, FindQualifiers fq, IdentifierBag identifiers, List<?> keysIn) {
public static List<Object> select(EntityManager em, FindQualifiers fq, IdentifierBag identifiers, List<Object> keysIn) {
return findQuery.select(em, fq, identifiers, keysIn);
}

Expand Down
Expand Up @@ -58,7 +58,7 @@ public class FindBusinessByNameQuery {
BusinessEntityQuery.SIGNATURE_PRESENT);
}

public static List<?> select(EntityManager em, FindQualifiers fq, List<Name> names, List<?> keysIn) {
public static List<Object> select(EntityManager em, FindQualifiers fq, List<Name> names, List<Object> keysIn) {
return findQuery.select(em, fq, names, keysIn);
}

Expand Down
Expand Up @@ -60,7 +60,7 @@ public class FindBusinessByTModelKeyQuery extends BusinessEntityQuery {
entityAliasChild = buildAlias(ENTITY_NAME_CHILD);
}

public static List<?> select(EntityManager em, FindQualifiers fq, TModelBag tModels, List<?> keysIn, DynamicQuery.Parameter... restrictions) {
public static List<Object> select(EntityManager em, FindQualifiers fq, TModelBag tModels, List<Object> keysIn, DynamicQuery.Parameter... restrictions) {
// If keysIn is not null and empty, then search is over.
if ((keysIn != null) && (keysIn.isEmpty()))
return keysIn;
Expand Down

0 comments on commit 8016bf3

Please sign in to comment.