Search in sources :

Example 1 with ServantAlreadyActive

use of org.omg.PortableServer.POAPackage.ServantAlreadyActive 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;
}
Also used : Node(org.codice.alliance.nsili.common.UCO.Node) ArrayList(java.util.ArrayList) Product(org.codice.alliance.nsili.common.UID.Product) Any(org.omg.CORBA.Any) DirectedAcyclicGraph(org.jgrapht.experimental.dag.DirectedAcyclicGraph) WrongPolicy(org.omg.PortableServer.POAPackage.WrongPolicy) List(java.util.List) ArrayList(java.util.ArrayList) ServantAlreadyActive(org.omg.PortableServer.POAPackage.ServantAlreadyActive) ObjectAlreadyActive(org.omg.PortableServer.POAPackage.ObjectAlreadyActive) DAG(org.codice.alliance.nsili.common.UCO.DAG) Metacard(ddf.catalog.data.Metacard) Edge(org.codice.alliance.nsili.common.UCO.Edge)

Example 2 with ServantAlreadyActive

use of org.omg.PortableServer.POAPackage.ServantAlreadyActive 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");
    }
}
Also used : ObjectAlreadyActive(org.omg.PortableServer.POAPackage.ObjectAlreadyActive) Time(org.codice.alliance.nsili.common.UCO.Time) AbsTime(org.codice.alliance.nsili.common.UCO.AbsTime) Date(org.codice.alliance.nsili.common.UCO.Date) KeyManagementException(java.security.KeyManagementException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) MalformedURLException(java.net.MalformedURLException) CertificateException(java.security.cert.CertificateException) NameValue(org.codice.alliance.nsili.common.UCO.NameValue) WrongPolicy(org.omg.PortableServer.POAPackage.WrongPolicy) Callback(org.codice.alliance.nsili.common.CB.Callback) QueryLifeSpan(org.codice.alliance.nsili.common.GIAS.QueryLifeSpan) Event(org.codice.alliance.nsili.common.GIAS.Event) LifeEvent(org.codice.alliance.nsili.common.GIAS.LifeEvent) LifeEvent(org.codice.alliance.nsili.common.GIAS.LifeEvent) ServantAlreadyActive(org.omg.PortableServer.POAPackage.ServantAlreadyActive)

Example 3 with ServantAlreadyActive

use of org.omg.PortableServer.POAPackage.ServantAlreadyActive 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;
}
Also used : WrongPolicy(org.omg.PortableServer.POAPackage.WrongPolicy) SubmitQueryRequest(org.codice.alliance.nsili.common.GIAS.SubmitQueryRequest) ObjectAlreadyActive(org.omg.PortableServer.POAPackage.ObjectAlreadyActive) ServantAlreadyActive(org.omg.PortableServer.POAPackage.ServantAlreadyActive) SubmitQueryRequestImpl(org.codice.alliance.nsili.mockserver.impl.requests.SubmitQueryRequestImpl)

Example 4 with ServantAlreadyActive

use of org.omg.PortableServer.POAPackage.ServantAlreadyActive 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;
}
Also used : WrongPolicy(org.omg.PortableServer.POAPackage.WrongPolicy) ObjectAlreadyActive(org.omg.PortableServer.POAPackage.ObjectAlreadyActive) HitCountRequestImpl(org.codice.alliance.nsili.mockserver.impl.requests.HitCountRequestImpl) ServantAlreadyActive(org.omg.PortableServer.POAPackage.ServantAlreadyActive) HitCountRequest(org.codice.alliance.nsili.common.GIAS.HitCountRequest)

Example 5 with ServantAlreadyActive

use of org.omg.PortableServer.POAPackage.ServantAlreadyActive 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;
}
Also used : WrongPolicy(org.omg.PortableServer.POAPackage.WrongPolicy) ObjectAlreadyActive(org.omg.PortableServer.POAPackage.ObjectAlreadyActive) OrderRequest(org.codice.alliance.nsili.common.GIAS.OrderRequest) OrderRequestImpl(org.codice.alliance.nsili.mockserver.impl.requests.OrderRequestImpl) ServantAlreadyActive(org.omg.PortableServer.POAPackage.ServantAlreadyActive)

Aggregations

ObjectAlreadyActive (org.omg.PortableServer.POAPackage.ObjectAlreadyActive)25 ServantAlreadyActive (org.omg.PortableServer.POAPackage.ServantAlreadyActive)25 WrongPolicy (org.omg.PortableServer.POAPackage.WrongPolicy)25 IOException (java.io.IOException)6 Object (org.omg.CORBA.Object)6 GeotoolsFilterBuilder (ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder)5 SecurityServiceException (ddf.security.service.SecurityServiceException)5 Before (org.junit.Before)5 InvalidName (org.omg.CORBA.ORBPackage.InvalidName)5 AdapterInactive (org.omg.PortableServer.POAManagerPackage.AdapterInactive)5 ServantNotActive (org.omg.PortableServer.POAPackage.ServantNotActive)5 Metacard (ddf.catalog.data.Metacard)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 ArrayList (java.util.ArrayList)2 GetParametersRequest (org.codice.alliance.nsili.common.GIAS.GetParametersRequest)2 GetRelatedFilesRequest (org.codice.alliance.nsili.common.GIAS.GetRelatedFilesRequest)2 HitCountRequest (org.codice.alliance.nsili.common.GIAS.HitCountRequest)2 OrderRequest (org.codice.alliance.nsili.common.GIAS.OrderRequest)2 SubmitQueryRequest (org.codice.alliance.nsili.common.GIAS.SubmitQueryRequest)2 NameValue (org.codice.alliance.nsili.common.UCO.NameValue)2