Search in sources :

Example 1 with WrongAdapter

use of org.omg.PortableServer.POAPackage.WrongAdapter in project alliance by codice.

the class OrderRequestImpl method complete.

@Override
public State complete(DeliveryManifestHolder deliveryManifestHolder) throws ProcessingFault, SystemFault {
    DeliveryManifest deliveryManifest = new DeliveryManifest();
    List<PackageElement> packageElements = new ArrayList<>();
    if (!orderContainsSupportedDelivery()) {
        throw new NO_IMPLEMENT("Only HTTP(s) is supported");
    }
    try {
        String filename = null;
        PackagingSpecFormatType packageFormatType = PackagingSpecFormatType.FILESUNC;
        List<ResourceContainer> files = new ArrayList<>();
        if (order.prod_list == null) {
            throw new BAD_OPERATION("No products specified for the order");
        }
        for (ProductDetails productDetails : order.prod_list) {
            requestProductResource(files, productDetails);
        }
        if (order.pSpec != null) {
            PackagingSpec packagingSpec = order.pSpec;
            filename = packagingSpec.package_identifier;
            packageFormatType = PackagingSpecFormatType.valueOf(packagingSpec.packaging_format_and_compression);
        }
        if (order.del_list != null) {
            for (DeliveryDetails deliveryDetails : order.del_list) {
                Destination destination = deliveryDetails.dests;
                Optional<DestinationSink> destinationSink = destinationSinkFactory.apply(destination);
                if (destinationSink.isPresent()) {
                    List<String> filesSent = writeData(destinationSink.get(), packageFormatType, files, filename);
                    PackageElement packageElement = new PackageElement();
                    packageElement.files = filesSent.toArray(new String[filesSent.size()]);
                    packageElements.add(packageElement);
                }
            }
        }
    } catch (UnsupportedEncodingException | WrongAdapter | WrongPolicy e) {
        LOGGER.debug("Unable to get Metacard for product:", e);
    } catch (IOException | ExecutionException | SecurityServiceException e) {
        LOGGER.debug("Unable to retrieve resource:", e);
    }
    if (order.pSpec != null) {
        deliveryManifest.package_name = order.pSpec.package_identifier;
    }
    deliveryManifest.elements = packageElements.toArray(new PackageElement[packageElements.size()]);
    deliveryManifestHolder.value = deliveryManifest;
    return State.COMPLETED;
}
Also used : NO_IMPLEMENT(org.omg.CORBA.NO_IMPLEMENT) Destination(org.codice.alliance.nsili.common.GIAS.Destination) SecurityServiceException(ddf.security.service.SecurityServiceException) DeliveryDetails(org.codice.alliance.nsili.common.GIAS.DeliveryDetails) DeliveryManifest(org.codice.alliance.nsili.common.GIAS.DeliveryManifest) ArrayList(java.util.ArrayList) WrongPolicy(org.omg.PortableServer.POAPackage.WrongPolicy) PackagingSpecFormatType(org.codice.alliance.nsili.common.PackagingSpecFormatType) ProductDetails(org.codice.alliance.nsili.common.GIAS.ProductDetails) PackagingSpec(org.codice.alliance.nsili.common.GIAS.PackagingSpec) ExecutionException(org.apache.shiro.subject.ExecutionException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IOException(java.io.IOException) WrongAdapter(org.omg.PortableServer.POAPackage.WrongAdapter) PackageElement(org.codice.alliance.nsili.common.GIAS.PackageElement) BAD_OPERATION(org.omg.CORBA.BAD_OPERATION)

Example 2 with WrongAdapter

use of org.omg.PortableServer.POAPackage.WrongAdapter in project alliance by codice.

the class ProductMgrImpl method get_related_files.

@Override
public GetRelatedFilesRequest get_related_files(Product[] products, FileLocation location, String type, NameValue[] properties) throws ProcessingFault, InvalidInputParameter, SystemFault {
    String id = UUID.randomUUID().toString();
    try {
        List<Metacard> metacards = new ArrayList<>();
        AccessManagerImpl accessMgr = getAccessManager();
        for (Product product : products) {
            Metacard metacard = accessMgr.getMetacard(accessMgr.getProductId(product));
            if (metacard != null) {
                metacards.add(metacard);
            }
        }
        Integer port = getPort(properties);
        GetRelatedFilesRequestImpl getRelatedFilesRequest = new GetRelatedFilesRequestImpl(metacards, location, type, port);
        _poa().activate_object_with_id(id.getBytes(Charset.forName(NsiliEndpoint.ENCODING)), getRelatedFilesRequest);
    } catch (ServantAlreadyActive | ObjectAlreadyActive | WrongPolicy | WrongAdapter | UnsupportedEncodingException e) {
        LOGGER.debug("get_related_files : Unable to activate getRelatedFilesRequest object.", e);
    }
    org.omg.CORBA.Object obj = _poa().create_reference_with_id(id.getBytes(Charset.forName(NsiliEndpoint.ENCODING)), GetRelatedFilesRequestHelper.id());
    GetRelatedFilesRequest queryRequest = GetRelatedFilesRequestHelper.narrow(obj);
    return queryRequest;
}
Also used : GetRelatedFilesRequestImpl(org.codice.alliance.nsili.endpoint.requests.GetRelatedFilesRequestImpl) ObjectAlreadyActive(org.omg.PortableServer.POAPackage.ObjectAlreadyActive) ArrayList(java.util.ArrayList) Product(org.codice.alliance.nsili.common.UID.Product) UnsupportedEncodingException(java.io.UnsupportedEncodingException) WrongPolicy(org.omg.PortableServer.POAPackage.WrongPolicy) Metacard(ddf.catalog.data.Metacard) WrongAdapter(org.omg.PortableServer.POAPackage.WrongAdapter) GetRelatedFilesRequest(org.codice.alliance.nsili.common.GIAS.GetRelatedFilesRequest) ServantAlreadyActive(org.omg.PortableServer.POAPackage.ServantAlreadyActive)

Example 3 with WrongAdapter

use of org.omg.PortableServer.POAPackage.WrongAdapter in project alliance by codice.

the class ProductMgrImpl method get_parameters.

@Override
public GetParametersRequest get_parameters(Product prod, String[] desired_parameters, NameValue[] properties) throws ProcessingFault, InvalidInputParameter, SystemFault {
    GetParametersRequest getParamRequest = null;
    String id = UUID.randomUUID().toString();
    try {
        String productIdStr = getAccessManager().getProductId(prod);
        GetParametersRequestImpl getParametersRequest = new GetParametersRequestImpl(productIdStr, desired_parameters, catalogFramework, filterBuilder, querySources, outgoingValidationEnabled);
        _poa().activate_object_with_id(id.getBytes(Charset.forName(NsiliEndpoint.ENCODING)), getParametersRequest);
        org.omg.CORBA.Object obj = _poa().create_reference_with_id(id.getBytes(Charset.forName(NsiliEndpoint.ENCODING)), GetParametersRequestHelper.id());
        getParamRequest = GetParametersRequestHelper.narrow(obj);
    } catch (WrongAdapter | WrongPolicy | UnsupportedEncodingException e) {
        LOGGER.debug("Unable to get ID from product reference: {}", NsilCorbaExceptionUtil.getExceptionDetails(e), e);
    } catch (ServantAlreadyActive | ObjectAlreadyActive e) {
        LOGGER.debug("get_parameters : Unable to activate getParametersRequest object. {}", NsilCorbaExceptionUtil.getExceptionDetails(e), e);
    }
    return getParamRequest;
}
Also used : ObjectAlreadyActive(org.omg.PortableServer.POAPackage.ObjectAlreadyActive) UnsupportedEncodingException(java.io.UnsupportedEncodingException) GetParametersRequestImpl(org.codice.alliance.nsili.endpoint.requests.GetParametersRequestImpl) WrongPolicy(org.omg.PortableServer.POAPackage.WrongPolicy) WrongAdapter(org.omg.PortableServer.POAPackage.WrongAdapter) ServantAlreadyActive(org.omg.PortableServer.POAPackage.ServantAlreadyActive) GetParametersRequest(org.codice.alliance.nsili.common.GIAS.GetParametersRequest)

Aggregations

UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 WrongAdapter (org.omg.PortableServer.POAPackage.WrongAdapter)3 WrongPolicy (org.omg.PortableServer.POAPackage.WrongPolicy)3 ArrayList (java.util.ArrayList)2 ObjectAlreadyActive (org.omg.PortableServer.POAPackage.ObjectAlreadyActive)2 ServantAlreadyActive (org.omg.PortableServer.POAPackage.ServantAlreadyActive)2 Metacard (ddf.catalog.data.Metacard)1 SecurityServiceException (ddf.security.service.SecurityServiceException)1 IOException (java.io.IOException)1 ExecutionException (org.apache.shiro.subject.ExecutionException)1 DeliveryDetails (org.codice.alliance.nsili.common.GIAS.DeliveryDetails)1 DeliveryManifest (org.codice.alliance.nsili.common.GIAS.DeliveryManifest)1 Destination (org.codice.alliance.nsili.common.GIAS.Destination)1 GetParametersRequest (org.codice.alliance.nsili.common.GIAS.GetParametersRequest)1 GetRelatedFilesRequest (org.codice.alliance.nsili.common.GIAS.GetRelatedFilesRequest)1 PackageElement (org.codice.alliance.nsili.common.GIAS.PackageElement)1 PackagingSpec (org.codice.alliance.nsili.common.GIAS.PackagingSpec)1 ProductDetails (org.codice.alliance.nsili.common.GIAS.ProductDetails)1 PackagingSpecFormatType (org.codice.alliance.nsili.common.PackagingSpecFormatType)1 Product (org.codice.alliance.nsili.common.UID.Product)1