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


Java IOUtils类代码示例

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


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

示例1: writeContent

import org.apache.chemistry.opencmis.commons.impl.IOUtils; //导入依赖的package包/类
/**
 * Writes the content to disc.
 */
private void writeContent(File newFile, InputStream stream) {
    OutputStream out = null;
    InputStream in = null;
    try {
        out = new BufferedOutputStream(new FileOutputStream(newFile), BUFFER_SIZE);
        in = new BufferedInputStream(stream, BUFFER_SIZE);

        byte[] buffer = new byte[BUFFER_SIZE];
        int b;
        while ((b = in.read(buffer)) > -1) {
            out.write(buffer, 0, b);
        }

        out.flush();
    } catch (IOException e) {
        throw new CmisStorageException("Could not write content: " + e.getMessage(), e);
    } finally {
        IOUtils.closeQuietly(out);
        IOUtils.closeQuietly(in);
    }
}
 
开发者ID:cmisdocs,项目名称:ServerDevelopmentGuideV2,代码行数:25,代码来源:FileBridgeRepository.java

示例2: writeContent

import org.apache.chemistry.opencmis.commons.impl.IOUtils; //导入依赖的package包/类
/**
 * Writes the content to disc.
 */
private void writeContent(File newFile, InputStream stream) {
	OutputStream out = null;
	InputStream in = null;
	try {
		out = new BufferedOutputStream(new FileOutputStream(newFile),
				BUFFER_SIZE);
		in = new BufferedInputStream(stream, BUFFER_SIZE);

		byte[] buffer = new byte[BUFFER_SIZE];
		int b;
		while ((b = in.read(buffer)) > -1) {
			out.write(buffer, 0, b);
		}

		out.flush();
	} catch (IOException e) {
		throw new CmisStorageException("Could not write content: "
				+ e.getMessage(), e);
	} finally {
		IOUtils.closeQuietly(out);
		IOUtils.closeQuietly(in);
	}
}
 
开发者ID:cmisdocs,项目名称:ServerDevelopmentGuide,代码行数:27,代码来源:FileBridgeRepository.java

示例3: buildAuthorizationUrl

import org.apache.chemistry.opencmis.commons.impl.IOUtils; //导入依赖的package包/类
private URL buildAuthorizationUrl(JSONObject oauthConfig) {
	try {
		String authUrl = getStringFromJSON(oauthConfig, "authURL");
		String clientId = getStringFromJSON(oauthConfig, "clientId");
		String redirectUrl = getStringFromJSON(oauthConfig, "redirectURL");

		if (authUrl == null || clientId == null || redirectUrl == null) {
			return null;
		}

		URL url = new URL(authUrl + "?client_id=" + IOUtils.encodeURL(clientId)
				+ "&response_type=code&scope=cmis_all&redirect_uri=" + IOUtils.encodeURL(redirectUrl));

		return url;
	} catch (Exception e) {
		throw new CmisConnectionException("Could not build authorization URL: " + e.toString(), e);
	}
}
 
开发者ID:SAP,项目名称:cloud-cmis-workbench,代码行数:19,代码来源:DocumentCenterLoginTab.java

示例4: setSession

import org.apache.chemistry.opencmis.commons.impl.IOUtils; //导入依赖的package包/类
@Override
public void setSession(BindingSession session) {
	super.setSession(session);

	shareId = IOUtils.encodeURL((String) session.get(MDOCS_SHARE_ID));
	sharePassword = IOUtils.encodeURL((String) session.get(MDOCS_SHARE_PWD));
}
 
开发者ID:SAP,项目名称:cloud-cmis-workbench,代码行数:8,代码来源:DocumentCenterPublicShareAuthenticationProvider.java

示例5: changeContentStream

import org.apache.chemistry.opencmis.commons.impl.IOUtils; //导入依赖的package包/类
/**
 * CMIS setContentStream, deleteContentStream, and appendContentStream.
 */
public void changeContentStream(CallContext context, Holder<String> objectId, Boolean overwriteFlag,
        ContentStream contentStream, boolean append) {
    checkUser(context, true);

    if (objectId == null) {
        throw new CmisInvalidArgumentException("Id is not valid!");
    }

    // get the file
    File file = getFile(objectId.getValue());
    if (!file.isFile()) {
        throw new CmisStreamNotSupportedException("Not a file!");
    }

    // check overwrite
    boolean owf = FileBridgeUtils.getBooleanParameter(overwriteFlag, true);
    if (!owf && file.length() > 0) {
        throw new CmisContentAlreadyExistsException("Content already exists!");
    }

    OutputStream out = null;
    InputStream in = null;
    try {
        out = new BufferedOutputStream(new FileOutputStream(file, append), BUFFER_SIZE);

        if (contentStream == null || contentStream.getStream() == null) {
            // delete content
            out.write(new byte[0]);
        } else {
            // set content
            in = new BufferedInputStream(contentStream.getStream(), BUFFER_SIZE);

            byte[] buffer = new byte[BUFFER_SIZE];
            int b;
            while ((b = in.read(buffer)) > -1) {
                out.write(buffer, 0, b);
            }
        }
    } catch (Exception e) {
        throw new CmisStorageException("Could not write content: " + e.getMessage(), e);
    } finally {
        IOUtils.closeQuietly(out);
        IOUtils.closeQuietly(in);
    }
}
 
开发者ID:cmisdocs,项目名称:ServerDevelopmentGuideV2,代码行数:49,代码来源:FileBridgeRepository.java

示例6: changeContentStream

import org.apache.chemistry.opencmis.commons.impl.IOUtils; //导入依赖的package包/类
/**
 * CMIS setContentStream, deleteContentStream, and appendContentStream.
 */
public void changeContentStream(CallContext context,
		Holder<String> objectId, Boolean overwriteFlag,
		ContentStream contentStream, boolean append) {
	checkUser(context, true);

	if (objectId == null) {
		throw new CmisInvalidArgumentException("Id is not valid!");
	}

	// get the file
	File file = getFile(objectId.getValue());
	if (!file.isFile()) {
		throw new CmisStreamNotSupportedException("Not a file!");
	}

	// check overwrite
	boolean owf = FileBridgeUtils.getBooleanParameter(overwriteFlag, true);
	if (!owf && file.length() > 0) {
		throw new CmisContentAlreadyExistsException(
				"Content already exists!");
	}

	OutputStream out = null;
	InputStream in = null;
	try {
		out = new BufferedOutputStream(new FileOutputStream(file, append),
				BUFFER_SIZE);

		if (contentStream == null || contentStream.getStream() == null) {
			// delete content
			out.write(new byte[0]);
		} else {
			// set content
			in = new BufferedInputStream(contentStream.getStream(),
					BUFFER_SIZE);

			byte[] buffer = new byte[BUFFER_SIZE];
			int b;
			while ((b = in.read(buffer)) > -1) {
				out.write(buffer, 0, b);
			}
		}
	} catch (Exception e) {
		throw new CmisStorageException("Could not write content: "
				+ e.getMessage(), e);
	} finally {
		IOUtils.closeQuietly(out);
		IOUtils.closeQuietly(in);
	}
}
 
开发者ID:cmisdocs,项目名称:ServerDevelopmentGuide,代码行数:54,代码来源:FileBridgeRepository.java

示例7: getOAuthConfigutation

import org.apache.chemistry.opencmis.commons.impl.IOUtils; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private JSONObject getOAuthConfigutation(URL authInfoUrl) {
	Reader reader = null;

	try {
		// get the OAuth config from server
		HttpURLConnection conn = (HttpURLConnection) authInfoUrl.openConnection();
		conn.setRequestMethod("GET");
		conn.setDoInput(true);
		conn.setDoOutput(false);
		conn.setAllowUserInteraction(false);
		conn.setUseCaches(false);
		conn.setRequestProperty("User-Agent", ClientVersion.OPENCMIS_USER_AGENT);
		conn.setConnectTimeout(60000);
		conn.setReadTimeout(30000);

		// connect
		conn.connect();
		int respCode = conn.getResponseCode();
		if (respCode != 200) {
			throw new CmisConnectionException("Could not load authentication data from " + authInfoUrl.toString()
					+ " . Response code: " + respCode);
		}

		// parse response
		reader = new InputStreamReader(conn.getInputStream(), "UTF-8");
		JSONParser parser = new JSONParser();
		Object obj = parser.parse(reader);

		if (obj instanceof List) {
			for (Object authEntry : (List<Object>) obj) {
				if (!(authEntry instanceof JSONObject)) {
					continue;
				}

				Object authList = ((JSONObject) authEntry).get("authentication");
				if (!(authList instanceof List)) {
					continue;
				}

				for (Object authType : (List<Object>) authList) {
					if (!(authType instanceof JSONObject)) {
						continue;
					}

					Object type = ((JSONObject) authType).get("type");
					if (!(type instanceof String)) {
						continue;
					}
					if (!type.toString().equals("oauth")) {
						continue;
					}

					return (JSONObject) authType;
				}
			}
		}

		return null;
	} catch (Exception e) {
		throw new CmisConnectionException(
				"Authentiction data from " + authInfoUrl.toString() + " is invalid: " + e.toString(), e);
	} finally {
		IOUtils.closeQuietly(reader);
	}
}
 
开发者ID:SAP,项目名称:cloud-cmis-workbench,代码行数:67,代码来源:DocumentCenterLoginTab.java


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