当前位置: 首页>>代码示例>>Java>>正文


Java IOExceptionWithCause类代码示例

本文整理汇总了Java中org.apache.commons.io.IOExceptionWithCause的典型用法代码示例。如果您正苦于以下问题:Java IOExceptionWithCause类的具体用法?Java IOExceptionWithCause怎么用?Java IOExceptionWithCause使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IOExceptionWithCause类属于org.apache.commons.io包,在下文中一共展示了IOExceptionWithCause类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseAnArrayOfColumnMetadata

import org.apache.commons.io.IOExceptionWithCause; //导入依赖的package包/类
/**
 * Reads token of the specified JsonParser and returns a list of column metadata.
 *
 * @param jsonParser the jsonParser whose next tokens are supposed to represent a list of column metadata
 * @return The column metadata parsed from JSON parser.
 * @throws IOException In case of JSON exception related error.
 */
private static List<ColumnMetadata> parseAnArrayOfColumnMetadata(JsonParser jsonParser) throws IOException {
    try {
        List<ColumnMetadata> columns = new ArrayList<>();
        // skip the array beginning [
        jsonParser.nextToken();
        while (jsonParser.nextToken() != JsonToken.END_ARRAY && !jsonParser.isClosed()) {
            ColumnMetadata columnMetadata = jsonParser.readValueAs(ColumnMetadata.class);
            columns.add(columnMetadata);
        }
        if (columns.isEmpty()) {
            throw new IllegalArgumentException(
                    "No column metadata has been retrieved when trying to parse the retrieved data set.");
        }
        return columns;
    } catch (IOException e) {
        throw new IOExceptionWithCause("Unable to parse and retrieve the list of column metadata", e);
    }
}
 
开发者ID:Talend,项目名称:data-prep,代码行数:26,代码来源:LightweightExportableDataSetUtils.java

示例2: parseDataSetMetadataAndReturnRowMetadata

import org.apache.commons.io.IOExceptionWithCause; //导入依赖的package包/类
private static RowMetadata parseDataSetMetadataAndReturnRowMetadata(JsonParser jsonParser) throws IOException {
    try {
        RowMetadata rowMetadata = null;
        while (jsonParser.nextToken() != JsonToken.END_OBJECT && !jsonParser.isClosed()) {
            String currentField = jsonParser.getCurrentName();
            if (StringUtils.equalsIgnoreCase("columns", currentField)) {
                rowMetadata = new RowMetadata(parseAnArrayOfColumnMetadata(jsonParser));
            }
        }
        LOGGER.debug("Skipping data to go back to the outer json object");
        while (jsonParser.getParsingContext().getParent().getCurrentName() != null && !jsonParser.isClosed()) {
            jsonParser.nextToken();
        }
        return rowMetadata;
    } catch (IOException e) {
        throw new IOExceptionWithCause("Unable to parse and retrieve the row metadata", e);
    }
}
 
开发者ID:Talend,项目名称:data-prep,代码行数:19,代码来源:LightweightExportableDataSetUtils.java

示例3: parseRecords

import org.apache.commons.io.IOExceptionWithCause; //导入依赖的package包/类
private static LightweightExportableDataSet parseRecords(JsonParser jsonParser, RowMetadata rowMetadata, String joinOnColumn)
        throws IOException {
    try {
        LightweightExportableDataSet lookupDataset = new LightweightExportableDataSet();
        lookupDataset.setMetadata(rowMetadata);
        jsonParser.nextToken();
        while (jsonParser.nextToken() != JsonToken.END_ARRAY && !jsonParser.isClosed()) {
            Map<String, String> values = jsonParser.readValueAs(Map.class);
            lookupDataset.addRecord(values.get(joinOnColumn), values);
        }
        if (lookupDataset.isEmpty()) {
            throw new IllegalArgumentException(
                    "No lookup record has been retrieved when trying to parse the retrieved data set.");
        }
        return lookupDataset;
    } catch (IOException e) {
        throw new IOExceptionWithCause("Unable to parse and retrieve the records of the data set", e);
    }
}
 
开发者ID:Talend,项目名称:data-prep,代码行数:20,代码来源:LightweightExportableDataSetUtils.java

示例4: doRequest

import org.apache.commons.io.IOExceptionWithCause; //导入依赖的package包/类
@Override
protected void doRequest(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	Map<String, String> params = new HashMap<String, String>();
	Enumeration<?> paramNames = req.getParameterNames();
	while (paramNames.hasMoreElements()) {
		Object paramName = paramNames.nextElement();
		String name = Utils.stripNonValidXMLCharacters(paramName.toString());
		String value = Utils.stripNonValidXMLCharacters(req.getParameter(name));
		params.put(name, value);
	}
	APoormansObject<?> po = ContextUtil.updatepo(params);
	logger.info("Saved pojo: " + po.toString());

	try {
		if (InstanceUtil.isSiteResource(po))
			velocityRenderer.render(resp.getWriter(), (ASiteResource) po);
		else
			velocityRenderer.render(resp.getWriter(), (IRenderable) po, ViewMode.PREVIEW);
	} catch (RenderingException e) {
		throw new IOExceptionWithCause(e);
	}
	
	resp.setHeader("Cache-Control", "no-cache");
}
 
开发者ID:th-schwarz,项目名称:pmcms,代码行数:25,代码来源:ContentSaverServlet.java

示例5: getInputStream

import org.apache.commons.io.IOExceptionWithCause; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * <p/>
 * Creates a ByteArrayInputStream implementation of InputStream of the XML
 * marshaled version of the Requisition class. Calling close on this stream
 * is safe.
 */
@Override
public InputStream getInputStream() throws IOException {

    InputStream stream = null;

    try {
        logger.debug("Getting existing requisition (if any) for VMware management server {}", m_hostname);
        Requisition curReq = getExistingRequisition();
        logger.debug("Building new requisition for VMware management server {}", m_hostname);
        Requisition newReq = buildVMwareRequisition();
        logger.debug("Finished building new requisition for VMware management server {}", m_hostname);
        if (curReq == null) {
            if (newReq == null) {
                // FIXME Is this correct ? This is the old behavior
                newReq = new Requisition(m_foreignSource);
            }
        } else {
            if (newReq == null) {
                // If there is a requisition and the vCenter is not responding for some reason, it is better to use the old requisition,
                // instead of returning an empty one, which can cause the lost of all the nodes from the DB.
                newReq = curReq;
            } else {
                // If there is already a requisition, retrieve the custom assets and categories from the old one, and put them on the new one.
                // The VMWare related assets and categories will be preserved.
                for (RequisitionNode newNode : newReq.getNodes()) {
                    for (RequisitionNode curNode : curReq.getNodes()) {
                        if (newNode.getForeignId().equals(curNode.getForeignId())) {
                            // Add existing custom assets
                            for (RequisitionAsset asset : curNode.getAssets()) {
                                if (!asset.getName().startsWith("vmware")) {
                                    newNode.putAsset(asset);
                                }
                            }
                            // Add existing custom categories
                            for (RequisitionCategory cat : curNode.getCategories()) {
                                if (!cat.getName().startsWith("VMWare")) {
                                    newNode.putCategory(cat);
                                }
                            }
                            // Add existing custom services
                            /*
                             * For each interface on the new requisition,
                             * - Retrieve the list of custom services from the corresponding interface on the existing requisition,
                             *   matching the interface by the IP address
                             * - If the list of services is not empty, add them to the new interface
                             */
                            for (RequisitionInterface intf : curNode.getInterfaces()) {
                                List<RequisitionMonitoredService> services = getManualyConfiguredServices(intf);
                                if (!services.isEmpty()) {
                                    RequisitionInterface newIntf = getRequisitionInterface(newNode, intf.getIpAddr());
                                    if (newIntf != null) {
                                        newIntf.getMonitoredServices().addAll(services);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        stream = new ByteArrayInputStream(jaxBMarshal(newReq).getBytes());
    } catch (Throwable e) {
        logger.warn("Problem getting input stream: '{}'", e);
        throw new IOExceptionWithCause("Problem getting input stream: " + e, e);
    }

    return stream;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:76,代码来源:VmwareRequisitionUrlConnection.java


注:本文中的org.apache.commons.io.IOExceptionWithCause类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。