mirror of
				https://github.com/owncloud/android-library.git
				synced 2025-10-28 00:48:50 +00:00 
			
		
		
		
	Merge branch 'develop' into regular_authentication_in_saml_server
This commit is contained in:
		
						commit
						ec2fcc0716
					
				| @ -42,7 +42,8 @@ public class WebdavUtils { | ||||
|             new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.US), | ||||
|             new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US), | ||||
|             new SimpleDateFormat("EEEEEE, dd-MMM-yy HH:mm:ss zzz", Locale.US), | ||||
|             new SimpleDateFormat("EEE MMMM d HH:mm:ss yyyy", Locale.US) }; | ||||
|             new SimpleDateFormat("EEE MMMM d HH:mm:ss yyyy", Locale.US) , | ||||
|     		new SimpleDateFormat("yyyy-MM-dd hh:mm:ss") }; | ||||
| 
 | ||||
|     public static String prepareXmlForPropFind() { | ||||
|         String ret = "<?xml version=\"1.0\" ?><D:propfind xmlns:D=\"DAV:\"><D:allprop/></D:propfind>"; | ||||
|  | ||||
| @ -103,7 +103,7 @@ public class CreateRemoteShareOperation extends RemoteOperation { | ||||
| 		try { | ||||
| 			// Post Method | ||||
| 			post = new PostMethod(client.getBaseUri() + ShareUtils.SHARING_API_PATH); | ||||
| 			Log.d(TAG, "URL ------> " + client.getBaseUri() + ShareUtils.SHARING_API_PATH); | ||||
| 			//Log.d(TAG, "URL ------> " + client.getBaseUri() + ShareUtils.SHARING_API_PATH); | ||||
| 
 | ||||
| 			post.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); // necessary for special characters | ||||
| 			post.addParameter(PARAM_PATH, mRemoteFilePath); | ||||
| @ -121,7 +121,6 @@ public class CreateRemoteShareOperation extends RemoteOperation { | ||||
| 
 | ||||
| 			if(isSuccess(status)) { | ||||
| 				String response = post.getResponseBodyAsString(); | ||||
| 				Log.d(TAG, "Successful response: " + response); | ||||
| 
 | ||||
| 				result = new RemoteOperationResult(ResultCode.OK); | ||||
| 				 | ||||
| @ -132,7 +131,7 @@ public class CreateRemoteShareOperation extends RemoteOperation { | ||||
| 				mShares = xmlParser.parseXMLResponse(is); | ||||
| 				if (xmlParser.isSuccess()) { | ||||
| 					if (mShares != null) { | ||||
| 						Log.d(TAG, "Shares: " + mShares.size()); | ||||
| 						Log.d(TAG, "Created " + mShares.size() + " share(s)"); | ||||
| 						result = new RemoteOperationResult(ResultCode.OK); | ||||
| 						ArrayList<Object> sharesObjects = new ArrayList<Object>(); | ||||
| 						for (OCShare share: mShares) { | ||||
|  | ||||
| @ -87,7 +87,6 @@ public class GetRemoteSharesForFileOperation extends RemoteOperation { | ||||
| 		try { | ||||
| 			// Get Method | ||||
| 			get = new GetMethod(client.getBaseUri() + ShareUtils.SHARING_API_PATH); | ||||
| 			Log.d(TAG, "URL ------> " + client.getBaseUri() + ShareUtils.SHARING_API_PATH); | ||||
| 
 | ||||
| 			// Add Parameters to Get Method | ||||
| 			get.setQueryString(new NameValuePair[] {  | ||||
| @ -102,7 +101,6 @@ public class GetRemoteSharesForFileOperation extends RemoteOperation { | ||||
| 
 | ||||
| 			if(isSuccess(status)) { | ||||
| 				String response = get.getResponseBodyAsString(); | ||||
| 				Log.d(TAG, "Successful response: " + response); | ||||
| 
 | ||||
| 				result = new RemoteOperationResult(ResultCode.OK); | ||||
| 				 | ||||
| @ -112,10 +110,14 @@ public class GetRemoteSharesForFileOperation extends RemoteOperation { | ||||
| 				ShareXMLParser xmlParser = new ShareXMLParser(); | ||||
| 				mShares = xmlParser.parseXMLResponse(is); | ||||
| 				if (mShares != null) { | ||||
| 					Log.d(TAG, "Shares: " + mShares.size()); | ||||
| 					Log.d(TAG, "Got " + mShares.size() + " shares"); | ||||
| 					result = new RemoteOperationResult(ResultCode.OK); | ||||
| 					ArrayList<Object> sharesObjects = new ArrayList<Object>(); | ||||
| 					for (OCShare share: mShares) { | ||||
| 						// Build the link  | ||||
| 						if (share.getToken().length() > 0) { | ||||
| 							share.setShareLink(client.getBaseUri() + ShareUtils.SHARING_LINK_TOKEN + share.getToken()); | ||||
| 						} | ||||
| 						sharesObjects.add(share); | ||||
| 					} | ||||
| 					result.setData(sharesObjects); | ||||
| @ -127,7 +129,7 @@ public class GetRemoteSharesForFileOperation extends RemoteOperation { | ||||
| 			 | ||||
| 		} catch (Exception e) { | ||||
| 			result = new RemoteOperationResult(e); | ||||
| 			Log.e(TAG, "Exception while Creating New Share", e); | ||||
| 			Log.e(TAG, "Exception while getting shares", e); | ||||
| 			 | ||||
| 		} finally { | ||||
| 			if (get != null) { | ||||
|  | ||||
| @ -67,13 +67,10 @@ public class GetRemoteSharesOperation extends RemoteOperation { | ||||
| 		// Get the response | ||||
| 		try{ | ||||
| 			get = new GetMethod(client.getBaseUri() + ShareUtils.SHARING_API_PATH); | ||||
| 			Log.d(TAG, "URL ------> " + client.getBaseUri() + ShareUtils.SHARING_API_PATH); | ||||
| 			get.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE); | ||||
| 			status = client.executeMethod(get); | ||||
| 			if(isSuccess(status)) { | ||||
| 				Log.d(TAG, "Obtain RESPONSE"); | ||||
| 				String response = get.getResponseBodyAsString(); | ||||
| 				Log.d(TAG, response); | ||||
| 
 | ||||
| 				// Parse xml response --> obtain the response in ShareFiles ArrayList | ||||
| 				// convert String into InputStream | ||||
| @ -81,7 +78,7 @@ public class GetRemoteSharesOperation extends RemoteOperation { | ||||
| 				ShareXMLParser xmlParser = new ShareXMLParser(); | ||||
| 				mShares = xmlParser.parseXMLResponse(is); | ||||
| 				if (mShares != null) { | ||||
| 					Log.d(TAG, "Shares: " + mShares.size()); | ||||
| 					Log.d(TAG, "Got " + mShares.size() + " shares"); | ||||
| 					result = new RemoteOperationResult(ResultCode.OK); | ||||
| 					ArrayList<Object> sharesObjects = new ArrayList<Object>(); | ||||
| 					for (OCShare share: mShares) { | ||||
|  | ||||
| @ -71,7 +71,6 @@ public class RemoveRemoteShareOperation extends RemoteOperation { | ||||
| 		try { | ||||
| 			String id = "/" + String.valueOf(mRemoteShareId); | ||||
| 			delete = new DeleteMethod(client.getBaseUri() + ShareUtils.SHARING_API_PATH + id); | ||||
| 			Log.d(TAG, "URL ------> " + client.getBaseUri() + ShareUtils.SHARING_API_PATH + id); | ||||
| 
 | ||||
| 			delete.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE); | ||||
|              | ||||
| @ -79,7 +78,6 @@ public class RemoveRemoteShareOperation extends RemoteOperation { | ||||
| 
 | ||||
| 			if(isSuccess(status)) { | ||||
| 				String response = delete.getResponseBodyAsString(); | ||||
| 				Log.d(TAG, "Successful response: " + response); | ||||
| 
 | ||||
| 				result = new RemoteOperationResult(ResultCode.OK); | ||||
| 				 | ||||
| @ -96,7 +94,7 @@ public class RemoveRemoteShareOperation extends RemoteOperation { | ||||
| 					result = new RemoteOperationResult(false, status, delete.getResponseHeaders());	 | ||||
| 				} | ||||
| 				 | ||||
| 				Log.i(TAG, "Unshare " + id + ": " + result.getLogMessage()); | ||||
| 				Log.d(TAG, "Unshare " + id + ": " + result.getLogMessage()); | ||||
| 			} else { | ||||
| 				result = new RemoteOperationResult(false, status, delete.getResponseHeaders()); | ||||
| 			} | ||||
|  | ||||
| @ -36,4 +36,7 @@ public class ShareUtils { | ||||
| 	// OCS Route | ||||
| 	public static final String SHARING_API_PATH ="/ocs/v1.php/apps/files_sharing/api/v1/shares";  | ||||
| 
 | ||||
|     // String to build the link with the token of a share: server address + "/public.php?service=files&t=" + token | ||||
|     public static final String SHARING_LINK_TOKEN = "/public.php?service=files&t="; | ||||
|      | ||||
| } | ||||
|  | ||||
| @ -35,6 +35,7 @@ import org.xmlpull.v1.XmlPullParserFactory; | ||||
| import android.util.Log; | ||||
| import android.util.Xml; | ||||
| 
 | ||||
| import com.owncloud.android.lib.common.network.WebdavUtils; | ||||
| import com.owncloud.android.lib.resources.files.FileUtils; | ||||
| 
 | ||||
| /** | ||||
| @ -181,7 +182,7 @@ public class ShareXMLParser { | ||||
| 	 */ | ||||
| 	private void readMeta(XmlPullParser parser) throws XmlPullParserException, IOException { | ||||
| 		parser.require(XmlPullParser.START_TAG, ns, NODE_META); | ||||
| 		Log.d(TAG, "---- NODE META ---"); | ||||
| 		//Log.d(TAG, "---- NODE META ---"); | ||||
| 		while (parser.next() != XmlPullParser.END_TAG) { | ||||
| 			if (parser.getEventType() != XmlPullParser.START_TAG) { | ||||
| 				continue; | ||||
| @ -213,7 +214,7 @@ public class ShareXMLParser { | ||||
| 		OCShare share = null; | ||||
| 
 | ||||
| 		parser.require(XmlPullParser.START_TAG, ns, NODE_DATA);		 | ||||
| 		Log.d(TAG, "---- NODE DATA ---"); | ||||
| 		//Log.d(TAG, "---- NODE DATA ---"); | ||||
| 		while (parser.next() != XmlPullParser.END_TAG) { | ||||
| 			if (parser.getEventType() != XmlPullParser.START_TAG) { | ||||
| 				continue; | ||||
| @ -263,7 +264,7 @@ public class ShareXMLParser { | ||||
| 		 | ||||
| 		OCShare share = new OCShare(); | ||||
| 		 | ||||
| 		Log.d(TAG, "---- NODE ELEMENT ---"); | ||||
| 		//Log.d(TAG, "---- NODE ELEMENT ---"); | ||||
| 		while (parser.next() != XmlPullParser.END_TAG) { | ||||
| 			if (parser.getEventType() != XmlPullParser.START_TAG) { | ||||
| 	            continue; | ||||
| @ -311,8 +312,8 @@ public class ShareXMLParser { | ||||
| 
 | ||||
| 			} else if (name.equalsIgnoreCase(NODE_EXPIRATION)) { | ||||
| 				String value = readNode(parser, NODE_EXPIRATION); | ||||
| 				if (!value.isEmpty()) { | ||||
| 					share.setExpirationDate(Long.parseLong(readNode(parser, NODE_EXPIRATION))); // check if expiration is in long format or date format | ||||
| 				if (!(value.length() == 0)) { | ||||
| 					share.setExpirationDate(WebdavUtils.parseResponseDate(value).getTime());  | ||||
| 				} | ||||
| 
 | ||||
| 			} else if (name.equalsIgnoreCase(NODE_TOKEN)) { | ||||
| @ -359,7 +360,7 @@ public class ShareXMLParser { | ||||
| 	private String readNode (XmlPullParser parser, String node) throws XmlPullParserException, IOException{ | ||||
| 		parser.require(XmlPullParser.START_TAG, ns, node); | ||||
| 		String value = readText(parser); | ||||
| 		Log.d(TAG, "node= " + node + ", value= " + value); | ||||
| 		//Log.d(TAG, "node= " + node + ", value= " + value); | ||||
| 		parser.require(XmlPullParser.END_TAG, ns, node); | ||||
| 		return value; | ||||
| 	} | ||||
| @ -402,4 +403,5 @@ public class ShareXMLParser { | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user