Search in sources :

Example 1 with PackagingSpec

use of org.codice.alliance.nsili.common.GIAS.PackagingSpec in project alliance by codice.

the class SampleNsiliClient method createFileOrder.

private OrderContents createFileOrder(Product product, String[] supportedPackagingSpecs, String filename) throws Exception {
    NameName[] nameName = { new NameName("", "") };
    String orderPackageId = UUID.randomUUID().toString();
    TailoringSpec tailoringSpec = new TailoringSpec(nameName);
    PackagingSpec pSpec = new PackagingSpec(orderPackageId, supportedPackagingSpecs[0]);
    Calendar cal = Calendar.getInstance();
    cal.setTime(new java.util.Date());
    int year = cal.get(Calendar.YEAR);
    year++;
    AbsTime needByDate = new AbsTime(new Date((short) year, (short) 2, (short) 10), new Time((short) 10, (short) 0, (short) 0));
    MediaType[] mTypes = { new MediaType("", (short) 1) };
    String[] benums = new String[0];
    Rectangle region = new Rectangle(new Coordinate2d(1.1, 1.1), new Coordinate2d(2.2, 2.2));
    ImageSpec imageSpec = new ImageSpec();
    imageSpec.encoding = SupportDataEncoding.ASCII;
    imageSpec.rrds = new short[] { 1 };
    imageSpec.algo = "";
    imageSpec.bpp = 0;
    imageSpec.comp = "A";
    imageSpec.imgform = "A";
    imageSpec.imageid = "1234abc";
    imageSpec.geo_region_type = GeoRegionType.LAT_LON;
    Rectangle subSection = new Rectangle();
    subSection.lower_right = new Coordinate2d(0, 0);
    subSection.upper_left = new Coordinate2d(1, 1);
    imageSpec.sub_section = subSection;
    Any imageSpecAny = orb.create_any();
    ImageSpecHelper.insert(imageSpecAny, imageSpec);
    AlterationSpec aSpec = new AlterationSpec("JPEG", imageSpecAny, region, GeoRegionType.NULL_REGION);
    FileLocation fileLocation = new FileLocation("user", "pass", "localhost", "/nsili/file", filename);
    Destination destination = new Destination();
    destination.f_dest(fileLocation);
    ProductDetails[] productDetails = { new ProductDetails(mTypes, benums, aSpec, product, ALLIANCE) };
    DeliveryDetails[] deliveryDetails = { new DeliveryDetails(destination, "", "") };
    return new OrderContents(ALLIANCE, tailoringSpec, pSpec, needByDate, "Give me an order!", (short) 1, productDetails, deliveryDetails);
}
Also used : Destination(org.codice.alliance.nsili.common.GIAS.Destination) DeliveryDetails(org.codice.alliance.nsili.common.GIAS.DeliveryDetails) Rectangle(org.codice.alliance.nsili.common.UCO.Rectangle) Time(org.codice.alliance.nsili.common.UCO.Time) AbsTime(org.codice.alliance.nsili.common.UCO.AbsTime) ImageSpec(org.codice.alliance.nsili.common.GIAS.ImageSpec) Any(org.omg.CORBA.Any) AlterationSpec(org.codice.alliance.nsili.common.GIAS.AlterationSpec) AbsTime(org.codice.alliance.nsili.common.UCO.AbsTime) Coordinate2d(org.codice.alliance.nsili.common.UCO.Coordinate2d) ProductDetails(org.codice.alliance.nsili.common.GIAS.ProductDetails) MediaType(org.codice.alliance.nsili.common.GIAS.MediaType) NameName(org.codice.alliance.nsili.common.UCO.NameName) PackagingSpec(org.codice.alliance.nsili.common.GIAS.PackagingSpec) Calendar(java.util.Calendar) Date(org.codice.alliance.nsili.common.UCO.Date) TailoringSpec(org.codice.alliance.nsili.common.GIAS.TailoringSpec) OrderContents(org.codice.alliance.nsili.common.GIAS.OrderContents) FileLocation(org.codice.alliance.nsili.common.UCO.FileLocation)

Example 2 with PackagingSpec

use of org.codice.alliance.nsili.common.GIAS.PackagingSpec in project alliance by codice.

the class OrderRequestImplTest method getUncompressedTestOrder.

private OrderContents getUncompressedTestOrder() {
    OrderContents order = new OrderContents();
    PackagingSpec packagingSpec = new PackagingSpec();
    packagingSpec.package_identifier = "pkg1234";
    packagingSpec.packaging_format_and_compression = PackagingSpecFormatType.FILESUNC.name();
    order.pSpec = packagingSpec;
    ProductDetails productDetail = new ProductDetails();
    productDetail.aProduct = mockProduct1;
    order.prod_list = new ProductDetails[] { productDetail };
    DeliveryDetails deliveryDetail = new DeliveryDetails();
    deliveryDetail.dests = getTestDestination();
    order.del_list = new DeliveryDetails[] { deliveryDetail };
    return order;
}
Also used : OrderContents(org.codice.alliance.nsili.common.GIAS.OrderContents) ProductDetails(org.codice.alliance.nsili.common.GIAS.ProductDetails) DeliveryDetails(org.codice.alliance.nsili.common.GIAS.DeliveryDetails) PackagingSpec(org.codice.alliance.nsili.common.GIAS.PackagingSpec)

Example 3 with PackagingSpec

use of org.codice.alliance.nsili.common.GIAS.PackagingSpec in project alliance by codice.

the class OrderRequestImplTest method getMultipleUncompressedTestOrder.

private OrderContents getMultipleUncompressedTestOrder() {
    OrderContents order = new OrderContents();
    PackagingSpec packagingSpec = new PackagingSpec();
    packagingSpec.package_identifier = "pkg1234";
    packagingSpec.packaging_format_and_compression = PackagingSpecFormatType.FILESUNC.name();
    order.pSpec = packagingSpec;
    ProductDetails productDetail1 = new ProductDetails();
    productDetail1.aProduct = mockProduct1;
    ProductDetails productDetail2 = new ProductDetails();
    productDetail2.aProduct = mockProduct2;
    order.prod_list = new ProductDetails[] { productDetail1, productDetail2 };
    DeliveryDetails deliveryDetail = new DeliveryDetails();
    deliveryDetail.dests = getTestDestination();
    order.del_list = new DeliveryDetails[] { deliveryDetail };
    return order;
}
Also used : OrderContents(org.codice.alliance.nsili.common.GIAS.OrderContents) ProductDetails(org.codice.alliance.nsili.common.GIAS.ProductDetails) DeliveryDetails(org.codice.alliance.nsili.common.GIAS.DeliveryDetails) PackagingSpec(org.codice.alliance.nsili.common.GIAS.PackagingSpec)

Example 4 with PackagingSpec

use of org.codice.alliance.nsili.common.GIAS.PackagingSpec 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 5 with PackagingSpec

use of org.codice.alliance.nsili.common.GIAS.PackagingSpec in project alliance by codice.

the class SampleNsiliClient method createEmailOrder.

private OrderContents createEmailOrder(ORB orb, Product product, String[] supportedPackagingSpecs) throws Exception {
    NameName[] nameName = { new NameName("", "") };
    String orderPackageId = UUID.randomUUID().toString();
    TailoringSpec tailoringSpec = new TailoringSpec(nameName);
    PackagingSpec pSpec = new PackagingSpec(orderPackageId, supportedPackagingSpecs[0]);
    Calendar cal = Calendar.getInstance();
    cal.setTime(new java.util.Date());
    int year = cal.get(Calendar.YEAR);
    year++;
    AbsTime needByDate = new AbsTime(new Date((short) year, (short) 2, (short) 10), new Time((short) 10, (short) 0, (short) 0));
    MediaType[] mTypes = { new MediaType("", (short) 1) };
    String[] benums = new String[0];
    Rectangle region = new Rectangle(new Coordinate2d(1.1, 1.1), new Coordinate2d(2.2, 2.2));
    ImageSpec imageSpec = new ImageSpec();
    imageSpec.encoding = SupportDataEncoding.ASCII;
    imageSpec.rrds = new short[] { 1 };
    imageSpec.algo = "";
    imageSpec.bpp = 0;
    imageSpec.comp = "A";
    imageSpec.imgform = "A";
    imageSpec.imageid = "1234abc";
    imageSpec.geo_region_type = GeoRegionType.LAT_LON;
    Rectangle subSection = new Rectangle();
    subSection.lower_right = new Coordinate2d(0, 0);
    subSection.upper_left = new Coordinate2d(1, 1);
    imageSpec.sub_section = subSection;
    Any imageSpecAny = orb.create_any();
    ImageSpecHelper.insert(imageSpecAny, imageSpec);
    AlterationSpec aSpec = new AlterationSpec("JPEG", imageSpecAny, region, GeoRegionType.NULL_REGION);
    Destination destination = new Destination();
    destination.e_dest(emailAddress);
    ProductDetails[] productDetails = { new ProductDetails(mTypes, benums, aSpec, product, ALLIANCE) };
    DeliveryDetails[] deliveryDetails = { new DeliveryDetails(destination, "", "") };
    return new OrderContents(ALLIANCE, tailoringSpec, pSpec, needByDate, "Give me an order!", (short) 1, productDetails, deliveryDetails);
}
Also used : Destination(org.codice.alliance.nsili.common.GIAS.Destination) DeliveryDetails(org.codice.alliance.nsili.common.GIAS.DeliveryDetails) Rectangle(org.codice.alliance.nsili.common.UCO.Rectangle) Time(org.codice.alliance.nsili.common.UCO.Time) AbsTime(org.codice.alliance.nsili.common.UCO.AbsTime) ImageSpec(org.codice.alliance.nsili.common.GIAS.ImageSpec) Any(org.omg.CORBA.Any) AlterationSpec(org.codice.alliance.nsili.common.GIAS.AlterationSpec) AbsTime(org.codice.alliance.nsili.common.UCO.AbsTime) Coordinate2d(org.codice.alliance.nsili.common.UCO.Coordinate2d) ProductDetails(org.codice.alliance.nsili.common.GIAS.ProductDetails) MediaType(org.codice.alliance.nsili.common.GIAS.MediaType) NameName(org.codice.alliance.nsili.common.UCO.NameName) PackagingSpec(org.codice.alliance.nsili.common.GIAS.PackagingSpec) Calendar(java.util.Calendar) Date(org.codice.alliance.nsili.common.UCO.Date) TailoringSpec(org.codice.alliance.nsili.common.GIAS.TailoringSpec) OrderContents(org.codice.alliance.nsili.common.GIAS.OrderContents)

Aggregations

DeliveryDetails (org.codice.alliance.nsili.common.GIAS.DeliveryDetails)5 PackagingSpec (org.codice.alliance.nsili.common.GIAS.PackagingSpec)5 ProductDetails (org.codice.alliance.nsili.common.GIAS.ProductDetails)5 OrderContents (org.codice.alliance.nsili.common.GIAS.OrderContents)4 Destination (org.codice.alliance.nsili.common.GIAS.Destination)3 Calendar (java.util.Calendar)2 AlterationSpec (org.codice.alliance.nsili.common.GIAS.AlterationSpec)2 ImageSpec (org.codice.alliance.nsili.common.GIAS.ImageSpec)2 MediaType (org.codice.alliance.nsili.common.GIAS.MediaType)2 TailoringSpec (org.codice.alliance.nsili.common.GIAS.TailoringSpec)2 AbsTime (org.codice.alliance.nsili.common.UCO.AbsTime)2 Coordinate2d (org.codice.alliance.nsili.common.UCO.Coordinate2d)2 Date (org.codice.alliance.nsili.common.UCO.Date)2 NameName (org.codice.alliance.nsili.common.UCO.NameName)2 Rectangle (org.codice.alliance.nsili.common.UCO.Rectangle)2 Time (org.codice.alliance.nsili.common.UCO.Time)2 Any (org.omg.CORBA.Any)2 SecurityServiceException (ddf.security.service.SecurityServiceException)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1