use of org.omg.CORBA.ORBPackage.InvalidName in project alliance by codice.
the class MockNsili method startMockServer.
public void startMockServer(int corbaPort) {
ORB orb = null;
try {
orb = getOrbForServer(corbaPort);
LOGGER.info("Server Started...");
// blocks the current thread until the ORB is shutdown
orb.run();
} catch (InvalidName | AdapterInactive | WrongPolicy | ServantNotActive e) {
LOGGER.error("Unable to start the CORBA server.", e);
} catch (IOException e) {
LOGGER.error("Unable to generate the IOR file.", e);
}
if (orb != null) {
orb.destroy();
}
}
use of org.omg.CORBA.ORBPackage.InvalidName in project alliance by codice.
the class AccessManagerImplTest method setUp.
@Before
public void setUp() throws Exception {
setupCommonMocks();
setupAccessMgrMocks();
try {
setupOrb();
orbRunThread = new Thread(() -> orb.run());
orbRunThread.start();
} catch (InvalidName | AdapterInactive | WrongPolicy | ServantNotActive e) {
LOGGER.error("Unable to start the CORBA server", e);
} catch (IOException e) {
LOGGER.error("Unable to generate the IOR file", e);
} catch (SecurityServiceException e) {
LOGGER.error("Unable to setup guest security credentials", e);
}
testQuery = new Query(NsiliConstants.NSIL_ALL_VIEW, bqsQuery);
String managerId = UUID.randomUUID().toString();
accessManager = new AccessManagerImpl();
accessManager.setFilterBuilder(new GeotoolsFilterBuilder());
accessManager.setCatalogFramework(mockCatalogFramework);
if (!CorbaUtils.isIdActive(rootPOA, managerId.getBytes(Charset.forName(NsiliEndpoint.ENCODING)))) {
try {
rootPOA.activate_object_with_id(managerId.getBytes(Charset.forName(NsiliEndpoint.ENCODING)), accessManager);
} catch (ServantAlreadyActive | ObjectAlreadyActive | WrongPolicy e) {
LOGGER.error("Error activating ProductMgr: {}", e);
}
}
rootPOA.create_reference_with_id(managerId.getBytes(Charset.forName(NsiliEndpoint.ENCODING)), ProductMgrHelper.id());
}
use of org.omg.CORBA.ORBPackage.InvalidName in project alliance by codice.
the class CatalogMgrImplTest method setUp.
@Before
public void setUp() throws Exception {
setupCommonMocks();
setupCatalogMgrMocks();
try {
setupOrb();
orbRunThread = new Thread(() -> orb.run());
orbRunThread.start();
} catch (InvalidName | AdapterInactive | WrongPolicy | ServantNotActive e) {
LOGGER.error("Unable to start the CORBA server", e);
} catch (IOException e) {
LOGGER.error("Unable to generate the IOR file", e);
} catch (SecurityServiceException e) {
LOGGER.error("Unable to setup guest security credentials", e);
}
testQuery = new Query(NsiliConstants.NSIL_ALL_VIEW, bqsQuery);
catalogMgr = new CatalogMgrImpl(rootPOA, new GeotoolsFilterBuilder(), null);
catalogMgr.setCatalogFramework(mockCatalogFramework);
}
use of org.omg.CORBA.ORBPackage.InvalidName in project alliance by codice.
the class CreationMgrImplTest method setUp.
@Before
public void setUp() throws Exception {
try {
setupOrb();
orbRunThread = new Thread(() -> orb.run());
orbRunThread.start();
} catch (InvalidName | AdapterInactive | WrongPolicy | ServantNotActive e) {
LOGGER.error("Unable to start the CORBA server", e);
} catch (IOException e) {
LOGGER.error("Unable to generate the IOR file", e);
} catch (SecurityServiceException e) {
LOGGER.error("Unable to setup guest security credentials", e);
}
String managerId = UUID.randomUUID().toString();
creationMgr = new CreationMgrImpl();
creationMgr.setFilterBuilder(new GeotoolsFilterBuilder());
creationMgr.setCatalogFramework(mockCatalogFramework);
if (!CorbaUtils.isIdActive(rootPOA, managerId.getBytes(Charset.forName(NsiliEndpoint.ENCODING)))) {
try {
rootPOA.activate_object_with_id(managerId.getBytes(Charset.forName(NsiliEndpoint.ENCODING)), creationMgr);
} catch (ServantAlreadyActive | ObjectAlreadyActive | WrongPolicy e) {
LOGGER.error("Error activating ProductMgr: {}", e);
}
}
rootPOA.create_reference_with_id(managerId.getBytes(Charset.forName(NsiliEndpoint.ENCODING)), ProductMgrHelper.id());
}
use of org.omg.CORBA.ORBPackage.InvalidName in project narayana by jbosstm.
the class Services method registerService.
public void registerService(org.omg.CORBA.Object objRef, String serviceName, Object[] params, int mechanism) throws org.omg.CORBA.ORBPackage.InvalidName, IOException, SystemException {
switch(mechanism) {
case RESOLVE_INITIAL_REFERENCES:
{
throw new BAD_PARAM();
}
case NAME_SERVICE:
{
String kind = ((params == null) ? null : (String) params[0]);
try {
org.omg.CORBA.Object initServ = _orb.orb().resolve_initial_references(Services.nameService);
NamingContext rootContext = NamingContextHelper.narrow(initServ);
NameComponent[] contextName = new NameComponent[1];
contextName[0] = new NameComponent(serviceName, kind);
rootContext.rebind(contextName, objRef);
if (opLogger.logger.isTraceEnabled()) {
opLogger.logger.trace("Services.registerService - object " + serviceName + " registered with name service.");
}
} catch (org.omg.CORBA.ORBPackage.InvalidName e) {
throw new InvalidName();
} catch (UserException e) {
throw new InvalidName();
} catch (SystemException e) {
throw e;
}
}
break;
case CONFIGURATION_FILE:
{
String cosservicesRoot = opPropertyManager.getOrbPortabilityEnvironmentBean().getInitialReferencesRoot();
String configLocation = opPropertyManager.getOrbPortabilityEnvironmentBean().getInitialReferencesFile();
String configFile = cosservicesRoot + File.separatorChar + configLocation;
LineNumberReader input = null;
String objString = _orb.orb().object_to_string(objRef);
File currFile = null;
String newFileName = configFile + Services.tmpFile;
try {
currFile = new File(configFile);
input = new LineNumberReader(new FileReader(currFile));
} catch (FileNotFoundException e) {
if (opLogger.logger.isTraceEnabled()) {
opLogger.logger.trace("Services.registerService could not open config file " + configFile);
}
currFile = null;
input = null;
/*
* File not present, so this must be the first
* entry.
*/
// file does not exist, so write directly.
newFileName = configFile;
}
File nuFile = new File(newFileName);
PrintWriter outputFile = new PrintWriter(new FileOutputStream(nuFile), true);
boolean found = false;
if (input != null) {
String line = null;
do {
line = input.readLine();
if (line != null) {
int occur = line.indexOf(serviceName);
if (// should be first on line
occur == 0) {
if (// found old line?
line.substring(serviceName.length() + 1) != null) {
found = true;
outputFile.println(serviceName + separator + objString);
}
} else
outputFile.println(line);
outputFile.flush();
}
} while (line != null);
}
if (!found) {
outputFile.println(serviceName + separator + objString);
outputFile.flush();
}
outputFile.close();
if (// file existed.
input != null) {
input.close();
if (currFile.exists()) {
currFile.delete();
}
nuFile.renameTo(currFile);
input = null;
}
newFileName = null;
outputFile = null;
nuFile = null;
if (opLogger.logger.isTraceEnabled()) {
opLogger.logger.trace("Services.registerService - object " + serviceName + " registered with configuration file: " + configFile);
}
}
break;
case FILE:
{
String fileDir = opPropertyManager.getOrbPortabilityEnvironmentBean().getFileDir();
FileOutputStream ofile = null;
if (fileDir != null && fileDir.length() != 0)
ofile = new FileOutputStream(fileDir + File.separator + serviceName);
else
ofile = new FileOutputStream(serviceName);
String objString = _orb.orb().object_to_string(objRef);
byte[] b = objString.getBytes(StandardCharsets.UTF_8);
ofile.write(b);
ofile.close();
if (opLogger.logger.isTraceEnabled()) {
opLogger.logger.trace("Services.registerService - object " + serviceName + " reference file created: " + fileDir + serviceName);
}
}
break;
case NAMED_CONNECT:
{
opLogger.i18NLogger.warn_Services_optionnotsupported("Services.registerService", "NAMED_CONNECT");
throw new BAD_PARAM();
}
default:
break;
}
}
Aggregations