├── .github └── PULL_REQUEST_TEMPLATE.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE.txt ├── NOTICE.txt ├── README.md ├── pom.xml └── src └── main ├── java └── com │ └── amazonaws │ ├── mobileconnectors │ └── cognito │ │ ├── CognitoSyncManager.java │ │ ├── Dataset.java │ │ ├── DatasetMetadata.java │ │ ├── DefaultDataset.java │ │ ├── DefaultSyncCallback.java │ │ ├── PushSyncUpdate.java │ │ ├── Record.java │ │ ├── SyncConflict.java │ │ ├── exceptions │ │ ├── DataAccessNotAuthorizedException.java │ │ ├── DataConflictException.java │ │ ├── DataLimitExceededException.java │ │ ├── DataStorageException.java │ │ ├── DatasetNotFoundException.java │ │ ├── NetworkException.java │ │ ├── RegistrationFailedException.java │ │ ├── SubscribeFailedException.java │ │ ├── UnsubscribeFailedException.java │ │ └── package-info.java │ │ ├── internal │ │ ├── storage │ │ │ ├── CognitoSyncStorage.java │ │ │ ├── LocalStorage.java │ │ │ ├── RemoteDataStorage.java │ │ │ └── SQLiteLocalStorage.java │ │ └── util │ │ │ ├── DatasetUtils.java │ │ │ └── StringUtils.java │ │ └── package-info.java │ └── services │ └── cognitosync │ ├── AmazonCognitoSync.java │ ├── AmazonCognitoSyncClient.java │ ├── model │ ├── BulkPublishStatus.java │ ├── Dataset.java │ ├── DeleteDatasetRequest.java │ ├── DeleteDatasetResult.java │ ├── DescribeDatasetRequest.java │ ├── DescribeDatasetResult.java │ ├── InternalErrorException.java │ ├── InvalidConfigurationException.java │ ├── InvalidLambdaFunctionOutputException.java │ ├── InvalidParameterException.java │ ├── LambdaThrottledException.java │ ├── LimitExceededException.java │ ├── ListDatasetsRequest.java │ ├── ListDatasetsResult.java │ ├── ListRecordsRequest.java │ ├── ListRecordsResult.java │ ├── NotAuthorizedException.java │ ├── Operation.java │ ├── Platform.java │ ├── Record.java │ ├── RecordPatch.java │ ├── RegisterDeviceRequest.java │ ├── RegisterDeviceResult.java │ ├── ResourceConflictException.java │ ├── ResourceNotFoundException.java │ ├── StreamingStatus.java │ ├── SubscribeToDatasetRequest.java │ ├── SubscribeToDatasetResult.java │ ├── TooManyRequestsException.java │ ├── UnsubscribeFromDatasetRequest.java │ ├── UnsubscribeFromDatasetResult.java │ ├── UpdateRecordsRequest.java │ ├── UpdateRecordsResult.java │ ├── package-info.java │ └── transform │ │ ├── DatasetJsonUnmarshaller.java │ │ ├── DeleteDatasetRequestMarshaller.java │ │ ├── DeleteDatasetResultJsonUnmarshaller.java │ │ ├── DescribeDatasetRequestMarshaller.java │ │ ├── DescribeDatasetResultJsonUnmarshaller.java │ │ ├── InternalErrorExceptionUnmarshaller.java │ │ ├── InvalidConfigurationExceptionUnmarshaller.java │ │ ├── InvalidLambdaFunctionOutputExceptionUnmarshaller.java │ │ ├── InvalidParameterExceptionUnmarshaller.java │ │ ├── LambdaThrottledExceptionUnmarshaller.java │ │ ├── LimitExceededExceptionUnmarshaller.java │ │ ├── ListDatasetsRequestMarshaller.java │ │ ├── ListDatasetsResultJsonUnmarshaller.java │ │ ├── ListRecordsRequestMarshaller.java │ │ ├── ListRecordsResultJsonUnmarshaller.java │ │ ├── NotAuthorizedExceptionUnmarshaller.java │ │ ├── RecordJsonUnmarshaller.java │ │ ├── RegisterDeviceRequestMarshaller.java │ │ ├── RegisterDeviceResultJsonUnmarshaller.java │ │ ├── ResourceConflictExceptionUnmarshaller.java │ │ ├── ResourceNotFoundExceptionUnmarshaller.java │ │ ├── SubscribeToDatasetRequestMarshaller.java │ │ ├── SubscribeToDatasetResultJsonUnmarshaller.java │ │ ├── TooManyRequestsExceptionUnmarshaller.java │ │ ├── UnsubscribeFromDatasetRequestMarshaller.java │ │ ├── UnsubscribeFromDatasetResultJsonUnmarshaller.java │ │ ├── UpdateRecordsRequestMarshaller.java │ │ ├── UpdateRecordsResultJsonUnmarshaller.java │ │ └── package-info.java │ └── package-info.java └── resources └── fabric └── com.amazonaws.aws-android-sdk-cognito.properties /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | *Issue #, if available:* 2 | 3 | *Description of changes:* 4 | 5 | 6 | By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice. 7 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 4 | opensource-codeofconduct@amazon.com with any additional questions or comments. 5 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guidelines 2 | 3 | Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional 4 | documentation, we greatly value feedback and contributions from our community. 5 | 6 | Please read through this document before submitting any issues or pull requests to ensure we have all the necessary 7 | information to effectively respond to your bug report or contribution. 8 | 9 | 10 | ## Reporting Bugs/Feature Requests 11 | 12 | We welcome you to use the GitHub issue tracker to report bugs or suggest features. 13 | 14 | When filing an issue, please check [existing open](https://github.com/aws/amazon-cognito-android/issues), or [recently closed](https://github.com/aws/amazon-cognito-android/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), issues to make sure somebody else hasn't already 15 | reported the issue. Please try to include as much information as you can. Details like these are incredibly useful: 16 | 17 | * A reproducible test case or series of steps 18 | * The version of our code being used 19 | * Any modifications you've made relevant to the bug 20 | * Anything unusual about your environment or deployment 21 | 22 | 23 | ## Contributing via Pull Requests 24 | Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that: 25 | 26 | 1. You are working against the latest source on the *master* branch. 27 | 2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already. 28 | 3. You open an issue to discuss any significant work - we would hate for your time to be wasted. 29 | 30 | To send us a pull request, please: 31 | 32 | 1. Fork the repository. 33 | 2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change. 34 | 3. Ensure local tests pass. 35 | 4. Commit to your fork using clear commit messages. 36 | 5. Send us a pull request, answering any default questions in the pull request interface. 37 | 6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation. 38 | 39 | GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and 40 | [creating a pull request](https://help.github.com/articles/creating-a-pull-request/). 41 | 42 | 43 | ## Finding contributions to work on 44 | Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels ((enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ['help wanted'](https://github.com/aws/amazon-cognito-android/labels/help%20wanted) issues is a great place to start. 45 | 46 | 47 | ## Code of Conduct 48 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 49 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 50 | opensource-codeofconduct@amazon.com with any additional questions or comments. 51 | 52 | 53 | ## Security issue notifications 54 | If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue. 55 | 56 | 57 | ## Licensing 58 | 59 | See the [LICENSE](https://github.com/aws/amazon-cognito-android/blob/master/LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution. 60 | 61 | We may ask you to sign a [Contributor License Agreement (CLA)](http://en.wikipedia.org/wiki/Contributor_License_Agreement) for larger changes. 62 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Amazon Software License 2 | This Amazon Software License (“License”) governs your use, reproduction, and distribution of the accompanying software as specified below. 3 | 1. Definitions 4 | “Licensor” means any person or entity that distributes its Work. 5 | 6 | “Software” means the original work of authorship made available under this License. 7 | 8 | “Work” means the Software and any additions to or derivative works of the Software that are made available under this License. 9 | 10 | The terms “reproduce,” “reproduction,” “derivative works,” and “distribution” have the meaning as provided under U.S. copyright law; provided, however, that for the purposes of this License, derivative works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work. 11 | 12 | Works, including the Software, are “made available” under this License by including in or with the Work either (a) a copyright notice referencing the applicability of this License to the Work, or (b) a copy of this License. 13 | 2. License Grants 14 | 2.1 Copyright Grant. Subject to the terms and conditions of this License, each Licensor grants to you a perpetual, worldwide, non-exclusive, royalty-free, copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense and distribute its Work and any resulting derivative works in any form. 15 | 2.2 Patent Grant. Subject to the terms and conditions of this License, each Licensor grants to you a perpetual, worldwide, non-exclusive, royalty-free patent license to make, have made, use, sell, offer for sale, import, and otherwise transfer its Work, in whole or in part. The foregoing license applies only to the patent claims licensable by Licensor that would be infringed by Licensor’s Work (or portion thereof) individually and excluding any combinations with any other materials or technology. 16 | 3. Limitations 17 | 3.1 Redistribution. You may reproduce or distribute the Work only if (a) you do so under this License, (b) you include a complete copy of this License with your distribution, and (c) you retain without modification any copyright, patent, trademark, or attribution notices that are present in the Work. 18 | 3.2 Derivative Works. You may specify that additional or different terms apply to the use, reproduction, and distribution of your derivative works of the Work (“Your Terms”) only if (a) Your Terms provide that the use limitation in Section 3.3 applies to your derivative works, and (b) you identify the specific derivative works that are subject to Your Terms. Notwithstanding Your Terms, this License (including the redistribution requirements in Section 3.1) will continue to apply to the Work itself. 19 | 3.3 Use Limitation. The Work and any derivative works thereof only may be used or intended for use with the web services, computing platforms or applications provided by Amazon.com, Inc. or its affiliates, including Amazon Web Services, Inc. 20 | 3.4 Patent Claims. If you bring or threaten to bring a patent claim against any Licensor (including any claim, cross-claim or counterclaim in a lawsuit) to enforce any patents that you allege are infringed by any Work, then your rights under this License from such Licensor (including the grants in Sections 2.1 and 2.2) will terminate immediately. 21 | 3.5 Trademarks. This License does not grant any rights to use any Licensor’s or its affiliates’ names, logos, or trademarks, except as necessary to reproduce the notices described in this License. 22 | 3.6 Termination. If you violate any term of this License, then your rights under this License (including the grants in Sections 2.1 and 2.2) will terminate immediately. 23 | 4. Disclaimer of Warranty. 24 | THE WORK IS PROVIDED “AS IS” WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WARRANTIES OR CONDITIONS OF M ERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE OR NON-INFRINGEMENT. YOU BEAR THE RISK OF UNDERTAKING ANY ACTIVITIES UNDER THIS LICENSE. SOME STATES’ CONSUMER LAWS DO NOT ALLOW EXCLUSION OF AN IMPLIED WARRANTY, SO THIS DISCLAIMER MAY NOT APPLY TO YOU. 25 | 5. Limitation of Liability. 26 | EXCEPT AS PROHIBITED BY APPLICABLE LAW, IN NO EVENT AND UNDER NO LEGAL THEORY, WHETHER IN TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE SHALL ANY LICENSOR BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATED TO THIS LICENSE, THE USE OR INABILITY TO USE THE WORK (INCLUDING BUT NOT LIMITED TO LOSS OF GOODWILL, BUSINESS INTERRUPTION, LOST PROFITS OR DATA, COMPUTER FAILURE OR MALFUNCTION, OR ANY OTHER COMM ERCIAL DAMAGES OR LOSSES), EVEN IF THE LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 27 | Effective Date – April 18, 2008 © 2008 Amazon.com, Inc. or its affiliates. All rights reserved. -------------------------------------------------------------------------------- /NOTICE.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amazon-archives/amazon-cognito-android/f44f76c2039755068b41a499a22d4c3a4a017946/NOTICE.txt -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # [MOVED] AWS SDK for Android (Amazon Cognito) 2 | 3 | **This repository has been merged into [AWS SDK for Android](https://github.com/aws/aws-sdk-android). All the code is moved under [aws-sdk-android/aws-android-sdk-cognito](https://github.com/aws/aws-sdk-android/tree/master/aws-android-sdk-cognito). Amazon Cognito Sync will continue to be developed and maintained in the master repo. Any future issues regarding Amazon Cognito should be posted at [aws-sdk-android/issues](https://github.com/aws/aws-sdk-android/issues). This repo will be inactive and is pending removal if necessary.** 4 | 5 | [Amazon Cognito](http://aws.amazon.com/cognito/) is a simple user identity and synchronization service that helps you securely manage and synchronize app data for your users across their mobile devices. With Amazon Cognito, you can save any kind of data, such as app preferences or game state, in the AWS Cloud without writing any backend code or managing any infrastructure. 6 | 7 | ## To learn more about Android Development 8 | 9 | For more information on Andorid development, see the Android developer site at: [developer.android.com](http://developer.android.com/index.html) 10 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | com.amazonaws 6 | aws-android-sdk-cognito 7 | jar 8 | AWS SDK for Android - Amazon Cognito Sync 9 | 2.2.12 10 | The AWS Android SDK for Amazon Cognito Sync module holds the client classes that are used for communicating with Amazon Cognito Sync Service 11 | http://aws.amazon.com/sdkforandroid 12 | 13 | 14 | 15 | UTF-8 16 | 17 | 18 | UTF-8 19 | 20 | 21 | 22 | 23 | http://github.com/aws/amazon-cognito-android.git 24 | 25 | 26 | 27 | 28 | Amazon Software License 29 | http://aws.amazon.com/asl/ 30 | repo 31 | 32 | 33 | 34 | 35 | 36 | amazonwebservices 37 | Amazon Web Services 38 | http://aws.amazon.com 39 | 40 | developer 41 | 42 | 43 | 44 | 45 | 46 | 47 | com.amazonaws 48 | aws-android-sdk-core 49 | false 50 | 2.2.12 51 | 52 | 53 | com.google.android 54 | android 55 | 2.3.3 56 | provided 57 | 58 | 59 | 60 | 61 | 62 | 63 | org.apache.maven.plugins 64 | maven-compiler-plugin 65 | 2.3 66 | 67 | 1.7 68 | 1.7 69 | UTF-8 70 | 71 | 72 | 73 | org.apache.maven.plugins 74 | maven-javadoc-plugin 75 | 2.9.1 76 | 77 | *.internal:*.transform 78 | 128m 79 | 1024m 80 | -Xdoclint:none 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | publishing 89 | 90 | 91 | 92 | org.apache.maven.plugins 93 | maven-gpg-plugin 94 | 95 | 96 | sign-artifacts 97 | verify 98 | 99 | sign 100 | 101 | 102 | 103 | 104 | 105 | org.sonatype.plugins 106 | nexus-staging-maven-plugin 107 | 1.5.1 108 | true 109 | 110 | sonatype-nexus-staging 111 | https://oss.sonatype.org 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/mobileconnectors/cognito/Dataset.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-2016 Amazon.com, 3 | * Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Licensed under the Amazon Software License (the "License"). 6 | * You may not use this file except in compliance with the 7 | * License. A copy of the License is located at 8 | * 9 | * http://aws.amazon.com/asl/ 10 | * 11 | * or in the "license" file accompanying this file. This file is 12 | * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13 | * CONDITIONS OF ANY KIND, express or implied. See the License 14 | * for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.amazonaws.mobileconnectors.cognito; 19 | 20 | import com.amazonaws.mobileconnectors.cognito.exceptions.DataStorageException; 21 | 22 | import java.util.List; 23 | import java.util.Map; 24 | 25 | /** 26 | * Dataset is the container of {@link Record}s. It can have up to 1k 27 | * {@link Record} or 1 MB in size. A typical use of {@link Dataset} is the 28 | * following. 29 | * 30 | *
 31 |  * // open or create dataset
 32 |  * Dataset dataset = cognitoClient.openOrCreate("new dataset");
 33 |  * // synchronize. It pulls down latest changes from remote storage
 34 |  * // and push local changes to remote storage
 35 |  * dataset.synchronize(syncCallback);
 36 |  * // reads value
 37 |  * String highScore = dataset.getValue("high_score");
 38 |  * String name = dataset.getValue("name");
 39 |  * // sets value
 40 |  * dataset.put("high_score", "90");
 41 |  * dataset.put("name", "John");
 42 |  * // push changes to remote if needed
 43 |  * dataset.synchronizesyncCallback);
 44 |  * 
45 | */ 46 | public interface Dataset { 47 | 48 | /** 49 | * Retrieves the associated {@link DatasetMetadata} from local storage. 50 | * 51 | * @return metadata 52 | */ 53 | DatasetMetadata getDatasetMetadata(); 54 | 55 | /** 56 | * Synchronize {@link Dataset} between local storage and remote storage. 57 | * 58 | * @param callback call back 59 | */ 60 | void synchronize(SyncCallback callback); 61 | 62 | /** 63 | * Attempt to synchronize {@link Dataset} when connectivity is available. If 64 | * the connectivity is available right away, it behaves the same as 65 | * {@link #synchronize(SyncCallback)}. Otherwise it listens to connectivity 66 | * changes, and will do a sync once the connectivity is back. Note that if 67 | * this method is called multiple times, only the last synchronize request 68 | * is kept and only the last callback will fire. If either the dataset or 69 | * the callback is garbage collected, this method will not perform a sync 70 | * and the callback won't fire. 71 | * 72 | * @param callback call back 73 | */ 74 | void synchronizeOnConnectivity(SyncCallback callback); 75 | 76 | /** 77 | * Gets the value of a {@link Record} with the given key. If the 78 | * {@link Record} doesn't exist or is marked deleted, null will be returned. 79 | * 80 | * @param key key of the record in the dataset. 81 | * @return the string value of the record, or null if the record doesn't 82 | * exist or is marked deleted. 83 | */ 84 | String get(String key); 85 | 86 | /** 87 | * Puts a {@link Record} with the given key and value into the 88 | * {@link Dataset}. If a {@link Record} with the same key exists, its value 89 | * will be overwritten. If a {@link Record} is marked as deleted previously, 90 | * then it will be resurrected with new value while the sync count continues 91 | * with previous value. No matter whether the value changes or not, the 92 | * record is considered as updated, and it will be written to Cognito Sync 93 | * service on next synchronize operation. If value is null, a 94 | * {@link NullPointerException} will be thrown. 95 | * 96 | * @param key key of the record 97 | * @param value string value of a {@link Record} to be put into the 98 | * {@link Dataset} 99 | */ 100 | void put(String key, String value); 101 | 102 | /** 103 | * @param values 104 | */ 105 | void putAll(Map values); 106 | 107 | /** 108 | * Marks a {@link Record} with the given key as deleted. Nothing happens if 109 | * the {@link Record} doesn't exist or is deleted already. 110 | * 111 | * @param key 112 | */ 113 | void remove(String key); 114 | 115 | /** 116 | * Saves resolved conflicting {@link Record}s into local storage. This is 117 | * used inside {@link SyncCallback#onConflict(Dataset, List)} after you 118 | * resolve all conflicts. 119 | * 120 | * @param resolvedConflicts a list of records to save into local storage 121 | */ 122 | void resolve(List resolvedConflicts); 123 | 124 | /** 125 | * Retrieves all raw records, marked deleted or not, from local storage. 126 | * 127 | * @return a list of all raw records 128 | */ 129 | List getAllRecords(); 130 | 131 | /** 132 | * Gets the key-value representation of all records of this dataset. Marked 133 | * as deleted records are excluded. 134 | * 135 | * @return key-value representation of all records, excluding deleted ones 136 | */ 137 | Map getAll(); 138 | 139 | /** 140 | * Gets the total size in bytes of this dataset. Records that are marked as 141 | * deleted don't contribute to the total size. 142 | * 143 | * @return size in bytes 144 | */ 145 | long getTotalSizeInBytes(); 146 | 147 | /** 148 | * Gets the size of a record with the given key. If the key is deleted, -1 149 | * will be returned. 150 | * 151 | * @param key the key of a record 152 | * @return size in bytes 153 | */ 154 | long getSizeInBytes(String key); 155 | 156 | /** 157 | * Retrieves the status of a record. 158 | * 159 | * @param key the key of a record 160 | * @return True if it is modified locally. False otherwise 161 | */ 162 | boolean isChanged(String key); 163 | 164 | /** 165 | * Delete this {@link Dataset}. No more following operations on this 166 | * dataset, or else {@link IllegalStateException} will be thrown. 167 | */ 168 | void delete(); 169 | 170 | /** 171 | * Get the last sync count of this {@link Dataset}. 172 | * 173 | * @return last sync count 174 | */ 175 | long getLastSyncCount(); 176 | 177 | /** 178 | * Subscribes the user to update notifications for a dataset. This should 179 | * only be called after the device has been registered. 180 | */ 181 | void subscribe(); 182 | 183 | /** 184 | * Unsubscribe the user from receiving notifications on updates to a dataset 185 | * which has previously been subscribed to. 186 | */ 187 | void unsubscribe(); 188 | 189 | /** 190 | * This is the callback used in {@link Dataset#synchronize(SyncCallback)}. 191 | */ 192 | interface SyncCallback { 193 | /** 194 | * This is called after remote changes are downloaded to local storage 195 | * and local changes are uploaded to remote storage. Updated records 196 | * from remote storage are passed in the callback. If conflicts occur 197 | * during synchronize and are resolved in {@link #onConflict} after 198 | * several retries, then updatedRecords will be what are pulled down 199 | * from remote in the last retry. 200 | * 201 | * @param dataset the dataset that performed sync 202 | * @param updatedRecords new records from remote storage that are 203 | * downloaded 204 | */ 205 | void onSuccess(Dataset dataset, List updatedRecords); 206 | 207 | /** 208 | * This can be triggered during two phases. One is when the remote 209 | * changes are about to be written to local storage. The other is when 210 | * local changes are uploaded to remote storage and got rejected. Here 211 | * is an example: 212 | * 213 | *
214 |          * List<Record> resolved = new ArrayList<Record>();
215 |          * for (SyncConflict conflict : conflicts) {
216 |          *     resolved.add(conflicts.resolveWithRemoteRecord());
217 |          * }
218 |          * dataset.save(resolved);
219 |          * return true; // so that synchronize() can retry
220 |          * 
221 | * 222 | * If you prefer to add additional logic when resolving conflict, you 223 | * can use {@link SyncConflict#resolveWithValue(String)} 224 | * 225 | *
226 |          * int remoteMoney = Integer.valueOf(conflicts.getRemote().getValue());
227 |          * int localMoney = Integer.valueOf(conflicts.getLocal().getValue());
228 |          * int total = remoteMoney + localMoney;
229 |          * Record resolve = conflicts.resolveWithValue(String.valueOf(total));
230 |          * 
231 | * 232 | * @param dataset the dataset that performed sync 233 | * @param conflicts conflicting records 234 | * @return true if conflicts are resolved so that synchronize will 235 | * retry, false otherwise. 236 | */ 237 | boolean onConflict(Dataset dataset, List conflicts); 238 | 239 | /** 240 | * This is triggered when the given dataset is deleted remotely. Return 241 | * true if you want to remove local dataset, or false if you want to 242 | * keep it. 243 | * 244 | * @param dataset dataset handler 245 | * @param datasetName the name of the dataset that is deleted remotely 246 | * @return true to remove local dataset, or false to keep it 247 | */ 248 | boolean onDatasetDeleted(Dataset dataset, String datasetName); 249 | 250 | /** 251 | * If two or more datasets are merged as a result of identity merge, 252 | * this will be triggered. A list of names of merged datasets' is passed 253 | * in. The merged dataset name will be appended with its old identity 254 | * id. One can open the merged dataset, synchronize the content, 255 | * reconcile with the current dataset, and remove it. This callback will 256 | * fire off until the merged dataset is removed. 257 | * 258 | * @param dataset dataset handler 259 | * @param datasetNames a list of names of merged datasets' 260 | * @return true if the merge is resolved so that synchronize will retry, false otherwise. 261 | */ 262 | boolean onDatasetsMerged(Dataset dataset, List datasetNames); 263 | 264 | /** 265 | * This is called when an exception occurs during sync. 266 | * 267 | * @param dse exception 268 | */ 269 | void onFailure(DataStorageException dse); 270 | } 271 | 272 | } 273 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/mobileconnectors/cognito/DatasetMetadata.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-2016 Amazon.com, 3 | * Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Licensed under the Amazon Software License (the "License"). 6 | * You may not use this file except in compliance with the 7 | * License. A copy of the License is located at 8 | * 9 | * http://aws.amazon.com/asl/ 10 | * 11 | * or in the "license" file accompanying this file. This file is 12 | * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13 | * CONDITIONS OF ANY KIND, express or implied. See the License 14 | * for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.amazonaws.mobileconnectors.cognito; 19 | 20 | import java.util.Date; 21 | 22 | /** 23 | * The metadata of a {@link Dataset}, including name, server sync count, last 24 | * modified date. The is the cached information of a dataset. It might not 25 | * reflect the most up-to-date information stored remotely. Please call 26 | * {@link CognitoSyncManager#refreshDatasetMetadata()} to pull the latest 27 | * information. 28 | */ 29 | public final class DatasetMetadata { 30 | /** 31 | * Non empty String name of the dataset 32 | */ 33 | private final String datasetName; 34 | /** 35 | * Date when the dataset is created 36 | */ 37 | private final Date creationDate; 38 | /** 39 | * Date when the dataset is last modified 40 | */ 41 | private final Date lastModifiedDate; 42 | /** 43 | * The device that made the last modification 44 | */ 45 | private final String lastModifiedBy; 46 | /** 47 | * The storage size in bytes of the dataset 48 | */ 49 | private final long storageSizeBytes; 50 | /** 51 | * Number of records in the dataset 52 | */ 53 | private final long recordCount; 54 | 55 | /** 56 | * Gets the name of this dataset. 57 | * 58 | * @return non empty String name of this dataset 59 | */ 60 | public String getDatasetName() { 61 | return datasetName; 62 | } 63 | 64 | /** 65 | * Gets the creation date of this dataset. 66 | * 67 | * @return creation date 68 | */ 69 | public Date getCreationDate() { 70 | return new Date(creationDate.getTime()); 71 | } 72 | 73 | /** 74 | * Gets last modified date of this dataset. 75 | * 76 | * @return date when this dataset is last modified 77 | */ 78 | public Date getLastModifiedDate() { 79 | return new Date(lastModifiedDate.getTime()); 80 | } 81 | 82 | /** 83 | * Gets the device that made the last modification to the dataset. 84 | * 85 | * @return the device that made the last modification, or null if unknown. 86 | */ 87 | public String getLastModifiedBy() { 88 | return lastModifiedBy; 89 | } 90 | 91 | /** 92 | * Gets the storage size in bytes of this dataset. It equals the sum of 93 | * UTF-8 encoded string length of record keys and values. 94 | * 95 | * @return storage size in bytes 96 | */ 97 | public long getStorageSizeBytes() { 98 | return storageSizeBytes; 99 | } 100 | 101 | /** 102 | * Gets the number of records in this dataset. 103 | * 104 | * @return number of records 105 | */ 106 | public long getRecordCount() { 107 | return recordCount; 108 | } 109 | 110 | /** 111 | * Private constructor of {@link DatasetMetadata}. 112 | * 113 | * @param builder builder object 114 | */ 115 | private DatasetMetadata(Builder builder) { 116 | this.datasetName = builder.datasetName; 117 | this.lastModifiedBy = builder.lastModifiedBy; 118 | this.creationDate = builder.creationDate == null 119 | ? new Date(0) : new 120 | Date(builder.creationDate.getTime()); 121 | this.lastModifiedDate = 122 | builder.lastModifiedDate == null 123 | ? new Date() // default is current time 124 | : new Date(builder.lastModifiedDate.getTime()); 125 | this.storageSizeBytes = builder.storageSizeBytes; 126 | this.recordCount = builder.recordCount; 127 | } 128 | 129 | /** 130 | * The builder to construct {@link DatasetMetadata} object. 131 | */ 132 | public static final class Builder { 133 | private final String datasetName; 134 | private Date creationDate; 135 | private Date lastModifiedDate; 136 | private String lastModifiedBy; 137 | private long storageSizeBytes; 138 | private long recordCount; 139 | 140 | /** 141 | * Constructs a {@link Builder} object with initial dataset name. 142 | * 143 | * @param datasetName name of the dataset to be constructed 144 | */ 145 | public Builder(String datasetName) { 146 | this.datasetName = datasetName; 147 | } 148 | 149 | /** 150 | * Sets the creation date of this dataset. Default is 0 (unknown). 151 | * 152 | * @param creationDate creation date of this dataset. 153 | * @return builder itself 154 | */ 155 | public Builder creationDate(Date creationDate) { 156 | this.creationDate = creationDate; 157 | return this; 158 | } 159 | 160 | /** 161 | * Sets the last modified date. Default is current date. 162 | * 163 | * @param lastModifiedDate last modified date 164 | * @return builder itself. 165 | */ 166 | public Builder lastModifiedDate(Date lastModifiedDate) { 167 | this.lastModifiedDate = lastModifiedDate; 168 | return this; 169 | } 170 | 171 | /** 172 | * Sets the device which made the last modification. Default is null. 173 | * 174 | * @param lastModifiedBy device which made the last modification 175 | * @return builder itself 176 | */ 177 | public Builder lastModifiedBy(String lastModifiedBy) { 178 | this.lastModifiedBy = lastModifiedBy; 179 | return this; 180 | } 181 | 182 | /** 183 | * Set the storage size in bytes of this dataset. Default is 0. 184 | * 185 | * @param storageSizeBytes storage size in bytes 186 | * @return builder itself 187 | */ 188 | public Builder storageSizeBytes(long storageSizeBytes) { 189 | if (storageSizeBytes < 0) { 190 | throw new IllegalArgumentException("Storage size can't be negative"); 191 | } 192 | this.storageSizeBytes = storageSizeBytes; 193 | return this; 194 | } 195 | 196 | /** 197 | * Sets the number of records in this dataset. Default is 0. 198 | * 199 | * @param recordCount number of records 200 | * @return builder itself 201 | */ 202 | public Builder recordCount(long recordCount) { 203 | if (recordCount < 0) { 204 | throw new IllegalArgumentException("Number of records can't be negative"); 205 | } 206 | this.recordCount = recordCount; 207 | return this; 208 | } 209 | 210 | /** 211 | * Builds the {@link DatasetMetadata} object. 212 | * 213 | * @return DatasetMetadata object 214 | */ 215 | public DatasetMetadata build() { 216 | return new DatasetMetadata(this); 217 | } 218 | } 219 | 220 | @Override 221 | public String toString() { 222 | StringBuilder sb = new StringBuilder(); 223 | sb.append("dataset_name:[").append(datasetName).append("],") 224 | .append("creation_date:[").append(creationDate).append("],") 225 | .append("last_modified_date:[").append(lastModifiedDate).append("],") 226 | .append("last_modified_by:[").append(lastModifiedBy).append("],") 227 | .append("storage_size_bytes:[").append(storageSizeBytes).append("],") 228 | .append("record_count:[").append(recordCount).append("]"); 229 | return sb.toString(); 230 | } 231 | } 232 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/mobileconnectors/cognito/DefaultSyncCallback.java: -------------------------------------------------------------------------------- 1 | 2 | package com.amazonaws.mobileconnectors.cognito; 3 | 4 | import android.util.Log; 5 | 6 | import com.amazonaws.mobileconnectors.cognito.Dataset.SyncCallback; 7 | import com.amazonaws.mobileconnectors.cognito.exceptions.DataStorageException; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | * A default implementation of SyncCallback. All methods but onConflict are 14 | * stubbed with logging. onConflict resolves conflicts using a 'last writer 15 | * wins' strategy 16 | */ 17 | public class DefaultSyncCallback implements SyncCallback { 18 | 19 | private static final String TAG = "DefaultSyncCallback"; 20 | 21 | @Override 22 | public void onSuccess(Dataset dataset, List updatedRecords) { 23 | Log.i(TAG, String.format("%d records synced successfully.", updatedRecords.size())); 24 | } 25 | 26 | @Override 27 | public boolean onConflict(Dataset dataset, List conflicts) { 28 | Log.i(TAG, "onConflict resolved with DefaultSyncCallback's default implementation (last writer wins)."); 29 | List resolvedConflicts = new ArrayList(conflicts.size()); 30 | for (SyncConflict conflict : conflicts) { 31 | resolvedConflicts.add(conflict.resolveWithLastWriterWins()); 32 | } 33 | dataset.resolve(resolvedConflicts); 34 | return true; 35 | } 36 | 37 | @Override 38 | public boolean onDatasetDeleted(Dataset dataset, String datasetName) { 39 | Log.w(TAG, "onDatasetDeleted was called and DefaultSyncCallback doesn't provide an implementation for it"); 40 | return false; 41 | } 42 | 43 | @Override 44 | public boolean onDatasetsMerged(Dataset dataset, List datasetNames) { 45 | Log.w(TAG, "onDatasetsMerged was called and DefaultSyncCallback doesn't provide an implementation for it"); 46 | return false; 47 | } 48 | 49 | @Override 50 | public void onFailure(DataStorageException dse) { 51 | Log.e(TAG, "Failure occurred during sync", dse); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/mobileconnectors/cognito/PushSyncUpdate.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-2016 Amazon.com, 3 | * Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Licensed under the Amazon Software License (the "License"). 6 | * You may not use this file except in compliance with the 7 | * License. A copy of the License is located at 8 | * 9 | * http://aws.amazon.com/asl/ 10 | * 11 | * or in the "license" file accompanying this file. This file is 12 | * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13 | * CONDITIONS OF ANY KIND, express or implied. See the License 14 | * for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.amazonaws.mobileconnectors.cognito; 18 | 19 | import android.os.Bundle; 20 | import android.content.Intent; 21 | import android.util.Log; 22 | 23 | import com.amazonaws.services.cognitosync.model.InvalidParameterException; 24 | 25 | /** 26 | * A class to keep handy the data that is given in a push sync message, for the 27 | * sake of parsing the message to uniquely identify the dataset for update and use 28 | * that information to synchronize the local data. This class should only be used 29 | * with a push sync notification, isPushSyncUpdate(Intent intent) can be used 30 | * to verify as much. 31 | */ 32 | public class PushSyncUpdate { 33 | private final String source; 34 | private final String identityPoolId; 35 | private final String identityId; 36 | private final String datasetName; 37 | private final long syncCount; 38 | 39 | PushSyncUpdate(Intent intent) { 40 | if(!isPushSyncUpdate(intent)) { 41 | throw new InvalidParameterException("Invalid bundle, only messages from Cognito for push sync are valid"); 42 | } 43 | else { 44 | Bundle extras = intent.getExtras(); 45 | this.source = extras.getString("source"); 46 | this.identityPoolId = extras.getString("identityPoolId"); 47 | this.identityId = extras.getString("identityId"); 48 | this.datasetName = extras.getString("datasetName"); 49 | this.syncCount = Long.parseLong(extras.getString("syncCount")); 50 | } 51 | } 52 | 53 | /** 54 | * Gets the source of the notification, 'cognito-sync' from push sync 55 | */ 56 | public String getSource() { 57 | return source; 58 | } 59 | 60 | /** 61 | * Gets the identity id for which the change was made 62 | */ 63 | public String getIdentityId() { 64 | return identityId; 65 | } 66 | 67 | /** 68 | * Gets the identity pool in which the user belongs 69 | */ 70 | public String getIdentityPoolId() { 71 | return identityPoolId; 72 | } 73 | 74 | /** 75 | * Gets the name of the changed datset 76 | */ 77 | public String getDatasetName() { 78 | return datasetName; 79 | } 80 | 81 | /** 82 | * Gets the sync count of the changed dataset 83 | */ 84 | public long getSyncCount() { 85 | return syncCount; 86 | } 87 | 88 | /** 89 | * A helper to determine if the intent in question is one received from 90 | * Cognito for a push sync update to a dataset. If there's question, this should 91 | * be called before creating a push sync object, as if it is not valid, that object 92 | * will be null. 93 | * 94 | * @param intent the intent to check the validity of format of 95 | * @return true if it's a push sync update, false if not. 96 | */ 97 | public static boolean isPushSyncUpdate(Intent intent){ 98 | return intent != null && (intent.hasExtra("source") && intent.hasExtra("identityPoolId") 99 | && intent.hasExtra("identityId") && intent.hasExtra("datasetName") && intent.hasExtra("syncCount")); 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/mobileconnectors/cognito/Record.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-2016 Amazon.com, 3 | * Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Licensed under the Amazon Software License (the "License"). 6 | * You may not use this file except in compliance with the 7 | * License. A copy of the License is located at 8 | * 9 | * http://aws.amazon.com/asl/ 10 | * 11 | * or in the "license" file accompanying this file. This file is 12 | * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13 | * CONDITIONS OF ANY KIND, express or implied. See the License 14 | * for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.amazonaws.mobileconnectors.cognito; 19 | 20 | import com.amazonaws.mobileconnectors.cognito.internal.util.StringUtils; 21 | 22 | import java.util.Date; 23 | 24 | /** 25 | * A Record is the element stored in a {@link Dataset}. There can be up to 1k 26 | * records or up to 1 MB in size in a {@link Dataset}. 27 | */ 28 | public final class Record { 29 | /** 30 | * The key of this record. It's a non empty string. 31 | */ 32 | private final String key; 33 | /** 34 | * The value of this record. If it's null, then the record is considered as 35 | * deleted. 36 | */ 37 | private final String value; 38 | /** 39 | * Equivalent to the version of this record. It's a increasing non negative 40 | * long number. The value is returned from server. Do not set this value 41 | * arbitrarily, or else update may fail. 42 | */ 43 | private final long syncCount; 44 | /** 45 | * The server timestamp of this record when it was last modified. 46 | */ 47 | private final Date lastModifiedDate; 48 | /** 49 | * An identifier of the user or device which modified this record last. 50 | */ 51 | private final String lastModifiedBy; 52 | /** 53 | * The local timestamp of this record when it was last modified. 54 | */ 55 | private final Date deviceLastModifiedDate; 56 | /** 57 | * A flag that indicates whether this record is modified locally but hasn't 58 | * been synced. 59 | */ 60 | private final boolean modified; 61 | 62 | /** 63 | * Gets the key of this record. It's a non empty string. 64 | * 65 | * @return key of this record 66 | */ 67 | public String getKey() { 68 | return key; 69 | } 70 | 71 | /** 72 | * Gets the value of this record. If it's null, then the record is 73 | * considered as deleted. 74 | * 75 | * @return nullable String value of this record 76 | */ 77 | public String getValue() { 78 | return value; 79 | } 80 | 81 | /** 82 | * Gets the sync count of this record. It's equivalent to the version of 83 | * this record. It's a increasing non negative long number. The value is 84 | * returned from server. Do not set this value arbitrarily, or else update 85 | * may fail. 86 | * 87 | * @return sync count of this record 88 | */ 89 | public long getSyncCount() { 90 | return syncCount; 91 | } 92 | 93 | /** 94 | * Gets the server timestamp of this record when it was last modified. 95 | * 96 | * @return the server timestamp when it was last modified. 97 | */ 98 | public Date getLastModifiedDate() { 99 | return new Date(lastModifiedDate.getTime()); 100 | } 101 | 102 | /** 103 | * Gets the identifier of the user or device which modified this record 104 | * last. 105 | * 106 | * @return an identifier of the user or device which made the last 107 | * modification 108 | */ 109 | public String getLastModifiedBy() { 110 | return lastModifiedBy; 111 | } 112 | 113 | /** 114 | * Gets the local timestamp of this record when it was last modified. 115 | * 116 | * @return the local timestamp of the device that made the last modification 117 | */ 118 | public Date getDeviceLastModifiedDate() { 119 | return new Date(deviceLastModifiedDate.getTime()); 120 | } 121 | 122 | /** 123 | * Gets a flag that indicates whether this record is modified locally but 124 | * hasn't been synced. 125 | * 126 | * @return the modified flag of this record 127 | */ 128 | public boolean isModified() { 129 | return modified; 130 | } 131 | 132 | /** 133 | * Gets whether the record is marked as deleted. True if value is null, 134 | * false otherwise. 135 | * 136 | * @return true if the record is marked as deleted, false otherwise. 137 | */ 138 | public boolean isDeleted() { 139 | return value == null; 140 | } 141 | 142 | /** 143 | * A private constructor for the {@link Builder} to build a new Record 144 | * object. 145 | * 146 | * @param builder a {@link Builder} object 147 | */ 148 | private Record(Builder builder) { 149 | key = builder.key; 150 | value = builder.value; 151 | syncCount = builder.syncCount; 152 | lastModifiedDate = builder.lastModifiedDate == null 153 | ? new Date() 154 | : new Date(builder.lastModifiedDate.getTime()); 155 | lastModifiedBy = builder.lastModifiedBy; 156 | deviceLastModifiedDate = builder.deviceLastModifiedDate == null 157 | ? new Date() 158 | : new Date(builder.deviceLastModifiedDate.getTime()); 159 | modified = builder.modified; 160 | } 161 | 162 | /** 163 | * A Builder class that helps build an immutable {@link Record} object. 164 | */ 165 | public final static class Builder { 166 | private final String key; 167 | private String value; 168 | private long syncCount; 169 | private Date lastModifiedDate; 170 | private String lastModifiedBy; 171 | private Date deviceLastModifiedDate; 172 | private boolean modified; 173 | 174 | /** 175 | * Construct a builder object for the new {@link Record} with given key. 176 | * 177 | * @param key Non empty String key of the record 178 | */ 179 | public Builder(String key) { 180 | if (StringUtils.isEmpty(key)) { 181 | throw new IllegalArgumentException("key can't be empty"); 182 | } 183 | this.key = key; 184 | } 185 | 186 | /** 187 | * Sets the value of the new {@link Record}. Default is null, aka 188 | * deleted record. 189 | * 190 | * @param value nullable String value of this record 191 | * @return builder itself 192 | */ 193 | public Builder value(String value) { 194 | this.value = value; 195 | return this; 196 | } 197 | 198 | /** 199 | * Sets the syncCount of the new {@link Record}. Default is the current 200 | * time. 201 | * 202 | * @param syncCount non negative long value 203 | * @return builder itself 204 | */ 205 | public Builder syncCount(long syncCount) { 206 | if (syncCount < 0) { 207 | throw new IllegalArgumentException("sync count can't be negative"); 208 | } 209 | this.syncCount = syncCount; 210 | return this; 211 | } 212 | 213 | /** 214 | * Sets the last modified date of this {@link Record}. Default is the 215 | * current time. 216 | * 217 | * @param lastModifiedDate last modified date of this record 218 | * @return builder itself 219 | */ 220 | public Builder lastModifiedDate(Date lastModifiedDate) { 221 | this.lastModifiedDate = lastModifiedDate; 222 | return this; 223 | } 224 | 225 | /** 226 | * Sets the last modified by of this {@link Record}. Default is empty 227 | * string. 228 | * 229 | * @param lastModifiedBy device name or user name that last modified 230 | * this record. 231 | * @return builder itself 232 | */ 233 | public Builder lastModifiedBy(String lastModifiedBy) { 234 | this.lastModifiedBy = lastModifiedBy; 235 | return this; 236 | } 237 | 238 | /** 239 | * Sets the device last modified date of this {@link Record}. It's the 240 | * local date of the device that modified this record. Default is the 241 | * current date. 242 | * 243 | * @param deviceLastModifiedDate device last modified date 244 | * @return builder itself 245 | */ 246 | public Builder deviceLastModifiedDate(Date deviceLastModifiedDate) { 247 | this.deviceLastModifiedDate = deviceLastModifiedDate; 248 | return this; 249 | } 250 | 251 | /** 252 | * Sets whether this {@link Record} has local modification. 253 | * 254 | * @param modified a flag that indicates whether the record has local 255 | * modification 256 | * @return builder itself 257 | */ 258 | public Builder modified(boolean modified) { 259 | this.modified = modified; 260 | return this; 261 | } 262 | 263 | /** 264 | * Builds a new {@link Record}. 265 | * 266 | * @return a new {@link Record} object 267 | */ 268 | public Record build() { 269 | return new Record(this); 270 | } 271 | } 272 | 273 | @Override 274 | public String toString() { 275 | StringBuilder sb = new StringBuilder(); 276 | sb.append("key:[").append(key).append("],") 277 | .append("value:[").append(value).append("],") 278 | .append("sync_count:[").append(syncCount).append("],") 279 | .append("last_modified_date:[").append(lastModifiedDate).append("],") 280 | .append("last_modified_by:[").append(lastModifiedBy).append("],") 281 | .append("device_last_modified_date:[").append(deviceLastModifiedDate).append("],") 282 | .append("last_modified_by:[").append(lastModifiedBy).append("],") 283 | .append("is_modified:[").append(modified).append("]"); 284 | return sb.toString(); 285 | } 286 | } 287 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/mobileconnectors/cognito/SyncConflict.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-2016 Amazon.com, 3 | * Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Licensed under the Amazon Software License (the "License"). 6 | * You may not use this file except in compliance with the 7 | * License. A copy of the License is located at 8 | * 9 | * http://aws.amazon.com/asl/ 10 | * 11 | * or in the "license" file accompanying this file. This file is 12 | * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13 | * CONDITIONS OF ANY KIND, express or implied. See the License 14 | * for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.amazonaws.mobileconnectors.cognito; 19 | 20 | import java.util.Date; 21 | 22 | /** 23 | * This consists of the conflicting record from the remote storage and the local 24 | * storage. 25 | */ 26 | public class SyncConflict { 27 | private final String key; 28 | private final Record remoteRecord; 29 | private final Record localRecord; 30 | 31 | /** 32 | * Constructs a SyncConflict object. 33 | * 34 | * @param remoteRecord record from remote storage 35 | * @param localRecord record from local storage 36 | */ 37 | public SyncConflict(Record remoteRecord, Record localRecord) { 38 | if (remoteRecord == null || localRecord == null) { 39 | throw new IllegalArgumentException("record can't be null"); 40 | } 41 | if (!remoteRecord.getKey().equals(localRecord.getKey())) { 42 | throw new IllegalArgumentException( 43 | "the keys of remote record and local record don't match"); 44 | } 45 | this.key = remoteRecord.getKey(); 46 | this.remoteRecord = remoteRecord; 47 | this.localRecord = localRecord; 48 | } 49 | 50 | /** 51 | * Gets the key of the record that is in conflict. 52 | * 53 | * @return key of the record 54 | */ 55 | public String getKey() { 56 | return key; 57 | } 58 | 59 | /** 60 | * Gets the remote record that is in conflict. 61 | * 62 | * @return record from remote storage 63 | */ 64 | public Record getRemoteRecord() { 65 | return remoteRecord; 66 | } 67 | 68 | /** 69 | * Gets the local record that is in conflict. 70 | * 71 | * @return record from local storage 72 | */ 73 | public Record getLocalRecord() { 74 | return localRecord; 75 | } 76 | 77 | /** 78 | * Resolves conflict with remote record 79 | * 80 | * @return resolved record 81 | */ 82 | public Record resolveWithRemoteRecord() { 83 | return new Record.Builder(key) 84 | .value(remoteRecord.getValue()) 85 | .syncCount(remoteRecord.getSyncCount()) 86 | .lastModifiedDate(remoteRecord.getLastModifiedDate()) 87 | .lastModifiedBy(remoteRecord.getLastModifiedBy()) 88 | .deviceLastModifiedDate(remoteRecord.getDeviceLastModifiedDate()) 89 | .modified(false) 90 | .build(); 91 | } 92 | 93 | /** 94 | * Resolves conflict with local record 95 | * 96 | * @return resolved record 97 | */ 98 | public Record resolveWithLocalRecord() { 99 | return new Record.Builder(key) 100 | .value(localRecord.getValue()) 101 | .syncCount(remoteRecord.getSyncCount()) 102 | .lastModifiedDate(localRecord.getLastModifiedDate()) 103 | .lastModifiedBy(localRecord.getLastModifiedBy()) 104 | .deviceLastModifiedDate(localRecord.getDeviceLastModifiedDate()) 105 | .modified(true) 106 | .build(); 107 | } 108 | 109 | /** 110 | * Resolves conflict with a new value. 111 | * 112 | * @param newValue new value of the record 113 | * @return resolved record 114 | */ 115 | public Record resolveWithValue(String newValue) { 116 | Date now = new Date(); 117 | return new Record.Builder(key) 118 | .value(newValue) 119 | .syncCount(remoteRecord.getSyncCount()) 120 | .lastModifiedDate(now) 121 | .lastModifiedBy(localRecord.getLastModifiedBy()) 122 | .deviceLastModifiedDate(now) 123 | .modified(true) 124 | .build(); 125 | } 126 | 127 | /** 128 | * Resolves conflict with last writer wins. The record with a later last 129 | * modified date wins the conflict. 130 | * 131 | * @return the record that has a later last modified date. 132 | */ 133 | public Record resolveWithLastWriterWins() { 134 | return remoteRecord.getLastModifiedDate().after(localRecord.getLastModifiedDate()) ? 135 | resolveWithRemoteRecord() : resolveWithLocalRecord(); 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/mobileconnectors/cognito/exceptions/DataAccessNotAuthorizedException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-2016 Amazon.com, 3 | * Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Licensed under the Amazon Software License (the "License"). 6 | * You may not use this file except in compliance with the 7 | * License. A copy of the License is located at 8 | * 9 | * http://aws.amazon.com/asl/ 10 | * 11 | * or in the "license" file accompanying this file. This file is 12 | * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13 | * CONDITIONS OF ANY KIND, express or implied. See the License 14 | * for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.amazonaws.mobileconnectors.cognito.exceptions; 19 | 20 | /** 21 | * This exception is thrown when the data set of interest is not authorized to 22 | * be accessed 23 | */ 24 | public class DataAccessNotAuthorizedException extends DataStorageException { 25 | 26 | private static final long serialVersionUID = 5067700802587075978L; 27 | 28 | public DataAccessNotAuthorizedException(String detailMessage, Throwable throwable) { 29 | super(detailMessage, throwable); 30 | } 31 | 32 | public DataAccessNotAuthorizedException(String detailMessage) { 33 | super(detailMessage); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/mobileconnectors/cognito/exceptions/DataConflictException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-2016 Amazon.com, 3 | * Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Licensed under the Amazon Software License (the "License"). 6 | * You may not use this file except in compliance with the 7 | * License. A copy of the License is located at 8 | * 9 | * http://aws.amazon.com/asl/ 10 | * 11 | * or in the "license" file accompanying this file. This file is 12 | * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13 | * CONDITIONS OF ANY KIND, express or implied. See the License 14 | * for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.amazonaws.mobileconnectors.cognito.exceptions; 19 | 20 | /** 21 | * This exception is thrown when an update fails due to conflicting states. 22 | */ 23 | public class DataConflictException extends DataStorageException { 24 | 25 | private static final long serialVersionUID = 4937963535057299466L; 26 | 27 | public DataConflictException(String detailMessage, Throwable throwable) { 28 | super(detailMessage, throwable); 29 | } 30 | 31 | public DataConflictException(String detailMessage) { 32 | super(detailMessage); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/mobileconnectors/cognito/exceptions/DataLimitExceededException.java: -------------------------------------------------------------------------------- 1 | 2 | package com.amazonaws.mobileconnectors.cognito.exceptions; 3 | 4 | /** 5 | * This exception is thrown when the dataset operation exceeds certain limit, 6 | * e.g. maximum of 20 datasets per identity, 1024 records per dataset, and 1mb 7 | * in size per dataset, etc. 8 | */ 9 | public class DataLimitExceededException extends DataStorageException { 10 | 11 | private static final long serialVersionUID = 4722137117318719134L; 12 | 13 | public DataLimitExceededException(String detailMessage, Throwable throwable) { 14 | super(detailMessage, throwable); 15 | } 16 | 17 | public DataLimitExceededException(String detailMessage) { 18 | super(detailMessage); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/mobileconnectors/cognito/exceptions/DataStorageException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-2016 Amazon.com, 3 | * Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Licensed under the Amazon Software License (the "License"). 6 | * You may not use this file except in compliance with the 7 | * License. A copy of the License is located at 8 | * 9 | * http://aws.amazon.com/asl/ 10 | * 11 | * or in the "license" file accompanying this file. This file is 12 | * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13 | * CONDITIONS OF ANY KIND, express or implied. See the License 14 | * for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.amazonaws.mobileconnectors.cognito.exceptions; 19 | 20 | import com.amazonaws.AmazonClientException; 21 | 22 | /** 23 | * This exception is thrown when an error occurs during an data storage 24 | * operation. 25 | */ 26 | public class DataStorageException extends AmazonClientException { 27 | 28 | private static final long serialVersionUID = -6906342391685175623L; 29 | 30 | public DataStorageException(String detailMessage, Throwable throwable) { 31 | super(detailMessage, throwable); 32 | } 33 | 34 | public DataStorageException(String detailMessage) { 35 | super(detailMessage); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/mobileconnectors/cognito/exceptions/DatasetNotFoundException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-2016 Amazon.com, 3 | * Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Licensed under the Amazon Software License (the "License"). 6 | * You may not use this file except in compliance with the 7 | * License. A copy of the License is located at 8 | * 9 | * http://aws.amazon.com/asl/ 10 | * 11 | * or in the "license" file accompanying this file. This file is 12 | * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13 | * CONDITIONS OF ANY KIND, express or implied. See the License 14 | * for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.amazonaws.mobileconnectors.cognito.exceptions; 19 | 20 | /** 21 | * This exception is thrown when the dataset that is attempted to access does 22 | * not exist. 23 | */ 24 | public class DatasetNotFoundException extends DataStorageException { 25 | 26 | private static final long serialVersionUID = -5043074429464815354L; 27 | 28 | public DatasetNotFoundException(String detailMessage, Throwable throwable) { 29 | super(detailMessage, throwable); 30 | } 31 | 32 | public DatasetNotFoundException(String detailMessage) { 33 | super(detailMessage); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/mobileconnectors/cognito/exceptions/NetworkException.java: -------------------------------------------------------------------------------- 1 | 2 | package com.amazonaws.mobileconnectors.cognito.exceptions; 3 | 4 | /** 5 | * This exception is thrown when a service request failed due to network 6 | * connectivity problem. 7 | */ 8 | public class NetworkException extends DataStorageException { 9 | 10 | private static final long serialVersionUID = 8685123233927843893L; 11 | 12 | public NetworkException(String detailMessage, Throwable throwable) { 13 | super(detailMessage, throwable); 14 | } 15 | 16 | public NetworkException(String detailMessage) { 17 | super(detailMessage); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/mobileconnectors/cognito/exceptions/RegistrationFailedException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-2016 Amazon.com, 3 | * Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Licensed under the Amazon Software License (the "License"). 6 | * You may not use this file except in compliance with the 7 | * License. A copy of the License is located at 8 | * 9 | * http://aws.amazon.com/asl/ 10 | * 11 | * or in the "license" file accompanying this file. This file is 12 | * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13 | * CONDITIONS OF ANY KIND, express or implied. See the License 14 | * for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.amazonaws.mobileconnectors.cognito.exceptions; 19 | 20 | import com.amazonaws.AmazonClientException; 21 | 22 | /** 23 | * An exception thrown when a registration of a device for silentsync fails 24 | */ 25 | public class RegistrationFailedException extends AmazonClientException { 26 | private static final long serialVersionUID = 5706724903415180392L; 27 | 28 | public RegistrationFailedException(String message, Throwable throwable) { 29 | super(message, throwable); 30 | } 31 | 32 | public RegistrationFailedException(String message) { 33 | super(message); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/mobileconnectors/cognito/exceptions/SubscribeFailedException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-2016 Amazon.com, 3 | * Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Licensed under the Amazon Software License (the "License"). 6 | * You may not use this file except in compliance with the 7 | * License. A copy of the License is located at 8 | * 9 | * http://aws.amazon.com/asl/ 10 | * 11 | * or in the "license" file accompanying this file. This file is 12 | * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13 | * CONDITIONS OF ANY KIND, express or implied. See the License 14 | * for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.amazonaws.mobileconnectors.cognito.exceptions; 19 | 20 | import com.amazonaws.AmazonClientException; 21 | 22 | /** 23 | * An exception that's thrown when the subscription to a silent sync dataset 24 | * fails 25 | */ 26 | public class SubscribeFailedException extends AmazonClientException { 27 | private static final long serialVersionUID = 5706724903415180392L; 28 | 29 | public SubscribeFailedException(String message, Throwable throwable) { 30 | super(message, throwable); 31 | } 32 | 33 | public SubscribeFailedException(String message) { 34 | super(message); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/mobileconnectors/cognito/exceptions/UnsubscribeFailedException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-2016 Amazon.com, 3 | * Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Licensed under the Amazon Software License (the "License"). 6 | * You may not use this file except in compliance with the 7 | * License. A copy of the License is located at 8 | * 9 | * http://aws.amazon.com/asl/ 10 | * 11 | * or in the "license" file accompanying this file. This file is 12 | * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13 | * CONDITIONS OF ANY KIND, express or implied. See the License 14 | * for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.amazonaws.mobileconnectors.cognito.exceptions; 19 | 20 | import com.amazonaws.AmazonClientException; 21 | 22 | /** 23 | * An exception thrown when silent sync dataset unsubscription fails 24 | */ 25 | public class UnsubscribeFailedException extends AmazonClientException { 26 | 27 | private static final long serialVersionUID = 5706724903415180392L; 28 | 29 | public UnsubscribeFailedException(String message, Throwable throwable) { 30 | super(message, throwable); 31 | } 32 | 33 | public UnsubscribeFailedException(String message) { 34 | super(message); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/mobileconnectors/cognito/exceptions/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Cognito mobile connector related exception classes. 3 | */ 4 | 5 | package com.amazonaws.mobileconnectors.cognito.exceptions; 6 | 7 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/mobileconnectors/cognito/internal/storage/LocalStorage.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-2016 Amazon.com, 3 | * Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Licensed under the Amazon Software License (the "License"). 6 | * You may not use this file except in compliance with the 7 | * License. A copy of the License is located at 8 | * 9 | * http://aws.amazon.com/asl/ 10 | * 11 | * or in the "license" file accompanying this file. This file is 12 | * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13 | * CONDITIONS OF ANY KIND, express or implied. See the License 14 | * for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.amazonaws.mobileconnectors.cognito.internal.storage; 19 | 20 | import com.amazonaws.mobileconnectors.cognito.Dataset; 21 | import com.amazonaws.mobileconnectors.cognito.DatasetMetadata; 22 | import com.amazonaws.mobileconnectors.cognito.Record; 23 | import com.amazonaws.mobileconnectors.cognito.exceptions.DataStorageException; 24 | import com.amazonaws.mobileconnectors.cognito.exceptions.DatasetNotFoundException; 25 | 26 | import java.util.List; 27 | import java.util.Map; 28 | 29 | /** 30 | * The interface of local storage of {@link Dataset}. 31 | */ 32 | public interface LocalStorage { 33 | 34 | /** 35 | * Retrieves the string value of a key in dataset. The value can be null 36 | * when the record doesn't exist or is marked as deleted. 37 | * 38 | * @param identityId identity id 39 | * @param datasetName dataset name 40 | * @param key key of the record 41 | * @return string value of the record, or null if not present or deleted. 42 | */ 43 | public String getValue(String identityId, String datasetName, String key); 44 | 45 | /** 46 | * Puts the value of a key in dataset. If a new value is assigned to the 47 | * key, the record is marked as dirty. If the value is null, then the record 48 | * is marked as deleted. The changed record will be synced with remote 49 | * storage. 50 | * 51 | * @param identityId identity id 52 | * @param datasetName dataset name 53 | * @param key key of the record 54 | * @param value string value. If null, the record is marked as deleted. 55 | */ 56 | public void putValue(String identityId, String datasetName, String key, String value); 57 | 58 | /** 59 | * Retrieves a key-value map from dataset, excluding marked as deleted 60 | * values. 61 | * 62 | * @param identityId identity id 63 | * @param dataset dataset name 64 | * @return a key-value map of all but deleted values 65 | */ 66 | public Map getValueMap(String identityId, String datasetName); 67 | 68 | /** 69 | * Puts a key-value map into a dataset. This is optimized for batch 70 | * operation. It's the preferred way to put a list of records into dataset. 71 | * 72 | * @param identityId identity id 73 | * @param datasetName dataset name 74 | * @param values a key-value map 75 | */ 76 | public void putAllValues(String identityId, String datasetName, Map values); 77 | 78 | /** 79 | * Gets a raw record from local store. If the dataset/key combo doesn't 80 | * exist, null will be returned. 81 | * 82 | * @param identityId identity id 83 | * @param datasetName dataset name 84 | * @param key key of the record 85 | * @return a Record object if found, null otherwise. 86 | */ 87 | public Record getRecord(String identityId, String datasetName, String key); 88 | 89 | /** 90 | * Gets a list of all records. 91 | * 92 | * @param identityId identity id 93 | * @param datasetName the dataset name 94 | * @return A list of records which have been updated since lastSyncCount. 95 | */ 96 | public List getRecords(String identityId, String datasetName); 97 | 98 | /** 99 | * Retrieves a list of locally modified records since last successful sync 100 | * operation. 101 | * 102 | * @param identityId identity id 103 | * @param datasetName dataset name 104 | * @return a list of locally modified records 105 | */ 106 | public List getModifiedRecords(String identityId, String datasetName); 107 | 108 | /** 109 | * Puts a list of raw records into dataset. 110 | * 111 | * @param identityId identity id 112 | * @param datasetName dataset name 113 | * @param records a list of records 114 | */ 115 | public void putRecords(String identityId, String datasetName, List records); 116 | 117 | /** 118 | * Puts a list of raw records into thet dataset if 119 | * the local version hasn't changed (to be used in 120 | * synchronizations). 121 | * 122 | * @param identityId identity id 123 | * @param datasetName dataset name 124 | * @param records a list of records to conditionally put 125 | * @param localRecords a list of records to check for changes 126 | */ 127 | public void conditionallyPutRecords(String identityId, String datasetName, 128 | List records, List localRecords); 129 | 130 | /** 131 | * Gets a list of datasets. 132 | * 133 | * @param identityId identity id 134 | * @return a list of dataset metadata 135 | */ 136 | public List getDatasets(String identityId) throws DataStorageException; 137 | 138 | /** 139 | * Deletes a dataset. It clears all records in this dataset and marked it as 140 | * deleted for future sync. It's still visible in {@link #getDatasets()} 141 | * 142 | * @param identityId identity id 143 | * @param datasetName non empty dataset name 144 | */ 145 | public void deleteDataset(String identityId, String datasetName) 146 | throws DatasetNotFoundException; 147 | 148 | /** 149 | * This is different from {@link #deleteDataset(String)}. Not only does it 150 | * clears all records in the dataset, it also remove it from metadata table. 151 | * It won't be visible in {@link #getDatasets()}. 152 | * 153 | * @param identityId identity id 154 | * @param datasetName non empty dataset name 155 | */ 156 | public void purgeDataset(String identityId, String datasetName); 157 | 158 | /** 159 | * Retrieves the metadata of a dataset. 160 | * 161 | * @param identityId identity id 162 | * @param datasetName dataset name 163 | * @return the corresponding metadata 164 | * @throws DataStorageException 165 | */ 166 | public DatasetMetadata getDatasetMetadata(String identityId, String datasetName) 167 | throws DataStorageException; 168 | 169 | /** 170 | * Retrieves the last sync count. This sync count is a counter that 171 | * represents when the last sync happened. The counter should be updated on 172 | * a successful sync. 173 | * 174 | * @param identityId identity id 175 | * @param datasetName dataset name 176 | * @return last sync count. 177 | */ 178 | public long getLastSyncCount(String identityId, String datasetName); 179 | 180 | /** 181 | * Updates the last sync count after successful sync with the remote data 182 | * store. 183 | * 184 | * @param identityId identity id 185 | * @param datasetName dataset name 186 | * @param lastSyncCount new last sync count value 187 | */ 188 | public void updateLastSyncCount(String identityId, String datasetName, long lastSyncCount); 189 | 190 | /** 191 | * Wipes all locally cached data including dataset metadata and records. All 192 | * opened dataset handler should not perform further operations to avoid 193 | * inconsistent state. 194 | */ 195 | public void wipeData(); 196 | 197 | /** 198 | * Reparent all datasets from old identity id to a new one. 199 | * 200 | * @param oldIdentityId old identity id 201 | * @param newIdentityId new identity id 202 | */ 203 | public void changeIdentityId(String oldIdentityId, String newIdentityId); 204 | 205 | /** 206 | * Updates local dataset metadata 207 | * 208 | * @param identityId identity id 209 | * @param datasetMetadata a list of metadata to update 210 | */ 211 | public void updateDatasetMetadata(String identityId, List datasetMetadata); 212 | } 213 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/mobileconnectors/cognito/internal/storage/RemoteDataStorage.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-2016 Amazon.com, 3 | * Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Licensed under the Amazon Software License (the "License"). 6 | * You may not use this file except in compliance with the 7 | * License. A copy of the License is located at 8 | * 9 | * http://aws.amazon.com/asl/ 10 | * 11 | * or in the "license" file accompanying this file. This file is 12 | * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13 | * CONDITIONS OF ANY KIND, express or implied. See the License 14 | * for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.amazonaws.mobileconnectors.cognito.internal.storage; 19 | 20 | import com.amazonaws.mobileconnectors.cognito.Dataset; 21 | import com.amazonaws.mobileconnectors.cognito.DatasetMetadata; 22 | import com.amazonaws.mobileconnectors.cognito.Record; 23 | import com.amazonaws.mobileconnectors.cognito.exceptions.DataConflictException; 24 | import com.amazonaws.mobileconnectors.cognito.exceptions.DataStorageException; 25 | import com.amazonaws.mobileconnectors.cognito.exceptions.DatasetNotFoundException; 26 | 27 | import java.util.List; 28 | 29 | /** 30 | * The interface of remote storage of {@link Dataset}. 31 | */ 32 | public interface RemoteDataStorage { 33 | 34 | /** 35 | * Gets a list of {@link DatasetMetadata}s. 36 | * 37 | * @return a list of dataset metadata 38 | */ 39 | public List getDatasets() throws DataStorageException; 40 | 41 | /** 42 | * Retrieves the metadata of a dataset. 43 | * 44 | * @param datasetName dataset name 45 | * @return the corresponding metadata 46 | * @throws DataStorageException 47 | */ 48 | public DatasetMetadata getDatasetMetadata(String datasetName) throws DataStorageException; 49 | 50 | /** 51 | * Gets a list of records which have been updated since lastSyncCount 52 | * (inclusive). If the value of a record equals null, then the record is 53 | * deleted. If you pass 0 as lastSyncCount, the full list of records will be 54 | * returned. 55 | * 56 | * @param datasetName the dataset name 57 | * @param lastSyncCount non negative long integer 58 | * @return A list of records which have been updated since lastSyncCount. 59 | */ 60 | public DatasetUpdates listUpdates(String datasetName, long lastSyncCount) 61 | throws DataStorageException; 62 | 63 | /** 64 | * Post updates to remote storage. Each record has a sync count. If the sync 65 | * count doesn't match what's on the remote storage, i.e. the record is 66 | * modified by a different device, this operation throws ConflictException. 67 | * Otherwise it returns a list of records that are updated successfully. 68 | * 69 | * @param datasetName the dataset name 70 | * @param records list of records to be updated remotely 71 | * @param syncSessionToken the sync session token retrieved from 72 | * {@link #listUpdates(String, long)} 73 | * @param deviceId the string deviceId for use with push sync updates, null 74 | * otherwise 75 | */ 76 | public List putRecords(String datasetName, List records, 77 | String syncSessionToken, String deviceId) 78 | throws DatasetNotFoundException, DataConflictException; 79 | 80 | /** 81 | * Unsubscribes the user from receiving notifications from a dataset they 82 | * had been previously subscribed to. 83 | * 84 | * @param datasetName the name of the dataset to be unsubscribed from 85 | * @param deviceId the id of the device to unsubscribe 86 | */ 87 | public void unsubscribeFromDataset(String datasetName, String deviceId); 88 | 89 | /** 90 | * Subscribes the user to update notifications for a dataset. This should 91 | * only be called after the device has been registered. 92 | * 93 | * @param datasetName the name of the dataset to be subscribed to 94 | * @param deviceId the id of the device to subscribe 95 | */ 96 | public void subscribeToDataset(String datasetName, String deviceId); 97 | 98 | /** 99 | * Deletes a dataset. 100 | * 101 | * @param datasetName 102 | */ 103 | public void deleteDataset(String datasetName) throws DatasetNotFoundException; 104 | 105 | public interface DatasetUpdates { 106 | public String getDatasetName(); 107 | 108 | public List getRecords(); 109 | 110 | /** 111 | * Gets the sync session token 112 | * 113 | * @return 114 | */ 115 | public String getSyncSessionToken(); 116 | 117 | public long getSyncCount(); 118 | 119 | public boolean isExists(); 120 | 121 | public boolean isDeleted(); 122 | 123 | public List getMergedDatasetNameList(); 124 | 125 | } 126 | 127 | } 128 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/mobileconnectors/cognito/internal/util/DatasetUtils.java: -------------------------------------------------------------------------------- 1 | 2 | package com.amazonaws.mobileconnectors.cognito.internal.util; 3 | 4 | import com.amazonaws.auth.CognitoCachingCredentialsProvider; 5 | import com.amazonaws.mobileconnectors.cognito.Record; 6 | 7 | import java.util.regex.Pattern; 8 | 9 | /** 10 | * A utility class for datasets objects. 11 | */ 12 | public final class DatasetUtils { 13 | 14 | /** 15 | * Valid dataset name pattern 16 | */ 17 | public static final Pattern DATASET_NAME_PATTERN = Pattern.compile("^[a-zA-Z0-9_.:-]{1,128}$"); 18 | /** 19 | * Unknown identity id when the identity id is null 20 | */ 21 | public static final String UNKNOWN_IDENTITY_ID = "unknown"; 22 | 23 | /** 24 | * Validates the dataset name. 25 | * 26 | * @param datasetName the dataset name to be validated 27 | * @return 28 | */ 29 | public static String validateDatasetName(String datasetName) { 30 | if (!DATASET_NAME_PATTERN.matcher(datasetName).matches()) { 31 | throw new IllegalArgumentException("Invalid dataset name"); 32 | } 33 | return datasetName; 34 | } 35 | 36 | /** 37 | * Validates the record key. It must be non empty and its length must be no 38 | * greater than 128. Otherwise {@link IllegalArgumentException} will be 39 | * thrown. 40 | * 41 | * @param key the record key to be validated 42 | * @return the key itself 43 | */ 44 | public static String validateRecordKey(String key) { 45 | if (StringUtils.isEmpty(key) || StringUtils.utf8ByteLength(key) > 128) { 46 | throw new IllegalArgumentException("Invalid record key"); 47 | } 48 | return key; 49 | } 50 | 51 | /** 52 | * A helper function to compute record size which equals the sum of the 53 | * UTF-8 string length of record key and value. 0 if record is null. 54 | * 55 | * @param record record to compute length 56 | * @return the sum UTF-8 string length of record key and value. 57 | */ 58 | public static long computeRecordSize(Record record) { 59 | if (record == null) { 60 | return 0; 61 | } 62 | return StringUtils.utf8ByteLength(record.getKey()) 63 | + StringUtils.utf8ByteLength(record.getValue()); 64 | } 65 | 66 | /** 67 | * A helper function to get the identity id of the dataset from credentials 68 | * provider. If the identity id is null, UNKNOWN_IDENTITY_ID will be 69 | * returned. 70 | * 71 | * @return the identity id associated with this dataset 72 | */ 73 | public static String getIdentityId(CognitoCachingCredentialsProvider provider) { 74 | return provider.getCachedIdentityId() == null 75 | ? UNKNOWN_IDENTITY_ID 76 | : provider.getCachedIdentityId(); 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/mobileconnectors/cognito/internal/util/StringUtils.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-2016 Amazon.com, 3 | * Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Licensed under the Amazon Software License (the "License"). 6 | * You may not use this file except in compliance with the 7 | * License. A copy of the License is located at 8 | * 9 | * http://aws.amazon.com/asl/ 10 | * 11 | * or in the "license" file accompanying this file. This file is 12 | * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13 | * CONDITIONS OF ANY KIND, express or implied. See the License 14 | * for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.amazonaws.mobileconnectors.cognito.internal.util; 19 | 20 | import java.nio.charset.Charset; 21 | 22 | /** 23 | * A utility class of String objects. 24 | */ 25 | public final class StringUtils { 26 | /** 27 | * UTF-8 {@link Charset} 28 | */ 29 | private static final Charset UTF_8 = Charset.forName("UTF-8"); 30 | 31 | /** 32 | * Calculates the byte length of a UTF-8 encoded string. 0 if the string is 33 | * null. 34 | * 35 | * @param string string to be computed 36 | * @return byte length of a UTF-8 string in bytes, 0 if null. 37 | */ 38 | public static long utf8ByteLength(String string) { 39 | if (string == null) { 40 | return 0; 41 | } 42 | return string.getBytes(UTF_8).length; 43 | } 44 | 45 | /** 46 | * Checks whether a String is empty. 47 | * 48 | * @param string a string to check 49 | * @return true if the string is null or empty, false otherwise 50 | */ 51 | public static boolean isEmpty(String string) { 52 | return string == null || string.trim().isEmpty(); 53 | } 54 | 55 | /** 56 | * Compares two Strings. Returns true if both are null or have the same 57 | * string value. 58 | * 59 | * @param s1 first string, can be null 60 | * @param s2 second string, can be null 61 | * @return true if both are null or have the same string value, false 62 | * otherwise 63 | */ 64 | public static boolean equals(String s1, String s2) { 65 | if (s1 == null) { 66 | return s2 == null; 67 | } else { 68 | return s1.equals(s2); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/mobileconnectors/cognito/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Primary classes for interacting with the AmazonCognitoSync mobile connector, 3 | * which is a high level client that provides data synchronization across multiple mobile devices and 4 | * powered by Amazon Cognito Identity service, Cognito Sync service, and Security Token 5 | * Service (STS). 6 | * 7 | * 8 | * Here is a sample usage: 9 | * 10 | *
11 |  * CognitoCachingCredentialsProvider provider = new CognitoCachingCredentialsProvider(
12 |  *         context, awsAccountId, identityPoolId, unauthRoleArn, authRoleArn, Regions.US_EAST_1);
13 |  * CognitoSyncManager client = new CognitoSyncManager(context, identityPoolId, provider);
14 |  * 
15 |  * Dataset dataset = client.openOrCreateDataset("default_dataset");
16 |  * dataset.put("high_score", "100");
17 |  * dataset.synchronize(new SyncCallback() {
18 |  *     // override callbacks
19 |  * });
20 |  * 
21 | * 22 | * Please refer to {@link com.amazonaws.mobileconnectors.cognito.CognitoSyncManager} and 23 | * {@link com.amazonaws.mobileconnectors.cognito.Dataset} for more details. 24 | */ 25 | 26 | package com.amazonaws.mobileconnectors.cognito; 27 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/BulkPublishStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model; 16 | 17 | /** 18 | * Bulk Publish Status 19 | */ 20 | public enum BulkPublishStatus { 21 | 22 | NOT_STARTED("NOT_STARTED"), 23 | IN_PROGRESS("IN_PROGRESS"), 24 | FAILED("FAILED"), 25 | SUCCEEDED("SUCCEEDED"); 26 | 27 | private String value; 28 | 29 | private BulkPublishStatus(String value) { 30 | this.value = value; 31 | } 32 | 33 | @Override 34 | public String toString() { 35 | return this.value; 36 | } 37 | 38 | /** 39 | * Use this in place of valueOf. 40 | * 41 | * @param value 42 | * real value 43 | * @return BulkPublishStatus corresponding to the value 44 | */ 45 | public static BulkPublishStatus fromValue(String value) { 46 | if (value == null || "".equals(value)) { 47 | throw new IllegalArgumentException("Value cannot be null or empty!"); 48 | 49 | } else if ("NOT_STARTED".equals(value)) { 50 | return BulkPublishStatus.NOT_STARTED; 51 | } else if ("IN_PROGRESS".equals(value)) { 52 | return BulkPublishStatus.IN_PROGRESS; 53 | } else if ("FAILED".equals(value)) { 54 | return BulkPublishStatus.FAILED; 55 | } else if ("SUCCEEDED".equals(value)) { 56 | return BulkPublishStatus.SUCCEEDED; 57 | } else { 58 | throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/DeleteDatasetResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model; 16 | 17 | import java.io.Serializable; 18 | 19 | /** 20 | *

21 | * Response to a successful DeleteDataset request. 22 | *

23 | */ 24 | public class DeleteDatasetResult implements Serializable { 25 | 26 | /** 27 | * A collection of data for an identity pool. An identity pool can have 28 | * multiple datasets. A dataset is per identity and can be general or 29 | * associated with a particular entity in an application (like a saved 30 | * game). Datasets are automatically created if they don't exist. Data is 31 | * synced by dataset, and a dataset can hold up to 1MB of key-value 32 | * pairs. 33 | */ 34 | private Dataset dataset; 35 | 36 | /** 37 | * A collection of data for an identity pool. An identity pool can have 38 | * multiple datasets. A dataset is per identity and can be general or 39 | * associated with a particular entity in an application (like a saved 40 | * game). Datasets are automatically created if they don't exist. Data is 41 | * synced by dataset, and a dataset can hold up to 1MB of key-value 42 | * pairs. 43 | * 44 | * @return A collection of data for an identity pool. An identity pool can have 45 | * multiple datasets. A dataset is per identity and can be general or 46 | * associated with a particular entity in an application (like a saved 47 | * game). Datasets are automatically created if they don't exist. Data is 48 | * synced by dataset, and a dataset can hold up to 1MB of key-value 49 | * pairs. 50 | */ 51 | public Dataset getDataset() { 52 | return dataset; 53 | } 54 | 55 | /** 56 | * A collection of data for an identity pool. An identity pool can have 57 | * multiple datasets. A dataset is per identity and can be general or 58 | * associated with a particular entity in an application (like a saved 59 | * game). Datasets are automatically created if they don't exist. Data is 60 | * synced by dataset, and a dataset can hold up to 1MB of key-value 61 | * pairs. 62 | * 63 | * @param dataset A collection of data for an identity pool. An identity pool can have 64 | * multiple datasets. A dataset is per identity and can be general or 65 | * associated with a particular entity in an application (like a saved 66 | * game). Datasets are automatically created if they don't exist. Data is 67 | * synced by dataset, and a dataset can hold up to 1MB of key-value 68 | * pairs. 69 | */ 70 | public void setDataset(Dataset dataset) { 71 | this.dataset = dataset; 72 | } 73 | 74 | /** 75 | * A collection of data for an identity pool. An identity pool can have 76 | * multiple datasets. A dataset is per identity and can be general or 77 | * associated with a particular entity in an application (like a saved 78 | * game). Datasets are automatically created if they don't exist. Data is 79 | * synced by dataset, and a dataset can hold up to 1MB of key-value 80 | * pairs. 81 | *

82 | * Returns a reference to this object so that method calls can be chained together. 83 | * 84 | * @param dataset A collection of data for an identity pool. An identity pool can have 85 | * multiple datasets. A dataset is per identity and can be general or 86 | * associated with a particular entity in an application (like a saved 87 | * game). Datasets are automatically created if they don't exist. Data is 88 | * synced by dataset, and a dataset can hold up to 1MB of key-value 89 | * pairs. 90 | * 91 | * @return A reference to this updated object so that method calls can be chained 92 | * together. 93 | */ 94 | public DeleteDatasetResult withDataset(Dataset dataset) { 95 | this.dataset = dataset; 96 | return this; 97 | } 98 | 99 | /** 100 | * Returns a string representation of this object; useful for testing and 101 | * debugging. 102 | * 103 | * @return A string representation of this object. 104 | * 105 | * @see java.lang.Object#toString() 106 | */ 107 | @Override 108 | public String toString() { 109 | StringBuilder sb = new StringBuilder(); 110 | sb.append("{"); 111 | if (getDataset() != null) sb.append("Dataset: " + getDataset() ); 112 | sb.append("}"); 113 | return sb.toString(); 114 | } 115 | 116 | @Override 117 | public int hashCode() { 118 | final int prime = 31; 119 | int hashCode = 1; 120 | 121 | hashCode = prime * hashCode + ((getDataset() == null) ? 0 : getDataset().hashCode()); 122 | return hashCode; 123 | } 124 | 125 | @Override 126 | public boolean equals(Object obj) { 127 | if (this == obj) return true; 128 | if (obj == null) return false; 129 | 130 | if (obj instanceof DeleteDatasetResult == false) return false; 131 | DeleteDatasetResult other = (DeleteDatasetResult)obj; 132 | 133 | if (other.getDataset() == null ^ this.getDataset() == null) return false; 134 | if (other.getDataset() != null && other.getDataset().equals(this.getDataset()) == false) return false; 135 | return true; 136 | } 137 | 138 | } 139 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/DescribeDatasetResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model; 16 | 17 | import java.io.Serializable; 18 | 19 | /** 20 | *

21 | * Response to a successful DescribeDataset request. 22 | *

23 | */ 24 | public class DescribeDatasetResult implements Serializable { 25 | 26 | /** 27 | * Meta data for a collection of data for an identity. An identity can 28 | * have multiple datasets. A dataset can be general or associated with a 29 | * particular entity in an application (like a saved game). Datasets are 30 | * automatically created if they don't exist. Data is synced by dataset, 31 | * and a dataset can hold up to 1MB of key-value pairs. 32 | */ 33 | private Dataset dataset; 34 | 35 | /** 36 | * Meta data for a collection of data for an identity. An identity can 37 | * have multiple datasets. A dataset can be general or associated with a 38 | * particular entity in an application (like a saved game). Datasets are 39 | * automatically created if they don't exist. Data is synced by dataset, 40 | * and a dataset can hold up to 1MB of key-value pairs. 41 | * 42 | * @return Meta data for a collection of data for an identity. An identity can 43 | * have multiple datasets. A dataset can be general or associated with a 44 | * particular entity in an application (like a saved game). Datasets are 45 | * automatically created if they don't exist. Data is synced by dataset, 46 | * and a dataset can hold up to 1MB of key-value pairs. 47 | */ 48 | public Dataset getDataset() { 49 | return dataset; 50 | } 51 | 52 | /** 53 | * Meta data for a collection of data for an identity. An identity can 54 | * have multiple datasets. A dataset can be general or associated with a 55 | * particular entity in an application (like a saved game). Datasets are 56 | * automatically created if they don't exist. Data is synced by dataset, 57 | * and a dataset can hold up to 1MB of key-value pairs. 58 | * 59 | * @param dataset Meta data for a collection of data for an identity. An identity can 60 | * have multiple datasets. A dataset can be general or associated with a 61 | * particular entity in an application (like a saved game). Datasets are 62 | * automatically created if they don't exist. Data is synced by dataset, 63 | * and a dataset can hold up to 1MB of key-value pairs. 64 | */ 65 | public void setDataset(Dataset dataset) { 66 | this.dataset = dataset; 67 | } 68 | 69 | /** 70 | * Meta data for a collection of data for an identity. An identity can 71 | * have multiple datasets. A dataset can be general or associated with a 72 | * particular entity in an application (like a saved game). Datasets are 73 | * automatically created if they don't exist. Data is synced by dataset, 74 | * and a dataset can hold up to 1MB of key-value pairs. 75 | *

76 | * Returns a reference to this object so that method calls can be chained together. 77 | * 78 | * @param dataset Meta data for a collection of data for an identity. An identity can 79 | * have multiple datasets. A dataset can be general or associated with a 80 | * particular entity in an application (like a saved game). Datasets are 81 | * automatically created if they don't exist. Data is synced by dataset, 82 | * and a dataset can hold up to 1MB of key-value pairs. 83 | * 84 | * @return A reference to this updated object so that method calls can be chained 85 | * together. 86 | */ 87 | public DescribeDatasetResult withDataset(Dataset dataset) { 88 | this.dataset = dataset; 89 | return this; 90 | } 91 | 92 | /** 93 | * Returns a string representation of this object; useful for testing and 94 | * debugging. 95 | * 96 | * @return A string representation of this object. 97 | * 98 | * @see java.lang.Object#toString() 99 | */ 100 | @Override 101 | public String toString() { 102 | StringBuilder sb = new StringBuilder(); 103 | sb.append("{"); 104 | if (getDataset() != null) sb.append("Dataset: " + getDataset() ); 105 | sb.append("}"); 106 | return sb.toString(); 107 | } 108 | 109 | @Override 110 | public int hashCode() { 111 | final int prime = 31; 112 | int hashCode = 1; 113 | 114 | hashCode = prime * hashCode + ((getDataset() == null) ? 0 : getDataset().hashCode()); 115 | return hashCode; 116 | } 117 | 118 | @Override 119 | public boolean equals(Object obj) { 120 | if (this == obj) return true; 121 | if (obj == null) return false; 122 | 123 | if (obj instanceof DescribeDatasetResult == false) return false; 124 | DescribeDatasetResult other = (DescribeDatasetResult)obj; 125 | 126 | if (other.getDataset() == null ^ this.getDataset() == null) return false; 127 | if (other.getDataset() != null && other.getDataset().equals(this.getDataset()) == false) return false; 128 | return true; 129 | } 130 | 131 | } 132 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/InternalErrorException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model; 16 | 17 | import com.amazonaws.AmazonServiceException; 18 | 19 | /** 20 | *

21 | * Indicates an internal service error. 22 | *

23 | */ 24 | public class InternalErrorException extends AmazonServiceException { 25 | private static final long serialVersionUID = 1L; 26 | 27 | /** 28 | * Constructs a new InternalErrorException with the specified error 29 | * message. 30 | * 31 | * @param message Describes the error encountered. 32 | */ 33 | public InternalErrorException(String message) { 34 | super(message); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/InvalidConfigurationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model; 16 | 17 | import com.amazonaws.AmazonServiceException; 18 | 19 | /** 20 | * 21 | */ 22 | public class InvalidConfigurationException extends AmazonServiceException { 23 | private static final long serialVersionUID = 1L; 24 | 25 | /** 26 | * Constructs a new InvalidConfigurationException with the specified error 27 | * message. 28 | * 29 | * @param message Describes the error encountered. 30 | */ 31 | public InvalidConfigurationException(String message) { 32 | super(message); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/InvalidLambdaFunctionOutputException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model; 16 | 17 | import com.amazonaws.AmazonServiceException; 18 | 19 | /** 20 | *

21 | * The AWS Lambda function returned invalid output or an exception. 22 | *

23 | */ 24 | public class InvalidLambdaFunctionOutputException extends AmazonServiceException { 25 | private static final long serialVersionUID = 1L; 26 | 27 | /** 28 | * Constructs a new InvalidLambdaFunctionOutputException with the specified error 29 | * message. 30 | * 31 | * @param message Describes the error encountered. 32 | */ 33 | public InvalidLambdaFunctionOutputException(String message) { 34 | super(message); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/InvalidParameterException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model; 16 | 17 | import com.amazonaws.AmazonServiceException; 18 | 19 | /** 20 | *

21 | * Thrown when a request parameter does not comply with the associated 22 | * constraints. 23 | *

24 | */ 25 | public class InvalidParameterException extends AmazonServiceException { 26 | private static final long serialVersionUID = 1L; 27 | 28 | /** 29 | * Constructs a new InvalidParameterException with the specified error 30 | * message. 31 | * 32 | * @param message Describes the error encountered. 33 | */ 34 | public InvalidParameterException(String message) { 35 | super(message); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/LambdaThrottledException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model; 16 | 17 | import com.amazonaws.AmazonServiceException; 18 | 19 | /** 20 | *

21 | * AWS Lambda throttled your account, please contact AWS Support 22 | *

23 | */ 24 | public class LambdaThrottledException extends AmazonServiceException { 25 | private static final long serialVersionUID = 1L; 26 | 27 | /** 28 | * Constructs a new LambdaThrottledException with the specified error 29 | * message. 30 | * 31 | * @param message Describes the error encountered. 32 | */ 33 | public LambdaThrottledException(String message) { 34 | super(message); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/LimitExceededException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model; 16 | 17 | import com.amazonaws.AmazonServiceException; 18 | 19 | /** 20 | *

21 | * Thrown when the limit on the number of objects or operations has been 22 | * exceeded. 23 | *

24 | */ 25 | public class LimitExceededException extends AmazonServiceException { 26 | private static final long serialVersionUID = 1L; 27 | 28 | /** 29 | * Constructs a new LimitExceededException with the specified error 30 | * message. 31 | * 32 | * @param message Describes the error encountered. 33 | */ 34 | public LimitExceededException(String message) { 35 | super(message); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/ListDatasetsResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model; 16 | 17 | import java.io.Serializable; 18 | 19 | /** 20 | *

21 | * Returned for a successful ListDatasets request. 22 | *

23 | */ 24 | public class ListDatasetsResult implements Serializable { 25 | 26 | /** 27 | * A set of datasets. 28 | */ 29 | private com.amazonaws.internal.ListWithAutoConstructFlag datasets; 30 | 31 | /** 32 | * Number of datasets returned. 33 | */ 34 | private Integer count; 35 | 36 | /** 37 | * A pagination token for obtaining the next page of results. 38 | */ 39 | private String nextToken; 40 | 41 | /** 42 | * A set of datasets. 43 | * 44 | * @return A set of datasets. 45 | */ 46 | public java.util.List getDatasets() { 47 | if (datasets == null) { 48 | datasets = new com.amazonaws.internal.ListWithAutoConstructFlag(); 49 | datasets.setAutoConstruct(true); 50 | } 51 | return datasets; 52 | } 53 | 54 | /** 55 | * A set of datasets. 56 | * 57 | * @param datasets A set of datasets. 58 | */ 59 | public void setDatasets(java.util.Collection datasets) { 60 | if (datasets == null) { 61 | this.datasets = null; 62 | return; 63 | } 64 | com.amazonaws.internal.ListWithAutoConstructFlag datasetsCopy = new com.amazonaws.internal.ListWithAutoConstructFlag(datasets.size()); 65 | datasetsCopy.addAll(datasets); 66 | this.datasets = datasetsCopy; 67 | } 68 | 69 | /** 70 | * A set of datasets. 71 | *

72 | * Returns a reference to this object so that method calls can be chained together. 73 | * 74 | * @param datasets A set of datasets. 75 | * 76 | * @return A reference to this updated object so that method calls can be chained 77 | * together. 78 | */ 79 | public ListDatasetsResult withDatasets(Dataset... datasets) { 80 | if (getDatasets() == null) setDatasets(new java.util.ArrayList(datasets.length)); 81 | for (Dataset value : datasets) { 82 | getDatasets().add(value); 83 | } 84 | return this; 85 | } 86 | 87 | /** 88 | * A set of datasets. 89 | *

90 | * Returns a reference to this object so that method calls can be chained together. 91 | * 92 | * @param datasets A set of datasets. 93 | * 94 | * @return A reference to this updated object so that method calls can be chained 95 | * together. 96 | */ 97 | public ListDatasetsResult withDatasets(java.util.Collection datasets) { 98 | if (datasets == null) { 99 | this.datasets = null; 100 | } else { 101 | com.amazonaws.internal.ListWithAutoConstructFlag datasetsCopy = new com.amazonaws.internal.ListWithAutoConstructFlag(datasets.size()); 102 | datasetsCopy.addAll(datasets); 103 | this.datasets = datasetsCopy; 104 | } 105 | 106 | return this; 107 | } 108 | 109 | /** 110 | * Number of datasets returned. 111 | * 112 | * @return Number of datasets returned. 113 | */ 114 | public Integer getCount() { 115 | return count; 116 | } 117 | 118 | /** 119 | * Number of datasets returned. 120 | * 121 | * @param count Number of datasets returned. 122 | */ 123 | public void setCount(Integer count) { 124 | this.count = count; 125 | } 126 | 127 | /** 128 | * Number of datasets returned. 129 | *

130 | * Returns a reference to this object so that method calls can be chained together. 131 | * 132 | * @param count Number of datasets returned. 133 | * 134 | * @return A reference to this updated object so that method calls can be chained 135 | * together. 136 | */ 137 | public ListDatasetsResult withCount(Integer count) { 138 | this.count = count; 139 | return this; 140 | } 141 | 142 | /** 143 | * A pagination token for obtaining the next page of results. 144 | * 145 | * @return A pagination token for obtaining the next page of results. 146 | */ 147 | public String getNextToken() { 148 | return nextToken; 149 | } 150 | 151 | /** 152 | * A pagination token for obtaining the next page of results. 153 | * 154 | * @param nextToken A pagination token for obtaining the next page of results. 155 | */ 156 | public void setNextToken(String nextToken) { 157 | this.nextToken = nextToken; 158 | } 159 | 160 | /** 161 | * A pagination token for obtaining the next page of results. 162 | *

163 | * Returns a reference to this object so that method calls can be chained together. 164 | * 165 | * @param nextToken A pagination token for obtaining the next page of results. 166 | * 167 | * @return A reference to this updated object so that method calls can be chained 168 | * together. 169 | */ 170 | public ListDatasetsResult withNextToken(String nextToken) { 171 | this.nextToken = nextToken; 172 | return this; 173 | } 174 | 175 | /** 176 | * Returns a string representation of this object; useful for testing and 177 | * debugging. 178 | * 179 | * @return A string representation of this object. 180 | * 181 | * @see java.lang.Object#toString() 182 | */ 183 | @Override 184 | public String toString() { 185 | StringBuilder sb = new StringBuilder(); 186 | sb.append("{"); 187 | if (getDatasets() != null) sb.append("Datasets: " + getDatasets() + ","); 188 | if (getCount() != null) sb.append("Count: " + getCount() + ","); 189 | if (getNextToken() != null) sb.append("NextToken: " + getNextToken() ); 190 | sb.append("}"); 191 | return sb.toString(); 192 | } 193 | 194 | @Override 195 | public int hashCode() { 196 | final int prime = 31; 197 | int hashCode = 1; 198 | 199 | hashCode = prime * hashCode + ((getDatasets() == null) ? 0 : getDatasets().hashCode()); 200 | hashCode = prime * hashCode + ((getCount() == null) ? 0 : getCount().hashCode()); 201 | hashCode = prime * hashCode + ((getNextToken() == null) ? 0 : getNextToken().hashCode()); 202 | return hashCode; 203 | } 204 | 205 | @Override 206 | public boolean equals(Object obj) { 207 | if (this == obj) return true; 208 | if (obj == null) return false; 209 | 210 | if (obj instanceof ListDatasetsResult == false) return false; 211 | ListDatasetsResult other = (ListDatasetsResult)obj; 212 | 213 | if (other.getDatasets() == null ^ this.getDatasets() == null) return false; 214 | if (other.getDatasets() != null && other.getDatasets().equals(this.getDatasets()) == false) return false; 215 | if (other.getCount() == null ^ this.getCount() == null) return false; 216 | if (other.getCount() != null && other.getCount().equals(this.getCount()) == false) return false; 217 | if (other.getNextToken() == null ^ this.getNextToken() == null) return false; 218 | if (other.getNextToken() != null && other.getNextToken().equals(this.getNextToken()) == false) return false; 219 | return true; 220 | } 221 | 222 | } 223 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/NotAuthorizedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model; 16 | 17 | import com.amazonaws.AmazonServiceException; 18 | 19 | /** 20 | *

21 | * Thrown when a user is not authorized to access the requested resource. 22 | *

23 | */ 24 | public class NotAuthorizedException extends AmazonServiceException { 25 | private static final long serialVersionUID = 1L; 26 | 27 | /** 28 | * Constructs a new NotAuthorizedException with the specified error 29 | * message. 30 | * 31 | * @param message Describes the error encountered. 32 | */ 33 | public NotAuthorizedException(String message) { 34 | super(message); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/Operation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model; 16 | 17 | /** 18 | * Operation 19 | */ 20 | public enum Operation { 21 | 22 | Replace("replace"), 23 | Remove("remove"); 24 | 25 | private String value; 26 | 27 | private Operation(String value) { 28 | this.value = value; 29 | } 30 | 31 | @Override 32 | public String toString() { 33 | return this.value; 34 | } 35 | 36 | /** 37 | * Use this in place of valueOf. 38 | * 39 | * @param value 40 | * real value 41 | * @return Operation corresponding to the value 42 | */ 43 | public static Operation fromValue(String value) { 44 | if (value == null || "".equals(value)) { 45 | throw new IllegalArgumentException("Value cannot be null or empty!"); 46 | 47 | } else if ("replace".equals(value)) { 48 | return Operation.Replace; 49 | } else if ("remove".equals(value)) { 50 | return Operation.Remove; 51 | } else { 52 | throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/Platform.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model; 16 | 17 | /** 18 | * Platform 19 | */ 20 | public enum Platform { 21 | 22 | APNS("APNS"), 23 | APNS_SANDBOX("APNS_SANDBOX"), 24 | GCM("GCM"), 25 | ADM("ADM"); 26 | 27 | private String value; 28 | 29 | private Platform(String value) { 30 | this.value = value; 31 | } 32 | 33 | @Override 34 | public String toString() { 35 | return this.value; 36 | } 37 | 38 | /** 39 | * Use this in place of valueOf. 40 | * 41 | * @param value 42 | * real value 43 | * @return Platform corresponding to the value 44 | */ 45 | public static Platform fromValue(String value) { 46 | if (value == null || "".equals(value)) { 47 | throw new IllegalArgumentException("Value cannot be null or empty!"); 48 | 49 | } else if ("APNS".equals(value)) { 50 | return Platform.APNS; 51 | } else if ("APNS_SANDBOX".equals(value)) { 52 | return Platform.APNS_SANDBOX; 53 | } else if ("GCM".equals(value)) { 54 | return Platform.GCM; 55 | } else if ("ADM".equals(value)) { 56 | return Platform.ADM; 57 | } else { 58 | throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/RegisterDeviceResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model; 16 | 17 | import java.io.Serializable; 18 | 19 | /** 20 | *

21 | * Response to a RegisterDevice request. 22 | *

23 | */ 24 | public class RegisterDeviceResult implements Serializable { 25 | 26 | /** 27 | * The unique ID generated for this device by Cognito. 28 | *

29 | * Constraints:
30 | * Length: 1 - 256
31 | */ 32 | private String deviceId; 33 | 34 | /** 35 | * The unique ID generated for this device by Cognito. 36 | *

37 | * Constraints:
38 | * Length: 1 - 256
39 | * 40 | * @return The unique ID generated for this device by Cognito. 41 | */ 42 | public String getDeviceId() { 43 | return deviceId; 44 | } 45 | 46 | /** 47 | * The unique ID generated for this device by Cognito. 48 | *

49 | * Constraints:
50 | * Length: 1 - 256
51 | * 52 | * @param deviceId The unique ID generated for this device by Cognito. 53 | */ 54 | public void setDeviceId(String deviceId) { 55 | this.deviceId = deviceId; 56 | } 57 | 58 | /** 59 | * The unique ID generated for this device by Cognito. 60 | *

61 | * Returns a reference to this object so that method calls can be chained together. 62 | *

63 | * Constraints:
64 | * Length: 1 - 256
65 | * 66 | * @param deviceId The unique ID generated for this device by Cognito. 67 | * 68 | * @return A reference to this updated object so that method calls can be chained 69 | * together. 70 | */ 71 | public RegisterDeviceResult withDeviceId(String deviceId) { 72 | this.deviceId = deviceId; 73 | return this; 74 | } 75 | 76 | /** 77 | * Returns a string representation of this object; useful for testing and 78 | * debugging. 79 | * 80 | * @return A string representation of this object. 81 | * 82 | * @see java.lang.Object#toString() 83 | */ 84 | @Override 85 | public String toString() { 86 | StringBuilder sb = new StringBuilder(); 87 | sb.append("{"); 88 | if (getDeviceId() != null) sb.append("DeviceId: " + getDeviceId() ); 89 | sb.append("}"); 90 | return sb.toString(); 91 | } 92 | 93 | @Override 94 | public int hashCode() { 95 | final int prime = 31; 96 | int hashCode = 1; 97 | 98 | hashCode = prime * hashCode + ((getDeviceId() == null) ? 0 : getDeviceId().hashCode()); 99 | return hashCode; 100 | } 101 | 102 | @Override 103 | public boolean equals(Object obj) { 104 | if (this == obj) return true; 105 | if (obj == null) return false; 106 | 107 | if (obj instanceof RegisterDeviceResult == false) return false; 108 | RegisterDeviceResult other = (RegisterDeviceResult)obj; 109 | 110 | if (other.getDeviceId() == null ^ this.getDeviceId() == null) return false; 111 | if (other.getDeviceId() != null && other.getDeviceId().equals(this.getDeviceId()) == false) return false; 112 | return true; 113 | } 114 | 115 | } 116 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/ResourceConflictException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model; 16 | 17 | import com.amazonaws.AmazonServiceException; 18 | 19 | /** 20 | *

21 | * Thrown if an update can't be applied because the resource was changed 22 | * by another call and this would result in a conflict. 23 | *

24 | */ 25 | public class ResourceConflictException extends AmazonServiceException { 26 | private static final long serialVersionUID = 1L; 27 | 28 | /** 29 | * Constructs a new ResourceConflictException with the specified error 30 | * message. 31 | * 32 | * @param message Describes the error encountered. 33 | */ 34 | public ResourceConflictException(String message) { 35 | super(message); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/ResourceNotFoundException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model; 16 | 17 | import com.amazonaws.AmazonServiceException; 18 | 19 | /** 20 | *

21 | * Thrown if the resource doesn't exist. 22 | *

23 | */ 24 | public class ResourceNotFoundException extends AmazonServiceException { 25 | private static final long serialVersionUID = 1L; 26 | 27 | /** 28 | * Constructs a new ResourceNotFoundException with the specified error 29 | * message. 30 | * 31 | * @param message Describes the error encountered. 32 | */ 33 | public ResourceNotFoundException(String message) { 34 | super(message); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/StreamingStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model; 16 | 17 | /** 18 | * Streaming Status 19 | */ 20 | public enum StreamingStatus { 21 | 22 | ENABLED("ENABLED"), 23 | DISABLED("DISABLED"); 24 | 25 | private String value; 26 | 27 | private StreamingStatus(String value) { 28 | this.value = value; 29 | } 30 | 31 | @Override 32 | public String toString() { 33 | return this.value; 34 | } 35 | 36 | /** 37 | * Use this in place of valueOf. 38 | * 39 | * @param value 40 | * real value 41 | * @return StreamingStatus corresponding to the value 42 | */ 43 | public static StreamingStatus fromValue(String value) { 44 | if (value == null || "".equals(value)) { 45 | throw new IllegalArgumentException("Value cannot be null or empty!"); 46 | 47 | } else if ("ENABLED".equals(value)) { 48 | return StreamingStatus.ENABLED; 49 | } else if ("DISABLED".equals(value)) { 50 | return StreamingStatus.DISABLED; 51 | } else { 52 | throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/SubscribeToDatasetResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model; 16 | 17 | import java.io.Serializable; 18 | 19 | /** 20 | *

21 | * Response to a SubscribeToDataset request. 22 | *

23 | */ 24 | public class SubscribeToDatasetResult implements Serializable { 25 | 26 | /** 27 | * Returns a string representation of this object; useful for testing and 28 | * debugging. 29 | * 30 | * @return A string representation of this object. 31 | * 32 | * @see java.lang.Object#toString() 33 | */ 34 | @Override 35 | public String toString() { 36 | StringBuilder sb = new StringBuilder(); 37 | sb.append("{"); 38 | sb.append("}"); 39 | return sb.toString(); 40 | } 41 | 42 | @Override 43 | public int hashCode() { 44 | final int prime = 31; 45 | int hashCode = 1; 46 | 47 | return hashCode; 48 | } 49 | 50 | @Override 51 | public boolean equals(Object obj) { 52 | if (this == obj) return true; 53 | if (obj == null) return false; 54 | 55 | if (obj instanceof SubscribeToDatasetResult == false) return false; 56 | SubscribeToDatasetResult other = (SubscribeToDatasetResult)obj; 57 | 58 | return true; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/TooManyRequestsException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model; 16 | 17 | import com.amazonaws.AmazonServiceException; 18 | 19 | /** 20 | *

21 | * Thrown if the request is throttled. 22 | *

23 | */ 24 | public class TooManyRequestsException extends AmazonServiceException { 25 | private static final long serialVersionUID = 1L; 26 | 27 | /** 28 | * Constructs a new TooManyRequestsException with the specified error 29 | * message. 30 | * 31 | * @param message Describes the error encountered. 32 | */ 33 | public TooManyRequestsException(String message) { 34 | super(message); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/UnsubscribeFromDatasetResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model; 16 | 17 | import java.io.Serializable; 18 | 19 | /** 20 | *

21 | * Response to an UnsubscribeFromDataset request. 22 | *

23 | */ 24 | public class UnsubscribeFromDatasetResult implements Serializable { 25 | 26 | /** 27 | * Returns a string representation of this object; useful for testing and 28 | * debugging. 29 | * 30 | * @return A string representation of this object. 31 | * 32 | * @see java.lang.Object#toString() 33 | */ 34 | @Override 35 | public String toString() { 36 | StringBuilder sb = new StringBuilder(); 37 | sb.append("{"); 38 | sb.append("}"); 39 | return sb.toString(); 40 | } 41 | 42 | @Override 43 | public int hashCode() { 44 | final int prime = 31; 45 | int hashCode = 1; 46 | 47 | return hashCode; 48 | } 49 | 50 | @Override 51 | public boolean equals(Object obj) { 52 | if (this == obj) return true; 53 | if (obj == null) return false; 54 | 55 | if (obj instanceof UnsubscribeFromDatasetResult == false) return false; 56 | UnsubscribeFromDatasetResult other = (UnsubscribeFromDatasetResult)obj; 57 | 58 | return true; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/UpdateRecordsResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model; 16 | 17 | import java.io.Serializable; 18 | 19 | /** 20 | *

21 | * Returned for a successful UpdateRecordsRequest. 22 | *

23 | */ 24 | public class UpdateRecordsResult implements Serializable { 25 | 26 | /** 27 | * A list of records that have been updated. 28 | */ 29 | private com.amazonaws.internal.ListWithAutoConstructFlag records; 30 | 31 | /** 32 | * A list of records that have been updated. 33 | * 34 | * @return A list of records that have been updated. 35 | */ 36 | public java.util.List getRecords() { 37 | if (records == null) { 38 | records = new com.amazonaws.internal.ListWithAutoConstructFlag(); 39 | records.setAutoConstruct(true); 40 | } 41 | return records; 42 | } 43 | 44 | /** 45 | * A list of records that have been updated. 46 | * 47 | * @param records A list of records that have been updated. 48 | */ 49 | public void setRecords(java.util.Collection records) { 50 | if (records == null) { 51 | this.records = null; 52 | return; 53 | } 54 | com.amazonaws.internal.ListWithAutoConstructFlag recordsCopy = new com.amazonaws.internal.ListWithAutoConstructFlag(records.size()); 55 | recordsCopy.addAll(records); 56 | this.records = recordsCopy; 57 | } 58 | 59 | /** 60 | * A list of records that have been updated. 61 | *

62 | * Returns a reference to this object so that method calls can be chained together. 63 | * 64 | * @param records A list of records that have been updated. 65 | * 66 | * @return A reference to this updated object so that method calls can be chained 67 | * together. 68 | */ 69 | public UpdateRecordsResult withRecords(Record... records) { 70 | if (getRecords() == null) setRecords(new java.util.ArrayList(records.length)); 71 | for (Record value : records) { 72 | getRecords().add(value); 73 | } 74 | return this; 75 | } 76 | 77 | /** 78 | * A list of records that have been updated. 79 | *

80 | * Returns a reference to this object so that method calls can be chained together. 81 | * 82 | * @param records A list of records that have been updated. 83 | * 84 | * @return A reference to this updated object so that method calls can be chained 85 | * together. 86 | */ 87 | public UpdateRecordsResult withRecords(java.util.Collection records) { 88 | if (records == null) { 89 | this.records = null; 90 | } else { 91 | com.amazonaws.internal.ListWithAutoConstructFlag recordsCopy = new com.amazonaws.internal.ListWithAutoConstructFlag(records.size()); 92 | recordsCopy.addAll(records); 93 | this.records = recordsCopy; 94 | } 95 | 96 | return this; 97 | } 98 | 99 | /** 100 | * Returns a string representation of this object; useful for testing and 101 | * debugging. 102 | * 103 | * @return A string representation of this object. 104 | * 105 | * @see java.lang.Object#toString() 106 | */ 107 | @Override 108 | public String toString() { 109 | StringBuilder sb = new StringBuilder(); 110 | sb.append("{"); 111 | if (getRecords() != null) sb.append("Records: " + getRecords() ); 112 | sb.append("}"); 113 | return sb.toString(); 114 | } 115 | 116 | @Override 117 | public int hashCode() { 118 | final int prime = 31; 119 | int hashCode = 1; 120 | 121 | hashCode = prime * hashCode + ((getRecords() == null) ? 0 : getRecords().hashCode()); 122 | return hashCode; 123 | } 124 | 125 | @Override 126 | public boolean equals(Object obj) { 127 | if (this == obj) return true; 128 | if (obj == null) return false; 129 | 130 | if (obj instanceof UpdateRecordsResult == false) return false; 131 | UpdateRecordsResult other = (UpdateRecordsResult)obj; 132 | 133 | if (other.getRecords() == null ^ this.getRecords() == null) return false; 134 | if (other.getRecords() != null && other.getRecords().equals(this.getRecords()) == false) return false; 135 | return true; 136 | } 137 | 138 | } 139 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Classes modeling the various types represented by AmazonCognitoSync. 4 | */ 5 | package com.amazonaws.services.cognitosync.model; 6 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/transform/DatasetJsonUnmarshaller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazonaws.services.cognitosync.model.transform; 17 | 18 | import java.util.Map; 19 | import java.util.Map.Entry; 20 | 21 | import com.amazonaws.services.cognitosync.model.*; 22 | import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; 23 | import com.amazonaws.transform.*; 24 | import com.amazonaws.util.json.AwsJsonReader; 25 | 26 | /** 27 | * Dataset JSON Unmarshaller 28 | */ 29 | public class DatasetJsonUnmarshaller implements Unmarshaller { 30 | 31 | public Dataset unmarshall(JsonUnmarshallerContext context) throws Exception { 32 | Dataset dataset = new Dataset(); 33 | 34 | AwsJsonReader reader = context.getReader(); 35 | reader.beginObject(); 36 | while (reader.hasNext()) { 37 | String name = reader.nextName(); 38 | 39 | if (name.equals("IdentityId")) { 40 | dataset.setIdentityId(StringJsonUnmarshaller.getInstance().unmarshall(context)); 41 | } else 42 | if (name.equals("DatasetName")) { 43 | dataset.setDatasetName(StringJsonUnmarshaller.getInstance().unmarshall(context)); 44 | } else 45 | if (name.equals("CreationDate")) { 46 | dataset.setCreationDate(DateJsonUnmarshaller.getInstance().unmarshall(context)); 47 | } else 48 | if (name.equals("LastModifiedDate")) { 49 | dataset.setLastModifiedDate(DateJsonUnmarshaller.getInstance().unmarshall(context)); 50 | } else 51 | if (name.equals("LastModifiedBy")) { 52 | dataset.setLastModifiedBy(StringJsonUnmarshaller.getInstance().unmarshall(context)); 53 | } else 54 | if (name.equals("DataStorage")) { 55 | dataset.setDataStorage(LongJsonUnmarshaller.getInstance().unmarshall(context)); 56 | } else 57 | if (name.equals("NumRecords")) { 58 | dataset.setNumRecords(LongJsonUnmarshaller.getInstance().unmarshall(context)); 59 | } else 60 | { 61 | reader.skipValue(); 62 | } 63 | 64 | } 65 | reader.endObject(); 66 | 67 | return dataset; 68 | } 69 | 70 | private static DatasetJsonUnmarshaller instance; 71 | public static DatasetJsonUnmarshaller getInstance() { 72 | if (instance == null) instance = new DatasetJsonUnmarshaller(); 73 | return instance; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/transform/DeleteDatasetRequestMarshaller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model.transform; 16 | 17 | import static com.amazonaws.util.StringUtils.UTF8; 18 | import java.io.ByteArrayInputStream; 19 | import java.io.ByteArrayOutputStream; 20 | import java.io.OutputStreamWriter; 21 | import java.io.StringWriter; 22 | import java.io.Writer; 23 | import java.util.Map; 24 | import java.util.List; 25 | 26 | import com.amazonaws.AmazonClientException; 27 | import com.amazonaws.Request; 28 | import com.amazonaws.DefaultRequest; 29 | import com.amazonaws.http.HttpMethodName; 30 | import com.amazonaws.services.cognitosync.model.*; 31 | import com.amazonaws.transform.Marshaller; 32 | import com.amazonaws.util.BinaryUtils; 33 | import com.amazonaws.util.StringUtils; 34 | import com.amazonaws.util.StringInputStream; 35 | import com.amazonaws.util.json.AwsJsonWriter; 36 | import com.amazonaws.util.json.JsonUtils; 37 | 38 | /** 39 | * Delete Dataset Request Marshaller 40 | */ 41 | public class DeleteDatasetRequestMarshaller implements Marshaller, DeleteDatasetRequest> { 42 | 43 | public Request marshall(DeleteDatasetRequest deleteDatasetRequest) { 44 | if (deleteDatasetRequest == null) { 45 | throw new AmazonClientException("Invalid argument passed to marshall(...)"); 46 | } 47 | 48 | Request request = new DefaultRequest(deleteDatasetRequest, "AmazonCognitoSync"); 49 | String target = "AWSCognitoSyncService.DeleteDataset"; 50 | request.addHeader("X-Amz-Target", target); 51 | 52 | request.setHttpMethod(HttpMethodName.DELETE); 53 | String uriResourcePath = "/identitypools/{IdentityPoolId}/identities/{IdentityId}/datasets/{DatasetName}"; 54 | uriResourcePath = uriResourcePath.replace("{IdentityPoolId}", (deleteDatasetRequest.getIdentityPoolId() == null) ? "" : StringUtils.fromString(deleteDatasetRequest.getIdentityPoolId())); 55 | uriResourcePath = uriResourcePath.replace("{IdentityId}", (deleteDatasetRequest.getIdentityId() == null) ? "" : StringUtils.fromString(deleteDatasetRequest.getIdentityId())); 56 | uriResourcePath = uriResourcePath.replace("{DatasetName}", (deleteDatasetRequest.getDatasetName() == null) ? "" : StringUtils.fromString(deleteDatasetRequest.getDatasetName())); 57 | 58 | uriResourcePath = uriResourcePath.replaceAll("//", "/"); 59 | 60 | if (uriResourcePath.contains("?")) { 61 | String queryString = uriResourcePath.substring(uriResourcePath.indexOf("?") + 1); 62 | uriResourcePath = uriResourcePath.substring(0, uriResourcePath.indexOf("?")); 63 | 64 | for (String s : queryString.split("[;&]")) { 65 | String[] nameValuePair = s.split("="); 66 | if (nameValuePair.length == 2) { 67 | if(!(nameValuePair[1].isEmpty())) 68 | request.addParameter(nameValuePair[0], nameValuePair[1]); 69 | } 70 | } 71 | } 72 | request.setResourcePath(uriResourcePath); 73 | 74 | if (!request.getHeaders().containsKey("Content-Type")) { 75 | request.addHeader("Content-Type", "application/x-amz-json-1.0"); 76 | } 77 | 78 | return request; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/transform/DeleteDatasetResultJsonUnmarshaller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazonaws.services.cognitosync.model.transform; 17 | 18 | import java.util.Map; 19 | import java.util.Map.Entry; 20 | 21 | import com.amazonaws.services.cognitosync.model.*; 22 | import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; 23 | import com.amazonaws.transform.*; 24 | import com.amazonaws.util.json.AwsJsonReader; 25 | 26 | /** 27 | * Delete Dataset Result JSON Unmarshaller 28 | */ 29 | public class DeleteDatasetResultJsonUnmarshaller implements Unmarshaller { 30 | 31 | public DeleteDatasetResult unmarshall(JsonUnmarshallerContext context) throws Exception { 32 | DeleteDatasetResult deleteDatasetResult = new DeleteDatasetResult(); 33 | 34 | AwsJsonReader reader = context.getReader(); 35 | reader.beginObject(); 36 | while (reader.hasNext()) { 37 | String name = reader.nextName(); 38 | 39 | if (name.equals("Dataset")) { 40 | deleteDatasetResult.setDataset(DatasetJsonUnmarshaller.getInstance().unmarshall(context)); 41 | } else 42 | { 43 | reader.skipValue(); 44 | } 45 | 46 | } 47 | reader.endObject(); 48 | 49 | return deleteDatasetResult; 50 | } 51 | 52 | private static DeleteDatasetResultJsonUnmarshaller instance; 53 | public static DeleteDatasetResultJsonUnmarshaller getInstance() { 54 | if (instance == null) instance = new DeleteDatasetResultJsonUnmarshaller(); 55 | return instance; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/transform/DescribeDatasetRequestMarshaller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model.transform; 16 | 17 | import static com.amazonaws.util.StringUtils.UTF8; 18 | import java.io.ByteArrayInputStream; 19 | import java.io.ByteArrayOutputStream; 20 | import java.io.OutputStreamWriter; 21 | import java.io.StringWriter; 22 | import java.io.Writer; 23 | import java.util.Map; 24 | import java.util.List; 25 | 26 | import com.amazonaws.AmazonClientException; 27 | import com.amazonaws.Request; 28 | import com.amazonaws.DefaultRequest; 29 | import com.amazonaws.http.HttpMethodName; 30 | import com.amazonaws.services.cognitosync.model.*; 31 | import com.amazonaws.transform.Marshaller; 32 | import com.amazonaws.util.BinaryUtils; 33 | import com.amazonaws.util.StringUtils; 34 | import com.amazonaws.util.StringInputStream; 35 | import com.amazonaws.util.json.AwsJsonWriter; 36 | import com.amazonaws.util.json.JsonUtils; 37 | 38 | /** 39 | * Describe Dataset Request Marshaller 40 | */ 41 | public class DescribeDatasetRequestMarshaller implements Marshaller, DescribeDatasetRequest> { 42 | 43 | public Request marshall(DescribeDatasetRequest describeDatasetRequest) { 44 | if (describeDatasetRequest == null) { 45 | throw new AmazonClientException("Invalid argument passed to marshall(...)"); 46 | } 47 | 48 | Request request = new DefaultRequest(describeDatasetRequest, "AmazonCognitoSync"); 49 | String target = "AWSCognitoSyncService.DescribeDataset"; 50 | request.addHeader("X-Amz-Target", target); 51 | 52 | request.setHttpMethod(HttpMethodName.GET); 53 | String uriResourcePath = "/identitypools/{IdentityPoolId}/identities/{IdentityId}/datasets/{DatasetName}"; 54 | uriResourcePath = uriResourcePath.replace("{IdentityPoolId}", (describeDatasetRequest.getIdentityPoolId() == null) ? "" : StringUtils.fromString(describeDatasetRequest.getIdentityPoolId())); 55 | uriResourcePath = uriResourcePath.replace("{IdentityId}", (describeDatasetRequest.getIdentityId() == null) ? "" : StringUtils.fromString(describeDatasetRequest.getIdentityId())); 56 | uriResourcePath = uriResourcePath.replace("{DatasetName}", (describeDatasetRequest.getDatasetName() == null) ? "" : StringUtils.fromString(describeDatasetRequest.getDatasetName())); 57 | 58 | uriResourcePath = uriResourcePath.replaceAll("//", "/"); 59 | 60 | if (uriResourcePath.contains("?")) { 61 | String queryString = uriResourcePath.substring(uriResourcePath.indexOf("?") + 1); 62 | uriResourcePath = uriResourcePath.substring(0, uriResourcePath.indexOf("?")); 63 | 64 | for (String s : queryString.split("[;&]")) { 65 | String[] nameValuePair = s.split("="); 66 | if (nameValuePair.length == 2) { 67 | if(!(nameValuePair[1].isEmpty())) 68 | request.addParameter(nameValuePair[0], nameValuePair[1]); 69 | } 70 | } 71 | } 72 | request.setResourcePath(uriResourcePath); 73 | 74 | if (!request.getHeaders().containsKey("Content-Type")) { 75 | request.addHeader("Content-Type", "application/x-amz-json-1.0"); 76 | } 77 | 78 | return request; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/transform/DescribeDatasetResultJsonUnmarshaller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazonaws.services.cognitosync.model.transform; 17 | 18 | import java.util.Map; 19 | import java.util.Map.Entry; 20 | 21 | import com.amazonaws.services.cognitosync.model.*; 22 | import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; 23 | import com.amazonaws.transform.*; 24 | import com.amazonaws.util.json.AwsJsonReader; 25 | 26 | /** 27 | * Describe Dataset Result JSON Unmarshaller 28 | */ 29 | public class DescribeDatasetResultJsonUnmarshaller implements Unmarshaller { 30 | 31 | public DescribeDatasetResult unmarshall(JsonUnmarshallerContext context) throws Exception { 32 | DescribeDatasetResult describeDatasetResult = new DescribeDatasetResult(); 33 | 34 | AwsJsonReader reader = context.getReader(); 35 | reader.beginObject(); 36 | while (reader.hasNext()) { 37 | String name = reader.nextName(); 38 | 39 | if (name.equals("Dataset")) { 40 | describeDatasetResult.setDataset(DatasetJsonUnmarshaller.getInstance().unmarshall(context)); 41 | } else 42 | { 43 | reader.skipValue(); 44 | } 45 | 46 | } 47 | reader.endObject(); 48 | 49 | return describeDatasetResult; 50 | } 51 | 52 | private static DescribeDatasetResultJsonUnmarshaller instance; 53 | public static DescribeDatasetResultJsonUnmarshaller getInstance() { 54 | if (instance == null) instance = new DescribeDatasetResultJsonUnmarshaller(); 55 | return instance; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/transform/InternalErrorExceptionUnmarshaller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model.transform; 16 | 17 | import com.amazonaws.AmazonServiceException; 18 | import com.amazonaws.http.JsonErrorResponseHandler.JsonErrorResponse; 19 | import com.amazonaws.transform.JsonErrorUnmarshaller; 20 | 21 | import com.amazonaws.services.cognitosync.model.InternalErrorException; 22 | 23 | public class InternalErrorExceptionUnmarshaller extends JsonErrorUnmarshaller { 24 | 25 | public InternalErrorExceptionUnmarshaller() { 26 | super(InternalErrorException.class); 27 | } 28 | 29 | @Override 30 | public boolean match(JsonErrorResponse error) throws Exception { 31 | return error.getErrorCode().equals("InternalErrorException"); 32 | } 33 | 34 | @Override 35 | public AmazonServiceException unmarshall(JsonErrorResponse error) throws Exception { 36 | InternalErrorException e = (InternalErrorException)super.unmarshall(error); 37 | e.setErrorCode("InternalErrorException"); 38 | 39 | return e; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/transform/InvalidConfigurationExceptionUnmarshaller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model.transform; 16 | 17 | import com.amazonaws.AmazonServiceException; 18 | import com.amazonaws.http.JsonErrorResponseHandler.JsonErrorResponse; 19 | import com.amazonaws.transform.JsonErrorUnmarshaller; 20 | 21 | import com.amazonaws.services.cognitosync.model.InvalidConfigurationException; 22 | 23 | public class InvalidConfigurationExceptionUnmarshaller extends JsonErrorUnmarshaller { 24 | 25 | public InvalidConfigurationExceptionUnmarshaller() { 26 | super(InvalidConfigurationException.class); 27 | } 28 | 29 | @Override 30 | public boolean match(JsonErrorResponse error) throws Exception { 31 | return error.getErrorCode().equals("InvalidConfigurationException"); 32 | } 33 | 34 | @Override 35 | public AmazonServiceException unmarshall(JsonErrorResponse error) throws Exception { 36 | InvalidConfigurationException e = (InvalidConfigurationException)super.unmarshall(error); 37 | e.setErrorCode("InvalidConfigurationException"); 38 | 39 | return e; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/transform/InvalidLambdaFunctionOutputExceptionUnmarshaller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model.transform; 16 | 17 | import com.amazonaws.AmazonServiceException; 18 | import com.amazonaws.http.JsonErrorResponseHandler.JsonErrorResponse; 19 | import com.amazonaws.transform.JsonErrorUnmarshaller; 20 | 21 | import com.amazonaws.services.cognitosync.model.InvalidLambdaFunctionOutputException; 22 | 23 | public class InvalidLambdaFunctionOutputExceptionUnmarshaller extends JsonErrorUnmarshaller { 24 | 25 | public InvalidLambdaFunctionOutputExceptionUnmarshaller() { 26 | super(InvalidLambdaFunctionOutputException.class); 27 | } 28 | 29 | @Override 30 | public boolean match(JsonErrorResponse error) throws Exception { 31 | return error.getErrorCode().equals("InvalidLambdaFunctionOutputException"); 32 | } 33 | 34 | @Override 35 | public AmazonServiceException unmarshall(JsonErrorResponse error) throws Exception { 36 | InvalidLambdaFunctionOutputException e = (InvalidLambdaFunctionOutputException)super.unmarshall(error); 37 | e.setErrorCode("InvalidLambdaFunctionOutputException"); 38 | 39 | return e; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/transform/InvalidParameterExceptionUnmarshaller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model.transform; 16 | 17 | import com.amazonaws.AmazonServiceException; 18 | import com.amazonaws.http.JsonErrorResponseHandler.JsonErrorResponse; 19 | import com.amazonaws.transform.JsonErrorUnmarshaller; 20 | 21 | import com.amazonaws.services.cognitosync.model.InvalidParameterException; 22 | 23 | public class InvalidParameterExceptionUnmarshaller extends JsonErrorUnmarshaller { 24 | 25 | public InvalidParameterExceptionUnmarshaller() { 26 | super(InvalidParameterException.class); 27 | } 28 | 29 | @Override 30 | public boolean match(JsonErrorResponse error) throws Exception { 31 | return error.getErrorCode().equals("InvalidParameterException"); 32 | } 33 | 34 | @Override 35 | public AmazonServiceException unmarshall(JsonErrorResponse error) throws Exception { 36 | InvalidParameterException e = (InvalidParameterException)super.unmarshall(error); 37 | e.setErrorCode("InvalidParameterException"); 38 | 39 | return e; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/transform/LambdaThrottledExceptionUnmarshaller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model.transform; 16 | 17 | import com.amazonaws.AmazonServiceException; 18 | import com.amazonaws.http.JsonErrorResponseHandler.JsonErrorResponse; 19 | import com.amazonaws.transform.JsonErrorUnmarshaller; 20 | 21 | import com.amazonaws.services.cognitosync.model.LambdaThrottledException; 22 | 23 | public class LambdaThrottledExceptionUnmarshaller extends JsonErrorUnmarshaller { 24 | 25 | public LambdaThrottledExceptionUnmarshaller() { 26 | super(LambdaThrottledException.class); 27 | } 28 | 29 | @Override 30 | public boolean match(JsonErrorResponse error) throws Exception { 31 | return error.getErrorCode().equals("LambdaThrottledException"); 32 | } 33 | 34 | @Override 35 | public AmazonServiceException unmarshall(JsonErrorResponse error) throws Exception { 36 | LambdaThrottledException e = (LambdaThrottledException)super.unmarshall(error); 37 | e.setErrorCode("LambdaThrottledException"); 38 | 39 | return e; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/transform/LimitExceededExceptionUnmarshaller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model.transform; 16 | 17 | import com.amazonaws.AmazonServiceException; 18 | import com.amazonaws.http.JsonErrorResponseHandler.JsonErrorResponse; 19 | import com.amazonaws.transform.JsonErrorUnmarshaller; 20 | 21 | import com.amazonaws.services.cognitosync.model.LimitExceededException; 22 | 23 | public class LimitExceededExceptionUnmarshaller extends JsonErrorUnmarshaller { 24 | 25 | public LimitExceededExceptionUnmarshaller() { 26 | super(LimitExceededException.class); 27 | } 28 | 29 | @Override 30 | public boolean match(JsonErrorResponse error) throws Exception { 31 | return error.getErrorCode().equals("LimitExceededException"); 32 | } 33 | 34 | @Override 35 | public AmazonServiceException unmarshall(JsonErrorResponse error) throws Exception { 36 | LimitExceededException e = (LimitExceededException)super.unmarshall(error); 37 | e.setErrorCode("LimitExceededException"); 38 | 39 | return e; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/transform/ListDatasetsRequestMarshaller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model.transform; 16 | 17 | import static com.amazonaws.util.StringUtils.UTF8; 18 | import java.io.ByteArrayInputStream; 19 | import java.io.ByteArrayOutputStream; 20 | import java.io.OutputStreamWriter; 21 | import java.io.StringWriter; 22 | import java.io.Writer; 23 | import java.util.Map; 24 | import java.util.List; 25 | 26 | import com.amazonaws.AmazonClientException; 27 | import com.amazonaws.Request; 28 | import com.amazonaws.DefaultRequest; 29 | import com.amazonaws.http.HttpMethodName; 30 | import com.amazonaws.services.cognitosync.model.*; 31 | import com.amazonaws.transform.Marshaller; 32 | import com.amazonaws.util.BinaryUtils; 33 | import com.amazonaws.util.StringUtils; 34 | import com.amazonaws.util.StringInputStream; 35 | import com.amazonaws.util.json.AwsJsonWriter; 36 | import com.amazonaws.util.json.JsonUtils; 37 | 38 | /** 39 | * List Datasets Request Marshaller 40 | */ 41 | public class ListDatasetsRequestMarshaller implements Marshaller, ListDatasetsRequest> { 42 | 43 | public Request marshall(ListDatasetsRequest listDatasetsRequest) { 44 | if (listDatasetsRequest == null) { 45 | throw new AmazonClientException("Invalid argument passed to marshall(...)"); 46 | } 47 | 48 | Request request = new DefaultRequest(listDatasetsRequest, "AmazonCognitoSync"); 49 | String target = "AWSCognitoSyncService.ListDatasets"; 50 | request.addHeader("X-Amz-Target", target); 51 | 52 | request.setHttpMethod(HttpMethodName.GET); 53 | String uriResourcePath = "/identitypools/{IdentityPoolId}/identities/{IdentityId}/datasets?maxResults={MaxResults};nextToken={NextToken}"; 54 | uriResourcePath = uriResourcePath.replace("{IdentityPoolId}", (listDatasetsRequest.getIdentityPoolId() == null) ? "" : StringUtils.fromString(listDatasetsRequest.getIdentityPoolId())); 55 | uriResourcePath = uriResourcePath.replace("{IdentityId}", (listDatasetsRequest.getIdentityId() == null) ? "" : StringUtils.fromString(listDatasetsRequest.getIdentityId())); 56 | uriResourcePath = uriResourcePath.replace("{NextToken}", (listDatasetsRequest.getNextToken() == null) ? "" : StringUtils.fromString(listDatasetsRequest.getNextToken())); 57 | uriResourcePath = uriResourcePath.replace("{MaxResults}", (listDatasetsRequest.getMaxResults() == null) ? "" : StringUtils.fromString(listDatasetsRequest.getMaxResults())); 58 | 59 | uriResourcePath = uriResourcePath.replaceAll("//", "/"); 60 | 61 | if (uriResourcePath.contains("?")) { 62 | String queryString = uriResourcePath.substring(uriResourcePath.indexOf("?") + 1); 63 | uriResourcePath = uriResourcePath.substring(0, uriResourcePath.indexOf("?")); 64 | 65 | for (String s : queryString.split("[;&]")) { 66 | String[] nameValuePair = s.split("="); 67 | if (nameValuePair.length == 2) { 68 | if(!(nameValuePair[1].isEmpty())) 69 | request.addParameter(nameValuePair[0], nameValuePair[1]); 70 | } 71 | } 72 | } 73 | request.setResourcePath(uriResourcePath); 74 | 75 | if (!request.getHeaders().containsKey("Content-Type")) { 76 | request.addHeader("Content-Type", "application/x-amz-json-1.0"); 77 | } 78 | 79 | return request; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/transform/ListDatasetsResultJsonUnmarshaller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazonaws.services.cognitosync.model.transform; 17 | 18 | import java.util.Map; 19 | import java.util.Map.Entry; 20 | 21 | import com.amazonaws.services.cognitosync.model.*; 22 | import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; 23 | import com.amazonaws.transform.*; 24 | import com.amazonaws.util.json.AwsJsonReader; 25 | 26 | /** 27 | * List Datasets Result JSON Unmarshaller 28 | */ 29 | public class ListDatasetsResultJsonUnmarshaller implements Unmarshaller { 30 | 31 | public ListDatasetsResult unmarshall(JsonUnmarshallerContext context) throws Exception { 32 | ListDatasetsResult listDatasetsResult = new ListDatasetsResult(); 33 | 34 | AwsJsonReader reader = context.getReader(); 35 | reader.beginObject(); 36 | while (reader.hasNext()) { 37 | String name = reader.nextName(); 38 | 39 | if (name.equals("Datasets")) { 40 | listDatasetsResult.setDatasets(new ListUnmarshaller(DatasetJsonUnmarshaller.getInstance()).unmarshall(context)); 41 | } else 42 | if (name.equals("Count")) { 43 | listDatasetsResult.setCount(IntegerJsonUnmarshaller.getInstance().unmarshall(context)); 44 | } else 45 | if (name.equals("NextToken")) { 46 | listDatasetsResult.setNextToken(StringJsonUnmarshaller.getInstance().unmarshall(context)); 47 | } else 48 | { 49 | reader.skipValue(); 50 | } 51 | 52 | } 53 | reader.endObject(); 54 | 55 | return listDatasetsResult; 56 | } 57 | 58 | private static ListDatasetsResultJsonUnmarshaller instance; 59 | public static ListDatasetsResultJsonUnmarshaller getInstance() { 60 | if (instance == null) instance = new ListDatasetsResultJsonUnmarshaller(); 61 | return instance; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/transform/ListRecordsRequestMarshaller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model.transform; 16 | 17 | import static com.amazonaws.util.StringUtils.UTF8; 18 | import java.io.ByteArrayInputStream; 19 | import java.io.ByteArrayOutputStream; 20 | import java.io.OutputStreamWriter; 21 | import java.io.StringWriter; 22 | import java.io.Writer; 23 | import java.util.Map; 24 | import java.util.List; 25 | 26 | import com.amazonaws.AmazonClientException; 27 | import com.amazonaws.Request; 28 | import com.amazonaws.DefaultRequest; 29 | import com.amazonaws.http.HttpMethodName; 30 | import com.amazonaws.services.cognitosync.model.*; 31 | import com.amazonaws.transform.Marshaller; 32 | import com.amazonaws.util.BinaryUtils; 33 | import com.amazonaws.util.StringUtils; 34 | import com.amazonaws.util.StringInputStream; 35 | import com.amazonaws.util.json.AwsJsonWriter; 36 | import com.amazonaws.util.json.JsonUtils; 37 | 38 | /** 39 | * List Records Request Marshaller 40 | */ 41 | public class ListRecordsRequestMarshaller implements Marshaller, ListRecordsRequest> { 42 | 43 | public Request marshall(ListRecordsRequest listRecordsRequest) { 44 | if (listRecordsRequest == null) { 45 | throw new AmazonClientException("Invalid argument passed to marshall(...)"); 46 | } 47 | 48 | Request request = new DefaultRequest(listRecordsRequest, "AmazonCognitoSync"); 49 | String target = "AWSCognitoSyncService.ListRecords"; 50 | request.addHeader("X-Amz-Target", target); 51 | 52 | request.setHttpMethod(HttpMethodName.GET); 53 | String uriResourcePath = "/identitypools/{IdentityPoolId}/identities/{IdentityId}/datasets/{DatasetName}/records?lastSyncCount={LastSyncCount};maxResults={MaxResults};nextToken={NextToken};syncSessionToken={SyncSessionToken}"; 54 | uriResourcePath = uriResourcePath.replace("{IdentityPoolId}", (listRecordsRequest.getIdentityPoolId() == null) ? "" : StringUtils.fromString(listRecordsRequest.getIdentityPoolId())); 55 | uriResourcePath = uriResourcePath.replace("{IdentityId}", (listRecordsRequest.getIdentityId() == null) ? "" : StringUtils.fromString(listRecordsRequest.getIdentityId())); 56 | uriResourcePath = uriResourcePath.replace("{DatasetName}", (listRecordsRequest.getDatasetName() == null) ? "" : StringUtils.fromString(listRecordsRequest.getDatasetName())); 57 | uriResourcePath = uriResourcePath.replace("{LastSyncCount}", (listRecordsRequest.getLastSyncCount() == null) ? "" : StringUtils.fromString(listRecordsRequest.getLastSyncCount())); 58 | uriResourcePath = uriResourcePath.replace("{NextToken}", (listRecordsRequest.getNextToken() == null) ? "" : StringUtils.fromString(listRecordsRequest.getNextToken())); 59 | uriResourcePath = uriResourcePath.replace("{MaxResults}", (listRecordsRequest.getMaxResults() == null) ? "" : StringUtils.fromString(listRecordsRequest.getMaxResults())); 60 | uriResourcePath = uriResourcePath.replace("{SyncSessionToken}", (listRecordsRequest.getSyncSessionToken() == null) ? "" : StringUtils.fromString(listRecordsRequest.getSyncSessionToken())); 61 | 62 | uriResourcePath = uriResourcePath.replaceAll("//", "/"); 63 | 64 | if (uriResourcePath.contains("?")) { 65 | String queryString = uriResourcePath.substring(uriResourcePath.indexOf("?") + 1); 66 | uriResourcePath = uriResourcePath.substring(0, uriResourcePath.indexOf("?")); 67 | 68 | for (String s : queryString.split("[;&]")) { 69 | String[] nameValuePair = s.split("="); 70 | if (nameValuePair.length == 2) { 71 | if(!(nameValuePair[1].isEmpty())) 72 | request.addParameter(nameValuePair[0], nameValuePair[1]); 73 | } 74 | } 75 | } 76 | request.setResourcePath(uriResourcePath); 77 | 78 | if (!request.getHeaders().containsKey("Content-Type")) { 79 | request.addHeader("Content-Type", "application/x-amz-json-1.0"); 80 | } 81 | 82 | return request; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/transform/ListRecordsResultJsonUnmarshaller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazonaws.services.cognitosync.model.transform; 17 | 18 | import java.util.Map; 19 | import java.util.Map.Entry; 20 | 21 | import com.amazonaws.services.cognitosync.model.*; 22 | import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; 23 | import com.amazonaws.transform.*; 24 | import com.amazonaws.util.json.AwsJsonReader; 25 | 26 | /** 27 | * List Records Result JSON Unmarshaller 28 | */ 29 | public class ListRecordsResultJsonUnmarshaller implements Unmarshaller { 30 | 31 | public ListRecordsResult unmarshall(JsonUnmarshallerContext context) throws Exception { 32 | ListRecordsResult listRecordsResult = new ListRecordsResult(); 33 | 34 | AwsJsonReader reader = context.getReader(); 35 | reader.beginObject(); 36 | while (reader.hasNext()) { 37 | String name = reader.nextName(); 38 | 39 | if (name.equals("Records")) { 40 | listRecordsResult.setRecords(new ListUnmarshaller(RecordJsonUnmarshaller.getInstance()).unmarshall(context)); 41 | } else 42 | if (name.equals("NextToken")) { 43 | listRecordsResult.setNextToken(StringJsonUnmarshaller.getInstance().unmarshall(context)); 44 | } else 45 | if (name.equals("Count")) { 46 | listRecordsResult.setCount(IntegerJsonUnmarshaller.getInstance().unmarshall(context)); 47 | } else 48 | if (name.equals("DatasetSyncCount")) { 49 | listRecordsResult.setDatasetSyncCount(LongJsonUnmarshaller.getInstance().unmarshall(context)); 50 | } else 51 | if (name.equals("LastModifiedBy")) { 52 | listRecordsResult.setLastModifiedBy(StringJsonUnmarshaller.getInstance().unmarshall(context)); 53 | } else 54 | if (name.equals("MergedDatasetNames")) { 55 | listRecordsResult.setMergedDatasetNames(new ListUnmarshaller(StringJsonUnmarshaller.getInstance()).unmarshall(context)); 56 | } else 57 | if (name.equals("DatasetExists")) { 58 | listRecordsResult.setDatasetExists(BooleanJsonUnmarshaller.getInstance().unmarshall(context)); 59 | } else 60 | if (name.equals("DatasetDeletedAfterRequestedSyncCount")) { 61 | listRecordsResult.setDatasetDeletedAfterRequestedSyncCount(BooleanJsonUnmarshaller.getInstance().unmarshall(context)); 62 | } else 63 | if (name.equals("SyncSessionToken")) { 64 | listRecordsResult.setSyncSessionToken(StringJsonUnmarshaller.getInstance().unmarshall(context)); 65 | } else 66 | { 67 | reader.skipValue(); 68 | } 69 | 70 | } 71 | reader.endObject(); 72 | 73 | return listRecordsResult; 74 | } 75 | 76 | private static ListRecordsResultJsonUnmarshaller instance; 77 | public static ListRecordsResultJsonUnmarshaller getInstance() { 78 | if (instance == null) instance = new ListRecordsResultJsonUnmarshaller(); 79 | return instance; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/transform/NotAuthorizedExceptionUnmarshaller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model.transform; 16 | 17 | import com.amazonaws.AmazonServiceException; 18 | import com.amazonaws.http.JsonErrorResponseHandler.JsonErrorResponse; 19 | import com.amazonaws.transform.JsonErrorUnmarshaller; 20 | 21 | import com.amazonaws.services.cognitosync.model.NotAuthorizedException; 22 | 23 | public class NotAuthorizedExceptionUnmarshaller extends JsonErrorUnmarshaller { 24 | 25 | public NotAuthorizedExceptionUnmarshaller() { 26 | super(NotAuthorizedException.class); 27 | } 28 | 29 | @Override 30 | public boolean match(JsonErrorResponse error) throws Exception { 31 | return error.getErrorCode().equals("NotAuthorizedException"); 32 | } 33 | 34 | @Override 35 | public AmazonServiceException unmarshall(JsonErrorResponse error) throws Exception { 36 | NotAuthorizedException e = (NotAuthorizedException)super.unmarshall(error); 37 | e.setErrorCode("NotAuthorizedException"); 38 | 39 | return e; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/transform/RecordJsonUnmarshaller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazonaws.services.cognitosync.model.transform; 17 | 18 | import java.util.Map; 19 | import java.util.Map.Entry; 20 | 21 | import com.amazonaws.services.cognitosync.model.*; 22 | import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; 23 | import com.amazonaws.transform.*; 24 | import com.amazonaws.util.json.AwsJsonReader; 25 | 26 | /** 27 | * Record JSON Unmarshaller 28 | */ 29 | public class RecordJsonUnmarshaller implements Unmarshaller { 30 | 31 | public Record unmarshall(JsonUnmarshallerContext context) throws Exception { 32 | Record record = new Record(); 33 | 34 | AwsJsonReader reader = context.getReader(); 35 | reader.beginObject(); 36 | while (reader.hasNext()) { 37 | String name = reader.nextName(); 38 | 39 | if (name.equals("Key")) { 40 | record.setKey(StringJsonUnmarshaller.getInstance().unmarshall(context)); 41 | } else 42 | if (name.equals("Value")) { 43 | record.setValue(StringJsonUnmarshaller.getInstance().unmarshall(context)); 44 | } else 45 | if (name.equals("SyncCount")) { 46 | record.setSyncCount(LongJsonUnmarshaller.getInstance().unmarshall(context)); 47 | } else 48 | if (name.equals("LastModifiedDate")) { 49 | record.setLastModifiedDate(DateJsonUnmarshaller.getInstance().unmarshall(context)); 50 | } else 51 | if (name.equals("LastModifiedBy")) { 52 | record.setLastModifiedBy(StringJsonUnmarshaller.getInstance().unmarshall(context)); 53 | } else 54 | if (name.equals("DeviceLastModifiedDate")) { 55 | record.setDeviceLastModifiedDate(DateJsonUnmarshaller.getInstance().unmarshall(context)); 56 | } else 57 | { 58 | reader.skipValue(); 59 | } 60 | 61 | } 62 | reader.endObject(); 63 | 64 | return record; 65 | } 66 | 67 | private static RecordJsonUnmarshaller instance; 68 | public static RecordJsonUnmarshaller getInstance() { 69 | if (instance == null) instance = new RecordJsonUnmarshaller(); 70 | return instance; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/transform/RegisterDeviceRequestMarshaller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model.transform; 16 | 17 | import static com.amazonaws.util.StringUtils.UTF8; 18 | import java.io.ByteArrayInputStream; 19 | import java.io.ByteArrayOutputStream; 20 | import java.io.OutputStreamWriter; 21 | import java.io.StringWriter; 22 | import java.io.Writer; 23 | import java.util.Map; 24 | import java.util.List; 25 | 26 | import com.amazonaws.AmazonClientException; 27 | import com.amazonaws.Request; 28 | import com.amazonaws.DefaultRequest; 29 | import com.amazonaws.http.HttpMethodName; 30 | import com.amazonaws.services.cognitosync.model.*; 31 | import com.amazonaws.transform.Marshaller; 32 | import com.amazonaws.util.BinaryUtils; 33 | import com.amazonaws.util.StringUtils; 34 | import com.amazonaws.util.StringInputStream; 35 | import com.amazonaws.util.json.AwsJsonWriter; 36 | import com.amazonaws.util.json.JsonUtils; 37 | 38 | /** 39 | * Register Device Request Marshaller 40 | */ 41 | public class RegisterDeviceRequestMarshaller implements Marshaller, RegisterDeviceRequest> { 42 | 43 | public Request marshall(RegisterDeviceRequest registerDeviceRequest) { 44 | if (registerDeviceRequest == null) { 45 | throw new AmazonClientException("Invalid argument passed to marshall(...)"); 46 | } 47 | 48 | Request request = new DefaultRequest(registerDeviceRequest, "AmazonCognitoSync"); 49 | String target = "AWSCognitoSyncService.RegisterDevice"; 50 | request.addHeader("X-Amz-Target", target); 51 | 52 | request.setHttpMethod(HttpMethodName.POST); 53 | String uriResourcePath = "/identitypools/{IdentityPoolId}/identity/{IdentityId}/device"; 54 | uriResourcePath = uriResourcePath.replace("{IdentityPoolId}", (registerDeviceRequest.getIdentityPoolId() == null) ? "" : StringUtils.fromString(registerDeviceRequest.getIdentityPoolId())); 55 | uriResourcePath = uriResourcePath.replace("{IdentityId}", (registerDeviceRequest.getIdentityId() == null) ? "" : StringUtils.fromString(registerDeviceRequest.getIdentityId())); 56 | 57 | uriResourcePath = uriResourcePath.replaceAll("//", "/"); 58 | 59 | if (uriResourcePath.contains("?")) { 60 | String queryString = uriResourcePath.substring(uriResourcePath.indexOf("?") + 1); 61 | uriResourcePath = uriResourcePath.substring(0, uriResourcePath.indexOf("?")); 62 | 63 | for (String s : queryString.split("[;&]")) { 64 | String[] nameValuePair = s.split("="); 65 | if (nameValuePair.length == 2) { 66 | if(!(nameValuePair[1].isEmpty())) 67 | request.addParameter(nameValuePair[0], nameValuePair[1]); 68 | } 69 | } 70 | } 71 | request.setResourcePath(uriResourcePath); 72 | 73 | try { 74 | StringWriter stringWriter = new StringWriter(); 75 | AwsJsonWriter jsonWriter = JsonUtils.getJsonWriter(stringWriter); 76 | 77 | jsonWriter.beginObject(); 78 | 79 | if (registerDeviceRequest.getPlatform() != null) { 80 | jsonWriter.name("Platform").value(registerDeviceRequest.getPlatform()); 81 | } 82 | if (registerDeviceRequest.getToken() != null) { 83 | jsonWriter.name("Token").value(registerDeviceRequest.getToken()); 84 | } 85 | 86 | jsonWriter.endObject(); 87 | 88 | jsonWriter.close(); 89 | String snippet = stringWriter.toString(); 90 | byte[] content = snippet.getBytes(UTF8); 91 | request.setContent(new StringInputStream(snippet)); 92 | request.addHeader("Content-Length", Integer.toString(content.length)); 93 | request.addHeader("Content-Type", "application/x-amz-json-1.0"); 94 | } catch(Throwable t) { 95 | throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); 96 | } 97 | 98 | return request; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/transform/RegisterDeviceResultJsonUnmarshaller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazonaws.services.cognitosync.model.transform; 17 | 18 | import java.util.Map; 19 | import java.util.Map.Entry; 20 | 21 | import com.amazonaws.services.cognitosync.model.*; 22 | import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; 23 | import com.amazonaws.transform.*; 24 | import com.amazonaws.util.json.AwsJsonReader; 25 | 26 | /** 27 | * Register Device Result JSON Unmarshaller 28 | */ 29 | public class RegisterDeviceResultJsonUnmarshaller implements Unmarshaller { 30 | 31 | public RegisterDeviceResult unmarshall(JsonUnmarshallerContext context) throws Exception { 32 | RegisterDeviceResult registerDeviceResult = new RegisterDeviceResult(); 33 | 34 | AwsJsonReader reader = context.getReader(); 35 | reader.beginObject(); 36 | while (reader.hasNext()) { 37 | String name = reader.nextName(); 38 | 39 | if (name.equals("DeviceId")) { 40 | registerDeviceResult.setDeviceId(StringJsonUnmarshaller.getInstance().unmarshall(context)); 41 | } else 42 | { 43 | reader.skipValue(); 44 | } 45 | 46 | } 47 | reader.endObject(); 48 | 49 | return registerDeviceResult; 50 | } 51 | 52 | private static RegisterDeviceResultJsonUnmarshaller instance; 53 | public static RegisterDeviceResultJsonUnmarshaller getInstance() { 54 | if (instance == null) instance = new RegisterDeviceResultJsonUnmarshaller(); 55 | return instance; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/transform/ResourceConflictExceptionUnmarshaller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model.transform; 16 | 17 | import com.amazonaws.AmazonServiceException; 18 | import com.amazonaws.http.JsonErrorResponseHandler.JsonErrorResponse; 19 | import com.amazonaws.transform.JsonErrorUnmarshaller; 20 | 21 | import com.amazonaws.services.cognitosync.model.ResourceConflictException; 22 | 23 | public class ResourceConflictExceptionUnmarshaller extends JsonErrorUnmarshaller { 24 | 25 | public ResourceConflictExceptionUnmarshaller() { 26 | super(ResourceConflictException.class); 27 | } 28 | 29 | @Override 30 | public boolean match(JsonErrorResponse error) throws Exception { 31 | return error.getErrorCode().equals("ResourceConflictException"); 32 | } 33 | 34 | @Override 35 | public AmazonServiceException unmarshall(JsonErrorResponse error) throws Exception { 36 | ResourceConflictException e = (ResourceConflictException)super.unmarshall(error); 37 | e.setErrorCode("ResourceConflictException"); 38 | 39 | return e; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/transform/ResourceNotFoundExceptionUnmarshaller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model.transform; 16 | 17 | import com.amazonaws.AmazonServiceException; 18 | import com.amazonaws.http.JsonErrorResponseHandler.JsonErrorResponse; 19 | import com.amazonaws.transform.JsonErrorUnmarshaller; 20 | 21 | import com.amazonaws.services.cognitosync.model.ResourceNotFoundException; 22 | 23 | public class ResourceNotFoundExceptionUnmarshaller extends JsonErrorUnmarshaller { 24 | 25 | public ResourceNotFoundExceptionUnmarshaller() { 26 | super(ResourceNotFoundException.class); 27 | } 28 | 29 | @Override 30 | public boolean match(JsonErrorResponse error) throws Exception { 31 | return error.getErrorCode().equals("ResourceNotFoundException"); 32 | } 33 | 34 | @Override 35 | public AmazonServiceException unmarshall(JsonErrorResponse error) throws Exception { 36 | ResourceNotFoundException e = (ResourceNotFoundException)super.unmarshall(error); 37 | e.setErrorCode("ResourceNotFoundException"); 38 | 39 | return e; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/transform/SubscribeToDatasetRequestMarshaller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model.transform; 16 | 17 | import static com.amazonaws.util.StringUtils.UTF8; 18 | import java.io.ByteArrayInputStream; 19 | import java.io.ByteArrayOutputStream; 20 | import java.io.OutputStreamWriter; 21 | import java.io.StringWriter; 22 | import java.io.Writer; 23 | import java.util.Map; 24 | import java.util.List; 25 | 26 | import com.amazonaws.AmazonClientException; 27 | import com.amazonaws.Request; 28 | import com.amazonaws.DefaultRequest; 29 | import com.amazonaws.http.HttpMethodName; 30 | import com.amazonaws.services.cognitosync.model.*; 31 | import com.amazonaws.transform.Marshaller; 32 | import com.amazonaws.util.BinaryUtils; 33 | import com.amazonaws.util.StringUtils; 34 | import com.amazonaws.util.StringInputStream; 35 | import com.amazonaws.util.json.AwsJsonWriter; 36 | import com.amazonaws.util.json.JsonUtils; 37 | 38 | /** 39 | * Subscribe To Dataset Request Marshaller 40 | */ 41 | public class SubscribeToDatasetRequestMarshaller implements Marshaller, SubscribeToDatasetRequest> { 42 | 43 | public Request marshall(SubscribeToDatasetRequest subscribeToDatasetRequest) { 44 | if (subscribeToDatasetRequest == null) { 45 | throw new AmazonClientException("Invalid argument passed to marshall(...)"); 46 | } 47 | 48 | Request request = new DefaultRequest(subscribeToDatasetRequest, "AmazonCognitoSync"); 49 | String target = "AWSCognitoSyncService.SubscribeToDataset"; 50 | request.addHeader("X-Amz-Target", target); 51 | 52 | request.setHttpMethod(HttpMethodName.POST); 53 | String uriResourcePath = "/identitypools/{IdentityPoolId}/identities/{IdentityId}/datasets/{DatasetName}/subscriptions/{DeviceId}"; 54 | uriResourcePath = uriResourcePath.replace("{IdentityPoolId}", (subscribeToDatasetRequest.getIdentityPoolId() == null) ? "" : StringUtils.fromString(subscribeToDatasetRequest.getIdentityPoolId())); 55 | uriResourcePath = uriResourcePath.replace("{IdentityId}", (subscribeToDatasetRequest.getIdentityId() == null) ? "" : StringUtils.fromString(subscribeToDatasetRequest.getIdentityId())); 56 | uriResourcePath = uriResourcePath.replace("{DatasetName}", (subscribeToDatasetRequest.getDatasetName() == null) ? "" : StringUtils.fromString(subscribeToDatasetRequest.getDatasetName())); 57 | uriResourcePath = uriResourcePath.replace("{DeviceId}", (subscribeToDatasetRequest.getDeviceId() == null) ? "" : StringUtils.fromString(subscribeToDatasetRequest.getDeviceId())); 58 | 59 | uriResourcePath = uriResourcePath.replaceAll("//", "/"); 60 | 61 | if (uriResourcePath.contains("?")) { 62 | String queryString = uriResourcePath.substring(uriResourcePath.indexOf("?") + 1); 63 | uriResourcePath = uriResourcePath.substring(0, uriResourcePath.indexOf("?")); 64 | 65 | for (String s : queryString.split("[;&]")) { 66 | String[] nameValuePair = s.split("="); 67 | if (nameValuePair.length == 2) { 68 | if(!(nameValuePair[1].isEmpty())) 69 | request.addParameter(nameValuePair[0], nameValuePair[1]); 70 | } 71 | } 72 | } 73 | request.setResourcePath(uriResourcePath); 74 | 75 | request.addHeader("Content-Length", "0"); 76 | request.setContent(new ByteArrayInputStream(new byte[0])); 77 | 78 | if (!request.getHeaders().containsKey("Content-Type")) { 79 | request.addHeader("Content-Type", "application/x-amz-json-1.0"); 80 | } 81 | 82 | return request; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/transform/SubscribeToDatasetResultJsonUnmarshaller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazonaws.services.cognitosync.model.transform; 17 | 18 | import java.util.Map; 19 | import java.util.Map.Entry; 20 | 21 | import com.amazonaws.services.cognitosync.model.*; 22 | import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; 23 | import com.amazonaws.transform.*; 24 | import com.amazonaws.util.json.AwsJsonReader; 25 | 26 | /** 27 | * Subscribe To Dataset Result JSON Unmarshaller 28 | */ 29 | public class SubscribeToDatasetResultJsonUnmarshaller implements Unmarshaller { 30 | 31 | public SubscribeToDatasetResult unmarshall(JsonUnmarshallerContext context) throws Exception { 32 | SubscribeToDatasetResult subscribeToDatasetResult = new SubscribeToDatasetResult(); 33 | 34 | return subscribeToDatasetResult; 35 | } 36 | 37 | private static SubscribeToDatasetResultJsonUnmarshaller instance; 38 | public static SubscribeToDatasetResultJsonUnmarshaller getInstance() { 39 | if (instance == null) instance = new SubscribeToDatasetResultJsonUnmarshaller(); 40 | return instance; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/transform/TooManyRequestsExceptionUnmarshaller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model.transform; 16 | 17 | import com.amazonaws.AmazonServiceException; 18 | import com.amazonaws.http.JsonErrorResponseHandler.JsonErrorResponse; 19 | import com.amazonaws.transform.JsonErrorUnmarshaller; 20 | 21 | import com.amazonaws.services.cognitosync.model.TooManyRequestsException; 22 | 23 | public class TooManyRequestsExceptionUnmarshaller extends JsonErrorUnmarshaller { 24 | 25 | public TooManyRequestsExceptionUnmarshaller() { 26 | super(TooManyRequestsException.class); 27 | } 28 | 29 | @Override 30 | public boolean match(JsonErrorResponse error) throws Exception { 31 | return error.getErrorCode().equals("TooManyRequestsException"); 32 | } 33 | 34 | @Override 35 | public AmazonServiceException unmarshall(JsonErrorResponse error) throws Exception { 36 | TooManyRequestsException e = (TooManyRequestsException)super.unmarshall(error); 37 | e.setErrorCode("TooManyRequestsException"); 38 | 39 | return e; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/transform/UnsubscribeFromDatasetRequestMarshaller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model.transform; 16 | 17 | import static com.amazonaws.util.StringUtils.UTF8; 18 | import java.io.ByteArrayInputStream; 19 | import java.io.ByteArrayOutputStream; 20 | import java.io.OutputStreamWriter; 21 | import java.io.StringWriter; 22 | import java.io.Writer; 23 | import java.util.Map; 24 | import java.util.List; 25 | 26 | import com.amazonaws.AmazonClientException; 27 | import com.amazonaws.Request; 28 | import com.amazonaws.DefaultRequest; 29 | import com.amazonaws.http.HttpMethodName; 30 | import com.amazonaws.services.cognitosync.model.*; 31 | import com.amazonaws.transform.Marshaller; 32 | import com.amazonaws.util.BinaryUtils; 33 | import com.amazonaws.util.StringUtils; 34 | import com.amazonaws.util.StringInputStream; 35 | import com.amazonaws.util.json.AwsJsonWriter; 36 | import com.amazonaws.util.json.JsonUtils; 37 | 38 | /** 39 | * Unsubscribe From Dataset Request Marshaller 40 | */ 41 | public class UnsubscribeFromDatasetRequestMarshaller implements Marshaller, UnsubscribeFromDatasetRequest> { 42 | 43 | public Request marshall(UnsubscribeFromDatasetRequest unsubscribeFromDatasetRequest) { 44 | if (unsubscribeFromDatasetRequest == null) { 45 | throw new AmazonClientException("Invalid argument passed to marshall(...)"); 46 | } 47 | 48 | Request request = new DefaultRequest(unsubscribeFromDatasetRequest, "AmazonCognitoSync"); 49 | String target = "AWSCognitoSyncService.UnsubscribeFromDataset"; 50 | request.addHeader("X-Amz-Target", target); 51 | 52 | request.setHttpMethod(HttpMethodName.DELETE); 53 | String uriResourcePath = "/identitypools/{IdentityPoolId}/identities/{IdentityId}/datasets/{DatasetName}/subscriptions/{DeviceId}"; 54 | uriResourcePath = uriResourcePath.replace("{IdentityPoolId}", (unsubscribeFromDatasetRequest.getIdentityPoolId() == null) ? "" : StringUtils.fromString(unsubscribeFromDatasetRequest.getIdentityPoolId())); 55 | uriResourcePath = uriResourcePath.replace("{IdentityId}", (unsubscribeFromDatasetRequest.getIdentityId() == null) ? "" : StringUtils.fromString(unsubscribeFromDatasetRequest.getIdentityId())); 56 | uriResourcePath = uriResourcePath.replace("{DatasetName}", (unsubscribeFromDatasetRequest.getDatasetName() == null) ? "" : StringUtils.fromString(unsubscribeFromDatasetRequest.getDatasetName())); 57 | uriResourcePath = uriResourcePath.replace("{DeviceId}", (unsubscribeFromDatasetRequest.getDeviceId() == null) ? "" : StringUtils.fromString(unsubscribeFromDatasetRequest.getDeviceId())); 58 | 59 | uriResourcePath = uriResourcePath.replaceAll("//", "/"); 60 | 61 | if (uriResourcePath.contains("?")) { 62 | String queryString = uriResourcePath.substring(uriResourcePath.indexOf("?") + 1); 63 | uriResourcePath = uriResourcePath.substring(0, uriResourcePath.indexOf("?")); 64 | 65 | for (String s : queryString.split("[;&]")) { 66 | String[] nameValuePair = s.split("="); 67 | if (nameValuePair.length == 2) { 68 | if(!(nameValuePair[1].isEmpty())) 69 | request.addParameter(nameValuePair[0], nameValuePair[1]); 70 | } 71 | } 72 | } 73 | request.setResourcePath(uriResourcePath); 74 | 75 | if (!request.getHeaders().containsKey("Content-Type")) { 76 | request.addHeader("Content-Type", "application/x-amz-json-1.0"); 77 | } 78 | 79 | return request; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/transform/UnsubscribeFromDatasetResultJsonUnmarshaller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazonaws.services.cognitosync.model.transform; 17 | 18 | import java.util.Map; 19 | import java.util.Map.Entry; 20 | 21 | import com.amazonaws.services.cognitosync.model.*; 22 | import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; 23 | import com.amazonaws.transform.*; 24 | import com.amazonaws.util.json.AwsJsonReader; 25 | 26 | /** 27 | * Unsubscribe From Dataset Result JSON Unmarshaller 28 | */ 29 | public class UnsubscribeFromDatasetResultJsonUnmarshaller implements Unmarshaller { 30 | 31 | public UnsubscribeFromDatasetResult unmarshall(JsonUnmarshallerContext context) throws Exception { 32 | UnsubscribeFromDatasetResult unsubscribeFromDatasetResult = new UnsubscribeFromDatasetResult(); 33 | 34 | return unsubscribeFromDatasetResult; 35 | } 36 | 37 | private static UnsubscribeFromDatasetResultJsonUnmarshaller instance; 38 | public static UnsubscribeFromDatasetResultJsonUnmarshaller getInstance() { 39 | if (instance == null) instance = new UnsubscribeFromDatasetResultJsonUnmarshaller(); 40 | return instance; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/transform/UpdateRecordsRequestMarshaller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazonaws.services.cognitosync.model.transform; 16 | 17 | import static com.amazonaws.util.StringUtils.UTF8; 18 | import java.io.ByteArrayInputStream; 19 | import java.io.ByteArrayOutputStream; 20 | import java.io.OutputStreamWriter; 21 | import java.io.StringWriter; 22 | import java.io.Writer; 23 | import java.util.Map; 24 | import java.util.List; 25 | 26 | import com.amazonaws.AmazonClientException; 27 | import com.amazonaws.Request; 28 | import com.amazonaws.DefaultRequest; 29 | import com.amazonaws.http.HttpMethodName; 30 | import com.amazonaws.services.cognitosync.model.*; 31 | import com.amazonaws.transform.Marshaller; 32 | import com.amazonaws.util.BinaryUtils; 33 | import com.amazonaws.util.StringUtils; 34 | import com.amazonaws.util.StringInputStream; 35 | import com.amazonaws.util.json.AwsJsonWriter; 36 | import com.amazonaws.util.json.JsonUtils; 37 | 38 | /** 39 | * Update Records Request Marshaller 40 | */ 41 | public class UpdateRecordsRequestMarshaller implements Marshaller, UpdateRecordsRequest> { 42 | 43 | public Request marshall(UpdateRecordsRequest updateRecordsRequest) { 44 | if (updateRecordsRequest == null) { 45 | throw new AmazonClientException("Invalid argument passed to marshall(...)"); 46 | } 47 | 48 | Request request = new DefaultRequest(updateRecordsRequest, "AmazonCognitoSync"); 49 | String target = "AWSCognitoSyncService.UpdateRecords"; 50 | request.addHeader("X-Amz-Target", target); 51 | 52 | request.setHttpMethod(HttpMethodName.POST); 53 | if (updateRecordsRequest.getClientContext() != null) 54 | request.addHeader("x-amz-Client-Context", StringUtils.fromString(updateRecordsRequest.getClientContext())); 55 | 56 | String uriResourcePath = "/identitypools/{IdentityPoolId}/identities/{IdentityId}/datasets/{DatasetName}"; 57 | uriResourcePath = uriResourcePath.replace("{IdentityPoolId}", (updateRecordsRequest.getIdentityPoolId() == null) ? "" : StringUtils.fromString(updateRecordsRequest.getIdentityPoolId())); 58 | uriResourcePath = uriResourcePath.replace("{IdentityId}", (updateRecordsRequest.getIdentityId() == null) ? "" : StringUtils.fromString(updateRecordsRequest.getIdentityId())); 59 | uriResourcePath = uriResourcePath.replace("{DatasetName}", (updateRecordsRequest.getDatasetName() == null) ? "" : StringUtils.fromString(updateRecordsRequest.getDatasetName())); 60 | 61 | uriResourcePath = uriResourcePath.replaceAll("//", "/"); 62 | 63 | if (uriResourcePath.contains("?")) { 64 | String queryString = uriResourcePath.substring(uriResourcePath.indexOf("?") + 1); 65 | uriResourcePath = uriResourcePath.substring(0, uriResourcePath.indexOf("?")); 66 | 67 | for (String s : queryString.split("[;&]")) { 68 | String[] nameValuePair = s.split("="); 69 | if (nameValuePair.length == 2) { 70 | if(!(nameValuePair[1].isEmpty())) 71 | request.addParameter(nameValuePair[0], nameValuePair[1]); 72 | } 73 | } 74 | } 75 | request.setResourcePath(uriResourcePath); 76 | 77 | try { 78 | StringWriter stringWriter = new StringWriter(); 79 | AwsJsonWriter jsonWriter = JsonUtils.getJsonWriter(stringWriter); 80 | 81 | jsonWriter.beginObject(); 82 | 83 | if (updateRecordsRequest.getDeviceId() != null) { 84 | jsonWriter.name("DeviceId").value(updateRecordsRequest.getDeviceId()); 85 | } 86 | 87 | com.amazonaws.internal.ListWithAutoConstructFlag recordPatchesList = (com.amazonaws.internal.ListWithAutoConstructFlag)(updateRecordsRequest.getRecordPatches()); 88 | if (recordPatchesList != null && !(recordPatchesList.isAutoConstruct() && recordPatchesList.isEmpty())) { 89 | 90 | jsonWriter.name("RecordPatches"); 91 | jsonWriter.beginArray(); 92 | 93 | for (RecordPatch recordPatchesListValue : recordPatchesList) { 94 | if (recordPatchesListValue != null) { 95 | jsonWriter.beginObject(); 96 | if (recordPatchesListValue.getOp() != null) { 97 | jsonWriter.name("Op").value(recordPatchesListValue.getOp()); 98 | } 99 | if (recordPatchesListValue.getKey() != null) { 100 | jsonWriter.name("Key").value(recordPatchesListValue.getKey()); 101 | } 102 | if (recordPatchesListValue.getValue() != null) { 103 | jsonWriter.name("Value").value(recordPatchesListValue.getValue()); 104 | } 105 | if (recordPatchesListValue.getSyncCount() != null) { 106 | jsonWriter.name("SyncCount").value(recordPatchesListValue.getSyncCount()); 107 | } 108 | if (recordPatchesListValue.getDeviceLastModifiedDate() != null) { 109 | jsonWriter.name("DeviceLastModifiedDate").value(recordPatchesListValue.getDeviceLastModifiedDate()); 110 | } 111 | jsonWriter.endObject(); 112 | } 113 | } 114 | jsonWriter.endArray(); 115 | } 116 | if (updateRecordsRequest.getSyncSessionToken() != null) { 117 | jsonWriter.name("SyncSessionToken").value(updateRecordsRequest.getSyncSessionToken()); 118 | } 119 | 120 | jsonWriter.endObject(); 121 | 122 | jsonWriter.close(); 123 | String snippet = stringWriter.toString(); 124 | byte[] content = snippet.getBytes(UTF8); 125 | request.setContent(new StringInputStream(snippet)); 126 | request.addHeader("Content-Length", Integer.toString(content.length)); 127 | request.addHeader("Content-Type", "application/x-amz-json-1.0"); 128 | } catch(Throwable t) { 129 | throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); 130 | } 131 | 132 | return request; 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/transform/UpdateRecordsResultJsonUnmarshaller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazonaws.services.cognitosync.model.transform; 17 | 18 | import java.util.Map; 19 | import java.util.Map.Entry; 20 | 21 | import com.amazonaws.services.cognitosync.model.*; 22 | import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; 23 | import com.amazonaws.transform.*; 24 | import com.amazonaws.util.json.AwsJsonReader; 25 | 26 | /** 27 | * Update Records Result JSON Unmarshaller 28 | */ 29 | public class UpdateRecordsResultJsonUnmarshaller implements Unmarshaller { 30 | 31 | public UpdateRecordsResult unmarshall(JsonUnmarshallerContext context) throws Exception { 32 | UpdateRecordsResult updateRecordsResult = new UpdateRecordsResult(); 33 | 34 | AwsJsonReader reader = context.getReader(); 35 | reader.beginObject(); 36 | while (reader.hasNext()) { 37 | String name = reader.nextName(); 38 | 39 | if (name.equals("Records")) { 40 | updateRecordsResult.setRecords(new ListUnmarshaller(RecordJsonUnmarshaller.getInstance()).unmarshall(context)); 41 | } else 42 | { 43 | reader.skipValue(); 44 | } 45 | 46 | } 47 | reader.endObject(); 48 | 49 | return updateRecordsResult; 50 | } 51 | 52 | private static UpdateRecordsResultJsonUnmarshaller instance; 53 | public static UpdateRecordsResultJsonUnmarshaller getInstance() { 54 | if (instance == null) instance = new UpdateRecordsResultJsonUnmarshaller(); 55 | return instance; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/model/transform/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Marhsalling for the various types represented by AmazonCognitoSync. 4 | */ 5 | package com.amazonaws.services.cognitosync.model.transform; 6 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/services/cognitosync/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Synchronous and asynchronous client classes for accessing AmazonCognitoSync. 4 | * 5 | * Amazon Cognito Sync

6 | * Amazon Cognito Sync provides an AWS service and client library that 7 | * enable cross-device syncing of application-related user data. 8 | * High-level client libraries are available for both iOS and Android. 9 | * You can use these libraries to persist data locally so that it's 10 | * available even if the device is offline. Developer credentials don't 11 | * need to be stored on the mobile device to access the service. You can 12 | * use Amazon Cognito to obtain a normalized user ID and credentials. 13 | * User data is persisted in a dataset that can store up to 1 MB of 14 | * key-value pairs, and you can have up to 20 datasets per user identity. 15 | *

16 | *

17 | * With Amazon Cognito Sync, the data stored for each identity is 18 | * accessible only to credentials assigned to that identity. In order to 19 | * use the Cognito Sync service, you need to make API calls using 20 | * credentials retrieved with 21 | * Amazon Cognito Identity service 22 | * . 23 | *

24 | *

25 | * If you want to use Cognito Sync in an Android or iOS application, you 26 | * will probably want to make API calls via the AWS Mobile SDK. To learn 27 | * more, see the 28 | * Developer Guide for Android and the Developer Guide for iOS 29 | * . 30 | *

31 | */ 32 | package com.amazonaws.services.cognitosync; 33 | -------------------------------------------------------------------------------- /src/main/resources/fabric/com.amazonaws.aws-android-sdk-cognito.properties: -------------------------------------------------------------------------------- 1 | fabric-identifier=com.amazonaws.aws-android-sdk-cognito 2 | fabric-version=2.2.12 3 | fabric-build-type=binary 4 | --------------------------------------------------------------------------------