/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* A convenience class to map the COS Naming exceptions to the JNDI exceptions.
* @author Raj Krishnamurthy
*/
public final class ExceptionMapper {
private static final boolean debug = false;
if (e instanceof NamingException) {
return (NamingException)e;
}
if (e instanceof RuntimeException) {
throw (RuntimeException)e;
}
if (e instanceof NotFound) {
if (ctx.federation) {
} else {
ne = new NameNotFoundException();
}
} else if (e instanceof CannotProceed) {
ne = new CannotProceedException();
// %%% We assume that rest returns *all* unprocessed components.
// Don't' know if that is a good assumption, given
// NotFound doesn't set rest as expected. -RL
// Wrap resolved NamingContext inside a CNCtx
// Guess that its name (which is relative to ctx)
// is the part of inputName minus rest_of_name
} else {
}
} 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.setRootCause(e);
return ne;
}
if (debug) {
}
// %%% Using 1.2 & 1.3 Sun's tnameserv, 'rest' contains only the first
// component that failed, not *rest* as advertized. This is useless
// If one of those is not found, you get "aa" as 'rest'.
// Check that we're not talking to 1.2/1.3 Sun tnameserv
// Might be legit
;
} else {
// Due to 1.2/1.3 bug that always returns single-item 'rest'
ne.setRootCause(e);
throw ne;
}
}
// Fixed in 1.4; perform calculations based on correct (1.4) behavior
// Calculate the components of the name that has been resolved
int len = 0;
// First component of rest is found but not a context; keep it
// as part of resolved name
// Remove resolved component from rest
// No more remaining
} else {
}
} else {
}
if (len > 0) {
}
}
// Create CPE and set common fields
cpe.setRootCause(e);
}
if (debug) {
}
// Lookup resolved name to get resolved object
// obj is a context and child is not found
// try getting its nns dynamically by constructing
// a Reference containing obj.
return resolvedObj;
}
private static final long serialVersionUID =
669984699392133792L;
};
// Resolved name has trailing slash to indicate nns
return cpe;
} else {
// Not a context, use object factory to transform object.
try {
} catch (NamingException ge) {
throw ge;
"problem generating object using object factory");
throw ne;
}
// If a context, continue operation with context
} else {
// Add trailing slash
// Create nns reference
return rf2;
}
private static final long serialVersionUID =
-785132553978269772L;
};
}
return cpe;
}
}
}