mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-08 00:16:09 +00:00
Handle specific forbidden error
This commit is contained in:
parent
21121e0189
commit
1aba54d0f9
@ -38,9 +38,6 @@ import java.io.InputStream;
|
|||||||
* @author masensio
|
* @author masensio
|
||||||
*/
|
*/
|
||||||
public class ForbiddenExceptionParser {
|
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;
|
private static final String ns = null;
|
||||||
|
|
||||||
@ -84,7 +81,7 @@ public class ForbiddenExceptionParser {
|
|||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
private String readError (XmlPullParser parser) throws XmlPullParserException, IOException {
|
private String readError (XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||||
String message = "";
|
String errorMessage = "";
|
||||||
parser.require(XmlPullParser.START_TAG, ns , NODE_ERROR);
|
parser.require(XmlPullParser.START_TAG, ns , NODE_ERROR);
|
||||||
while (parser.next() != XmlPullParser.END_TAG) {
|
while (parser.next() != XmlPullParser.END_TAG) {
|
||||||
if (parser.getEventType() != XmlPullParser.START_TAG) {
|
if (parser.getEventType() != XmlPullParser.START_TAG) {
|
||||||
@ -93,13 +90,12 @@ public class ForbiddenExceptionParser {
|
|||||||
String name = parser.getName();
|
String name = parser.getName();
|
||||||
// read NODE_MESSAGE
|
// read NODE_MESSAGE
|
||||||
if (name.equalsIgnoreCase(NODE_MESSAGE)) {
|
if (name.equalsIgnoreCase(NODE_MESSAGE)) {
|
||||||
message = readText(parser);
|
errorMessage = readText(parser);
|
||||||
} else {
|
} else {
|
||||||
skip(parser);
|
skip(parser);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return message;
|
return errorMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -107,6 +107,7 @@ public class RemoteOperationResult implements Serializable {
|
|||||||
LOCAL_STORAGE_NOT_REMOVED,
|
LOCAL_STORAGE_NOT_REMOVED,
|
||||||
FORBIDDEN,
|
FORBIDDEN,
|
||||||
SHARE_FORBIDDEN,
|
SHARE_FORBIDDEN,
|
||||||
|
SPECIFIC_FORBIDDEN,
|
||||||
OK_REDIRECT_TO_NON_SECURE_CONNECTION,
|
OK_REDIRECT_TO_NON_SECURE_CONNECTION,
|
||||||
INVALID_MOVE_INTO_DESCENDANT,
|
INVALID_MOVE_INTO_DESCENDANT,
|
||||||
INVALID_COPY_INTO_DESCENDANT,
|
INVALID_COPY_INTO_DESCENDANT,
|
||||||
@ -252,7 +253,11 @@ public class RemoteOperationResult implements Serializable {
|
|||||||
InputStream is = new ByteArrayInputStream(bodyResponse.getBytes());
|
InputStream is = new ByteArrayInputStream(bodyResponse.getBytes());
|
||||||
ForbiddenExceptionParser xmlParser = new ForbiddenExceptionParser();
|
ForbiddenExceptionParser xmlParser = new ForbiddenExceptionParser();
|
||||||
try {
|
try {
|
||||||
mHttpPhrase = xmlParser.parseXMLResponse(is);
|
String errorMessage = xmlParser.parseXMLResponse(is);
|
||||||
|
if (errorMessage != "" && errorMessage != null) {
|
||||||
|
mCode = ResultCode.SPECIFIC_FORBIDDEN;
|
||||||
|
mHttpPhrase = errorMessage;
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log_OC.w(TAG, "Error reading exception from server: " + e.getMessage());
|
Log_OC.w(TAG, "Error reading exception from server: " + e.getMessage());
|
||||||
// mCode stays as set in this(success, httpCode, headers)
|
// mCode stays as set in this(success, httpCode, headers)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user