Search in sources :

Example 1 with InvalidName

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();
    }
}
Also used : WrongPolicy(org.omg.PortableServer.POAPackage.WrongPolicy) InvalidName(org.omg.CORBA.ORBPackage.InvalidName) AdapterInactive(org.omg.PortableServer.POAManagerPackage.AdapterInactive) ServantNotActive(org.omg.PortableServer.POAPackage.ServantNotActive) IOException(java.io.IOException) ORB(org.omg.CORBA.ORB)

Example 2 with InvalidName

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());
}
Also used : AccessManagerImpl(org.codice.alliance.nsili.endpoint.managers.AccessManagerImpl) SecurityServiceException(ddf.security.service.SecurityServiceException) Query(org.codice.alliance.nsili.common.GIAS.Query) ObjectAlreadyActive(org.omg.PortableServer.POAPackage.ObjectAlreadyActive) AdapterInactive(org.omg.PortableServer.POAManagerPackage.AdapterInactive) ServantNotActive(org.omg.PortableServer.POAPackage.ServantNotActive) IOException(java.io.IOException) WrongPolicy(org.omg.PortableServer.POAPackage.WrongPolicy) InvalidName(org.omg.CORBA.ORBPackage.InvalidName) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) ServantAlreadyActive(org.omg.PortableServer.POAPackage.ServantAlreadyActive) Before(org.junit.Before)

Example 3 with InvalidName

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);
}
Also used : WrongPolicy(org.omg.PortableServer.POAPackage.WrongPolicy) SecurityServiceException(ddf.security.service.SecurityServiceException) InvalidName(org.omg.CORBA.ORBPackage.InvalidName) Query(org.codice.alliance.nsili.common.GIAS.Query) AdapterInactive(org.omg.PortableServer.POAManagerPackage.AdapterInactive) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) CatalogMgrImpl(org.codice.alliance.nsili.endpoint.managers.CatalogMgrImpl) ServantNotActive(org.omg.PortableServer.POAPackage.ServantNotActive) IOException(java.io.IOException) Before(org.junit.Before)

Example 4 with InvalidName

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());
}
Also used : SecurityServiceException(ddf.security.service.SecurityServiceException) ObjectAlreadyActive(org.omg.PortableServer.POAPackage.ObjectAlreadyActive) AdapterInactive(org.omg.PortableServer.POAManagerPackage.AdapterInactive) ServantNotActive(org.omg.PortableServer.POAPackage.ServantNotActive) IOException(java.io.IOException) WrongPolicy(org.omg.PortableServer.POAPackage.WrongPolicy) CreationMgrImpl(org.codice.alliance.nsili.endpoint.managers.CreationMgrImpl) InvalidName(org.omg.CORBA.ORBPackage.InvalidName) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) ServantAlreadyActive(org.omg.PortableServer.POAPackage.ServantAlreadyActive) Before(org.junit.Before)

Example 5 with InvalidName

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;
    }
}
Also used : NameComponent(org.omg.CosNaming.NameComponent) BAD_PARAM(org.omg.CORBA.BAD_PARAM) FileNotFoundException(java.io.FileNotFoundException) NamingContext(org.omg.CosNaming.NamingContext) LineNumberReader(java.io.LineNumberReader) InvalidName(org.omg.CORBA.ORBPackage.InvalidName) SystemException(org.omg.CORBA.SystemException) FileOutputStream(java.io.FileOutputStream) FileReader(java.io.FileReader) UserException(org.omg.CORBA.UserException) File(java.io.File) PrintWriter(java.io.PrintWriter)

Aggregations

InvalidName (org.omg.CORBA.ORBPackage.InvalidName)13 IOException (java.io.IOException)9 AdapterInactive (org.omg.PortableServer.POAManagerPackage.AdapterInactive)8 ServantNotActive (org.omg.PortableServer.POAPackage.ServantNotActive)7 WrongPolicy (org.omg.PortableServer.POAPackage.WrongPolicy)7 GeotoolsFilterBuilder (ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder)6 SecurityServiceException (ddf.security.service.SecurityServiceException)6 Before (org.junit.Before)6 ObjectAlreadyActive (org.omg.PortableServer.POAPackage.ObjectAlreadyActive)5 ServantAlreadyActive (org.omg.PortableServer.POAPackage.ServantAlreadyActive)5 BAD_PARAM (org.omg.CORBA.BAD_PARAM)3 SystemException (org.omg.CORBA.SystemException)3 UserException (org.omg.CORBA.UserException)3 GroupInfoService (com.sun.corba.ee.spi.folb.GroupInfoService)2 File (java.io.File)2 FileNotFoundException (java.io.FileNotFoundException)2 FileReader (java.io.FileReader)2 LineNumberReader (java.io.LineNumberReader)2 Query (org.codice.alliance.nsili.common.GIAS.Query)2 ORB (org.omg.CORBA.ORB)2