use of org.codice.alliance.nsili.common.UCO.InvalidInputParameter in project alliance by codice.
the class LibraryImpl method get_manager.
@Override
public LibraryManager get_manager(String manager_type, AccessCriteria access_criteria) throws ProcessingFault, InvalidInputParameter, SystemFault {
org.omg.CORBA.Object obj;
switch(manager_type) {
case "CatalogMgr":
CatalogMgrImpl catalogMgr = new CatalogMgrImpl(poa_);
try {
poa_.activate_object_with_id(manager_type.getBytes(Charset.forName(ENCODING)), catalogMgr);
} catch (Exception e) {
// Ignore
}
obj = poa_.create_reference_with_id(manager_type.getBytes(Charset.forName(ENCODING)), CatalogMgrHelper.id());
break;
case "OrderMgr":
OrderMgrImpl orderMgr = new OrderMgrImpl();
try {
poa_.activate_object_with_id(manager_type.getBytes(Charset.forName(ENCODING)), orderMgr);
} catch (Exception e) {
// Ignore
}
obj = poa_.create_reference_with_id(manager_type.getBytes(Charset.forName(ENCODING)), OrderMgrHelper.id());
break;
case "ProductMgr":
ProductMgrImpl productMgr = new ProductMgrImpl();
try {
poa_.activate_object_with_id(manager_type.getBytes(Charset.forName(ENCODING)), productMgr);
} catch (Exception e) {
// Ignore
}
obj = poa_.create_reference_with_id(manager_type.getBytes(Charset.forName(ENCODING)), ProductMgrHelper.id());
break;
case "DataModelMgr":
DataModelMgrImpl dataModelMgr = new DataModelMgrImpl();
try {
poa_.activate_object_with_id(manager_type.getBytes(Charset.forName(ENCODING)), dataModelMgr);
} catch (Exception e) {
// Ignore
}
obj = poa_.create_reference_with_id(manager_type.getBytes(Charset.forName(ENCODING)), DataModelMgrHelper.id());
break;
default:
String[] bad_params = { manager_type };
throw new InvalidInputParameter("UnknownMangerType", new exception_details("UnknownMangerType", true, manager_type), bad_params);
}
LibraryManager libraryManager = LibraryManagerHelper.narrow(obj);
return libraryManager;
}
use of org.codice.alliance.nsili.common.UCO.InvalidInputParameter in project alliance by codice.
the class NsiliSource method submitQuery.
/**
* Submits and completes a BQS Query to the STANAG 4559 server and returns the response.
*
* @param queryRequest - the query request generated from the search
* @param query - a BQS query
* @param resultAttributes - a list of desired result attributes
* @param sortAttributes - a list of attributes to sort by
* @param properties - a list of properties for the query
* @return - the server's response
*/
private SourceResponse submitQuery(QueryRequest queryRequest, org.codice.alliance.nsili.common.GIAS.Query query, String[] resultAttributes, SortAttribute[] sortAttributes, NameValue[] properties) {
DAGListHolder dagListHolder = new DAGListHolder();
SourceResponseImpl sourceResponse = null;
long numHits = 0;
try {
synchronized (queryLockObj) {
LOGGER.debug("{} : Submit query: {}", sourceId, query.bqs_query);
LOGGER.debug("{} : Requesting result attributes: {}", sourceId, resultAttributes);
LOGGER.debug("{} : Sort Attributes: {}", sourceId, sortAttributes);
LOGGER.debug("{} : Properties: {}", sourceId, properties);
HitCountRequest hitCountRequest = catalogMgr.hit_count(query, properties);
IntHolder hitHolder = new IntHolder();
hitCountRequest.complete(hitHolder);
numHits = hitHolder.value;
SubmitQueryRequest submitQueryRequest;
if (hitHolder.value > 1) {
submitQueryRequest = catalogMgr.submit_query(query, resultAttributes, sortAttributes, properties);
} else {
submitQueryRequest = catalogMgr.submit_query(query, resultAttributes, new SortAttribute[0], new NameValue[0]);
}
submitQueryRequest.set_user_info(ddfOrgName);
submitQueryRequest.set_number_of_hits(maxHitCount);
submitQueryRequest.complete_DAG_results(dagListHolder);
}
} catch (ProcessingFault | SystemFault | InvalidInputParameter e) {
LOGGER.debug("{} : Unable to query source. {}", sourceId, NsilCorbaExceptionUtil.getExceptionDetails(e), e);
}
if (dagListHolder.value != null) {
List<Result> results = new ArrayList<>();
String id = getId();
List<Future> futures = new ArrayList<>(dagListHolder.value.length);
for (DAG dag : dagListHolder.value) {
Callable<Result> convertRunner = () -> {
DAGConverter dagConverter = new DAGConverter(resourceReader);
dagConverter.setNsiliMetacardType(nsiliMetacardType);
Metacard card = dagConverter.convertDAG(dag, swapCoordinates, id);
if (card != null) {
if (LOGGER.isTraceEnabled()) {
DAGConverter.logMetacard(card, getId());
}
return new ResultImpl(card);
} else {
LOGGER.debug("{} : Unable to convert DAG to metacard, returned card is null", getId());
}
return null;
};
futures.add(completionService.submit(convertRunner));
}
Future<Result> completedFuture;
while (!futures.isEmpty()) {
try {
completedFuture = completionService.take();
futures.remove(completedFuture);
results.add(completedFuture.get());
} catch (ExecutionException e) {
LOGGER.debug("Unable to create result.", e);
} catch (InterruptedException ignore) {
// ignore
}
}
sourceResponse = new SourceResponseImpl(queryRequest, results, numHits);
} else {
LOGGER.debug("{} : Source returned empty DAG list", getId());
}
return sourceResponse;
}
use of org.codice.alliance.nsili.common.UCO.InvalidInputParameter in project alliance by codice.
the class NsiliSource method initSortableAndResultAttributes.
/**
* Obtains all possible attributes for all possible views that the Federated Source can provide,
* and populates a sortableAttributes map, as well as resultAttributes map that will be used for
* querying the server. According to ANNEX D, TABLE D-6, the passed parameter in get_view_names is
* an empty list(not used).
*
* @return a map of each view and the attributes provided by the source for that view
*/
private void initSortableAndResultAttributes() {
if (views == null || views.length == 0) {
return;
}
HashMap<String, String[]> resultAttributesMap = new HashMap<>();
HashMap<String, List<String>> sortableAttributesMap = new HashMap<>();
try {
for (int i = 0; i < views.length; i++) {
List<String> sortableAttributesList = new ArrayList<>();
AttributeInformation[] attributeInformationArray = dataModelMgr.get_attributes(views[i].view_name, new NameValue[0]);
String[] resultAttributes = new String[attributeInformationArray.length];
LOGGER.debug("Attributes for view: {}", views[i].view_name);
for (int c = 0; c < attributeInformationArray.length; c++) {
AttributeInformation attributeInformation = attributeInformationArray[c];
resultAttributes[c] = attributeInformation.attribute_name;
if (LOGGER.isDebugEnabled()) {
getModeStr(attributeInformation);
}
if (attributeInformation.sortable) {
sortableAttributesList.add(attributeInformation.attribute_name);
}
}
sortableAttributesMap.put(views[i].view_name, sortableAttributesList);
resultAttributesMap.put(views[i].view_name, resultAttributes);
}
} catch (ProcessingFault | SystemFault | InvalidInputParameter e) {
LOGGER.debug("{} : Unable to retrieve queryable attributes.", sourceId, e);
}
if (resultAttributesMap.size() == 0) {
LOGGER.debug("{} : Received empty attributes list from STANAG source.", getId());
}
this.sortableAttributes = sortableAttributesMap;
this.resultAttributes = resultAttributesMap;
}
use of org.codice.alliance.nsili.common.UCO.InvalidInputParameter in project alliance by codice.
the class NsiliSource method initMandatoryManagers.
/**
* Initializes all STANAG 4559 mandatory managers: CatalogMgr OrderMgr DataModelMgr ProductMgr
*/
private void initMandatoryManagers() {
try {
accessCriteria = new AccessCriteria(accessUserId, accessPassword, accessLicenseKey);
LibraryManager libraryManager = library.get_manager(CATALOG_MGR, accessCriteria);
setCatalogMgr(CatalogMgrHelper.narrow(libraryManager));
libraryManager = library.get_manager(ORDER_MGR, accessCriteria);
setOrderMgr(OrderMgrHelper.narrow(libraryManager));
libraryManager = library.get_manager(PRODUCT_MGR, accessCriteria);
setProductMgr(ProductMgrHelper.narrow(libraryManager));
libraryManager = library.get_manager(DATA_MODEL_MGR, accessCriteria);
setDataModelMgr(DataModelMgrHelper.narrow(libraryManager));
} catch (ProcessingFault | SystemFault | InvalidInputParameter e) {
LOGGER.debug("{} : Unable to retrieve mandatory managers.", sourceId, e);
}
if (catalogMgr != null && orderMgr != null && productMgr != null && dataModelMgr != null) {
LOGGER.debug("{} : Initialized STANAG mandatory managers.", getId());
} else {
LOGGER.debug("{} : Unable to initialize mandatory mangers.", getId());
}
}
use of org.codice.alliance.nsili.common.UCO.InvalidInputParameter in project alliance by codice.
the class StandingQueryMgrImpl method submit_standing_query.
@Override
public SubmitStandingQueryRequest submit_standing_query(Query aQuery, String[] result_attributes, SortAttribute[] sort_attributes, QueryLifeSpan lifespan, NameValue[] properties) throws InvalidInputParameter, ProcessingFault, SystemFault {
if (aQuery == null) {
InvalidInputParameter except = new InvalidInputParameter();
exception_details details = new exception_details();
details.exception_name = "No Query Specified";
details.exception_desc = "Query must be specified for standing query request";
except.details = details;
throw except;
}
LOGGER.debug("Registering Standing Query View: {}, BQS: {}", aQuery.view, aQuery.bqs_query);
SubmitStandingQueryRequestImpl standingQueryRequest = new SubmitStandingQueryRequestImpl(aQuery, result_attributes, sort_attributes, lifespan, properties, catalogFramework, filterBuilder, defaultUpdateFrequencyMsec, querySources, maxPendingResults, removeSourceLibrary, outgoingValidationEnabled, maxWaitToStartTimeMsecs);
String id = UUID.randomUUID().toString();
try {
_poa().activate_object_with_id(id.getBytes(Charset.forName(NsiliEndpoint.ENCODING)), standingQueryRequest);
} catch (ServantAlreadyActive | ObjectAlreadyActive | WrongPolicy e) {
LOGGER.debug("submit_standing_query : Unable to activate submitStandingQueryRequest object.", e);
}
org.omg.CORBA.Object obj = _poa().create_reference_with_id(id.getBytes(Charset.forName(NsiliEndpoint.ENCODING)), SubmitStandingQueryRequestHelper.id());
SubmitStandingQueryRequest submitStandingQueryRequest = SubmitStandingQueryRequestHelper.narrow(obj);
return submitStandingQueryRequest;
}
Aggregations