Example usage for java.lang.reflect UndeclaredThrowableException UndeclaredThrowableException

List of usage examples for java.lang.reflect UndeclaredThrowableException UndeclaredThrowableException

Introduction

In this page you can find the example usage for java.lang.reflect UndeclaredThrowableException UndeclaredThrowableException.

Prototype

public UndeclaredThrowableException(Throwable undeclaredThrowable) 

Source Link

Document

Constructs an UndeclaredThrowableException with the specified Throwable .

Usage

From source file:it.cnr.icar.eric.client.ui.common.UIUtility.java

/**
 * Class Constructor.//  w ww  .j  ava2 s. c om
 *
 *
 * @see
 */
protected UIUtility() {
    try {
        getUIJAXBContext();
        fac = new it.cnr.icar.eric.client.ui.common.conf.bindings.ObjectFactory();
    } catch (JAXBException e) {
        throw new UndeclaredThrowableException(e);
    }

    ConfigurationType uiConfigurationType = getConfigurationType();
    if (uiConfigurationType == null) {
        log.error(UICommonResourceBundle.getInstance().getString("message.nullConfig"));
    }
    List<?> otCfgs = uiConfigurationType.getObjectTypeConfig();
    Iterator<?> iter = otCfgs.iterator();

    while (iter.hasNext()) {
        ObjectTypeConfigType otCfg = (ObjectTypeConfigType) iter.next();
        String id = otCfg.getId();
        objectTypeToConfigMap.put(id, otCfg);
    }
}

From source file:com.ibm.jaql.lang.expr.xml.XmlToJsonFn.java

@Override
public void endElement(String uri, String localName, String name) throws SAXException {
    try {/*  w ww .  j  a v  a 2 s .  com*/
        endText();
        SpilledJsonArray ca = (SpilledJsonArray) stack.pop();
        BufferedJsonRecord r = new BufferedJsonRecord();
        if (uri != null && uri.length() > 0) {
            r.add(new JsonString("xmlns"), new JsonString(uri));
        }
        r.add(new JsonString(localName), ca);
        SpilledJsonArray pa = (SpilledJsonArray) stack.peek();
        pa.addCopy(r);
    } catch (IOException e) {
        throw new UndeclaredThrowableException(e);
    }
}

From source file:juzu.plugin.upload.impl.UploadPlugin.java

public void invoke(Request request) {

    ///*w  w  w . j  a  v a  2  s .  c o  m*/
    final ClientContext clientContext = request.getClientContext();

    //
    if (clientContext != null) {
        String contentType = clientContext.getContentType();
        if (contentType != null) {
            if (contentType.startsWith("multipart/")) {

                //
                org.apache.commons.fileupload.RequestContext ctx = new org.apache.commons.fileupload.RequestContext() {
                    public String getCharacterEncoding() {
                        return clientContext.getCharacterEncoding();
                    }

                    public String getContentType() {
                        return clientContext.getContentType();
                    }

                    public int getContentLength() {
                        return clientContext.getContentLenth();
                    }

                    public InputStream getInputStream() throws IOException {
                        return clientContext.getInputStream();
                    }
                };

                //
                FileUpload upload = new FileUpload(new DiskFileItemFactory());

                //
                try {
                    List<FileItem> list = (List<FileItem>) upload.parseRequest(ctx);
                    HashMap<String, RequestParameter> parameters = new HashMap<String, RequestParameter>();
                    for (FileItem file : list) {
                        String name = file.getFieldName();
                        if (file.isFormField()) {
                            RequestParameter parameter = parameters.get(name);
                            if (parameter != null) {
                                parameter = parameter.append(new String[] { file.getString() });
                            } else {
                                parameter = RequestParameter.create(name, file.getString());
                            }
                            parameter.appendTo(parameters);
                        } else {
                            ControlParameter parameter = request.getMethod().getParameter(name);
                            if (parameter instanceof ContextualParameter
                                    && FileItem.class.isAssignableFrom(parameter.getType())) {
                                request.setArgument(parameter, file);
                            }
                        }
                    }

                    // Keep original parameters that may come from the request path
                    for (RequestParameter parameter : request.getParameters().values()) {
                        if (!parameters.containsKey(parameter.getName())) {
                            parameter.appendTo(parameters);
                        }
                    }

                    // Redecode phase arguments from updated request
                    Method<?> method = request.getMethod();
                    Map<ControlParameter, Object> arguments = method.getArguments(parameters);

                    // Update with existing contextual arguments
                    for (Map.Entry<ControlParameter, Object> argument : request.getArguments().entrySet()) {
                        if (argument.getKey() instanceof ContextualParameter) {
                            arguments.put(argument.getKey(), argument.getValue());
                        }
                    }

                    // Replace all arguments
                    request.setArguments(arguments);
                } catch (FileUploadException e) {
                    throw new UndeclaredThrowableException(e);
                }
            }
        }
    }

    //
    request.invoke();
}

From source file:org.opennms.ng.services.trapd.Trapd.java

/**
 * <p>onInit</p>/*from   ww w .jav a2 s  .  com*/
 */
public synchronized void onInit() {
    BeanUtils.assertAutowiring(this);

    Assert.state(m_backlogQ != null, "backlogQ must be set");

    try {
        m_trapdIpMgr.dataSourceSync();
    } catch (final SQLException e) {
        LOG.error("init: Failed to load known IP address list", e);
        throw new UndeclaredThrowableException(e);
    }

    try {
        InetAddress address = getInetAddress();
        LOG.info("Listening on {}:{}", address == null ? "[all interfaces]" : InetAddressUtils.str(address),
                m_snmpTrapPort);
        SnmpUtils.registerForTraps(this, this, address, m_snmpTrapPort, m_snmpV3Users);
        m_registeredForTraps = true;

        LOG.debug("init: Creating the trap session");
    } catch (final IOException e) {
        if (e instanceof java.net.BindException) {
            Logging.withPrefix("OpenNMS.Manager", new Runnable() {
                @Override
                public void run() {
                    LOG.error(
                            "init: Failed to listen on SNMP trap port, perhaps something else is already listening?",
                            e);
                }
            });
            LOG.error("init: Failed to listen on SNMP trap port, perhaps something else is already listening?",
                    e);
        } else {
            LOG.error("init: Failed to initialize SNMP trap socket", e);
        }
        throw new UndeclaredThrowableException(e);
    }

    try {
        m_eventReader.open();
    } catch (final Throwable e) {
        LOG.error("init: Failed to open event reader", e);
        throw new UndeclaredThrowableException(e);
    }
}

From source file:org.opennms.netmgt.provision.server.SSLServer.java

/**
 * <p>getRunnable</p>/*  w w  w  .  j ava 2 s .c o  m*/
 *
 * @return a {@link java.lang.Runnable} object.
 * @throws java.lang.Exception if any.
 */
@Override
protected SimpleServerRunnable getRunnable() throws IOException {
    return new SimpleServerRunnable() {

        @Override
        public void run() {
            try {
                OutputStream out = null;
                BufferedReader in = null;
                ready();
                try {
                    getServerSocket().setSoTimeout(getTimeout());
                    setSocket(getServerSocket().accept());

                    if (getThreadSleepLength() > 0) {
                        Thread.sleep(getThreadSleepLength());
                    }
                    getSocket().setSoTimeout(getTimeout());

                    out = getSocket().getOutputStream();
                    if (getBanner() != null) {
                        sendBanner(out);
                    }
                    ;

                    in = new BufferedReader(new InputStreamReader(getSocket().getInputStream()));
                    attemptConversation(in, out);
                } finally {
                    IOUtils.closeQuietly(in);
                    IOUtils.closeQuietly(out);
                    getSocket().close();
                }
            } catch (Throwable e) {
                throw new UndeclaredThrowableException(e);
            } finally {
                finished();
                try {
                    stopServer();
                } catch (final IOException e) {
                    LOG.debug("unable to stop server", e);
                }
            }
        }

    };
}

From source file:org.forgerock.openidm.provisioner.Id.java

@SuppressWarnings("fallthrough")
public Id(String id) throws JsonResourceException {
    if (StringUtils.isBlank(id)) {
        throw new JsonResourceException(400, "Id can not be blank");
    }/* w  ww .  j av a  2  s  .  c  o  m*/
    int index = id.indexOf(SYSTEM_BASE);
    String relativeId = id;
    if (index > -1) {
        relativeId = id.substring(index + 7);
    }
    try {
        String[] segments = relativeId.split("\\/");
        if (2 <= segments.length && segments.length <= 3) {
            switch (segments.length > 2 ? 3 : segments.length) {
            case 3:
                localId = URLDecoder.decode(segments[2], CHARACTER_ENCODING_UTF_8);
            case 2:
                objectType = URLDecoder.decode(segments[1], CHARACTER_ENCODING_UTF_8);
            case 1:
                systemName = URLDecoder.decode(segments[0], CHARACTER_ENCODING_UTF_8);
            }
        } else {
            throw new JsonResourceException(400, "Invalid number of tokens in ID " + id);
        }
        this.baseURI = new URI("");
    } catch (UnsupportedEncodingException e) {
        // Should never happen.
        throw new UndeclaredThrowableException(e);
    } catch (URISyntaxException e) {
        // Should never happen.
        throw new UndeclaredThrowableException(e);
    }
}

From source file:org.opennms.netmgt.provision.server.SimpleUDPServer.java

/**
 * <p>getRunnable</p>/*from   w w w .  j  a v a 2 s .  c o  m*/
 *
 * @return a {@link java.lang.Runnable} object.
 * @throws java.lang.Exception if any.
 */
public SimpleServerRunnable getRunnable() throws IOException {
    return new SimpleServerRunnable() {

        @Override
        public void run() {
            try {
                m_socket = new DatagramSocket(getPort(), getInetAddress());
                m_socket.setSoTimeout(getTimeout());
                ready();

                attemptConversation(m_socket);
            } catch (Throwable e) {
                throw new UndeclaredThrowableException(e);
            } finally {
                IOUtils.closeQuietly(m_socket);
                finished();
                try {
                    // just in case we're stopping because of an exception
                    stopServer();
                } catch (final Exception e) {
                    LOG.info("error while stopping server", e);
                }
            }
        }

    };
}

From source file:it.cnr.icar.eric.client.xml.registry.infomodel.IdentifiableImpl.java

public int hashCode() {
    int result = HashCodeUtil.SEED;
    try {/*from  www . java  2  s .c o m*/
        if (key != null) {
            result = HashCodeUtil.hash(result, key.getId());
        }
        result = HashCodeUtil.hash(result, this.getClass());
    } catch (JAXRException e) {
        throw new UndeclaredThrowableException(e);
    }
    return result;
}

From source file:org.kitodo.production.services.image.ImageGenerator.java

/**
 * Generates a set of derivatives./*from w ww  .ja v  a  2s  . c  o  m*/
 *
 * @param instruction
 *            Instruction, which pictures are to be generated. Left: image
 *            source, right: destination folder. The image source consists
 *            of the canonical part of the file name and the resolved file
 *            name for the source image. The canonical part of the file name
 *            is needed to calculate the corresponding file name in the
 *            destination folder. The type of derivative to be generated is
 *            defined in the properties of the destination folder.
 */
public void createDerivatives(ContentToBeGenerated instruction) {
    try {
        for (Subfolder destinationFolder : instruction.getSubfoldersWhoseContentsAreToBeGenerated()) {
            generateDerivative(instruction.getSourceURI(), destinationFolder, instruction.getCanonical());
        }
    } catch (IOException e) {
        throw new UndeclaredThrowableException(e);
    }
}

From source file:org.opennms.ng.services.databaseschemaconfig.JdbcFilterDao.java

/**
 * {@inheritDoc}//www. j av a2  s .  com
 *
 * This method returns a map of all nodeids and nodelabels that match
 * the rule that is passed in, sorted by nodeid.
 * @exception org.opennms.ng.services.databaseschemaconfig.FilterParseException
 *                if a rule is syntactically incorrect or failed in
 *                executing the SQL statement
 */
@Override
public SortedMap<Integer, String> getNodeMap(final String rule) throws FilterParseException {
    final SortedMap<Integer, String> resultMap = new TreeMap<Integer, String>();
    String sqlString;

    LOG.debug("Filter.getNodeMap({})", rule);

    // get the database connection
    Connection conn = null;
    final DBUtils d = new DBUtils(getClass());
    try {
        conn = getDataSource().getConnection();
        d.watch(conn);

        // parse the rule and get the sql select statement
        sqlString = getNodeMappingStatement(rule);
        LOG.debug("Filter.getNodeMap({}): SQL statement: {}", rule, sqlString);

        // execute query
        final Statement stmt = conn.createStatement();
        d.watch(stmt);
        final ResultSet rset = stmt.executeQuery(sqlString);
        d.watch(rset);

        if (rset != null) {
            // Iterate through the result and build the map
            while (rset.next()) {
                resultMap.put(Integer.valueOf(rset.getInt(1)), rset.getString(2));
            }
        }
    } catch (final FilterParseException e) {
        LOG.warn("Filter Parse Exception occurred getting node map.", e);
        throw new FilterParseException(
                "Filter Parse Exception occurred getting node map: " + e.getLocalizedMessage(), e);
    } catch (final SQLException e) {
        LOG.warn("SQL Exception occurred getting node map.", e);
        throw new FilterParseException("SQL Exception occurred getting node map: " + e.getLocalizedMessage(),
                e);
    } catch (final Throwable e) {
        LOG.error("Exception getting database connection.", e);
        throw new UndeclaredThrowableException(e);
    } finally {
        d.cleanUp();
    }

    return Collections.unmodifiableSortedMap(resultMap);
}