mirror of
				https://github.com/owncloud/android-library.git
				synced 2025-10-31 10:27:45 +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 | ||||
|  */ | ||||
| public class ForbiddenExceptionParser { | ||||
| 
 | ||||
|     private static final String EXCEPTION_STRING = "OCA\\DAV\\Connector\\Sabre\\Exception\\Forbidden"; | ||||
| 
 | ||||
| 	// No namespaces | ||||
| 	private static final String ns = null; | ||||
| 
 | ||||
| @ -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) { | ||||
| @ -93,13 +90,12 @@ public class ForbiddenExceptionParser { | ||||
| 			String name = parser.getName(); | ||||
| 			// read NODE_MESSAGE | ||||
| 			if (name.equalsIgnoreCase(NODE_MESSAGE)) { | ||||
|                 message = readText(parser); | ||||
| 				errorMessage = readText(parser); | ||||
| 			} else { | ||||
| 				skip(parser); | ||||
| 			} | ||||
| 
 | ||||
| 		} | ||||
|         return message; | ||||
| 		return errorMessage; | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
|  | ||||
| @ -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) | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user