Example usage for javax.naming NamingException printStackTrace

List of usage examples for javax.naming NamingException printStackTrace

Introduction

In this page you can find the example usage for javax.naming NamingException printStackTrace.

Prototype

public void printStackTrace(PrintStream s) 

Source Link

Document

Prints this throwable and its backtrace to the specified print stream.

Usage

From source file:de.micromata.genome.util.runtime.jndi.JndiDumper.java

public static void dumpJndi() {
    StringBuilder sb = new StringBuilder();
    try {//from   w  ww  . j  a v a2  s .  c o  m
        dumpJndi(sb, "");
    } catch (NamingException ex) {
        ex.printStackTrace(System.out);
    }
    System.out.println(sb.toString());
    ;
}

From source file:de.zib.gndms.GORFX.ORQ.service.globus.resource.ExtORQResourceHome.java

@SuppressWarnings({ "UseOfSystemOutOrSystemErr" })
@Override//  www  .  ja  va  2  s.  c  om
public synchronized void initialize() throws Exception {
    if (!initialized) {
        logger.info("Extended ORQ home initializing");
        try {
            try {
                final GridConfig gridConfig = ExtGORFXResourceHome.getGridConfig();
                logger.debug("Config: " + gridConfig.asString());
                system = gridConfig.retrieveSystemReference();
                serviceAddress = GNDMSTools.getServiceAddressFromContext();

                initialized = true;

                super.initialize(); // Overridden method
            } catch (NamingException e) {
                throw new RuntimeException(e);
            }
        } catch (RuntimeException e) {
            initialized = false;
            logger.error("Initialization failed", e);
            e.printStackTrace(System.err);
            throw e;
        }
    }
}

From source file:de.zib.gndms.dspace.slice.service.globus.resource.ExtSliceResourceHome.java

@Override
public synchronized void initialize() throws Exception {
    if (!initialized) {
        logger.info("Extended Slice home initializing");
        try {/*from w  w  w  .  j  a  v  a2  s .c o  m*/
            try {
                final GridConfig gridConfig = ExtDSpaceResourceHome.getGridConfig();
                logger.debug("Config: " + gridConfig.asString());
                system = gridConfig.retrieveSystemReference();
                serviceAddress = GNDMSTools.getServiceAddressFromContext();

                initialized = true;

                super.initialize(); // Overridden method
            } catch (NamingException e) {
                throw new RuntimeException(e);
            }
        } catch (RuntimeException e) {
            initialized = false;
            logger.error("Initialization failed", e);
            e.printStackTrace(System.err);
            throw e;
        }
    }
}

From source file:de.zib.gndms.GORFX.service.globus.resource.ExtGORFXResourceHome.java

@SuppressWarnings({ "UseOfSystemOutOrSystemErr" })
@Override/*from  w w w  . ja va  2  s.  co m*/
public synchronized void initialize() throws Exception {
    if (!initialized) {
        logger.info("Extended GORFX home initializing");
        try {
            try {
                final GridConfig gridConfig = getGridConfig();
                logger.debug("Config: " + gridConfig.asString());
                system = gridConfig.retrieveSystemReference();
                serviceAddress = GNDMSTools.getServiceAddressFromContext();

                // todo add ProviderStageInXSD to system
                // no nice place here but i currently don't know another
                system.getInstanceDir().addInstance(ProviderStageInXML.class.getName(),
                        new ProviderStageInXMLImpl());
                ParmFormatAux.setXmlWriter(new ProviderStageInXMLImpl());

                initialized = true;

                super.initialize(); // Overridden method
            } catch (NamingException e) {
                throw new RuntimeException(e);
            }
        } catch (RuntimeException e) {
            initialized = false;
            logger.error("Initialization failed", e);
            e.printStackTrace(System.err);
            throw e;
        }
    }
}

From source file:de.zib.gndms.GORFX.context.service.globus.resource.ExtTaskResourceHome.java

@Override
public synchronized void initialize() throws Exception {
    if (!initialized) {
        logger.info("Extended Task home initializing");
        try {/*from   w  w  w. j a  v a 2 s.  c o  m*/
            try {
                final GridConfig gridConfig = ExtGORFXResourceHome.getGridConfig();
                logger.debug("Config: " + gridConfig.asString());
                system = gridConfig.retrieveSystemReference();
                serviceAddress = GNDMSTools.getServiceAddressFromContext();

                initialized = true;
                super.initialize(); // Overridden method
                resumeTasks();
            } catch (NamingException e) {
                throw new RuntimeException(e);
            }
        } catch (RuntimeException e) {
            initialized = false;
            logger.error("Initialization failed", e);
            e.printStackTrace(System.err);
            throw e;
        }
    }
}

From source file:de.zib.gndms.dspace.subspace.service.globus.resource.ExtSubspaceResourceHome.java

@Override
public synchronized void initialize() throws Exception {
    if (!initialized) {
        logger.info("Extended Subspace home initializing");
        try {//from www  .java  2  s . co  m
            try {
                final GridConfig gridConfig = ExtDSpaceResourceHome.getGridConfig();
                logger.debug("Config: " + gridConfig.asString());
                system = gridConfig.retrieveSystemReference();
                serviceAddress = GNDMSTools.getServiceAddressFromContext();

                initialized = true;

                super.initialize(); // Overridden method
            } catch (NamingException e) {
                throw new RuntimeException(e);
            }
        } catch (RuntimeException e) {
            initialized = false;
            logger.error("Initialization failed", e);
            e.printStackTrace(System.err);
            throw e;
        }
    }
}

From source file:de.zib.gndms.dspace.service.globus.resource.ExtDSpaceResourceHome.java

@Override
public synchronized void initialize() throws Exception {
    if (!initialized) {
        logger.info("Extended DSpace home initializing");
        try {//w  ww .j a va  2s  . co  m
            try {
                final GridConfig gridConfig = ExtDSpaceResourceHome.getGridConfig();
                logger.debug("Config: " + gridConfig.asString());
                system = gridConfig.retrieveSystemReference();
                serviceAddress = GNDMSTools.getServiceAddressFromContext();

                initialized = true;

                super.initialize(); // Overridden method
            } catch (NamingException e) {
                throw new RuntimeException(e);
            }
        } catch (RuntimeException e) {
            initialized = false;
            logger.error("Initialization failed", e);
            e.printStackTrace(System.err);
            throw e;
        }
    }
}

From source file:com.zeroio.webdav.WebdavServlet.java

/**
 * Description of the Method//from w  w  w.j  a  va2 s  .com
 *
 * @param thisSystem Description of the Parameter
 * @param db         Description of the Parameter
 * @param resources  Description of the Parameter
 * @param errorList  Description of the Parameter
 * @param source     Description of the Parameter
 * @param dest       Description of the Parameter
 * @return Description of the Return Value
 * @throws SQLException          Description of the Exception
 * @throws FileNotFoundException Description of the Exception
 */
private boolean moveResource(SystemStatus thisSystem, Connection db, ModuleContext resources,
        Hashtable errorList, String source, String dest) throws SQLException, FileNotFoundException {

    if (debug > 1) {
        System.out.println("Move: " + source + " To: " + dest);
    }

    Object object = null;
    try {
        object = resources.lookup(thisSystem, db, source);
        boolean complete = resources.move(thisSystem, db, dest, object);
        if (!complete) {
            errorList.put(dest, new Integer(WebdavStatus.SC_FORBIDDEN));
            return false;
        }
        //resources.unbind(db, path);
    } catch (NamingException e) {
        e.printStackTrace(System.out);
        errorList.put(dest, new Integer(WebdavStatus.SC_CONFLICT));
        return false;
    }

    return true;
}

From source file:com.zeroio.webdav.WebdavServlet.java

/**
 * Deletes a collection./*from ww w.ja  v a 2 s . co  m*/
 *
 * @param resources Resources implementation associated with the
 *                  context
 * @param path      Path to the collection to be deleted
 * @param errorList Contains the list of the errors which occurred
 * @param req       Description of the Parameter
 * @param db        Description of the Parameter
 * @throws SQLException Description of the Exception
 */
private void deleteCollection(SystemStatus thisSystem, Connection db, HttpServletRequest req,
        ModuleContext resources, String path, Hashtable errorList) throws SQLException {

    if (debug > 1) {
        System.out.println("Delete:" + path);
    }

    if ((path.toUpperCase().startsWith("/WEB-INF")) || (path.toUpperCase().startsWith("/META-INF"))) {
        errorList.put(path, new Integer(WebdavStatus.SC_FORBIDDEN));
        return;
    }

    String ifHeader = req.getHeader("If");
    if (ifHeader == null) {
        ifHeader = "";
    }

    String lockTokenHeader = req.getHeader("Lock-Token");
    if (lockTokenHeader == null) {
        lockTokenHeader = "";
    }

    Enumeration enum1 = null;
    try {
        enum1 = resources.list(path);
    } catch (NamingException e) {
        e.printStackTrace(System.out);
        errorList.put(path, new Integer(WebdavStatus.SC_INTERNAL_SERVER_ERROR));
        return;
    }

    while (enum1.hasMoreElements()) {
        NameClassPair ncPair = (NameClassPair) enum1.nextElement();
        String childName = path;
        if (!childName.equals("/")) {
            if (!childName.endsWith("/")) {
                childName += "/";
            }
        }
        childName += ncPair.getName();

        if (isLocked(childName, ifHeader + lockTokenHeader)) {
            errorList.put(childName, new Integer(WebdavStatus.SC_LOCKED));
        } else {
            try {
                Object object = resources.lookup(childName);
                if (object instanceof ModuleContext) {
                    deleteCollection(thisSystem, db, req, resources, childName, errorList);
                }
                try {
                    resources.unbind(thisSystem, db, childName);
                } catch (NamingException e) {
                    if (!(object instanceof ModuleContext)) {
                        // If it's not a collection, then it's an unknown
                        // error
                        errorList.put(childName, new Integer(WebdavStatus.SC_INTERNAL_SERVER_ERROR));
                    }
                }
            } catch (NamingException e) {
                errorList.put(childName, new Integer(WebdavStatus.SC_INTERNAL_SERVER_ERROR));
            }
        }
    }
}

From source file:com.zeroio.webdav.WebdavServlet.java

/**
 * Copy a collection./*  w  ww . j a  va2  s . com*/
 *
 * @param resources  Resources implementation to be used
 * @param errorList  Hashtable containing the list of errors
 *                   which occurred during the copy operation
 * @param source     Path of the resource to be copied
 * @param dest       Destination path
 * @param thisSystem Description of the Parameter
 * @param db         Description of the Parameter
 * @return Description of the Return Value
 * @throws SQLException          Description of the Exception
 * @throws FileNotFoundException Description of the Exception
 */
private boolean copyResource(ActionContext context, SystemStatus thisSystem, Connection db,
        ModuleContext resources, Hashtable errorList, String source, String dest)
        throws SQLException, FileNotFoundException {

    if (debug > 1) {
        System.out.println("Copy: " + source + " To: " + dest);
    }

    Object object = null;
    try {
        object = resources.lookup(thisSystem, db, source);
    } catch (NamingException e) {
        e.printStackTrace(System.out);
    }

    if (object instanceof ModuleContext) {
        try {
            resources.createSubcontext(thisSystem, db, dest);
        } catch (NamingException e) {
            e.printStackTrace(System.out);
            errorList.put(dest, new Integer(WebdavStatus.SC_CONFLICT));
            return false;
        }

        try {
            //System.out.println("Listing resources at path: " + source);
            //System.out.println("OBJECT: " + object);
            object = resources.lookup(thisSystem, db, source);
            NamingEnumeration enum1 = resources.list(source);
            while (enum1.hasMoreElements()) {
                //System.out.println("COPYING CHILD CONTEXT.........................");
                NameClassPair ncPair = (NameClassPair) enum1.nextElement();
                String childDest = dest;
                if (!childDest.equals("/")) {
                    childDest += "/";
                }
                childDest += ncPair.getName();
                String childSrc = source;
                if (!childSrc.equals("/")) {
                    childSrc += "/";
                }
                childSrc += ncPair.getName();
                copyResource(context, thisSystem, db, resources, errorList, childSrc, childDest);
            }
        } catch (NamingException e) {
            e.printStackTrace(System.out);
            errorList.put(dest, new Integer(WebdavStatus.SC_INTERNAL_SERVER_ERROR));
            return false;
        }

    } else {

        if (object instanceof Resource) {
            try {
                Object resource = resources.copyResource(thisSystem, db, dest, object);
                if (resource != null) {
                    processInsertHook(context, resource);
                }
            } catch (NamingException e) {
                errorList.put(source, new Integer(WebdavStatus.SC_INTERNAL_SERVER_ERROR));
                return false;
            } catch (IOException io) {
                errorList.put(source, new Integer(WebdavStatus.SC_INTERNAL_SERVER_ERROR));
                return false;
            }
        } else {
            errorList.put(source, new Integer(WebdavStatus.SC_INTERNAL_SERVER_ERROR));
            return false;
        }
    }
    return true;
}