Search in sources :

Example 26 with OrderContents

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

the class OrderRequestImplTest method testSingleUncompressedOrder.

@Test
public void testSingleUncompressedOrder() throws SystemFault, ProcessingFault {
    OrderContents order = getUncompressedTestOrder();
    OrderRequestImpl orderRequest = new OrderRequestImpl(order, accessManager, mockCatalogFramework, destination -> Optional.of(mock(DestinationSink.class)));
    DeliveryManifestHolder holder = new DeliveryManifestHolder();
    orderRequest.complete(holder);
    assertThat(holder.value, notNullValue());
    assertThat(holder.value.elements[0].files.length, is(1));
}
Also used : OrderContents(org.codice.alliance.nsili.common.GIAS.OrderContents) DeliveryManifestHolder(org.codice.alliance.nsili.common.GIAS.DeliveryManifestHolder) Test(org.junit.Test)

Example 27 with OrderContents

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

the class OrderRequestImplTest method testNoPSpec.

@Test
public void testNoPSpec() throws SystemFault, ProcessingFault {
    OrderContents order = getUncompressedTestOrder();
    order.pSpec = null;
    OrderRequestImpl orderRequest = new OrderRequestImpl(order, accessManager, mockCatalogFramework, destination -> Optional.of(mock(DestinationSink.class)));
    DeliveryManifestHolder holder = new DeliveryManifestHolder();
    orderRequest.complete(holder);
    assertThat(holder.value, notNullValue());
    assertThat(holder.value.elements[0].files.length, is(1));
}
Also used : OrderContents(org.codice.alliance.nsili.common.GIAS.OrderContents) DeliveryManifestHolder(org.codice.alliance.nsili.common.GIAS.DeliveryManifestHolder) Test(org.junit.Test)

Example 28 with OrderContents

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

the class OrderRequestImplTest method getRemainingDelay.

@Test
public void getRemainingDelay() throws SystemFault, ProcessingFault {
    OrderContents order = getUncompressedTestOrder();
    OrderRequestImpl orderRequest = new OrderRequestImpl(order, PROTOCOL, PORT, accessManager, mockCatalogFramework, emailConfiguration);
    DelayEstimate delayEstimate = orderRequest.get_remaining_delay();
    assertThat(delayEstimate, notNullValue());
}
Also used : OrderContents(org.codice.alliance.nsili.common.GIAS.OrderContents) DelayEstimate(org.codice.alliance.nsili.common.GIAS.DelayEstimate) Test(org.junit.Test)

Example 29 with OrderContents

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

the class OrderRequestImplTest method testSingleFilesZipOrder.

@Test
public void testSingleFilesZipOrder() throws SystemFault, ProcessingFault {
    OrderContents order = getUncompressedTestOrder();
    order.pSpec.packaging_format_and_compression = PackagingSpecFormatType.FILESZIP.name();
    OrderRequestImpl orderRequest = new OrderRequestImpl(order, accessManager, mockCatalogFramework, destination -> Optional.of(mock(DestinationSink.class)));
    DeliveryManifestHolder holder = new DeliveryManifestHolder();
    orderRequest.complete(holder);
    assertThat(holder.value, notNullValue());
    assertThat(holder.value.elements[0].files.length, is(1));
}
Also used : OrderContents(org.codice.alliance.nsili.common.GIAS.OrderContents) DeliveryManifestHolder(org.codice.alliance.nsili.common.GIAS.DeliveryManifestHolder) Test(org.junit.Test)

Example 30 with OrderContents

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

the class SampleNsiliClient method order.

public PackageElement[] order(DAG dag) throws Exception {
    if (orderMgr == null) {
        LOGGER.warn("OrderMgr is not initialized, unable to submit order");
        return null;
    }
    LOGGER.info("--------------------------");
    LOGGER.info("OrderMgr getting package specifications");
    String[] supportedPackageSpecs = orderMgr.get_package_specifications();
    if (supportedPackageSpecs != null && supportedPackageSpecs.length > 0) {
        for (String supportedPackageSpec : supportedPackageSpecs) {
            LOGGER.info(TAB_LOG_MSG, supportedPackageSpec);
        }
    } else {
        LOGGER.warn("Server returned no packaging specifications");
        supportedPackageSpecs = new String[0];
    }
    LOGGER.info("Getting OrderMgr Use Modes");
    String[] useModes = orderMgr.get_use_modes();
    for (String useMode : useModes) {
        LOGGER.info(TAB_LOG_MSG, useMode);
    }
    LOGGER.info("Order Mgr num of priorities: {} ", orderMgr.get_number_of_priorities());
    Product product = getProductFromDag(dag);
    String filename = getAttributeFromDag(dag, NsiliConstants.FILENAME) + ".dat";
    // Product available
    boolean productAvail = orderMgr.is_available(product, useModes[0]);
    LOGGER.info("Product available: {}", productAvail);
    LOGGER.info("Creating order request...");
    Any portAny = orb.create_any();
    Any protocolAny = orb.create_any();
    protocolAny.insert_string("http");
    portAny.insert_long(listenPort);
    NameValue portProp = new NameValue("PORT", portAny);
    NameValue protocolProp = new NameValue("PROTOCOL", protocolAny);
    NameValue[] properties = new NameValue[] { portProp, protocolProp };
    OrderContents order = createFileOrder(product, supportedPackageSpecs, filename);
    // Validating Order
    LOGGER.info("Validating Order...");
    ValidationResults validationResults = orderMgr.validate_order(order, properties);
    LOGGER.info("Validation Results: ");
    LOGGER.info("\tValid : {} \n" + "\tWarning : {} \n" + "\tDetails : {}", validationResults.valid, validationResults.warning, validationResults.details);
    OrderRequest orderRequest = orderMgr.order(order, properties);
    LOGGER.info("Completing OrderRequest...");
    DeliveryManifestHolder deliveryManifestHolder = new DeliveryManifestHolder();
    orderRequest.set_user_info(ALLIANCE);
    PackageElement[] elements;
    try {
        orderRequest.complete(deliveryManifestHolder);
        if (emailAddress != null) {
            order = createEmailOrder(orb, product, supportedPackageSpecs);
            // Validating Order
            LOGGER.info("Validating Email Order...");
            validationResults = orderMgr.validate_order(order, properties);
            LOGGER.info("Email Validation Results: ");
            LOGGER.info("\tValid : {}\n\tWarning : {}\n\tDetails : {}\n", validationResults.valid, validationResults.warning, validationResults.details);
            orderRequest = orderMgr.order(order, properties);
            orderRequest.set_user_info(ALLIANCE);
            orderRequest.complete(deliveryManifestHolder);
        }
        DeliveryManifest deliveryManifest = deliveryManifestHolder.value;
        LOGGER.info("Completed Order : {}", deliveryManifest.package_name);
        elements = deliveryManifest.elements;
        if (deliveryManifest.elements != null) {
            for (PackageElement element : elements) {
                for (String file : element.files) {
                    LOGGER.info(TAB_LOG_MSG, file);
                }
            }
        }
        return elements;
    } catch (Exception e) {
        LOGGER.error("Error completing order request", NsilCorbaExceptionUtil.getExceptionDetails(e));
        return null;
    }
}
Also used : OrderRequest(org.codice.alliance.nsili.common.GIAS.OrderRequest) DeliveryManifest(org.codice.alliance.nsili.common.GIAS.DeliveryManifest) Product(org.codice.alliance.nsili.common.UID.Product) Any(org.omg.CORBA.Any) 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) ValidationResults(org.codice.alliance.nsili.common.GIAS.ValidationResults) OrderContents(org.codice.alliance.nsili.common.GIAS.OrderContents) DeliveryManifestHolder(org.codice.alliance.nsili.common.GIAS.DeliveryManifestHolder) PackageElement(org.codice.alliance.nsili.common.GIAS.PackageElement)

Aggregations

OrderContents (org.codice.alliance.nsili.common.GIAS.OrderContents)31 Test (org.junit.Test)26 DeliveryManifestHolder (org.codice.alliance.nsili.common.GIAS.DeliveryManifestHolder)22 DeliveryDetails (org.codice.alliance.nsili.common.GIAS.DeliveryDetails)6 PackagingSpec (org.codice.alliance.nsili.common.GIAS.PackagingSpec)4 ProductDetails (org.codice.alliance.nsili.common.GIAS.ProductDetails)4 Any (org.omg.CORBA.Any)3 Calendar (java.util.Calendar)2 AlterationSpec (org.codice.alliance.nsili.common.GIAS.AlterationSpec)2 Destination (org.codice.alliance.nsili.common.GIAS.Destination)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 IOException (java.io.IOException)1