diff --git a/src/com/owncloud/android/lib/common/operations/ForbiddenExceptionParser.java b/src/com/owncloud/android/lib/common/operations/ForbiddenExceptionParser.java index c6d9124f..27d11aad 100644 --- a/src/com/owncloud/android/lib/common/operations/ForbiddenExceptionParser.java +++ b/src/com/owncloud/android/lib/common/operations/ForbiddenExceptionParser.java @@ -38,17 +38,14 @@ import java.io.InputStream; * @author masensio */ public class ForbiddenExceptionParser { - - private static final String EXCEPTION_STRING = "OCA\\DAV\\Connector\\Sabre\\Exception\\Forbidden"; - - // No namespaces + // No namespaces private static final String ns = null; - // Nodes for XML Parser - private static final String NODE_ERROR = "d:error"; + // Nodes for XML Parser + private static final String NODE_ERROR = "d:error"; private static final String NODE_MESSAGE = "s:message"; - /** + /** * Parse is as an forbidden exception * @param is * @return reason for forbidden exception @@ -56,8 +53,8 @@ public class ForbiddenExceptionParser { * @throws IOException */ public String parseXMLResponse(InputStream is) throws XmlPullParserException, - IOException { - String errorMessage = ""; + IOException { + String errorMessage = ""; try { // XMLPullParser @@ -68,7 +65,7 @@ public class ForbiddenExceptionParser { parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false); parser.setInput(is, null); parser.nextTag(); - errorMessage = readError(parser); + errorMessage = readError(parser); } finally { is.close(); @@ -84,7 +81,7 @@ public class ForbiddenExceptionParser { * @throws IOException */ private String readError (XmlPullParser parser) throws XmlPullParserException, IOException { - String message = ""; + String errorMessage = ""; parser.require(XmlPullParser.START_TAG, ns , NODE_ERROR); while (parser.next() != XmlPullParser.END_TAG) { if (parser.getEventType() != XmlPullParser.START_TAG) { @@ -92,14 +89,13 @@ public class ForbiddenExceptionParser { } String name = parser.getName(); // read NODE_MESSAGE - if (name.equalsIgnoreCase(NODE_MESSAGE)) { - message = readText(parser); - } else { + if (name.equalsIgnoreCase(NODE_MESSAGE)) { + errorMessage = readText(parser); + } else { skip(parser); } - } - return message; + return errorMessage; } /** @@ -115,17 +111,17 @@ public class ForbiddenExceptionParser { int depth = 1; while (depth != 0) { switch (parser.next()) { - case XmlPullParser.END_TAG: - depth--; - break; - case XmlPullParser.START_TAG: - depth++; - break; + case XmlPullParser.END_TAG: + depth--; + break; + case XmlPullParser.START_TAG: + depth++; + break; } } } - /** + /** * Read the text from a node * @param parser * @return Text of the node @@ -140,4 +136,4 @@ public class ForbiddenExceptionParser { } return result; } -} +} \ No newline at end of file diff --git a/src/com/owncloud/android/lib/common/operations/RemoteOperationResult.java b/src/com/owncloud/android/lib/common/operations/RemoteOperationResult.java index 7008cc07..b14efdb7 100644 --- a/src/com/owncloud/android/lib/common/operations/RemoteOperationResult.java +++ b/src/com/owncloud/android/lib/common/operations/RemoteOperationResult.java @@ -107,6 +107,7 @@ public class RemoteOperationResult implements Serializable { LOCAL_STORAGE_NOT_REMOVED, FORBIDDEN, SHARE_FORBIDDEN, + SPECIFIC_FORBIDDEN, OK_REDIRECT_TO_NON_SECURE_CONNECTION, INVALID_MOVE_INTO_DESCENDANT, INVALID_COPY_INTO_DESCENDANT, @@ -252,7 +253,11 @@ public class RemoteOperationResult implements Serializable { InputStream is = new ByteArrayInputStream(bodyResponse.getBytes()); ForbiddenExceptionParser xmlParser = new ForbiddenExceptionParser(); try { - mHttpPhrase = xmlParser.parseXMLResponse(is); + String errorMessage = xmlParser.parseXMLResponse(is); + if (errorMessage != "" && errorMessage != null) { + mCode = ResultCode.SPECIFIC_FORBIDDEN; + mHttpPhrase = errorMessage; + } } catch (Exception e) { Log_OC.w(TAG, "Error reading exception from server: " + e.getMessage()); // mCode stays as set in this(success, httpCode, headers)