use of org.omg.PortableServer.POAPackage.WrongPolicy in project alliance by codice.
the class ResultDAGConverter method convertResult.
public static DAG convertResult(Result result, ORB orb, POA poa, List<String> resultAttributes, Map<String, List<String>> mandatoryAttributes) throws DagParsingException {
Metacard metacard = result.getMetacard();
DAG dag = new DAG();
DirectedAcyclicGraph<Node, Edge> graph = new DirectedAcyclicGraph<>(Edge.class);
ProductImpl productImpl = new ProductImpl();
String id = result.getMetacard().getId();
if (!CorbaUtils.isIdActive(poa, id.getBytes(Charset.forName(ENCODING)))) {
try {
poa.activate_object_with_id(id.getBytes(Charset.forName(ENCODING)), productImpl);
} catch (ServantAlreadyActive | ObjectAlreadyActive | WrongPolicy e) {
LOGGER.debug("Convert DAG : Unable to activate product impl object ({}): {}", result.getMetacard().getId(), e.getLocalizedMessage());
}
}
org.omg.CORBA.Object obj = poa.create_reference_with_id(id.getBytes(Charset.forName(ENCODING)), ProductHelper.id());
Product product = ProductHelper.narrow(obj);
Node productNode = createRootNode(orb);
String attributeName = NsiliConstants.NSIL_PRODUCT;
Any productAny = orb.create_any();
ProductHelper.insert(productAny, product);
productNode.value = productAny;
graph.addVertex(productNode);
List<String> addedAttributes = new ArrayList<>();
addedAttributes.addAll(addCardNodeWithAttributes(graph, productNode, metacard, orb, attributeName + ":", resultAttributes));
addedAttributes.addAll(addFileNodeWithAttributes(graph, productNode, metacard, orb, attributeName + ":", resultAttributes));
addedAttributes.addAll(addSecurityNodeWithAttributes(graph, productNode, metacard, orb, attributeName + ":", resultAttributes));
addedAttributes.addAll(addMetadataSecurityNodeWithAttributes(graph, productNode, metacard, orb, attributeName + ":", resultAttributes));
addedAttributes.addAll(addParts(graph, productNode, metacard, orb, attributeName + ":", resultAttributes));
if (metacard.getThumbnail() != null && metacard.getThumbnail().length > 0) {
addedAttributes.addAll(addThumbnailRelatedFile(graph, productNode, metacard, orb, attributeName + ":", resultAttributes));
}
if (mandatoryAttributes != null && !mandatoryAttributes.isEmpty()) {
final ThreadLocal<Boolean> dataIsValid = new ThreadLocal<>();
dataIsValid.set(true);
Map<String, List<String>> addedAttrMap = getAttrMap(addedAttributes);
addedAttrMap.entrySet().forEach(entry -> dataIsValid.set(dataIsValid.get() && processEntry(entry.getKey(), mandatoryAttributes.get(entry.getKey()), entry.getValue())));
if (!dataIsValid.get()) {
throw new DagParsingException("One or more mandatory attributes is missing on outgoing data");
}
}
graph.addVertex(productNode);
NsiliCommonUtils.setUCOEdgeIds(graph);
NsiliCommonUtils.setUCOEdges(productNode, graph);
dag.edges = NsiliCommonUtils.getEdgeArrayFromGraph(graph);
dag.nodes = NsiliCommonUtils.getNodeArrayFromGraph(graph);
return dag;
}
use of org.omg.PortableServer.POAPackage.WrongPolicy in project alliance by codice.
the class SampleNsiliClient method testStandingQueryMgr.
public void testStandingQueryMgr() throws Exception {
if (standingQueryMgr != null) {
LOGGER.info("----------------------");
LOGGER.info("Standing Query Manager Test");
Event[] events = standingQueryMgr.get_event_descriptions();
if (events != null) {
Arrays.stream(events).forEach(event -> LOGGER.info("Event: {}\n Name: {}\n Desc: {}", event.event_type.value(), event.event_name, event.event_description));
}
LifeEvent start = new LifeEvent();
java.util.Date startDate = new java.util.Date();
start.at(ResultDAGConverter.getAbsTime(startDate));
LifeEvent end = new LifeEvent();
final long ONE_YEAR_IN_MS = TimeUnit.DAYS.toMillis(365);
long endTime = System.currentTimeMillis() + ONE_YEAR_IN_MS;
java.util.Date endDate = new java.util.Date();
endDate.setTime(endTime);
end.at(ResultDAGConverter.getAbsTime(endDate));
LifeEvent[] frequency = new LifeEvent[1];
LifeEvent freqOne = new LifeEvent();
Time time = new Time((short) 0, (short) 0, 30.0f);
freqOne.rt(time);
frequency[0] = freqOne;
QueryLifeSpan queryLifeSpan = new QueryLifeSpan(start, end, frequency);
NameValue[] props = new NameValue[0];
String callbackId = UUID.randomUUID().toString();
try {
standingQueryRequest = standingQueryMgr.submit_standing_query(STANDING_ALL_QUERY, getResultAttributes(), getSortableAttributes(), queryLifeSpan, props);
standingQueryRequest.set_user_info(ALLIANCE);
standingQueryRequest.set_number_of_hits(200);
TestNsiliStandingQueryCallback nsiliCallback = new TestNsiliStandingQueryCallback(standingQueryRequest);
final String ENCODING = "ISO-8859-1";
try {
poa.activate_object_with_id(callbackId.getBytes(Charset.forName(ENCODING)), nsiliCallback);
} catch (ServantAlreadyActive | ObjectAlreadyActive | WrongPolicy e) {
LOGGER.error("Order : Unable to activate callback object, already active : {}", NsilCorbaExceptionUtil.getExceptionDetails(e), e);
}
org.omg.CORBA.Object obj = poa.create_reference_with_id(callbackId.getBytes(Charset.forName(ENCODING)), CallbackHelper.id());
Callback callback = CallbackHelper.narrow(obj);
String standingQueryCallbackId = standingQueryRequest.register_callback(callback);
nsiliCallback.setCallbackID(standingQueryCallbackId);
standingQueryCallbacks.add(nsiliCallback);
LOGGER.info("Registered NSILI Callback: {}", standingQueryCallbackId);
LOGGER.info("Standing Query Submitted");
} catch (Exception e) {
LOGGER.debug("Error submitting standing query: ", NsilCorbaExceptionUtil.getExceptionDetails(e));
throw (e);
}
} else {
LOGGER.info("StandingQueryMgr is not initialized, unable to test");
}
}
use of org.omg.PortableServer.POAPackage.WrongPolicy in project alliance by codice.
the class CatalogMgrImpl method submit_query.
@Override
public SubmitQueryRequest submit_query(Query aQuery, String[] result_attributes, SortAttribute[] sort_attributes, NameValue[] properties) throws ProcessingFault, InvalidInputParameter, SystemFault {
SubmitQueryRequestImpl submitQueryRequest = new SubmitQueryRequestImpl();
try {
poa_.activate_object_with_id("submit_query".getBytes(Charset.forName(ENCODING)), submitQueryRequest);
} catch (ServantAlreadyActive | ObjectAlreadyActive | WrongPolicy e) {
LOGGER.warn("submit_query : Unable to activate submitQueryRequest object.", e);
}
org.omg.CORBA.Object obj = poa_.create_reference_with_id("submit_query".getBytes(Charset.forName(ENCODING)), SubmitQueryRequestHelper.id());
SubmitQueryRequest queryRequest = SubmitQueryRequestHelper.narrow(obj);
return queryRequest;
}
use of org.omg.PortableServer.POAPackage.WrongPolicy in project alliance by codice.
the class CatalogMgrImpl method hit_count.
@Override
public HitCountRequest hit_count(Query aQuery, NameValue[] properties) throws ProcessingFault, InvalidInputParameter, SystemFault {
HitCountRequestImpl hitCountRequest = new HitCountRequestImpl();
try {
poa_.activate_object_with_id("hit_count".getBytes(Charset.forName(ENCODING)), hitCountRequest);
} catch (ServantAlreadyActive | ObjectAlreadyActive | WrongPolicy e) {
LOGGER.warn("hit_count : Unable to activate hitCountRequest object.", e);
}
org.omg.CORBA.Object obj = poa_.create_reference_with_id("hit_count".getBytes(Charset.forName(ENCODING)), HitCountRequestHelper.id());
HitCountRequest queryRequest = HitCountRequestHelper.narrow(obj);
return queryRequest;
}
use of org.omg.PortableServer.POAPackage.WrongPolicy in project alliance by codice.
the class OrderMgrImpl method order.
@Override
public OrderRequest order(OrderContents order, NameValue[] properties) throws ProcessingFault, InvalidInputParameter, SystemFault {
OrderRequestImpl orderRequest = new OrderRequestImpl();
try {
_poa().activate_object_with_id("order".getBytes(Charset.forName(ENCODING)), orderRequest);
} catch (ServantAlreadyActive | ObjectAlreadyActive | WrongPolicy e) {
LOGGER.warn("Order : Unable to activate orderRequest object.", e);
}
org.omg.CORBA.Object obj = _poa().create_reference_with_id("order".getBytes(Charset.forName(ENCODING)), OrderRequestHelper.id());
OrderRequest queryRequest = OrderRequestHelper.narrow(obj);
return queryRequest;
}
Aggregations