Search in sources :

Example 6 with NotFound

use of org.omg.CosNaming.NamingContextPackage.NotFound in project wildfly by wildfly.

the class ExceptionMapper method mapException.

public static NamingException mapException(Exception e, CNCtx ctx, NameComponent[] inputName) throws NamingException {
    if (e instanceof NamingException) {
        return (NamingException) e;
    }
    if (e instanceof RuntimeException) {
        throw (RuntimeException) e;
    }
    NamingException ne;
    if (e instanceof NotFound) {
        if (ctx.federation) {
            return tryFed((NotFound) e, ctx, inputName);
        } else {
            ne = new NameNotFoundException();
        }
    } else if (e instanceof CannotProceed) {
        ne = new CannotProceedException();
        NamingContext nc = ((CannotProceed) e).cxt;
        NameComponent[] rest = ((CannotProceed) e).rest_of_name;
        // NotFound doesn't set rest as expected. -RL
        if (inputName != null && (inputName.length > rest.length)) {
            NameComponent[] resolvedName = new NameComponent[inputName.length - rest.length];
            System.arraycopy(inputName, 0, resolvedName, 0, resolvedName.length);
            // Wrap resolved NamingContext inside a CNCtx
            // Guess that its name (which is relative to ctx)
            // is the part of inputName minus rest_of_name
            ne.setResolvedObj(new CNCtx(ctx._orb, nc, ctx._env, ctx.makeFullName(resolvedName)));
        } else {
            ne.setResolvedObj(ctx);
        }
        ne.setRemainingName(org.wildfly.iiop.openjdk.naming.jndi.CNNameParser.cosNameToName(rest));
    } else if (e instanceof InvalidName) {
        ne = new InvalidNameException();
    } else if (e instanceof AlreadyBound) {
        ne = new NameAlreadyBoundException();
    } else if (e instanceof NotEmpty) {
        ne = new ContextNotEmptyException();
    } else {
        ne = new NamingException();
    }
    ne.setRootCause(e);
    return ne;
}
Also used : NameNotFoundException(javax.naming.NameNotFoundException) CannotProceed(org.omg.CosNaming.NamingContextPackage.CannotProceed) NamingContext(org.omg.CosNaming.NamingContext) NameAlreadyBoundException(javax.naming.NameAlreadyBoundException) InvalidName(org.omg.CosNaming.NamingContextPackage.InvalidName) InvalidNameException(javax.naming.InvalidNameException) CannotProceedException(javax.naming.CannotProceedException) ContextNotEmptyException(javax.naming.ContextNotEmptyException) NamingException(javax.naming.NamingException) AlreadyBound(org.omg.CosNaming.NamingContextPackage.AlreadyBound) NotEmpty(org.omg.CosNaming.NamingContextPackage.NotEmpty) NotFound(org.omg.CosNaming.NamingContextPackage.NotFound)

Example 7 with NotFound

use of org.omg.CosNaming.NamingContextPackage.NotFound in project wildfly by wildfly.

the class CorbaNamingContext method rebind_context.

public void rebind_context(NameComponent[] nc, NamingContext obj) throws NotFound, CannotProceed, InvalidName {
    if (this.destroyed)
        throw new CannotProceed();
    if (nc == null || nc.length == 0)
        throw new InvalidName();
    if (obj == null)
        throw new org.omg.CORBA.BAD_PARAM();
    Name n = new Name(nc);
    Name ctx = n.ctxName();
    NameComponent nb = n.baseNameComponent();
    if (ctx == null) {
        // the name is bound, but it is bound to an object - the client should have been using rebind().
        if (this.names.containsKey(n))
            throw new NotFound(NotFoundReason.not_context, new NameComponent[] { nb });
        // try to remove an existing context binding.
        org.omg.CORBA.Object ref = (org.omg.CORBA.Object) this.contexts.remove(n);
        if (ref != null) {
            ref._release();
            // remove the old context from the implementation cache.
            String oid = this.getObjectOID(ref);
            if (oid != null)
                contextImpls.remove(oid);
        }
        this.contexts.put(n, obj);
        IIOPLogger.ROOT_LOGGER.debugf("Bound context: %s", n.baseNameComponent().id);
    } else {
        // rebind in the correct context
        NameComponent[] ncx = new NameComponent[] { nb };
        org.omg.CORBA.Object context = this.resolve(ctx.components());
        // try first to call the context implementation object directly.
        String contextOID = this.getObjectOID(context);
        CorbaNamingContext jbossContext = (contextOID == null ? null : contextImpls.get(contextOID));
        if (jbossContext != null)
            jbossContext.rebind_context(ncx, obj);
        else
            NamingContextExtHelper.narrow(context).rebind_context(ncx, obj);
    }
}
Also used : NameComponent(org.omg.CosNaming.NameComponent) CannotProceed(org.omg.CosNaming.NamingContextPackage.CannotProceed) InvalidName(org.omg.CosNaming.NamingContextPackage.InvalidName) InvalidName(org.omg.CosNaming.NamingContextPackage.InvalidName) NotFound(org.omg.CosNaming.NamingContextPackage.NotFound)

Example 8 with NotFound

use of org.omg.CosNaming.NamingContextPackage.NotFound in project wildfly by wildfly.

the class CorbaNamingContext method unbind.

public void unbind(NameComponent[] nc) throws NotFound, CannotProceed, InvalidName {
    if (this.destroyed)
        throw new CannotProceed();
    if (nc == null || nc.length == 0)
        throw new InvalidName();
    Name n = new Name(nc);
    Name ctx = n.ctxName();
    NameComponent nb = n.baseNameComponent();
    if (ctx == null) {
        if (this.names.containsKey(n)) {
            org.omg.CORBA.Object ref = (org.omg.CORBA.Object) this.names.remove(n);
            ref._release();
            IIOPLogger.ROOT_LOGGER.debugf("Unbound: %s", n);
        } else if (this.contexts.containsKey(n)) {
            org.omg.CORBA.Object ref = (org.omg.CORBA.Object) this.contexts.remove(n);
            ref._release();
            // remove the context from the implementation cache.
            String oid = this.getObjectOID(ref);
            if (oid != null)
                contextImpls.remove(oid);
            IIOPLogger.ROOT_LOGGER.debugf("Unbound: %s", n);
        } else {
            IIOPLogger.ROOT_LOGGER.failedToUnbindObject(n);
            throw new NotFound(NotFoundReason.not_context, n.components());
        }
    } else {
        NameComponent[] ncx = new NameComponent[] { nb };
        org.omg.CORBA.Object context = this.resolve(ctx.components());
        // try first to call the context implementation object directly.
        String contextOID = this.getObjectOID(context);
        CorbaNamingContext jbossContext = (contextOID == null ? null : contextImpls.get(contextOID));
        if (jbossContext != null)
            jbossContext.unbind(ncx);
        else
            NamingContextExtHelper.narrow(context).unbind(ncx);
    }
}
Also used : NameComponent(org.omg.CosNaming.NameComponent) CannotProceed(org.omg.CosNaming.NamingContextPackage.CannotProceed) InvalidName(org.omg.CosNaming.NamingContextPackage.InvalidName) InvalidName(org.omg.CosNaming.NamingContextPackage.InvalidName) NotFound(org.omg.CosNaming.NamingContextPackage.NotFound)

Example 9 with NotFound

use of org.omg.CosNaming.NamingContextPackage.NotFound in project wildfly by wildfly.

the class CorbaNamingContext method resolve.

public org.omg.CORBA.Object resolve(NameComponent[] nc) throws NotFound, CannotProceed, InvalidName {
    if (this.destroyed)
        throw new CannotProceed();
    if (nc == null || nc.length == 0)
        throw new InvalidName();
    Name n = new Name(nc[0]);
    if (nc.length > 1) {
        org.omg.CORBA.Object next_context = (org.omg.CORBA.Object) this.contexts.get(n);
        if ((next_context == null) || (isDead(next_context)))
            throw new NotFound(NotFoundReason.missing_node, nc);
        NameComponent[] nc_prime = new NameComponent[nc.length - 1];
        System.arraycopy(nc, 1, nc_prime, 0, nc_prime.length);
        // try first to call the context implementation object directly.
        String contextOID = this.getObjectOID(next_context);
        CorbaNamingContext jbossContext = (contextOID == null ? null : contextImpls.get(contextOID));
        if (jbossContext != null)
            return jbossContext.resolve(nc_prime);
        else
            return NamingContextExtHelper.narrow(next_context).resolve(nc_prime);
    } else {
        org.omg.CORBA.Object result = (org.omg.CORBA.Object) this.contexts.get(n);
        if (result == null)
            result = (org.omg.CORBA.Object) this.names.get(n);
        if (result == null)
            throw new NotFound(NotFoundReason.missing_node, n.components());
        if (!noPing && isDead(result))
            throw new NotFound(NotFoundReason.missing_node, n.components());
        return result;
    }
}
Also used : NameComponent(org.omg.CosNaming.NameComponent) CannotProceed(org.omg.CosNaming.NamingContextPackage.CannotProceed) InvalidName(org.omg.CosNaming.NamingContextPackage.InvalidName) InvalidName(org.omg.CosNaming.NamingContextPackage.InvalidName) NotFound(org.omg.CosNaming.NamingContextPackage.NotFound)

Example 10 with NotFound

use of org.omg.CosNaming.NamingContextPackage.NotFound in project wildfly by wildfly.

the class CorbaNamingContext method rebind.

public void rebind(NameComponent[] nc, org.omg.CORBA.Object obj) throws NotFound, CannotProceed, InvalidName {
    if (this.destroyed)
        throw new CannotProceed();
    if (nc == null || nc.length == 0)
        throw new InvalidName();
    if (obj == null)
        throw new org.omg.CORBA.BAD_PARAM();
    Name n = new Name(nc);
    Name ctx = n.ctxName();
    NameComponent nb = n.baseNameComponent();
    if (ctx == null) {
        // the name is bound, but it is bound to a context - the client should have been using rebind_context!
        if (this.contexts.containsKey(n))
            throw new NotFound(NotFoundReason.not_object, new NameComponent[] { nb });
        // try remove an existing binding.
        org.omg.CORBA.Object ref = (org.omg.CORBA.Object) this.names.remove(n);
        if (ref != null)
            ref._release();
        // do the rebinding in this context
        this.names.put(n, obj);
        IIOPLogger.ROOT_LOGGER.debugf("Bound name: %s", n);
    } else {
        // rebind in the correct context
        NameComponent[] ncx = new NameComponent[] { nb };
        org.omg.CORBA.Object context = this.resolve(ctx.components());
        // try first to call the context implementation object directly.
        String contextOID = this.getObjectOID(context);
        CorbaNamingContext jbossContext = (contextOID == null ? null : contextImpls.get(contextOID));
        if (jbossContext != null)
            jbossContext.rebind(ncx, obj);
        else
            NamingContextExtHelper.narrow(context).rebind(ncx, obj);
    }
}
Also used : NameComponent(org.omg.CosNaming.NameComponent) CannotProceed(org.omg.CosNaming.NamingContextPackage.CannotProceed) InvalidName(org.omg.CosNaming.NamingContextPackage.InvalidName) InvalidName(org.omg.CosNaming.NamingContextPackage.InvalidName) NotFound(org.omg.CosNaming.NamingContextPackage.NotFound)

Aggregations

NotFound (org.omg.CosNaming.NamingContextPackage.NotFound)10 NameComponent (org.omg.CosNaming.NameComponent)9 InvalidName (org.omg.CosNaming.NamingContextPackage.InvalidName)7 CannotProceed (org.omg.CosNaming.NamingContextPackage.CannotProceed)6 NamingContext (org.omg.CosNaming.NamingContext)4 CannotProceedException (javax.naming.CannotProceedException)3 NameNotFoundException (javax.naming.NameNotFoundException)3 NamingException (javax.naming.NamingException)3 ContextNotEmptyException (javax.naming.ContextNotEmptyException)2 InvalidNameException (javax.naming.InvalidNameException)2 NameAlreadyBoundException (javax.naming.NameAlreadyBoundException)2 CompositeName (javax.naming.CompositeName)1 Name (javax.naming.Name)1 NotContextException (javax.naming.NotContextException)1 RefAddr (javax.naming.RefAddr)1 Reference (javax.naming.Reference)1 StartException (org.jboss.msc.service.StartException)1 NamingContextExt (org.omg.CosNaming.NamingContextExt)1 AlreadyBound (org.omg.CosNaming.NamingContextPackage.AlreadyBound)1 NotEmpty (org.omg.CosNaming.NamingContextPackage.NotEmpty)1