Author: fmui
Date: Fri Sep 19 12:34:20 2014
New Revision: 1626192
URL: http://svn.apache.org/r1626192
Log:
Minor improvements
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/SessionFactoryFinder.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/FormDataWriter.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/http/AbstractApacheClientHttpInvoker.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/DocumentImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/spi/CmisBinding.java
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/WSConverter.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomEntryParser.java
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/SessionFactoryFinder.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/SessionFactoryFinder.java?rev=1626192&r1=1626191&r2=1626192&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/SessionFactoryFinder.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/SessionFactoryFinder.java
Fri Sep 19 12:34:20 2014
@@ -148,9 +148,18 @@ public final class SessionFactoryFinder
try {
reader = new BufferedReader(new
InputStreamReader(stream, "UTF-8"));
factoryClassName = reader.readLine();
- reader.close();
} catch (IOException e) {
factoryClassName = null;
+ } finally {
+ try {
+ if (reader != null) {
+ reader.close();
+ } else {
+ stream.close();
+ }
+ } catch (IOException e) {
+ // ignore
+ }
}
}
}
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/FormDataWriter.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/FormDataWriter.java?rev=1626192&r1=1626191&r2=1626192&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/FormDataWriter.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/FormDataWriter.java
Fri Sep 19 12:34:20 2014
@@ -22,6 +22,7 @@ import static org.apache.chemistry.openc
import static
org.apache.chemistry.opencmis.commons.impl.CollectionsHelper.isNullOrEmpty;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.util.GregorianCalendar;
@@ -225,7 +226,9 @@ public final class FormDataWriter {
}
public void write(OutputStream out) throws IOException {
- if (contentStream == null || contentStream.getStream() == null) {
+ InputStream stream = (contentStream == null ? null :
contentStream.getStream());
+
+ if (stream == null) {
boolean first = true;
byte[] amp = IOUtils.toUTF8Bytes("&");
@@ -271,7 +274,7 @@ public final class FormDataWriter {
writeLine(out, "Content-Transfer-Encoding: binary");
writeLine(out);
- IOUtils.copy(contentStream.getStream(), out, BUFFER_SIZE);
+ IOUtils.copy(stream, out, BUFFER_SIZE);
writeLine(out);
writeLine(out, "--" + boundary + "--");
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/http/AbstractApacheClientHttpInvoker.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/http/AbstractApacheClientHttpInvoker.java?rev=1626192&r1=1626191&r2=1626192&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/http/AbstractApacheClientHttpInvoker.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/http/AbstractApacheClientHttpInvoker.java
Fri Sep 19 12:34:20 2014
@@ -42,6 +42,7 @@ import org.apache.chemistry.opencmis.cli
import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
import org.apache.chemistry.opencmis.commons.SessionParameter;
import
org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
import org.apache.chemistry.opencmis.commons.impl.IOUtils;
import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
import org.apache.chemistry.opencmis.commons.spi.AuthenticationProvider;
@@ -132,6 +133,8 @@ public abstract class AbstractApacheClie
request = new HttpPut(url.toString());
} else if ("DELETE".equals(method)) {
request = new HttpDelete(url.toString());
+ } else {
+ throw new CmisRuntimeException("Invalid HTTP method!");
}
// set content type
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/DocumentImpl.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/DocumentImpl.java?rev=1626192&r1=1626191&r2=1626192&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/DocumentImpl.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/DocumentImpl.java
Fri Sep 19 12:34:20 2014
@@ -21,6 +21,7 @@ package org.apache.chemistry.opencmis.cl
import static org.apache.chemistry.opencmis.commons.impl.CollectionsHelper.*;
import java.io.IOException;
+import java.io.InputStream;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.EnumSet;
@@ -205,11 +206,14 @@ public class DocumentImpl extends Abstra
return getSession().createDocument(newProperties, targetFolderId,
contentStream, versioningState, policies,
addAces, removeAces);
} finally {
- if (contentStream != null && contentStream.getStream() != null) {
- try {
- contentStream.getStream().close();
- } catch (IOException ioe) {
- throw new CmisRuntimeException("Cannot close source
stream!", ioe);
+ if (contentStream != null) {
+ InputStream stream = contentStream.getStream();
+ if (stream != null) {
+ try {
+ stream.close();
+ } catch (IOException ioe) {
+ throw new CmisRuntimeException("Cannot close source
stream!", ioe);
+ }
}
}
}
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/spi/CmisBinding.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/spi/CmisBinding.java?rev=1626192&r1=1626191&r2=1626192&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/spi/CmisBinding.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/spi/CmisBinding.java
Fri Sep 19 12:34:20 2014
@@ -18,6 +18,8 @@
*/
package org.apache.chemistry.opencmis.commons.spi;
+import java.io.Serializable;
+
import org.apache.chemistry.opencmis.commons.enums.BindingType;
/**
@@ -33,7 +35,7 @@ import org.apache.chemistry.opencmis.com
* provided if they are supported by the underlying binding.
* </p>
*/
-public interface CmisBinding {
+public interface CmisBinding extends Serializable {
/**
* Returns the client session id.
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/WSConverter.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/WSConverter.java?rev=1626192&r1=1626191&r2=1626192&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/WSConverter.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/WSConverter.java
Fri Sep 19 12:34:20 2014
@@ -2666,7 +2666,7 @@ public final class WSConverter {
if (!(in instanceof BufferedInputStream) && !(in instanceof
ByteArrayInputStream)) {
stream = new BufferedInputStream(in, BUFFER_SIZE);
} else {
- stream = contentStream.getStream();
+ stream = in;
}
result.setStream(new DataHandler(new DataSource() {
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomEntryParser.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomEntryParser.java?rev=1626192&r1=1626191&r2=1626192&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomEntryParser.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomEntryParser.java
Fri Sep 19 12:34:20 2014
@@ -346,8 +346,13 @@ public final class AtomEntryParser {
}
if (ths != null) {
- atomContentStream.setStream(ths.getInputStream());
- atomContentStream.setLength(BigInteger.valueOf(ths.getSize()));
+ try {
+ atomContentStream.setStream(ths.getInputStream());
+ atomContentStream.setLength(BigInteger.valueOf(ths.getSize()));
+ } catch (IOException e) {
+ ths.destroy();
+ throw e;
+ }
}
if (bytes != null) {
@@ -376,8 +381,13 @@ public final class AtomEntryParser {
cmisContentStream.setMimeType(XMLUtils.readText(parser,
XMLConstraints.MAX_STRING_LENGTH));
} else if (TAG_BASE64.equals(name.getLocalPart())) {
ThresholdOutputStream ths = readBase64(parser);
- cmisContentStream.setStream(ths.getInputStream());
-
cmisContentStream.setLength(BigInteger.valueOf(ths.getSize()));
+ try {
+ cmisContentStream.setStream(ths.getInputStream());
+
cmisContentStream.setLength(BigInteger.valueOf(ths.getSize()));
+ } catch (IOException e) {
+ ths.destroy();
+ throw e;
+ }
} else {
XMLUtils.skip(parser);
}
@@ -423,6 +433,7 @@ public final class AtomEntryParser {
cappedStream.deductBytes(bytes.length);
}
} else if (event == XMLStreamReader.START_ELEMENT) {
+ bufferStream.destroy();
throw new CmisInvalidArgumentException("Unexpected tag: "
+ parser.getName());
}