use of org.codice.alliance.nsili.common.GIAS.GetRelatedFilesRequest in project alliance by codice.
the class ProductMgrImplTest method testGetRelatedFilesWithBadPort.
@Test
public void testGetRelatedFilesWithBadPort() throws Exception {
MetacardImpl testMetacard = new MetacardImpl();
testMetacard.setId(testMetacardId);
testMetacard.setTitle("JUnit Test Card");
Result testResult = new ResultImpl(testMetacard);
DAG dag = ResultDAGConverter.convertResult(testResult, orb, rootPOA, new ArrayList<>(), new HashMap<>());
Product product = ProductHelper.extract(dag.nodes[0].value);
Product[] products = new Product[] { product };
String userName = "";
String password = "";
String hostName = "localhost";
String pathName = "/nsili/file";
FileLocation location = new FileLocation(userName, password, hostName, pathName, null);
NameValue[] props = new NameValue[1];
Any portAny = orb.create_any();
portAny.insert_string("NOPE");
NameValue prop = new NameValue("PORT", portAny);
props[0] = prop;
GetRelatedFilesRequest request = productMgr.get_related_files(products, location, NsiliConstants.THUMBNAIL_TYPE, props);
assertThat(request, notNullValue());
}
use of org.codice.alliance.nsili.common.GIAS.GetRelatedFilesRequest 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;
}
use of org.codice.alliance.nsili.common.GIAS.GetRelatedFilesRequest in project alliance by codice.
the class ProductMgrImplTest method testGetRelatedFiles.
@Test
public void testGetRelatedFiles() throws Exception {
MetacardImpl testMetacard = new MetacardImpl();
testMetacard.setId(testMetacardId);
testMetacard.setTitle("JUnit Test Card");
Result testResult = new ResultImpl(testMetacard);
DAG dag = ResultDAGConverter.convertResult(testResult, orb, rootPOA, new ArrayList<>(), new HashMap<>());
Product product = ProductHelper.extract(dag.nodes[0].value);
Product[] products = new Product[] { product };
String userName = "";
String password = "";
String hostName = "localhost";
String pathName = "/nsili/file";
FileLocation location = new FileLocation(userName, password, hostName, pathName, null);
NameValue[] props = new NameValue[0];
GetRelatedFilesRequest request = productMgr.get_related_files(products, location, NsiliConstants.THUMBNAIL_TYPE, props);
assertThat(request, notNullValue());
}
use of org.codice.alliance.nsili.common.GIAS.GetRelatedFilesRequest in project alliance by codice.
the class ProductMgrImplTest method testGetRelatedFilesWithPort.
@Test
public void testGetRelatedFilesWithPort() throws Exception {
MetacardImpl testMetacard = new MetacardImpl();
testMetacard.setId(testMetacardId);
testMetacard.setTitle("JUnit Test Card");
Result testResult = new ResultImpl(testMetacard);
DAG dag = ResultDAGConverter.convertResult(testResult, orb, rootPOA, new ArrayList<>(), new HashMap<>());
Product product = ProductHelper.extract(dag.nodes[0].value);
Product[] products = new Product[] { product };
String userName = "";
String password = "";
String hostName = "localhost";
String pathName = "/nsili/file";
FileLocation location = new FileLocation(userName, password, hostName, pathName, null);
NameValue[] props = new NameValue[1];
Any portAny = orb.create_any();
portAny.insert_string("2000");
NameValue prop = new NameValue("PORT", portAny);
props[0] = prop;
GetRelatedFilesRequest request = productMgr.get_related_files(products, location, NsiliConstants.THUMBNAIL_TYPE, props);
assertThat(request, notNullValue());
}
use of org.codice.alliance.nsili.common.GIAS.GetRelatedFilesRequest in project alliance by codice.
the class SampleNsiliClient method getRelatedFiles.
public String[] getRelatedFiles(Product product) throws Exception {
if (productMgr != null) {
LOGGER.info("Sending Get Related Files Request...");
final FileLocation fileLocation = new FileLocation("user", "pass", "localhost", "/nsili/file", "");
Any portAny = orb.create_any();
portAny.insert_string(String.valueOf(listenPort));
NameValue portProp = new NameValue("PORT", portAny);
NameValue[] properties = new NameValue[] { portProp };
Product[] products = { product };
GetRelatedFilesRequest relatedFilesRequest = productMgr.get_related_files(products, fileLocation, NsiliConstants.THUMBNAIL_TYPE, properties);
relatedFilesRequest.set_user_info(ALLIANCE);
NameListHolder locations = new NameListHolder();
relatedFilesRequest.complete(locations);
String[] locationList = locations.value;
if (locationList.length > 0) {
LOGGER.info("Location List : ");
for (String location : locationList) {
LOGGER.info("\t Stored File: {}", location);
}
} else {
LOGGER.info("No locations returned from Get Related Files Request");
}
return locationList;
} else {
LOGGER.warn("ProductMgr is not initialized, unable to get related files");
return null;
}
}
Aggregations