本文整理匯總了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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}