You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2012/02/09 11:01:41 UTC
svn commit: r1242257 -
/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomEntryParser.java
Author: fmui
Date: Thu Feb 9 10:01:41 2012
New Revision: 1242257
URL: http://svn.apache.org/viewvc?rev=1242257&view=rev
Log:
Server: remove temp file if upload via AtomPub fails
Modified:
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-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=1242257&r1=1242256&r2=1242257&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 Thu Feb 9 10:01:41 2012
@@ -388,25 +388,30 @@ public class AtomEntryParser {
next(parser);
- while (true) {
- int event = parser.getEventType();
- if (event == XMLStreamReader.END_ELEMENT) {
- break;
- } else if (event == XMLStreamReader.CHARACTERS) {
- String s = parser.getText();
- if (s != null) {
- b64stream.write(s.getBytes("US-ASCII"));
+ try {
+ while (true) {
+ int event = parser.getEventType();
+ if (event == XMLStreamReader.END_ELEMENT) {
+ break;
+ } else if (event == XMLStreamReader.CHARACTERS) {
+ String s = parser.getText();
+ if (s != null) {
+ b64stream.write(s.getBytes("US-ASCII"));
+ }
+ } else if (event == XMLStreamReader.START_ELEMENT) {
+ throw new RuntimeException("Unexpected tag: " + parser.getName());
}
- } else if (event == XMLStreamReader.START_ELEMENT) {
- throw new RuntimeException("Unexpected tag: " + parser.getName());
- }
- if (!next(parser)) {
- break;
+ if (!next(parser)) {
+ break;
+ }
}
- }
- b64stream.close();
+ b64stream.close();
+ } catch (Exception e) {
+ bufferStream.destroy(); // remove temp file
+ throw e;
+ }
next(parser);
@@ -673,6 +678,20 @@ public class AtomEntryParser {
}
}
+ public void destroy() {
+ try {
+ close();
+ } catch (Exception e) {
+ // ignore
+ }
+
+ if (tmpFile != null) {
+ tmpFile.delete();
+ }
+
+ buf = null;
+ }
+
public InputStream getInputStream() throws Exception {
if (tmpStream != null) {
close();