You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by to...@apache.org on 2015/02/11 22:18:10 UTC
[01/25] incubator-usergrid git commit: add initial windows adapter
Repository: incubator-usergrid
Updated Branches:
refs/heads/USERGRID-273 bc6fec485 -> 05e06671c
add initial windows adapter
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/6e01907d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/6e01907d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/6e01907d
Branch: refs/heads/USERGRID-273
Commit: 6e01907dcd6cc7f8f1e50d0e7704361fd2dc27a1
Parents: bcabda2
Author: Shawn Feldman <sf...@apache.org>
Authored: Thu Jan 15 15:55:13 2015 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Thu Jan 15 15:55:13 2015 -0700
----------------------------------------------------------------------
portal/js/global/ug-service.js | 67 ++++++---------
portal/js/push/push-config-controller.js | 18 +++--
portal/js/push/push-config.html | 48 +++++++++++
.../usergrid/persistence/entities/Notifier.java | 31 +++++--
.../persistence/queue/impl/QueueScopeImpl.java | 4 -
stack/services/pom.xml | 7 +-
.../notifications/ProviderAdapterFactory.java | 2 +
.../services/notifications/wns/WNSAdapter.java | 85 ++++++++++++++++++++
8 files changed, 204 insertions(+), 58 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e01907d/portal/js/global/ug-service.js
----------------------------------------------------------------------
diff --git a/portal/js/global/ug-service.js b/portal/js/global/ug-service.js
index 3401060..0e2c880 100644
--- a/portal/js/global/ug-service.js
+++ b/portal/js/global/ug-service.js
@@ -797,6 +797,20 @@ AppServices.Services.factory('ug', function(configuration, $rootScope, utility,
}
});
},
+ createWinNotifier: function(name,sid,apiKey, logging){
+ var options = {
+ method: 'POST',
+ endpoint: 'notifiers',
+ body: {
+ "sid": sid,
+ "apiKey": apiKey,
+ "name": name,
+ "logging": logging,
+ "provider": "windows"
+ }
+ };
+ this.client().request(options, this.notifierResponseReceived);
+ },
createAndroidNotifier: function(name, APIkey) {
var options = {
method: 'POST',
@@ -807,18 +821,7 @@ AppServices.Services.factory('ug', function(configuration, $rootScope, utility,
"provider": "google"
}
};
- this.client().request(options, function(err, data) {
- if (err) {
- console.error(data);
- $rootScope.$broadcast('alert', 'error',
- 'error creating notifier ');
- } else {
- $rootScope.$broadcast('alert', 'success',
- 'New notifier created successfully.');
- $rootScope.$broadcast('notifier-update');
- }
- });
-
+ this.client().request(options, this.notifierResponseReceived);
},
createAppleNotifier: function(file, name, environment,
certificatePassword) {
@@ -832,41 +835,23 @@ AppServices.Services.factory('ug', function(configuration, $rootScope, utility,
formData.append('provider', provider);
formData.append('environment', environment);
formData.append('certificatePassword', certificatePassword || "");
- //var body = {'p12Certificate':file, "name":name,'environment':environment,"provider":provider};
- //if(certificatePassword){
- // body.certificatePassword = certificatePassword;
- //}
+
var options = {
method: 'POST',
endpoint: 'notifiers',
formData: formData
};
- this.client().request(options, function(err, data) {
- if (err) {
- console.error(data);
- $rootScope.$broadcast('alert', 'error', data.error_description ||
- 'error creating notifier');
- } else {
- $rootScope.$broadcast('alert', 'success',
- 'New notifier created successfully.');
- $rootScope.$broadcast('notifier-update');
- }
- });
-
+ this.client().request(options, this.notifierResponseReceived);
},
- deleteNotifier: function(name) {
- var options = {
- method: 'DELETE',
- endpoint: 'notifiers/' + name
- };
- this.client().request(options, function(err, data) {
- if (err) {
- $rootScope.$broadcast('alert', 'error', 'error deleting notifier');
- } else {
- $rootScope.$broadcast('notifier-update');
- }
- });
-
+ notifierResponseReceived:function(err, data) {
+ if (err) {
+ console.error(data);
+ $rootScope.$broadcast('alert', 'error', data.error_description || 'error creating notifier');
+ } else {
+ $rootScope.$broadcast('alert', 'success',
+ 'New notifier created successfully.');
+ $rootScope.$broadcast('notifier-update');
+ }
},
initializeCurrentUser: function(callback) {
callback = callback || function() {};
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e01907d/portal/js/push/push-config-controller.js
----------------------------------------------------------------------
diff --git a/portal/js/push/push-config-controller.js b/portal/js/push/push-config-controller.js
index 0fb5c1c..9a5cf7e 100644
--- a/portal/js/push/push-config-controller.js
+++ b/portal/js/push/push-config-controller.js
@@ -28,8 +28,7 @@ AppServices.Controllers.controller('PushConfigCtrl', ['ug', '$scope', '$rootScop
$scope.notifier.notifierCertPassword = '';
$scope.notifier.androidNotifierName = '';
$scope.notifier.androidNotifierAPIKey = '';
-
-
+ $scope.notifier.winNotifierLogging = true;
$scope.notifiersCollection = {};
@@ -52,19 +51,24 @@ AppServices.Controllers.controller('PushConfigCtrl', ['ug', '$scope', '$rootScop
$scope.applyScope();
});
-
- $rootScope.createAppleNotifier = function() {
+ $scope.createAppleNotifier = function() {
//$scope.appleNotifierCert - this comes from the directive below
ug.createAppleNotifier($scope.appleNotifierCert, $scope.notifier.appleNotifierName, $scope.notifier.appleEnvironment, $scope.notifier.appleCertPassword);
$scope.notifier = {};
$scope.clearNotificationFile();
//angular.element("#ios-cert")[0].value = ""; // this is bad
- }
+ };
- $rootScope.createAndroidNotifier = function() {
+ $scope.createAndroidNotifier = function() {
ug.createAndroidNotifier($scope.notifier.androidNotifierName, $scope.notifier.androidNotifierAPIKey);
$scope.notifier = {};
- }
+ };
+
+ $scope.createWinNotifier = function(){
+ $scope.notifier.winNotifierLogging = $scope.notifier.winNotifierLogging || false;
+ ug.createWinNotifier($scope.notifier.winNotifierName,$scope.notifier.winNotifierSid, $scope.notifier.winNotifierAPISecret, $scope.notifier.winNotifierLogging);
+ $scope.notifier = {};
+ };
$scope.$on('notifier-update', function(event) {
ug.getNotifiers();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e01907d/portal/js/push/push-config.html
----------------------------------------------------------------------
diff --git a/portal/js/push/push-config.html b/portal/js/push/push-config.html
index 1184964..8dbdf38 100644
--- a/portal/js/push/push-config.html
+++ b/portal/js/push/push-config.html
@@ -159,6 +159,54 @@
</pane>
+ <pane heading="Windows">
+ <div style="margin-top: 10px;">
+ <span class="title">Windows Notifications Service</span>
+ <br>
+ A Notifier allows App Services to connect to and deliver a message to a communication provider such as
+ Windows Notifications Service (WNS). Copy and paste your API key to create a bridge between your app
+ and GCM for push notifications on Android devices..
+ <br><br>
+
+ For more help: see our <a href="#!/getting-started/setup" class="notifications-links">getting started page</a> page.
+
+ <form id="winNotifierForm" name="winNotifierForm" ng-submit="createWinNotifier()" class="form-horizontal" novalidate>
+ <fieldset>
+ <div class="control-group">
+ <strong>Name this notifier </strong>
+ <div >
+ <input ng-model="notifier.winNotifierName" id="win-notifier-name" required ug-validate type="text" class="span6" autocomplete="off" placeholder="ex: winDev"/>
+ <br>
+ The notifier name is used as the key for push data. Give this a name that describes the API key being uploaded.
+ </div>
+ </div>
+
+ <div class="control-group">
+ <strong>WNS Sid </strong>
+ <div >
+ <input ng-model="notifier.winNotifierSid" id="win-sid-value" required type="text" class="span6" autocomplete="off" ug-validate/>
+ </div>
+ </div>
+
+ <div class="control-group">
+ <strong>API Key </strong>
+ <div >
+ <input ng-model="notifier.winNotifierAPISecret" id="win-secret-value" required type="text" class="span6" autocomplete="off" ug-validate/>
+ </div>
+ </div>
+
+ <div class="control-group">
+ <strong>Logging </strong>
+ <div >
+ <input type="checkbox" title="Yes" ng-model="notifier.winNotifierLogging" name="win-logging-value" checked /> Logging Enabled
+ </div>
+ </div>
+
+ <input type="submit" href="" class="btn btn-primary" ng-disabled="!winNotifierForm.$valid" value="Create Notifier"/>
+ </fieldset>
+ </form>
+ </div>
+ </pane>
</tabs>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e01907d/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notifier.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notifier.java b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notifier.java
index 1de2753..2f23249 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notifier.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notifier.java
@@ -34,6 +34,13 @@ public class Notifier extends TypedEntity {
public static final String ENTITY_TYPE = "notifier";
+ public Notifier() {
+ }
+
+ public Notifier(UUID id) {
+ uuid = id;
+ }
+
@EntityProperty(aliasProperty = true, unique = true, basic = true)
protected String name;
@@ -51,16 +58,30 @@ public class Notifier extends TypedEntity {
@EntityProperty(indexed = false, includedInExport = false, encrypted = true)
protected String certificatePassword;
- // Google GCM
+ // Google GCM and Windows WNS
@EntityProperty(indexed = false, includedInExport = false, encrypted = true)
protected String apiKey;
- private javax.net.ssl.SSLContext SSLContext;
- public Notifier() {
+ //Windows WNS sid
+ @EntityProperty(indexed = false, includedInExport = false, encrypted = true)
+ protected String sid;
+
+ @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+ public String getSid() {
+ return sid;
}
- public Notifier(UUID id) {
- uuid = id;
+ public void setSid(String sid) { this.sid = sid; }
+
+ //Windows WNS logging
+ @EntityProperty(indexed = false, includedInExport = false, encrypted = true)
+ protected boolean logging = true;
+
+ @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+ public boolean getLogging() { return logging; }
+
+ public void setLogging(boolean logging) {
+ this.logging = logging;
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e01907d/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueScopeImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueScopeImpl.java b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueScopeImpl.java
index d78a66d..a928803 100644
--- a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueScopeImpl.java
+++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueScopeImpl.java
@@ -27,14 +27,11 @@ public class QueueScopeImpl implements QueueScope {
private final Id owner;
private final String name;
-
public QueueScopeImpl( final Id owner, final String name ) {
this.owner = owner;
this.name = name;
}
-
-
@Override
public Id getApplication() {
return owner;
@@ -46,7 +43,6 @@ public class QueueScopeImpl implements QueueScope {
return name;
}
-
@Override
public boolean equals( final Object o ) {
if ( this == o ) {
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e01907d/stack/services/pom.xml
----------------------------------------------------------------------
diff --git a/stack/services/pom.xml b/stack/services/pom.xml
index dd94eb7..83d49e3 100644
--- a/stack/services/pom.xml
+++ b/stack/services/pom.xml
@@ -280,7 +280,7 @@
<!-- Testing and Logging Dependencies -->
<dependency>
<!--
- Do not remove this slf4j-api dependency remove even though pulled
+ Do not remove this slf4j-api dependency remove even though pulled
in transitively. If not present IntelliJ IDEA wigs out.
-->
<groupId>org.slf4j</groupId>
@@ -400,6 +400,11 @@
<artifactId>stream</artifactId>
<version>2.7.0</version>
</dependency>
+ <dependency>
+ <groupId>com.github.fernandospr</groupId>
+ <artifactId>java-wns</artifactId>
+ <version>1.3</version>
+ </dependency>
</dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e01907d/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapterFactory.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapterFactory.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapterFactory.java
index ea42480..652415b 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapterFactory.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapterFactory.java
@@ -24,6 +24,7 @@ import org.apache.usergrid.persistence.EntityManager;
import org.apache.usergrid.persistence.entities.Notifier;
import org.apache.usergrid.services.notifications.apns.APNsAdapter;
import org.apache.usergrid.services.notifications.gcm.GCMAdapter;
+import org.apache.usergrid.services.notifications.wns.WNSAdapter;
import java.util.HashMap;
@@ -37,6 +38,7 @@ public class ProviderAdapterFactory {
switch(notifier.getProvider().toLowerCase()){
case "apple" : adapter = new APNsAdapter(entityManager,notifier); break;
case "google" : adapter = new GCMAdapter(entityManager ,notifier); break;
+ case "windows" : adapter = new WNSAdapter(entityManager ,notifier); break;
case "noop" : adapter = new TestAdapter(notifier); break;
}
return adapter;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e01907d/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java
new file mode 100644
index 0000000..6dcf67c
--- /dev/null
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java
@@ -0,0 +1,85 @@
+/*
+ *
+ * * Licensed to the Apache Software Foundation (ASF) under one or more
+ * * contributor license agreements. The ASF licenses this file to You
+ * * under the Apache License, Version 2.0 (the "License"); you may not
+ * * use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License. For additional information regarding
+ * * copyright in this work, please see the NOTICE file in the top level
+ * * directory of this distribution.
+ *
+ */
+
+package org.apache.usergrid.services.notifications.wns;
+
+import ar.com.fernandospr.wns.WnsService;
+import org.apache.usergrid.persistence.EntityManager;
+import org.apache.usergrid.persistence.entities.Notification;
+import org.apache.usergrid.persistence.entities.Notifier;
+import org.apache.usergrid.services.ServicePayload;
+import org.apache.usergrid.services.notifications.ConnectionException;
+import org.apache.usergrid.services.notifications.ProviderAdapter;
+import org.apache.usergrid.services.notifications.TaskTracker;
+
+/**
+ * Windows Notifications Service adapter to send windows notifications
+ */
+public class WNSAdapter implements ProviderAdapter {
+
+
+ private final EntityManager entityManager;
+
+
+ public WNSAdapter(EntityManager entityManager, Notifier notifier) {
+ this.entityManager = entityManager;
+ WnsService service = new WnsService(notifier.getSid(), notifier.getApiKey(), notifier.getLogging());
+ }
+
+ @Override
+ public void testConnection() throws ConnectionException {
+
+ }
+
+ @Override
+ public void sendNotification(String providerId, Object payload, Notification notification, TaskTracker tracker) throws Exception {
+
+ }
+
+ @Override
+ public void doneSendingNotifications() throws Exception {
+
+ }
+
+ @Override
+ public void removeInactiveDevices() throws Exception {
+
+ }
+
+ @Override
+ public Object translatePayload(Object payload) throws Exception {
+ return null;
+ }
+
+ @Override
+ public void validateCreateNotifier(ServicePayload payload) throws Exception {
+
+ }
+
+ @Override
+ public void stop() {
+
+ }
+
+ @Override
+ public Notifier getNotifier() {
+ return null;
+ }
+}
[02/25] incubator-usergrid git commit: Addition of deleteIndex()
method, improvements to logging and minor formatting changes.
Posted by to...@apache.org.
Addition of deleteIndex() method, improvements to logging and minor formatting changes.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/0408b4b7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/0408b4b7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/0408b4b7
Branch: refs/heads/USERGRID-273
Commit: 0408b4b7f4f5cf549ccc0fc0f8029d12ef02dd22
Parents: bcabda2
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Jan 20 11:58:31 2015 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Jan 20 11:58:31 2015 -0500
----------------------------------------------------------------------
.../usergrid/persistence/index/EntityIndex.java | 2 +
.../index/impl/EsEntityIndexBatchImpl.java | 14 +--
.../index/impl/EsEntityIndexImpl.java | 115 ++++++++-----------
.../persistence/index/impl/EsIndexCache.java | 12 +-
4 files changed, 62 insertions(+), 81 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0408b4b7/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
index eb9f61e..e221f0e 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
@@ -100,6 +100,8 @@ public interface EntityIndex {
* Check health of this specific index.
*/
public Health getIndexHealth();
+
+ public void deleteIndex();
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0408b4b7/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
index c9a4769..20669b3 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
@@ -123,16 +123,10 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
final String entityType = entity.getId().getType();
if ( log.isDebugEnabled() ) {
- log.debug( "Indexing entity {}:{} in scope\n app {}\n "
- + "owner {}\n name {}\n type {} \n scope type {}", new Object[] {
- entity.getId().getType(),
- entity.getId().getUuid(),
- applicationScope.getApplication(),
- indexScope.getOwner(),
- indexScope.getName(),
- entityType,
- context
- } );
+ log.debug( "Indexing entity {}:{}\n alias: {}\n" +
+ " app: {}\n scope owner: {}\n scope name: {}\n context: {}",
+ entity.getId().getType(), entity.getId().getUuid(), alias.getWriteAlias(),
+ applicationScope.getApplication(), indexScope.getOwner(), indexScope.getName(), context );
}
ValidationUtils.verifyEntityWrite( entity );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0408b4b7/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
index b743d83..9e9cebf 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
@@ -21,29 +21,13 @@ package org.apache.usergrid.persistence.index.impl;
import com.google.common.collect.ImmutableMap;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.ArrayUtils;
import org.apache.usergrid.persistence.core.scope.ApplicationScope;
import org.apache.usergrid.persistence.core.util.Health;
import org.apache.usergrid.persistence.core.util.ValidationUtils;
-import org.apache.usergrid.persistence.index.AliasedEntityIndex;
-import org.apache.usergrid.persistence.index.AliasedEntityIndex.AliasType;
-import org.apache.usergrid.persistence.index.EntityIndexBatch;
-import org.apache.usergrid.persistence.index.IndexFig;
-import org.apache.usergrid.persistence.index.IndexIdentifier;
-import org.apache.usergrid.persistence.index.IndexScope;
-import org.apache.usergrid.persistence.index.SearchTypes;
+import org.apache.usergrid.persistence.index.*;
import org.apache.usergrid.persistence.index.exceptions.IndexException;
-import static org.apache.usergrid.persistence.index.impl.IndexingUtils.BOOLEAN_PREFIX;
-import static org.apache.usergrid.persistence.index.impl.IndexingUtils.ENTITYID_ID_FIELDNAME;
-import static org.apache.usergrid.persistence.index.impl.IndexingUtils.ENTITY_VERSION_FIELDNAME;
-import static org.apache.usergrid.persistence.index.impl.IndexingUtils.NUMBER_PREFIX;
-import static org.apache.usergrid.persistence.index.impl.IndexingUtils.SPLITTER;
-import static org.apache.usergrid.persistence.index.impl.IndexingUtils.STRING_PREFIX;
import org.apache.usergrid.persistence.index.query.CandidateResult;
import org.apache.usergrid.persistence.index.query.CandidateResults;
import org.apache.usergrid.persistence.index.query.Query;
@@ -68,13 +52,7 @@ import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
-import org.elasticsearch.index.query.FilterBuilder;
-import org.elasticsearch.index.query.FilterBuilders;
-import org.elasticsearch.index.query.FilteredQueryBuilder;
-import org.elasticsearch.index.query.MatchAllQueryBuilder;
-import org.elasticsearch.index.query.QueryBuilder;
-import org.elasticsearch.index.query.QueryBuilders;
-import org.elasticsearch.index.query.TermQueryBuilder;
+import org.elasticsearch.index.query.*;
import org.elasticsearch.indices.IndexAlreadyExistsException;
import org.elasticsearch.indices.IndexMissingException;
import org.elasticsearch.search.SearchHit;
@@ -87,6 +65,14 @@ import org.slf4j.LoggerFactory;
import rx.Observable;
import rx.functions.Func1;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import static org.apache.usergrid.persistence.index.impl.IndexingUtils.*;
+
/**
* Implements index using ElasticSearch Java API.
@@ -197,23 +183,25 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
String[] indexNames = getIndexes(AliasType.Write);
- for(String currentIndex : indexNames){
+ for (String currentIndex : indexNames){
isAck = adminClient.indices().prepareAliases().removeAlias(currentIndex,
alias.getWriteAlias()).execute().actionGet().isAcknowledged();
- logger.info("Removed Index Name [{}] from Alias=[{}] ACK=[{}]",currentIndex, alias, isAck);
+ logger.info("Removed Index Name [{}] from Alias=[{}] ACK=[{}]", currentIndex, alias, isAck);
}
- //add read alias
+ // add read alias
isAck = adminClient.indices().prepareAliases().addAlias(
indexName, alias.getReadAlias()).execute().actionGet().isAcknowledged();
- logger.info("Created new read Alias Name [{}] ACK=[{}]", alias, isAck);
-
- //add write alias
+ logger.info("Created new read Alias Name [{}] ACK=[{}]", alias.getReadAlias(), isAck);
+
+ // add write alias
isAck = adminClient.indices().prepareAliases().addAlias(
indexName, alias.getWriteAlias()).execute().actionGet().isAcknowledged();
- logger.info("Created new write Alias Name [{}] ACK=[{}]", alias, isAck);
+ logger.info("Created new write Alias Name [{}] ACK=[{}]", alias.getWriteAlias(), isAck);
+
aliasCache.invalidate(alias);
+
} catch (Exception e) {
logger.warn("Failed to create alias ", e);
}
@@ -236,7 +224,7 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
// to receive documents. Occasionally we see errors.
// See this post: http://s.apache.org/index-missing-exception
- logger.debug( "Testing new index name [{}]", alias);
+ logger.debug( "Testing new index name: read {} write {}", alias.getReadAlias(), alias.getWriteAlias());
final RetryOperation retryOperation = new RetryOperation() {
@Override
@@ -244,18 +232,19 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
final String tempId = UUIDGenerator.newTimeUUID().toString();
esProvider.getClient().prepareIndex( alias.getWriteAlias(), VERIFY_TYPE, tempId )
- .setSource(DEFAULT_PAYLOAD).get();
+ .setSource(DEFAULT_PAYLOAD).get();
logger.info( "Successfully created new document with docId {} "
- + "in index {} and type {}", tempId, alias, VERIFY_TYPE );
+ + "in index read {} write {} and type {}",
+ tempId, alias.getReadAlias(), alias.getWriteAlias(), VERIFY_TYPE );
// delete all types, this way if we miss one it will get cleaned up
- esProvider.getClient().prepareDeleteByQuery( alias.getWriteAlias() )
- .setTypes(VERIFY_TYPE)
+ esProvider.getClient().prepareDeleteByQuery( alias.getWriteAlias())
+ .setTypes(VERIFY_TYPE)
.setQuery(MATCH_ALL_QUERY_BUILDER).get();
- logger.info( "Successfully deleted all documents in index {} and type {}",
- alias, VERIFY_TYPE );
+ logger.info( "Successfully deleted all documents in index {} read {} write {} and type {}",
+ alias.getReadAlias(), alias.getWriteAlias(), VERIFY_TYPE );
return true;
}
@@ -359,16 +348,15 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
if ( logger.isDebugEnabled() ) {
- logger.debug( "Searching index {}\n scope{} \n type {}\n query {} ",
- new Object[] { this.alias, context, entityTypes, srb
- } );
+ logger.debug( "Searching index (read alias): {}\n scope: {} \n type: {}\n query: {} ",
+ this.alias.getReadAlias(), context, entityTypes, srb );
}
try {
searchResponse = srb.execute().actionGet();
}
catch ( Throwable t ) {
- logger.error( "Unable to communicate with elasticsearch", t );
+ logger.error( "Unable to communicate with Elasticsearch", t );
failureMonitor.fail( "Unable to execute batch", t );
throw t;
}
@@ -445,17 +433,14 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
@Override
public boolean doOp() {
try {
- String[] indexes = getIndexes(AliasType.Read);
- Observable.from(indexes).map(new Func1<String, String>() {
- @Override
- public String call(String index) {
- esProvider.getClient().admin().indices().prepareRefresh( index ).execute().actionGet();
- return index;
- }
- }).toBlocking().last();
-
- logger.debug( "Refreshed index: " + alias);
-
+ String[] indexes = ArrayUtils.addAll( getIndexes(AliasType.Write), getIndexes(AliasType.Write) );
+ if ( indexes.length == 0 ) {
+ logger.debug( "Not refreshing indexes, none found for app {}",
+ applicationScope.getApplication().getUuid() );
+ return true;
+ }
+ esProvider.getClient().admin().indices().prepareRefresh( indexes ).execute().actionGet();
+ logger.debug("Refreshed indexes: {}", StringUtils.join(indexes, ", "));
return true;
}
catch ( IndexMissingException e ) {
@@ -466,8 +451,6 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
};
doInRetry( retryOperation );
-
- logger.debug( "Refreshed index: " + alias);
}
@@ -517,7 +500,7 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
@Override
public void deleteAllVersionsOfEntity( Id entityId ) {
- String idString = IndexingUtils.idString( entityId ).toLowerCase();
+ String idString = IndexingUtils.idString(entityId).toLowerCase();
final TermQueryBuilder tqb = QueryBuilders.termQuery( ENTITYID_ID_FIELDNAME, idString );
@@ -526,7 +509,7 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
logger.debug( "Deleted entity {}:{} from all index scopes with response status = {}",
- new Object[] { entityId.getType(), entityId.getUuid(), response.status().toString() });
+ entityId.getType(), entityId.getUuid(), response.status().toString());
checkDeleteByQueryResponse( tqb, response );
@@ -539,8 +522,8 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
String idString = IndexingUtils.idString( entityId ).toLowerCase();
final FilteredQueryBuilder fqb = QueryBuilders.filteredQuery(
- QueryBuilders.termQuery( ENTITYID_ID_FIELDNAME, idString ),
- FilterBuilders.rangeFilter( ENTITY_VERSION_FIELDNAME ).lt( version.timestamp() )
+ QueryBuilders.termQuery(ENTITYID_ID_FIELDNAME, idString),
+ FilterBuilders.rangeFilter(ENTITY_VERSION_FIELDNAME).lt(version.timestamp())
);
final DeleteByQueryResponse response = esProvider.getClient()
@@ -549,7 +532,7 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
//error message needs to be retooled so that it describes the entity more throughly
logger.debug( "Deleted entity {}:{} with version {} from all "
+ "index scopes with response status = {}",
- new Object[] { entityId.getType(), entityId.getUuid(), version, response.status().toString() } );
+ entityId.getType(), entityId.getUuid(), version, response.status().toString() );
checkDeleteByQueryResponse( fqb, response );
}
@@ -565,10 +548,10 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
final ShardOperationFailedException[] failures = indexDeleteByQueryResponse.getFailures();
for ( ShardOperationFailedException failedException : failures ) {
- throw new IndexException( String.format("Unable to delete by query %s. "
+ throw new IndexException( String.format("Unable to delete by query %s. "
+ "Failed with code %d and reason %s on shard %s in index %s",
query.toString(),
- failedException.status(),
+ failedException.status().getStatus(),
failedException.reason(),
failedException.shardId(),
failedException.index() ) );
@@ -579,7 +562,7 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
/**
- * For testing only.
+ * Completely delete an index.
*/
public void deleteIndex() {
AdminClient adminClient = esProvider.getClient().admin();
@@ -588,10 +571,10 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
.prepareDelete( indexIdentifier.getIndex(null) ).get();
if ( response.isAcknowledged() ) {
- logger.info( "Deleted index: " + alias);
+ logger.info( "Deleted index: read {} write {}", alias.getReadAlias(), alias.getWriteAlias());
}
else {
- logger.info( "Failed to delete index " + alias);
+ logger.info( "Failed to delete index: read {} write {}", alias.getReadAlias(), alias.getWriteAlias());
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0408b4b7/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexCache.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexCache.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexCache.java
index c607222..0c07a34 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexCache.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexCache.java
@@ -45,6 +45,7 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
+
/**
* Cache for Es index operations
*/
@@ -58,8 +59,10 @@ public class EsIndexCache {
@Inject
public EsIndexCache(final EsProvider provider, final IndexFig indexFig) {
+
this.refreshExecutors = MoreExecutors
.listeningDecorator(Executors.newScheduledThreadPool(indexFig.getIndexCacheMaxWorkers()));
+
aliasIndexCache = CacheBuilder.newBuilder().maximumSize(1000)
.refreshAfterWrite(5,TimeUnit.MINUTES)
.build(new CacheLoader<String, String[]>() {
@@ -78,17 +81,16 @@ public class EsIndexCache {
public String[] load(final String aliasName) {
final AdminClient adminClient = provider.getClient().admin();
//remove write alias, can only have one
- ImmutableOpenMap<String, List<AliasMetaData>> aliasMap = adminClient.indices().getAliases(new GetAliasesRequest(aliasName)).actionGet().getAliases();
+ ImmutableOpenMap<String, List<AliasMetaData>> aliasMap =
+ adminClient.indices().getAliases(new GetAliasesRequest(aliasName)).actionGet().getAliases();
return aliasMap.keys().toArray(String.class);
}
}) ;
}
+
/**
* Get indexes for an alias
- * @param alias
- * @param aliasType
- * @return
*/
public String[] getIndexes(IndexIdentifier.IndexAlias alias, AliasedEntityIndex.AliasType aliasType) {
String[] indexes;
@@ -101,9 +103,9 @@ public class EsIndexCache {
return indexes;
}
+
/**
* clean up cache
- * @param alias
*/
public void invalidate(IndexIdentifier.IndexAlias alias){
aliasIndexCache.invalidate(alias.getWriteAlias());
[15/25] incubator-usergrid git commit: compile issue...
Posted by to...@apache.org.
compile issue...
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/0fc961ed
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/0fc961ed
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/0fc961ed
Branch: refs/heads/USERGRID-273
Commit: 0fc961ed80238d6408693e79b79a31a2d0d04bb2
Parents: f675224
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Jan 27 09:10:16 2015 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Jan 27 09:10:16 2015 -0700
----------------------------------------------------------------------
.../usergrid/services/notifications/ProviderAdapterFactory.java | 1 -
1 file changed, 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0fc961ed/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapterFactory.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapterFactory.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapterFactory.java
index 9a48c35..2ee9042 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapterFactory.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapterFactory.java
@@ -20,7 +20,6 @@
package org.apache.usergrid.services.notifications;
-import com.sun.javafx.tools.ant.Application;
import org.apache.usergrid.persistence.EntityManager;
import org.apache.usergrid.persistence.entities.Notifier;
import org.apache.usergrid.services.notifications.apns.APNsAdapter;
[16/25] incubator-usergrid git commit: remove lexer
Posted by to...@apache.org.
remove lexer
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/df29a99c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/df29a99c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/df29a99c
Branch: refs/heads/USERGRID-273
Commit: df29a99c4218a39269151a8773c0b0e051507650
Parents: 0fc961e
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Jan 27 09:11:04 2015 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Jan 27 09:11:04 2015 -0700
----------------------------------------------------------------------
.gitignore | 6 ------
1 file changed, 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/df29a99c/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 522f674..6f8e854 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,8 +1,6 @@
.DS_Store
.AppleDouble
.LSOverride
-stack/core/src/main/java/org/apache/usergrid/persistence/query/tree/QueryFilterParser.java
-stack/core/src/main/java/org/apache/usergrid/persistence/query/tree/QueryFilterLexer.java
target
@@ -41,8 +39,6 @@ stack/corepersistence/graph/nbactions.xml
stack/corepersistence/model/nbactions.xml
stack/corepersistence/nbactions.xml
stack/corepersistence/queryindex/nbactions.xml
-stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/QueryFilterLexer.java
-stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/QueryFilterParser.java
/stack/corepersistence/perftest2/src/main/resources/finefoods.txt
/stack/corepersistence/perftest1/src/main/resources/finefoods.txt
/stack/corepersistence/perftest2/nbactions.xml
@@ -80,8 +76,6 @@ portal/js/templates.js
/release/target/
/portal/seleniumLog.txt
-/stack/core/src/main/java/org/apache/usergrid/persistence/query/tree/QueryFilterLexer.java
-/stack/core/src/main/java/org/apache/usergrid/persistence/query/tree/QueryFilterParser.java
!/stack/corepersistence/common/src/test/resources/usergrid-UNIT.properties
*.iml
sdks/dotnet/samples/notifications/packages/*
[05/25] incubator-usergrid git commit: Merge branch
'usergrid-312-appdelete' of github.com:snoopdave/incubator-usergrid into
apache_usergrid/two-dot-o
Posted by to...@apache.org.
Merge branch 'usergrid-312-appdelete' of github.com:snoopdave/incubator-usergrid into apache_usergrid/two-dot-o
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/e4cb321e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/e4cb321e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/e4cb321e
Branch: refs/heads/USERGRID-273
Commit: e4cb321e9e1832af13d97796c1be3f0a91131d8c
Parents: 6ebbe50 4384975
Author: Rod Simpson <ro...@apigee.com>
Authored: Wed Jan 21 16:10:26 2015 -0700
Committer: Rod Simpson <ro...@apigee.com>
Committed: Wed Jan 21 16:10:26 2015 -0700
----------------------------------------------------------------------
.../corepersistence/CpEntityManagerFactory.java | 56 +++++++--
.../HybridEntityManagerFactory.java | 9 +-
.../persistence/EntityManagerFactory.java | 11 +-
.../cassandra/EntityManagerFactoryImpl.java | 11 +-
.../cassandra/EntityManagerFactoryImplIT.java | 71 +++++++-----
.../usergrid/persistence/index/EntityIndex.java | 2 +
.../index/impl/EsEntityIndexBatchImpl.java | 14 +--
.../index/impl/EsEntityIndexImpl.java | 115 ++++++++-----------
.../persistence/index/impl/EsIndexCache.java | 12 +-
.../rest/applications/ApplicationResource.java | 32 +++++-
.../applications/ApplicationDeleteTest.java | 54 +++++++++
11 files changed, 257 insertions(+), 130 deletions(-)
----------------------------------------------------------------------
[23/25] incubator-usergrid git commit: Use example URL instead
Posted by to...@apache.org.
Use example URL instead
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/198f4795
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/198f4795
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/198f4795
Branch: refs/heads/USERGRID-273
Commit: 198f4795af99a466d2657bc078868d5a3312df98
Parents: bfdacb3
Author: Dave Johnson <sn...@apache.org>
Authored: Wed Jan 28 10:51:54 2015 -0500
Committer: Dave Johnson <sn...@apache.org>
Committed: Wed Jan 28 10:51:54 2015 -0500
----------------------------------------------------------------------
.../samples/notifications/Usergrid.Notifications/MainPage.xaml.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/198f4795/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml.cs
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml.cs b/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml.cs
index 6d4c4ec..a550954 100644
--- a/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml.cs
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml.cs
@@ -44,7 +44,7 @@ namespace Usergrid.Notifications
{
this.InitializeComponent();
//TODO: change me to your server
- serverUrl = "https://apigee-internal-prod.mars.apigee.net";
+ serverUrl = "https://usergrid-push.example.com";
//TODO: change me to your org
org = "ugvalidate";
//TODO: change me to your app
[13/25] incubator-usergrid git commit: add illegal argument type
Posted by to...@apache.org.
add illegal argument type
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/506fd89d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/506fd89d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/506fd89d
Branch: refs/heads/USERGRID-273
Commit: 506fd89d1821d38148a9155479f4b2728378bf9e
Parents: 20d905f
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Jan 23 16:17:06 2015 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Jan 23 16:17:06 2015 -0700
----------------------------------------------------------------------
.../org/apache/usergrid/services/notifications/wns/WNSAdapter.java | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/506fd89d/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java
index 0ba2db3..6ea3839 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java
@@ -87,6 +87,7 @@ public class WNSAdapter implements ProviderAdapter {
}
service.pushBadge(providerId, badge);
break;
+ default : throw new IllegalArgumentException(translatedNotification.getType()+" does not match a valid notification type.");
}
}
tracker.completed();
[25/25] incubator-usergrid git commit: Fixed index alias cache
invalidation
Posted by to...@apache.org.
Fixed index alias cache invalidation
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/05e06671
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/05e06671
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/05e06671
Branch: refs/heads/USERGRID-273
Commit: 05e06671cce05610395de0934fc89ba1b185104f
Parents: 02852a7
Author: Todd Nine <tn...@apigee.com>
Authored: Wed Feb 11 14:18:07 2015 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Wed Feb 11 14:18:07 2015 -0700
----------------------------------------------------------------------
.../cassandra/EntityManagerFactoryImplIT.java | 29 +++++++++++++-----
.../usergrid/persistence/index/EntityIndex.java | 2 --
.../index/impl/EsEntityIndexImpl.java | 32 +++++++++++---------
3 files changed, 39 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/05e06671/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
index f69eed3..3ffc4e0 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
@@ -17,10 +17,22 @@
package org.apache.usergrid.persistence.cassandra;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import org.apache.commons.lang3.RandomStringUtils;
+
import org.apache.usergrid.AbstractCoreIT;
-import org.apache.usergrid.cassandra.CassandraResource;
-import org.apache.usergrid.cassandra.Concurrent;
import org.apache.usergrid.persistence.Entity;
import org.apache.usergrid.persistence.EntityManager;
import org.apache.usergrid.persistence.EntityManagerFactory;
@@ -29,11 +41,14 @@ import org.apache.usergrid.persistence.SimpleEntityRef;
import org.apache.usergrid.persistence.cassandra.util.TraceTag;
import org.apache.usergrid.persistence.cassandra.util.TraceTagManager;
import org.apache.usergrid.persistence.cassandra.util.TraceTagReporter;
-import org.apache.usergrid.persistence.index.impl.ElasticSearchResource;
-
-import java.util.*;
-
-import static org.junit.Assert.*;
+import org.apache.usergrid.setup.ConcurrentProcessSingleton;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
public class EntityManagerFactoryImplIT extends AbstractCoreIT {
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/05e06671/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
index ef510b2..d239641 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
@@ -105,8 +105,6 @@ public interface EntityIndex {
* Check health of this specific index.
*/
public Health getIndexHealth();
-
- public void deleteIndex();
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/05e06671/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
index 9e9cebf..a53733f 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
@@ -194,14 +194,14 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
isAck = adminClient.indices().prepareAliases().addAlias(
indexName, alias.getReadAlias()).execute().actionGet().isAcknowledged();
logger.info("Created new read Alias Name [{}] ACK=[{}]", alias.getReadAlias(), isAck);
-
+
// add write alias
isAck = adminClient.indices().prepareAliases().addAlias(
indexName, alias.getWriteAlias()).execute().actionGet().isAcknowledged();
logger.info("Created new write Alias Name [{}] ACK=[{}]", alias.getWriteAlias(), isAck);
-
+
aliasCache.invalidate(alias);
-
+
} catch (Exception e) {
logger.warn("Failed to create alias ", e);
}
@@ -235,7 +235,7 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
.setSource(DEFAULT_PAYLOAD).get();
logger.info( "Successfully created new document with docId {} "
- + "in index read {} write {} and type {}",
+ + "in index read {} write {} and type {}",
tempId, alias.getReadAlias(), alias.getWriteAlias(), VERIFY_TYPE );
// delete all types, this way if we miss one it will get cleaned up
@@ -255,7 +255,7 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
/**
- * Setup ElasticSearch type mappings as a template that applies to all new indexes.
+ * Setup ElasticSearch type mappings as a template that applies to all new indexes.
* Applies to all indexes that* start with our prefix.
*/
private void createMappings() throws IOException {
@@ -277,13 +277,13 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
@Override
public EntityIndexBatch createBatch() {
- return new EsEntityIndexBatchImpl(
+ return new EsEntityIndexBatchImpl(
applicationScope, esProvider.getClient(), config, 1000, failureMonitor, this );
}
@Override
- public CandidateResults search( final IndexScope indexScope, final SearchTypes searchTypes,
+ public CandidateResults search( final IndexScope indexScope, final SearchTypes searchTypes,
final Query query ) {
final String context = IndexingUtils.createContextName(indexScope);
@@ -322,8 +322,8 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
}
// we do not know the type of the "order by" property and so we do not know what
- // type prefix to use. So, here we add an order by clause for every possible type
- // that you can order by: string, number and boolean and we ask ElasticSearch
+ // type prefix to use. So, here we add an order by clause for every possible type
+ // that you can order by: string, number and boolean and we ask ElasticSearch
// to ignore any fields that are not present.
final String stringFieldName = STRING_PREFIX + sp.getPropertyName();
@@ -435,7 +435,7 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
try {
String[] indexes = ArrayUtils.addAll( getIndexes(AliasType.Write), getIndexes(AliasType.Write) );
if ( indexes.length == 0 ) {
- logger.debug( "Not refreshing indexes, none found for app {}",
+ logger.debug( "Not refreshing indexes, none found for app {}",
applicationScope.getApplication().getUuid() );
return true;
}
@@ -472,7 +472,7 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
final String context = IndexingUtils.createContextName(scope);
final SearchTypes searchTypes = SearchTypes.fromTypes( id.getType() );
- final QueryBuilder queryBuilder =
+ final QueryBuilder queryBuilder =
QueryBuilders.termQuery( IndexingUtils.ENTITY_CONTEXT_FIELDNAME, context );
final SearchRequestBuilder srb = esProvider.getClient().prepareSearch( alias.getReadAlias() )
@@ -519,7 +519,7 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
@Override
public void deletePreviousVersions( final Id entityId, final UUID version ) {
- String idString = IndexingUtils.idString( entityId ).toLowerCase();
+ String idString = IndexingUtils.idString( entityId ).toLowerCase();
final FilteredQueryBuilder fqb = QueryBuilders.filteredQuery(
QueryBuilders.termQuery(ENTITYID_ID_FIELDNAME, idString),
@@ -541,7 +541,7 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
/**
* Validate the response doesn't contain errors, if it does, fail fast at the first error we encounter
*/
- private void checkDeleteByQueryResponse(
+ private void checkDeleteByQueryResponse(
final QueryBuilder query, final DeleteByQueryResponse response ) {
for ( IndexDeleteByQueryResponse indexDeleteByQueryResponse : response ) {
@@ -550,9 +550,9 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
for ( ShardOperationFailedException failedException : failures ) {
throw new IndexException( String.format("Unable to delete by query %s. "
+ "Failed with code %d and reason %s on shard %s in index %s",
- query.toString(),
+ query.toString(),
failedException.status().getStatus(),
- failedException.reason(),
+ failedException.reason(),
failedException.shardId(),
failedException.index() ) );
}
@@ -572,6 +572,8 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
if ( response.isAcknowledged() ) {
logger.info( "Deleted index: read {} write {}", alias.getReadAlias(), alias.getWriteAlias());
+ //invlaidate the alias
+ aliasCache.invalidate(alias);
}
else {
logger.info( "Failed to delete index: read {} write {}", alias.getReadAlias(), alias.getWriteAlias());
[06/25] incubator-usergrid git commit: Working windows phone toasts
Posted by to...@apache.org.
Working windows phone toasts
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/74ea17e7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/74ea17e7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/74ea17e7
Branch: refs/heads/USERGRID-273
Commit: 74ea17e7072f45064f83eeed6142bd7b9c464681
Parents: 6e01907
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Jan 21 16:35:56 2015 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Jan 21 16:35:56 2015 -0700
----------------------------------------------------------------------
.../services/notifications/wns/WNSAdapter.java | 62 +++++++++++++++++---
1 file changed, 54 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/74ea17e7/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java
index 6dcf67c..b331e86 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java
@@ -21,6 +21,9 @@
package org.apache.usergrid.services.notifications.wns;
import ar.com.fernandospr.wns.WnsService;
+import ar.com.fernandospr.wns.exceptions.WnsException;
+import ar.com.fernandospr.wns.model.WnsToast;
+import ar.com.fernandospr.wns.model.builders.WnsToastBuilder;
import org.apache.usergrid.persistence.EntityManager;
import org.apache.usergrid.persistence.entities.Notification;
import org.apache.usergrid.persistence.entities.Notifier;
@@ -28,29 +31,50 @@ import org.apache.usergrid.services.ServicePayload;
import org.apache.usergrid.services.notifications.ConnectionException;
import org.apache.usergrid.services.notifications.ProviderAdapter;
import org.apache.usergrid.services.notifications.TaskTracker;
+import org.mortbay.util.ajax.JSON;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.Map;
/**
* Windows Notifications Service adapter to send windows notifications
*/
public class WNSAdapter implements ProviderAdapter {
+ private static final Logger LOG = LoggerFactory.getLogger(WNSAdapter.class);
private final EntityManager entityManager;
-
+ private final Notifier notifier;
+ private final WnsService service;
public WNSAdapter(EntityManager entityManager, Notifier notifier) {
this.entityManager = entityManager;
- WnsService service = new WnsService(notifier.getSid(), notifier.getApiKey(), notifier.getLogging());
+ this.notifier = notifier;
+ this.service = new WnsService(notifier.getSid(), notifier.getApiKey(), notifier.getLogging());
}
@Override
public void testConnection() throws ConnectionException {
-
+ WnsToast toast = new WnsToastBuilder().bindingTemplateToastText01("test").build();
+ try{
+ service.pushToast("ms-app://s-1-15-2-2411381248-444863693-3819932088-4077691928-1194867744-112853457-373132695",toast);
+ }catch (Exception e){
+ LOG.error(e.toString());
+ }
}
@Override
public void sendNotification(String providerId, Object payload, Notification notification, TaskTracker tracker) throws Exception {
-
+ try {
+ WnsToast toast = new WnsToastBuilder().bindingTemplateToastText01(payload.toString()).build();
+ service.pushToast(providerId, toast);
+ tracker.completed();
+ } catch (Exception e) {
+ tracker.failed(0,e.toString());
+ LOG.error("Failed to send notification",e);
+ }
}
@Override
@@ -65,21 +89,43 @@ public class WNSAdapter implements ProviderAdapter {
@Override
public Object translatePayload(Object payload) throws Exception {
- return null;
+ String toast = "";
+ if (payload instanceof Map) {
+ toast = ((Map<String, Object>) payload).get("toast").toString();
+ } else {
+ if (payload instanceof String) {
+ toast = (String) payload;
+ }else{
+ throw new IllegalArgumentException("format is messed up");
+ }
+ }
+ return toast;
}
@Override
public void validateCreateNotifier(ServicePayload payload) throws Exception {
-
+ String apiKey = payload.getStringProperty("apiKey");
+ String sid = payload.getStringProperty("sid");
+ Object logging = payload.getProperty("logging");
+ if(sid == null){
+ throw new IllegalArgumentException("sid is missing");
+ }
+ if(logging == null){
+ throw new IllegalArgumentException("logging is missing");
+ }
+ if(apiKey == null){
+ throw new IllegalArgumentException("apiKey is missing");
+ }
}
@Override
public void stop() {
-
+ //Do nothing
}
@Override
public Notifier getNotifier() {
- return null;
+ return notifier;
}
+
}
[21/25] incubator-usergrid git commit: Added JVM args for remote
debugging
Posted by to...@apache.org.
Added JVM args for remote debugging
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/b3951eef
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/b3951eef
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/b3951eef
Branch: refs/heads/USERGRID-273
Commit: b3951eefc87761739829032ec694cba67bdb0899
Parents: bc6fec4
Author: Todd Nine <tn...@apigee.com>
Authored: Tue Jan 27 14:21:59 2015 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Tue Jan 27 14:21:59 2015 -0700
----------------------------------------------------------------------
stack/rest/pom.xml | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b3951eef/stack/rest/pom.xml
----------------------------------------------------------------------
diff --git a/stack/rest/pom.xml b/stack/rest/pom.xml
index fa79ad8..c2b8502 100644
--- a/stack/rest/pom.xml
+++ b/stack/rest/pom.xml
@@ -228,12 +228,11 @@
<configuration>
<container>
<containerId>tomcat7x</containerId>
- <!-- Type == Installed means that you want to deploy to a container that's installed on your computer -->
+ <!-- Run the latest version of to tomcat 7 -->
<zipUrlInstaller>
<url>http://mirror.tcpdiag.net/apache/tomcat/tomcat-7/v7.0.57/bin/apache-tomcat-7.0.57.zip</url>
</zipUrlInstaller>
-
</container>
<configuration>
<configfiles>
@@ -243,11 +242,14 @@
</configfile>
</configfiles>
<!--If you're getting port conflicts, override the ports here-->
- <!--<properties>-->
+ <properties>
+ <cargo.jvmargs>-Xmx1G -Xms500m -server -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000</cargo.jvmargs>
<!--<cargo.rmi.port>10200</cargo.rmi.port>-->
<!--<cargo.servlet.port>${cargo.servlet.port}</cargo.servlet.port>-->
<!--<cargo.tomcat.ajp.port>10201</cargo.tomcat.ajp.port>-->
- <!--</properties>-->
+ </properties>
+
+
</configuration>
<deployables>
[03/25] incubator-usergrid git commit: Addition of
emf.deleteApplicaton() method and a test for it in
EntityManagerFacotryImplIT.
Posted by to...@apache.org.
Addition of emf.deleteApplicaton() method and a test for it in EntityManagerFacotryImplIT.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/7335f941
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/7335f941
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/7335f941
Branch: refs/heads/USERGRID-273
Commit: 7335f9411aa20357bc3c4b3c866b12dfdadb23a3
Parents: 0408b4b
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Jan 20 11:59:34 2015 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Jan 20 11:59:34 2015 -0500
----------------------------------------------------------------------
.../corepersistence/CpEntityManagerFactory.java | 56 ++++++++++++---
.../HybridEntityManagerFactory.java | 9 ++-
.../persistence/EntityManagerFactory.java | 11 ++-
.../cassandra/EntityManagerFactoryImpl.java | 11 ++-
.../cassandra/EntityManagerFactoryImplIT.java | 71 +++++++++++++-------
5 files changed, 115 insertions(+), 43 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7335f941/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
index 7016d3c..93eb15e 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
@@ -123,8 +123,6 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
this.cass = cass;
this.counterUtils = counterUtils;
-
-
}
@@ -136,8 +134,8 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
if ( em.getApplication() == null ) {
logger.info("Creating system application");
Map sysAppProps = new HashMap<String, Object>();
- sysAppProps.put( PROPERTY_NAME, "systemapp");
- em.create( CpNamingUtils.SYSTEM_APP_ID, TYPE_APPLICATION, sysAppProps );
+ sysAppProps.put(PROPERTY_NAME, "systemapp");
+ em.create(CpNamingUtils.SYSTEM_APP_ID, TYPE_APPLICATION, sysAppProps);
em.getApplication();
em.createIndex();
em.refreshIndex();
@@ -165,7 +163,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
@Override
- public String getImpementationDescription() throws Exception {
+ public String getImplementationDescription() throws Exception {
return IMPLEMENTATION_DESCRIPTION;
}
@@ -187,7 +185,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
EntityManager em = new CpEntityManager();
em.init( this, applicationId );
- // only need to do this once
+ // only need to do this once
if ( !applicationIndexesCreated.contains( applicationId ) ) {
em.createIndex();
applicationIndexesCreated.add( applicationId );
@@ -285,6 +283,36 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
}
+ /**
+ * Delete Application.
+ *
+ * <p>The Application Entity is be moved to a Deleted_Applications collection and the
+ * Application index will be removed.
+ *
+ * <p>TODO: add scheduled task that can completely delete all deleted application data.</p>
+ *
+ * @param applicationId UUID of Application to be deleted.
+ */
+ @Override
+ public void deleteApplication(UUID applicationId) throws Exception {
+
+ // remove old appinfo Entity, which is in the System App's appinfos collection
+ EntityManager em = getEntityManager(CpNamingUtils.SYSTEM_APP_ID);
+ Query q = Query.fromQL(String.format("select * where applicationUuid = '%s'", applicationId.toString()));
+ Results results = em.searchCollection( em.getApplicationRef(), "appinfos", q);
+ Entity appToDelete = results.getEntity();
+ em.delete( appToDelete );
+
+ // create new Entity in deleted_appinfos collection, with same UUID and properties as deleted appinfo
+ em.create( "deleted_appinfo", appToDelete.getProperties() );
+
+ em.refreshIndex();
+
+ // delete the application's index
+ EntityIndex ei = managerCache.getEntityIndex(new ApplicationScopeImpl(
+ new SimpleId(applicationId, TYPE_APPLICATION)));
+ ei.deleteIndex();
+ }
@Override
@@ -395,6 +423,11 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
managerCache.getEntityCollectionManager( collScope ).load( targetId )
.toBlockingObservable().lastOrDefault(null);
+ if ( e == null ) {
+ logger.warn("Applicaion {} in index but not found in collections", targetId );
+ continue;
+ }
+
appMap.put(
(String)e.getField( PROPERTY_NAME ).getValue(),
(UUID)e.getField( "applicationUuid" ).getValue());
@@ -407,6 +440,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
@Override
public void setup() throws Exception {
getSetup().init();
+ init();
}
@@ -460,7 +494,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
propsEntity = EntityFactory.newEntity( UUIDUtils.newTimeUUID(), "propertymap");
}
- // intentionally going only one-level deep into fields and treating all
+ // intentionally going only one-level deep into fields and treating all
// values as strings because that is all we need for service properties
for ( String key : properties.keySet() ) {
propsEntity.setProperty( key, properties.get(key).toString() );
@@ -711,13 +745,13 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
public Health getEntityStoreHealth() {
// could use any collection scope here, does not matter
- EntityCollectionManager ecm = getManagerCache().getEntityCollectionManager(
- new CollectionScopeImpl(
+ EntityCollectionManager ecm = getManagerCache().getEntityCollectionManager(
+ new CollectionScopeImpl(
new SimpleId( CpNamingUtils.SYSTEM_APP_ID, "application"),
new SimpleId( CpNamingUtils.SYSTEM_APP_ID, "application"),
"dummy"
));
-
+
return ecm.getHealth();
- }
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7335f941/stack/core/src/main/java/org/apache/usergrid/corepersistence/HybridEntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/HybridEntityManagerFactory.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/HybridEntityManagerFactory.java
index af4acdb..a8dd404 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/HybridEntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/HybridEntityManagerFactory.java
@@ -57,8 +57,8 @@ public class HybridEntityManagerFactory implements EntityManagerFactory, Applica
}
@Override
- public String getImpementationDescription() throws Exception {
- return factory.getImpementationDescription();
+ public String getImplementationDescription() throws Exception {
+ return factory.getImplementationDescription();
}
@Override
@@ -78,6 +78,11 @@ public class HybridEntityManagerFactory implements EntityManagerFactory, Applica
}
@Override
+ public void deleteApplication(UUID applicationId) throws Exception {
+ factory.deleteApplication( applicationId );
+ }
+
+ @Override
public UUID importApplication(String organization, UUID applicationId, String name,
Map<String, Object> properties) throws Exception {
return factory.importApplication(organization, applicationId, name, properties);
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7335f941/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
index 3d4827b..b4bfbd2 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
@@ -40,7 +40,7 @@ public interface EntityManagerFactory {
*
* @throws Exception the exception
*/
- public abstract String getImpementationDescription() throws Exception;
+ public abstract String getImplementationDescription() throws Exception;
/**
* Gets the entity manager.
@@ -73,9 +73,16 @@ public interface EntityManagerFactory {
*
* @throws Exception the exception
*/
- public abstract UUID createApplication(
+ public abstract UUID createApplication(
String organizationName, String name, Map<String, Object> properties ) throws Exception;
+ /**
+ * Delete Application.
+ *
+ * @param applicationId UUID of Application to be deleted.
+ */
+ public abstract void deleteApplication( UUID applicationId ) throws Exception;
+
public abstract UUID importApplication( String organization, UUID applicationId, String name,
Map<String, Object> properties ) throws Exception;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7335f941/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
index f073da7..a598a82 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
@@ -119,10 +119,10 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory, Applicati
/*
* (non-Javadoc)
*
- * @see org.apache.usergrid.core.Datastore#getImpementationDescription()
+ * @see org.apache.usergrid.core.Datastore#getImplementationDescription()
*/
@Override
- public String getImpementationDescription() {
+ public String getImplementationDescription() {
return IMPLEMENTATION_DESCRIPTION;
}
@@ -218,6 +218,13 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory, Applicati
return applicationId;
}
+
+ @Override
+ public void deleteApplication(UUID applicationId) throws Exception {
+ // TODO implement deleteApplication in Usergrid 1 code base (master branch?)
+ throw new UnsupportedOperationException("Not supported.");
+ }
+
private String buildAppName( String organizationName, String name ) {
return StringUtils.lowerCase( name.contains( "/" ) ? name : organizationName + "/" + name );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7335f941/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
index 4edd121..8841e56 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
@@ -17,39 +17,22 @@
package org.apache.usergrid.persistence.cassandra;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import org.apache.commons.lang3.RandomStringUtils;
-
import org.apache.usergrid.AbstractCoreIT;
import org.apache.usergrid.cassandra.CassandraResource;
import org.apache.usergrid.cassandra.Concurrent;
-import org.apache.usergrid.persistence.Entity;
-import org.apache.usergrid.persistence.EntityManager;
-import org.apache.usergrid.persistence.EntityManagerFactory;
-import org.apache.usergrid.persistence.Results;
-import org.apache.usergrid.persistence.SimpleEntityRef;
+import org.apache.usergrid.persistence.*;
import org.apache.usergrid.persistence.cassandra.util.TraceTag;
import org.apache.usergrid.persistence.cassandra.util.TraceTagManager;
import org.apache.usergrid.persistence.cassandra.util.TraceTagReporter;
import org.apache.usergrid.persistence.index.impl.ElasticSearchResource;
+import org.junit.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.*;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
@Concurrent()
@@ -107,8 +90,43 @@ public class EntityManagerFactoryImplIT extends AbstractCoreIT {
}
- public void testRebuildIndexes() throws Exception {
+ @Test
+ public void testDeleteApplication() throws Exception {
+
+ String rand = RandomStringUtils.randomAlphabetic(20);
+
+ // create an application with a collection and an entity
+ UUID applicationId = setup.createApplication( "test-org-" + rand, "test-app-" + rand );
+
+ EntityManager em = setup.getEmf().getEntityManager( applicationId );
+
+ Map<String, Object> properties1 = new LinkedHashMap<String, Object>();
+ properties1.put( "Name", "12 Angry Men" );
+ properties1.put( "Year", 1957 );
+ Entity film1 = em.create("film", properties1);
+
+ Map<String, Object> properties2 = new LinkedHashMap<String, Object>();
+ properties2.put( "Name", "Reservoir Dogs" );
+ properties2.put( "Year", 1992 );
+ Entity film2 = em.create( "film", properties2 );
+
+ em.refreshIndex();
+
+ // delete the application
+
+ setup.getEmf().deleteApplication( applicationId );
+
+ // attempt to get entities in application's collections in various ways should all fail
+
+ assertNull( setup.getEmf().lookupApplication("test-app-" + rand) );
+
+ Map<String, UUID> appMap = setup.getEmf().getApplications();
+ for ( String appName : appMap.keySet() ) {
+ UUID appId = appMap.get( appName );
+ assertNotEquals( appId, applicationId );
+ assertNotEquals( appName, "test-app-" + rand );
+ }
}
@@ -119,7 +137,8 @@ public class EntityManagerFactoryImplIT extends AbstractCoreIT {
traceTagManager.attach( traceTag );
logger.info( "EntityDaoTest.testCreateAndGet" );
- UUID applicationId = createApplication( "EntityManagerFactoryImplIT", "testCreateAndGet" + RandomStringUtils.randomAlphabetic(20) );
+ UUID applicationId = createApplication( "EntityManagerFactoryImplIT", "testCreateAndGet"
+ + RandomStringUtils.randomAlphabetic(20) );
logger.info( "Application id " + applicationId );
EntityManager em = emf.getEntityManager( applicationId );
[18/25] incubator-usergrid git commit: remove lexer
Posted by to...@apache.org.
remove lexer
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/6da8119f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/6da8119f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/6da8119f
Branch: refs/heads/USERGRID-273
Commit: 6da8119f8fef8d3b42c90bbfb9053baa3b60d7c4
Parents: eafdf63
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Jan 27 09:19:55 2015 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Jan 27 09:19:55 2015 -0700
----------------------------------------------------------------------
.gitignore | 3 ---
1 file changed, 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6da8119f/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 522f674..b516ec8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,9 +1,6 @@
.DS_Store
.AppleDouble
.LSOverride
-stack/core/src/main/java/org/apache/usergrid/persistence/query/tree/QueryFilterParser.java
-stack/core/src/main/java/org/apache/usergrid/persistence/query/tree/QueryFilterLexer.java
-
target
# Icon must ends with two \r.
[09/25] incubator-usergrid git commit: Merge branch 'two-dot-o' of
https://git-wip-us.apache.org/repos/asf/incubator-usergrid into
USERGRID-323-Win-phone
Posted by to...@apache.org.
Merge branch 'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into USERGRID-323-Win-phone
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/2d0d68ce
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/2d0d68ce
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/2d0d68ce
Branch: refs/heads/USERGRID-273
Commit: 2d0d68ce7453a3cc4b6a58432c0186b4b5e1fa1a
Parents: 122607d 6dc62ed
Author: Shawn Feldman <sf...@apache.org>
Authored: Thu Jan 22 08:47:56 2015 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Thu Jan 22 08:47:56 2015 -0700
----------------------------------------------------------------------
.../corepersistence/CpEntityManagerFactory.java | 56 +-
.../HybridEntityManagerFactory.java | 9 +-
.../persistence/EntityManagerFactory.java | 11 +-
.../cassandra/EntityManagerFactoryImpl.java | 11 +-
.../cassandra/EntityManagerFactoryImplIT.java | 71 ++-
.../usergrid/persistence/index/EntityIndex.java | 2 +
.../index/impl/EsEntityIndexBatchImpl.java | 14 +-
.../index/impl/EsEntityIndexImpl.java | 115 ++--
.../persistence/index/impl/EsIndexCache.java | 12 +-
.../rest/applications/ApplicationResource.java | 32 +-
.../apache/usergrid/rest/PartialUpdateTest.java | 170 +++---
.../applications/ApplicationDeleteTest.java | 54 ++
.../collection/groups/GroupResourceIT.java | 2 +-
.../applications/queries/AndOrQueryTest.java | 528 ++++++++++---------
.../queries/BadGrammarQueryTest.java | 213 ++++++--
.../applications/queries/GeoPagingTest.java | 2 +-
.../rest/applications/queries/OrderByTest.java | 447 +++++++++++-----
.../applications/queries/QueryTestBase.java | 72 +++
.../endpoints/CollectionEndpoint.java | 2 +-
19 files changed, 1193 insertions(+), 630 deletions(-)
----------------------------------------------------------------------
[24/25] incubator-usergrid git commit: Merge branch 'two-dot-o' of
https://git-wip-us.apache.org/repos/asf/incubator-usergrid into USERGRID-273
Posted by to...@apache.org.
Merge branch 'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into USERGRID-273
Conflicts:
stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
stack/core/src/main/java/org/apache/usergrid/corepersistence/HybridEntityManagerFactory.java
stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/02852a74
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/02852a74
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/02852a74
Branch: refs/heads/USERGRID-273
Commit: 02852a74a902a4abb287516b927b03406525ae15
Parents: b3951ee 198f479
Author: Todd Nine <tn...@apigee.com>
Authored: Wed Feb 11 14:17:36 2015 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Wed Feb 11 14:17:36 2015 -0700
----------------------------------------------------------------------
.gitignore | 4 +-
portal/js/global/ug-service.js | 72 +++----
portal/js/push/push-config-controller.js | 18 +-
portal/js/push/push-config.html | 50 +++++
.../Usergrid.Notifications/App.xaml | 27 +++
.../Usergrid.Notifications/App.xaml.cs | 150 ++++++++++++++
.../Assets/Logo.scale-240.png | Bin 0 -> 2516 bytes
.../Assets/SmallLogo.scale-240.png | Bin 0 -> 753 bytes
.../Assets/SplashScreen.scale-240.png | Bin 0 -> 14715 bytes
.../Assets/Square71x71Logo.scale-240.png | Bin 0 -> 1122 bytes
.../Assets/StoreLogo.scale-240.png | Bin 0 -> 2200 bytes
.../Assets/WideLogo.scale-240.png | Bin 0 -> 4530 bytes
.../Client/EntityResponse.cs | 80 ++++++++
.../Client/IUsergridClient.cs | 123 ++++++++++++
.../Usergrid.Notifications/Client/PushClient.cs | 155 +++++++++++++++
.../Usergrid.Notifications/Client/Usergrid.cs | 122 ++++++++++++
.../Usergrid.Notifications/MainPage.xaml | 38 ++++
.../Usergrid.Notifications/MainPage.xaml.cs | 124 ++++++++++++
.../Package.StoreAssociation.xml | 194 +++++++++++++++++++
.../Usergrid.Notifications/Package.appxmanifest | 53 +++++
.../Properties/AssemblyInfo.cs | 29 +++
.../Usergrid.Notifications.csproj | 142 ++++++++++++++
.../Usergrid.Notifications/packages.config | 25 +++
.../notifications/packages/repositories.config | 4 +
.../corepersistence/CpEntityManagerFactory.java | 56 +++++-
.../persistence/EntityManagerFactory.java | 7 +
.../cassandra/EntityManagerFactoryImpl.java | 8 +-
.../usergrid/persistence/entities/Notifier.java | 31 ++-
.../cassandra/EntityManagerFactoryImplIT.java | 65 ++++---
.../usergrid/persistence/index/EntityIndex.java | 2 +
.../index/impl/EsEntityIndexBatchImpl.java | 14 +-
.../index/impl/EsEntityIndexImpl.java | 115 +++++------
.../persistence/index/impl/EsIndexCache.java | 12 +-
.../persistence/queue/impl/QueueScopeImpl.java | 4 -
.../rest/applications/ApplicationResource.java | 32 ++-
.../applications/ApplicationDeleteTest.java | 54 ++++++
.../collection/groups/GroupResourceIT.java | 2 +-
stack/services/pom.xml | 5 +
.../notifications/ProviderAdapterFactory.java | 5 +
.../impl/ApplicationQueueManagerImpl.java | 8 +-
.../wns/TranslatedNotification.java | 50 +++++
.../services/notifications/wns/WNSAdapter.java | 163 ++++++++++++++++
42 files changed, 1857 insertions(+), 186 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/02852a74/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
----------------------------------------------------------------------
diff --cc stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
index c9319fb,93eb15e..bf85b45
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
@@@ -163,17 -147,27 +163,18 @@@ public class CpEntityManagerFactory imp
}
- public ManagerCache getManagerCache() {
-
- if ( managerCache == null ) {
-
- // TODO: better solution for getting injector?
- Injector injector = CpSetup.getInjector();
-
- managerCache = injector.getInstance( ManagerCache.class );
-
- dataMigrationManager = injector.getInstance( DataMigrationManager.class );
- }
- return managerCache;
- }
-
+// public ManagerCache getManagerCache() {
+//
+// if ( managerCache == null ) {
+// managerCache = injector.getInstance( ManagerCache.class );
+//
+// dataMigrationManager = injector.getInstance( DataMigrationManager.class );
+// }
+// return managerCache;
+// }
- @Override
- public String getImplementationDescription() throws Exception {
- return IMPLEMENTATION_DESCRIPTION;
- }
+
@Override
public EntityManager getEntityManager(UUID applicationId) {
try {
@@@ -413,6 -423,11 +444,11 @@@
managerCache.getEntityCollectionManager( collScope ).load( targetId )
.toBlockingObservable().lastOrDefault(null);
+ if ( e == null ) {
+ logger.warn("Applicaion {} in index but not found in collections", targetId );
+ continue;
- }
-
++ }
++
appMap.put(
(String)e.getField( PROPERTY_NAME ).getValue(),
(UUID)e.getField( "applicationUuid" ).getValue());
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/02852a74/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/02852a74/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
----------------------------------------------------------------------
diff --cc stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
index 086b039,a598a82..b7808d8
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
@@@ -116,10 -116,20 +116,9 @@@ public class EntityManagerFactoryImpl i
}
-
/*
* (non-Javadoc)
- *
- * @see org.apache.usergrid.core.Datastore#getImplementationDescription()
- */
- @Override
- public String getImplementationDescription() {
- return IMPLEMENTATION_DESCRIPTION;
- }
-
-
- /*
- * (non-Javadoc)
- *
+ *
* @see org.apache.usergrid.core.Datastore#getEntityDao(java.util.UUID,
* java.util.UUID)
*/
@@@ -208,7 -218,14 +207,14 @@@
return applicationId;
}
-
+
+ @Override
+ public void deleteApplication(UUID applicationId) throws Exception {
+ // TODO implement deleteApplication in Usergrid 1 code base (master branch?)
- throw new UnsupportedOperationException("Not supported.");
++ throw new UnsupportedOperationException("Not supported.");
+ }
+
+
private String buildAppName( String organizationName, String name ) {
return StringUtils.lowerCase( name.contains( "/" ) ? name : organizationName + "/" + name );
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/02852a74/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
----------------------------------------------------------------------
diff --cc stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
index e953fd2,8841e56..f69eed3
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
@@@ -17,42 -17,25 +17,25 @@@
package org.apache.usergrid.persistence.cassandra;
- import java.util.ArrayList;
- import java.util.LinkedHashMap;
- import java.util.List;
- import java.util.Map;
- import java.util.UUID;
-
- import org.junit.AfterClass;
- import org.junit.Before;
- import org.junit.BeforeClass;
- import org.junit.ClassRule;
- import org.junit.Test;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
-
import org.apache.commons.lang3.RandomStringUtils;
-
import org.apache.usergrid.AbstractCoreIT;
- import org.apache.usergrid.cassandra.SpringResource;
+ import org.apache.usergrid.cassandra.CassandraResource;
+ import org.apache.usergrid.cassandra.Concurrent;
-import org.apache.usergrid.persistence.*;
+import org.apache.usergrid.persistence.Entity;
+import org.apache.usergrid.persistence.EntityManager;
+import org.apache.usergrid.persistence.EntityManagerFactory;
+import org.apache.usergrid.persistence.Results;
+import org.apache.usergrid.persistence.SimpleEntityRef;
import org.apache.usergrid.persistence.cassandra.util.TraceTag;
import org.apache.usergrid.persistence.cassandra.util.TraceTagManager;
import org.apache.usergrid.persistence.cassandra.util.TraceTagReporter;
import org.apache.usergrid.persistence.index.impl.ElasticSearchResource;
- import org.apache.usergrid.setup.ConcurrentProcessSingleton;
-import org.junit.*;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
- import static org.junit.Assert.assertEquals;
- import static org.junit.Assert.assertFalse;
- import static org.junit.Assert.assertNotNull;
- import static org.junit.Assert.assertTrue;
+ import java.util.*;
+ import static org.junit.Assert.*;
-@Concurrent()
public class EntityManagerFactoryImplIT extends AbstractCoreIT {
@SuppressWarnings("PointlessBooleanExpression")
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/02852a74/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
----------------------------------------------------------------------
diff --cc stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
index d239641,e221f0e..ef510b2
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
@@@ -105,8 -100,9 +105,10 @@@ public interface EntityIndex
* Check health of this specific index.
*/
public Health getIndexHealth();
+
+ public void deleteIndex();
+
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/02852a74/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/02852a74/stack/services/pom.xml
----------------------------------------------------------------------
[11/25] incubator-usergrid git commit: remove sln file
Posted by to...@apache.org.
remove sln file
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/69c3b0f2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/69c3b0f2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/69c3b0f2
Branch: refs/heads/USERGRID-273
Commit: 69c3b0f2c5bda0e38271af2cc95f193381510ab2
Parents: eb025c9
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Jan 23 16:04:14 2015 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Jan 23 16:04:14 2015 -0700
----------------------------------------------------------------------
.../notifications/Usergrid.Notifications.sln | 40 --------------------
1 file changed, 40 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/69c3b0f2/sdks/dotnet/samples/notifications/Usergrid.Notifications.sln
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications.sln b/sdks/dotnet/samples/notifications/Usergrid.Notifications.sln
deleted file mode 100644
index 5474b5b..0000000
--- a/sdks/dotnet/samples/notifications/Usergrid.Notifications.sln
+++ /dev/null
@@ -1,40 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2013
-VisualStudioVersion = 12.0.31101.0
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Usergrid.Notifications", "Usergrid.Notifications\Usergrid.Notifications.csproj", "{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Debug|ARM = Debug|ARM
- Debug|x86 = Debug|x86
- Release|Any CPU = Release|Any CPU
- Release|ARM = Release|ARM
- Release|x86 = Release|x86
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
- {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|ARM.ActiveCfg = Debug|ARM
- {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|ARM.Build.0 = Debug|ARM
- {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|ARM.Deploy.0 = Debug|ARM
- {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|x86.ActiveCfg = Debug|x86
- {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|x86.Build.0 = Debug|x86
- {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|x86.Deploy.0 = Debug|x86
- {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|Any CPU.Build.0 = Release|Any CPU
- {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|Any CPU.Deploy.0 = Release|Any CPU
- {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|ARM.ActiveCfg = Release|ARM
- {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|ARM.Build.0 = Release|ARM
- {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|ARM.Deploy.0 = Release|ARM
- {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|x86.ActiveCfg = Release|x86
- {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|x86.Build.0 = Release|x86
- {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|x86.Deploy.0 = Release|x86
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
[17/25] incubator-usergrid git commit: Revert "remove lexer"
Posted by to...@apache.org.
Revert "remove lexer"
This reverts commit df29a99c4218a39269151a8773c0b0e051507650.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/eafdf633
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/eafdf633
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/eafdf633
Branch: refs/heads/USERGRID-273
Commit: eafdf633b7500d9b224b66046aea3dafb466627d
Parents: df29a99
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Jan 27 09:19:11 2015 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Jan 27 09:19:11 2015 -0700
----------------------------------------------------------------------
.gitignore | 6 ++++++
1 file changed, 6 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/eafdf633/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 6f8e854..522f674 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,8 @@
.DS_Store
.AppleDouble
.LSOverride
+stack/core/src/main/java/org/apache/usergrid/persistence/query/tree/QueryFilterParser.java
+stack/core/src/main/java/org/apache/usergrid/persistence/query/tree/QueryFilterLexer.java
target
@@ -39,6 +41,8 @@ stack/corepersistence/graph/nbactions.xml
stack/corepersistence/model/nbactions.xml
stack/corepersistence/nbactions.xml
stack/corepersistence/queryindex/nbactions.xml
+stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/QueryFilterLexer.java
+stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/QueryFilterParser.java
/stack/corepersistence/perftest2/src/main/resources/finefoods.txt
/stack/corepersistence/perftest1/src/main/resources/finefoods.txt
/stack/corepersistence/perftest2/nbactions.xml
@@ -76,6 +80,8 @@ portal/js/templates.js
/release/target/
/portal/seleniumLog.txt
+/stack/core/src/main/java/org/apache/usergrid/persistence/query/tree/QueryFilterLexer.java
+/stack/core/src/main/java/org/apache/usergrid/persistence/query/tree/QueryFilterParser.java
!/stack/corepersistence/common/src/test/resources/usergrid-UNIT.properties
*.iml
sdks/dotnet/samples/notifications/packages/*
[20/25] incubator-usergrid git commit: Merge branch 'two-dot-o' of
https://git-wip-us.apache.org/repos/asf/incubator-usergrid into
apache_usergrid/two-dot-o
Posted by to...@apache.org.
Merge branch 'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into apache_usergrid/two-dot-o
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/6ba340a3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/6ba340a3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/6ba340a3
Branch: refs/heads/USERGRID-273
Commit: 6ba340a360a605826fcc2a49cbbac15dc1cf814e
Parents: 373248b 6da8119
Author: Rod Simpson <ro...@apigee.com>
Authored: Tue Jan 27 13:24:54 2015 -0600
Committer: Rod Simpson <ro...@apigee.com>
Committed: Tue Jan 27 13:24:54 2015 -0600
----------------------------------------------------------------------
.gitignore | 4 +-
portal/js/global/ug-service.js | 67 +++----
portal/js/push/push-config-controller.js | 18 +-
portal/js/push/push-config.html | 50 +++++
.../Usergrid.Notifications/App.xaml | 27 +++
.../Usergrid.Notifications/App.xaml.cs | 150 ++++++++++++++
.../Assets/Logo.scale-240.png | Bin 0 -> 2516 bytes
.../Assets/SmallLogo.scale-240.png | Bin 0 -> 753 bytes
.../Assets/SplashScreen.scale-240.png | Bin 0 -> 14715 bytes
.../Assets/Square71x71Logo.scale-240.png | Bin 0 -> 1122 bytes
.../Assets/StoreLogo.scale-240.png | Bin 0 -> 2200 bytes
.../Assets/WideLogo.scale-240.png | Bin 0 -> 4530 bytes
.../Client/EntityResponse.cs | 80 ++++++++
.../Client/IUsergridClient.cs | 123 ++++++++++++
.../Usergrid.Notifications/Client/PushClient.cs | 153 +++++++++++++++
.../Usergrid.Notifications/Client/Usergrid.cs | 120 ++++++++++++
.../Usergrid.Notifications/MainPage.xaml | 38 ++++
.../Usergrid.Notifications/MainPage.xaml.cs | 127 ++++++++++++
.../Package.StoreAssociation.xml | 194 +++++++++++++++++++
.../Usergrid.Notifications/Package.appxmanifest | 53 +++++
.../Properties/AssemblyInfo.cs | 29 +++
.../Usergrid.Notifications.csproj | 142 ++++++++++++++
.../Usergrid.Notifications/packages.config | 25 +++
.../notifications/packages/repositories.config | 4 +
.../usergrid/persistence/entities/Notifier.java | 31 ++-
.../persistence/queue/impl/QueueScopeImpl.java | 4 -
stack/services/pom.xml | 7 +-
.../notifications/ProviderAdapterFactory.java | 5 +
.../impl/ApplicationQueueManagerImpl.java | 8 +-
.../wns/TranslatedNotification.java | 50 +++++
.../services/notifications/wns/WNSAdapter.java | 163 ++++++++++++++++
31 files changed, 1609 insertions(+), 63 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6ba340a3/portal/js/global/ug-service.js
----------------------------------------------------------------------
[22/25] incubator-usergrid git commit: fix authentication workflow
Posted by to...@apache.org.
fix authentication workflow
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/bfdacb34
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/bfdacb34
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/bfdacb34
Branch: refs/heads/USERGRID-273
Commit: bfdacb34ebdf918fcf92307c14808cadd5bdd7fd
Parents: 6ba340a
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Jan 27 19:31:58 2015 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Jan 27 19:31:58 2015 -0700
----------------------------------------------------------------------
.../Usergrid.Notifications/Client/PushClient.cs | 12 +++++++-----
.../Usergrid.Notifications/Client/Usergrid.cs | 10 ++++++----
.../Usergrid.Notifications/MainPage.xaml.cs | 15 ++++++---------
3 files changed, 19 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bfdacb34/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/PushClient.cs
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/PushClient.cs b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/PushClient.cs
index 8668626..fb8860c 100644
--- a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/PushClient.cs
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/PushClient.cs
@@ -35,12 +35,14 @@ namespace Usergrid.Notifications.Client
private IUsergridHttpClient usergrid;
private ApplicationDataContainer settings;
private PushNotificationChannel channel;
+ private string userId;
- public PushClient(IUsergridHttpClient usergrid, string notifier)
+ public PushClient(IUsergridHttpClient usergrid,string userId, string notifier)
{
this.usergrid = usergrid;
this.settings = ApplicationData.Current.LocalSettings;
this.Notifier = notifier;
+ this.userId = userId;
this.init().ContinueWith(t =>
{
LastException = t.Exception;
@@ -62,7 +64,7 @@ namespace Usergrid.Notifications.Client
payloads.Add(Notifier, payload);
jsonObject.Add("payloads", payloads);
jsonObject.Add("debug", true);
- var jsonResponse = await usergrid.SendAsync(HttpMethod.Post, String.Format("devices/{0}/notifications", this.DeviceId), jsonObject);
+ var jsonResponse = await usergrid.SendAsync(HttpMethod.Post, String.Format("users/{1}/devices/{0}/notifications", this.DeviceId,userId), jsonObject);
return jsonResponse.StatusIsOk;
}
@@ -79,7 +81,7 @@ namespace Usergrid.Notifications.Client
payloads.Add(Notifier, payload);
jsonObject.Add("payloads", payloads);
jsonObject.Add("debug", true);
- var jsonResponse = await usergrid.SendAsync(HttpMethod.Post, String.Format("devices/{0}/notifications", this.DeviceId), jsonObject);
+ var jsonResponse = await usergrid.SendAsync(HttpMethod.Post, String.Format("users/{1}/devices/{0}/notifications", this.DeviceId,userId), jsonObject);
return jsonResponse.StatusIsOk;
}
@@ -114,7 +116,7 @@ namespace Usergrid.Notifications.Client
private async Task<JToken> GetDevice(Guid deviceId)
{
- var jsonResponse = await usergrid.SendAsync(HttpMethod.Get, "devices/" + deviceId, null);
+ var jsonResponse = await usergrid.SendAsync(HttpMethod.Get, "users/"+userId+"/devices/" + deviceId, null);
if (jsonResponse.StatusIsOk)
{
@@ -130,7 +132,7 @@ namespace Usergrid.Notifications.Client
obj.Add(Notifier + ".notifier.id", new JValue(channel.Uri));
var jsonResponse = await usergrid.SendAsync(
(isNew ? HttpMethod.Post : HttpMethod.Put),
- "devices/" + (isNew ? "" : this.DeviceId.ToString()),
+ "users/"+userId+"/devices/" + (isNew ? "" : this.DeviceId.ToString()),
obj
);
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bfdacb34/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/Usergrid.cs
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/Usergrid.cs b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/Usergrid.cs
index cd0330d..977eb8b 100644
--- a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/Usergrid.cs
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/Usergrid.cs
@@ -48,13 +48,15 @@ namespace Usergrid.Notifications.Client
/// <param name="org"></param>
/// <param name="app"></param>
/// <param name="channel"></param>
- internal Usergrid(string serverUrl, string org, string app, string notifier)
+ internal Usergrid(string serverUrl, string org, string app, string userId, string password,string notifier)
{
string serverUrlWithSlash = serverUrl.EndsWith("/", StringComparison.CurrentCulture) ? serverUrl : serverUrl + "/";
this.appUrl = String.Format("{0}{1}/{2}/", serverUrlWithSlash, org, app);
this.managementUrl = serverUrlWithSlash + "management/";
this.client = new HttpClient();
- this.push = new PushClient(this,notifier);
+ Authenticate(userId, password, false).ContinueWith(task => {
+ this.push = new PushClient(this, userId, notifier);
+ });
}
public async Task Authenticate(string user, string password, bool isManagement)
@@ -69,7 +71,7 @@ namespace Usergrid.Notifications.Client
if (response.StatusIsOk)
{
this.token = response.GetValue("access_token").Value<String>();
- client.DefaultRequestHeaders.Add("X-Authorization", token);
+ client.DefaultRequestHeaders.Add("Authorization", "Bearer "+ token);
}
else
{
@@ -89,7 +91,7 @@ namespace Usergrid.Notifications.Client
public async Task<EntityResponse> SendAsync(HttpMethod method, string url, object obj, bool useManagementUrl)
{
- HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Post, (useManagementUrl ? this.managementUrl : this.appUrl) + url);
+ HttpRequestMessage message = new HttpRequestMessage(method, (useManagementUrl ? this.managementUrl : this.appUrl) + url);
if (obj != null)
{
message.Content = getJsonBody(obj);
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bfdacb34/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml.cs
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml.cs b/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml.cs
index 7e03c79..6d4c4ec 100644
--- a/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml.cs
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml.cs
@@ -44,27 +44,24 @@ namespace Usergrid.Notifications
{
this.InitializeComponent();
//TODO: change me to your server
- serverUrl = "http://10.0.1.20:8080";
+ serverUrl = "https://apigee-internal-prod.mars.apigee.net";
//TODO: change me to your org
- org = "mobile";
+ org = "ugvalidate";
//TODO: change me to your app
app = "sandbox";
//TODO: change me to your notifier name
notifier = "winphone";
//TODO: change me to your user
- user = "superuser";
+ user = "mobileuser";
//TODO: change me to your password
- password = "test";
+ password = "******";
this.NavigationCacheMode = NavigationCacheMode.Required;
- this.setup().ContinueWith(t => {
- LastException = t.Exception;
- });
+ usergrid = new Client.Usergrid(serverUrl, org, app, user, password, notifier);
+
}
private async Task setup()
{
- usergrid = new Client.Usergrid(serverUrl, org, app, notifier);
- await usergrid.Authenticate(user, password, true);
}
/// <summary>
[08/25] incubator-usergrid git commit: push sample
Posted by to...@apache.org.
push sample
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/122607d1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/122607d1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/122607d1
Branch: refs/heads/USERGRID-273
Commit: 122607d13d5b551a1474eb4f748948922aa46f2c
Parents: 74ea17e
Author: Shawn Feldman <sf...@apache.org>
Authored: Thu Jan 22 08:47:41 2015 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Thu Jan 22 08:47:41 2015 -0700
----------------------------------------------------------------------
.../Usergrid.Notifications/App.xaml | 7 +
.../Usergrid.Notifications/App.xaml.cs | 131 ++++++++++++
.../Assets/Logo.scale-240.png | Bin 0 -> 2516 bytes
.../Assets/SmallLogo.scale-240.png | Bin 0 -> 753 bytes
.../Assets/SplashScreen.scale-240.png | Bin 0 -> 14715 bytes
.../Assets/Square71x71Logo.scale-240.png | Bin 0 -> 1122 bytes
.../Assets/StoreLogo.scale-240.png | Bin 0 -> 2200 bytes
.../Assets/WideLogo.scale-240.png | Bin 0 -> 4530 bytes
.../Usergrid.Notifications/MainPage.xaml | 20 ++
.../Usergrid.Notifications/MainPage.xaml.cs | 89 ++++++++
.../Package.StoreAssociation.xml | 194 +++++++++++++++++
.../Usergrid.Notifications/Package.appxmanifest | 32 +++
.../Properties/AssemblyInfo.cs | 29 +++
.../Usergrid.Notifications.csproj | 139 ++++++++++++
.../Usergrid.Notifications/Usergrid.cs | 209 +++++++++++++++++++
.../Usergrid.Notifications/packages.config | 4 +
16 files changed, 854 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/122607d1/sdks/dotnet/samples/notifications/Usergrid.Notifications/App.xaml
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/App.xaml b/sdks/dotnet/samples/notifications/Usergrid.Notifications/App.xaml
new file mode 100644
index 0000000..8a36359
--- /dev/null
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/App.xaml
@@ -0,0 +1,7 @@
+<Application
+ x:Class="Usergrid.Notifications.App"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:local="using:Usergrid.Notifications">
+
+</Application>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/122607d1/sdks/dotnet/samples/notifications/Usergrid.Notifications/App.xaml.cs
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/App.xaml.cs b/sdks/dotnet/samples/notifications/Usergrid.Notifications/App.xaml.cs
new file mode 100644
index 0000000..9bf62ac
--- /dev/null
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/App.xaml.cs
@@ -0,0 +1,131 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices.WindowsRuntime;
+using Windows.ApplicationModel;
+using Windows.ApplicationModel.Activation;
+using Windows.Foundation;
+using Windows.Foundation.Collections;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Controls.Primitives;
+using Windows.UI.Xaml.Data;
+using Windows.UI.Xaml.Input;
+using Windows.UI.Xaml.Media;
+using Windows.UI.Xaml.Media.Animation;
+using Windows.UI.Xaml.Navigation;
+
+// The Blank Application template is documented at http://go.microsoft.com/fwlink/?LinkId=391641
+
+namespace Usergrid.Notifications
+{
+ /// <summary>
+ /// Provides application-specific behavior to supplement the default Application class.
+ /// </summary>
+ public sealed partial class App : Application
+ {
+ private TransitionCollection transitions;
+
+ /// <summary>
+ /// Initializes the singleton application object. This is the first line of authored code
+ /// executed, and as such is the logical equivalent of main() or WinMain().
+ /// </summary>
+ public App()
+ {
+ this.InitializeComponent();
+ this.Suspending += this.OnSuspending;
+ }
+
+ /// <summary>
+ /// Invoked when the application is launched normally by the end user. Other entry points
+ /// will be used when the application is launched to open a specific file, to display
+ /// search results, and so forth.
+ /// </summary>
+ /// <param name="e">Details about the launch request and process.</param>
+ protected override void OnLaunched(LaunchActivatedEventArgs e)
+ {
+#if DEBUG
+ if (System.Diagnostics.Debugger.IsAttached)
+ {
+ this.DebugSettings.EnableFrameRateCounter = true;
+ }
+#endif
+
+ Frame rootFrame = Window.Current.Content as Frame;
+
+ // Do not repeat app initialization when the Window already has content,
+ // just ensure that the window is active
+ if (rootFrame == null)
+ {
+ // Create a Frame to act as the navigation context and navigate to the first page
+ rootFrame = new Frame();
+
+ // TODO: change this value to a cache size that is appropriate for your application
+ rootFrame.CacheSize = 1;
+
+ if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
+ {
+ // TODO: Load state from previously suspended application
+ }
+
+ // Place the frame in the current Window
+ Window.Current.Content = rootFrame;
+ }
+
+ if (rootFrame.Content == null)
+ {
+ // Removes the turnstile navigation for startup.
+ if (rootFrame.ContentTransitions != null)
+ {
+ this.transitions = new TransitionCollection();
+ foreach (var c in rootFrame.ContentTransitions)
+ {
+ this.transitions.Add(c);
+ }
+ }
+
+ rootFrame.ContentTransitions = null;
+ rootFrame.Navigated += this.RootFrame_FirstNavigated;
+
+ // When the navigation stack isn't restored navigate to the first page,
+ // configuring the new page by passing required information as a navigation
+ // parameter
+ if (!rootFrame.Navigate(typeof(MainPage), e.Arguments))
+ {
+ throw new Exception("Failed to create initial page");
+ }
+ }
+
+ // Ensure the current window is active
+ Window.Current.Activate();
+ }
+
+ /// <summary>
+ /// Restores the content transitions after the app has launched.
+ /// </summary>
+ /// <param name="sender">The object where the handler is attached.</param>
+ /// <param name="e">Details about the navigation event.</param>
+ private void RootFrame_FirstNavigated(object sender, NavigationEventArgs e)
+ {
+ var rootFrame = sender as Frame;
+ rootFrame.ContentTransitions = this.transitions ?? new TransitionCollection() { new NavigationThemeTransition() };
+ rootFrame.Navigated -= this.RootFrame_FirstNavigated;
+ }
+
+ /// <summary>
+ /// Invoked when application execution is being suspended. Application state is saved
+ /// without knowing whether the application will be terminated or resumed with the contents
+ /// of memory still intact.
+ /// </summary>
+ /// <param name="sender">The source of the suspend request.</param>
+ /// <param name="e">Details about the suspend request.</param>
+ private void OnSuspending(object sender, SuspendingEventArgs e)
+ {
+ var deferral = e.SuspendingOperation.GetDeferral();
+
+ // TODO: Save application state and stop any background activity
+ deferral.Complete();
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/122607d1/sdks/dotnet/samples/notifications/Usergrid.Notifications/Assets/Logo.scale-240.png
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Assets/Logo.scale-240.png b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Assets/Logo.scale-240.png
new file mode 100644
index 0000000..76921ca
Binary files /dev/null and b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Assets/Logo.scale-240.png differ
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/122607d1/sdks/dotnet/samples/notifications/Usergrid.Notifications/Assets/SmallLogo.scale-240.png
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Assets/SmallLogo.scale-240.png b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Assets/SmallLogo.scale-240.png
new file mode 100644
index 0000000..3166301
Binary files /dev/null and b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Assets/SmallLogo.scale-240.png differ
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/122607d1/sdks/dotnet/samples/notifications/Usergrid.Notifications/Assets/SplashScreen.scale-240.png
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Assets/SplashScreen.scale-240.png b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Assets/SplashScreen.scale-240.png
new file mode 100644
index 0000000..33f26b3
Binary files /dev/null and b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Assets/SplashScreen.scale-240.png differ
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/122607d1/sdks/dotnet/samples/notifications/Usergrid.Notifications/Assets/Square71x71Logo.scale-240.png
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Assets/Square71x71Logo.scale-240.png b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Assets/Square71x71Logo.scale-240.png
new file mode 100644
index 0000000..cfa54be
Binary files /dev/null and b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Assets/Square71x71Logo.scale-240.png differ
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/122607d1/sdks/dotnet/samples/notifications/Usergrid.Notifications/Assets/StoreLogo.scale-240.png
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Assets/StoreLogo.scale-240.png b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Assets/StoreLogo.scale-240.png
new file mode 100644
index 0000000..47e084b
Binary files /dev/null and b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Assets/StoreLogo.scale-240.png differ
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/122607d1/sdks/dotnet/samples/notifications/Usergrid.Notifications/Assets/WideLogo.scale-240.png
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Assets/WideLogo.scale-240.png b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Assets/WideLogo.scale-240.png
new file mode 100644
index 0000000..6249d29
Binary files /dev/null and b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Assets/WideLogo.scale-240.png differ
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/122607d1/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml b/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml
new file mode 100644
index 0000000..3e0affd
--- /dev/null
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml
@@ -0,0 +1,20 @@
+<Page
+ x:Class="Usergrid.Notifications.MainPage"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:local="using:Usergrid.Notifications"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ mc:Ignorable="d"
+ Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
+
+ <Grid>
+ <TextBox x:Name="pushText" HorizontalAlignment="Left" Margin="75,46,0,0" TextWrapping="Wrap" Text="Push Text" VerticalAlignment="Top" Width="261" TextChanged="pushText_TextChanged"/>
+ <Button Content="Send" HorizontalAlignment="Left" Margin="146,121,0,0" VerticalAlignment="Top" Click="Button_Click"/>
+ <TextBox x:Name="NotifierName" HorizontalAlignment="Left" Margin="75,210,0,0" TextWrapping="Wrap" Text="Notifier Name" VerticalAlignment="Top" Width="261"/>
+ <TextBox x:Name="Api_Key" HorizontalAlignment="Left" Margin="75,276,0,0" TextWrapping="Wrap" Text="Sid" VerticalAlignment="Top" Width="261"/>
+ <TextBox x:Name="Sid" HorizontalAlignment="Left" Margin="75,348,0,0" TextWrapping="Wrap" Text="Api Key" VerticalAlignment="Top" Width="261"/>
+ <Button x:Name="AddNotifierButton" Content="Add Notifier" HorizontalAlignment="Left" Margin="146,405,0,0" VerticalAlignment="Top" Click="AddNotifierButton_Click"/>
+
+ </Grid>
+</Page>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/122607d1/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml.cs
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml.cs b/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml.cs
new file mode 100644
index 0000000..882838d
--- /dev/null
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml.cs
@@ -0,0 +1,89 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices.WindowsRuntime;
+using Windows.Foundation;
+using Windows.Foundation.Collections;
+using Windows.Networking.PushNotifications;
+using Windows.Storage;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Controls.Primitives;
+using Windows.UI.Xaml.Data;
+using Windows.UI.Xaml.Input;
+using Windows.UI.Xaml.Media;
+using Windows.UI.Xaml.Navigation;
+
+// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=391641
+
+namespace Usergrid.Notifications
+{
+ /// <summary>
+ /// An empty page that can be used on its own or navigated to within a Frame.
+ /// </summary>
+ public sealed partial class MainPage : Page
+ {
+ private Usergrid usergrid;
+ private string serverUrl;
+ private string org;
+ private string app;
+ private string notifier;
+ private string apiKey;
+ private string secret;
+ private Guid deviceId;
+ public MainPage()
+ {
+ this.InitializeComponent();
+ var myIp = "10.0.1.20";
+ serverUrl = "http://" + myIp + ":8080";
+ org = "mobile";
+ app = "sandbox";
+ notifier = "winphone";
+ this.NavigationCacheMode = NavigationCacheMode.Required;
+ this.setup();
+ }
+
+ private async void setup()
+ {
+ usergrid = new Usergrid(serverUrl, org, app);
+ await this.usergrid.Authenticate("superuser", "test", true);
+ await usergrid.Push.RegisterDevice(notifier);
+
+
+ }
+
+ /// <summary>
+ /// Invoked when this page is about to be displayed in a Frame.
+ /// </summary>
+ /// <param name="e">Event data that describes how this page was reached.
+ /// This parameter is typically used to configure the page.</param>
+ protected override void OnNavigatedTo(NavigationEventArgs e)
+ {
+ // TODO: Prepare page for display here.
+
+ // TODO: If your application contains multiple pages, ensure that you are
+ // handling the hardware Back button by registering for the
+ // Windows.Phone.UI.Input.HardwareButtons.BackPressed event.
+ // If you are using the NavigationHelper provided by some templates,
+ // this event is handled for you.
+ }
+
+ private async void Button_Click(object sender, RoutedEventArgs e)
+ {
+
+ var message = this.pushText.Text;
+ await usergrid.Push.SendNotification(deviceId,message);
+ }
+
+ private void pushText_TextChanged(object sender, TextChangedEventArgs e)
+ {
+
+ }
+
+ private async void AddNotifierButton_Click(object sender, RoutedEventArgs e)
+ {
+ await usergrid.Push.AddNotifier(NotifierName.Text,Sid.Text,Api_Key.Text);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/122607d1/sdks/dotnet/samples/notifications/Usergrid.Notifications/Package.StoreAssociation.xml
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Package.StoreAssociation.xml b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Package.StoreAssociation.xml
new file mode 100644
index 0000000..c6278a4
--- /dev/null
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Package.StoreAssociation.xml
@@ -0,0 +1,194 @@
+<?xml version="1.0" encoding="utf-8"?>
+<StoreAssociation xmlns="http://schemas.microsoft.com/appx/2010/storeassociation">
+ <Publisher>CN=AC3A1EB7-E4EA-48C0-9556-C37AA8BAE0CF</Publisher>
+ <PublisherDisplayName>feldrocker</PublisherDisplayName>
+ <GeneratePackageHash>http://www.w3.org/2001/04/xmlenc#sha256</GeneratePackageHash>
+ <SupportedLocales>
+ <Language Code="af" InMinimumRequirementSet="true" />
+ <Language Code="af-za" InMinimumRequirementSet="true" />
+ <Language Code="sq" InMinimumRequirementSet="true" />
+ <Language Code="sq-al" InMinimumRequirementSet="true" />
+ <Language Code="ar" InMinimumRequirementSet="true" />
+ <Language Code="ar-ae" InMinimumRequirementSet="true" />
+ <Language Code="ar-bh" InMinimumRequirementSet="true" />
+ <Language Code="ar-dz" InMinimumRequirementSet="true" />
+ <Language Code="ar-eg" InMinimumRequirementSet="true" />
+ <Language Code="ar-iq" InMinimumRequirementSet="true" />
+ <Language Code="ar-jo" InMinimumRequirementSet="true" />
+ <Language Code="ar-kw" InMinimumRequirementSet="true" />
+ <Language Code="ar-lb" InMinimumRequirementSet="true" />
+ <Language Code="ar-ly" InMinimumRequirementSet="true" />
+ <Language Code="ar-ma" InMinimumRequirementSet="true" />
+ <Language Code="ar-om" InMinimumRequirementSet="true" />
+ <Language Code="ar-qa" InMinimumRequirementSet="true" />
+ <Language Code="ar-sa" InMinimumRequirementSet="true" />
+ <Language Code="ar-sy" InMinimumRequirementSet="true" />
+ <Language Code="ar-tn" InMinimumRequirementSet="true" />
+ <Language Code="ar-ye" InMinimumRequirementSet="true" />
+ <Language Code="az-latn" InMinimumRequirementSet="true" />
+ <Language Code="az-latn-az" InMinimumRequirementSet="true" />
+ <Language Code="az" InMinimumRequirementSet="true" />
+ <Language Code="eu" InMinimumRequirementSet="true" />
+ <Language Code="eu-es" InMinimumRequirementSet="true" />
+ <Language Code="be" InMinimumRequirementSet="true" />
+ <Language Code="be-by" InMinimumRequirementSet="true" />
+ <Language Code="pt-br" InMinimumRequirementSet="true" />
+ <Language Code="bg" InMinimumRequirementSet="true" />
+ <Language Code="bg-bg" InMinimumRequirementSet="true" />
+ <Language Code="ca" InMinimumRequirementSet="true" />
+ <Language Code="ca-es" InMinimumRequirementSet="true" />
+ <Language Code="hr" InMinimumRequirementSet="true" />
+ <Language Code="hr-hr" InMinimumRequirementSet="true" />
+ <Language Code="hr-ba" InMinimumRequirementSet="true" />
+ <Language Code="cs" InMinimumRequirementSet="true" />
+ <Language Code="cs-cz" InMinimumRequirementSet="true" />
+ <Language Code="da" InMinimumRequirementSet="true" />
+ <Language Code="da-dk" InMinimumRequirementSet="true" />
+ <Language Code="nl" InMinimumRequirementSet="true" />
+ <Language Code="nl-nl" InMinimumRequirementSet="true" />
+ <Language Code="nl-be" InMinimumRequirementSet="true" />
+ <Language Code="en" InMinimumRequirementSet="true" />
+ <Language Code="en-gb" InMinimumRequirementSet="true" />
+ <Language Code="en-029" InMinimumRequirementSet="true" />
+ <Language Code="en-au" InMinimumRequirementSet="true" />
+ <Language Code="en-bz" InMinimumRequirementSet="true" />
+ <Language Code="en-ie" InMinimumRequirementSet="true" />
+ <Language Code="en-in" InMinimumRequirementSet="true" />
+ <Language Code="en-jm" InMinimumRequirementSet="true" />
+ <Language Code="en-my" InMinimumRequirementSet="true" />
+ <Language Code="en-nz" InMinimumRequirementSet="true" />
+ <Language Code="en-ph" InMinimumRequirementSet="true" />
+ <Language Code="en-sg" InMinimumRequirementSet="true" />
+ <Language Code="en-tt" InMinimumRequirementSet="true" />
+ <Language Code="en-za" InMinimumRequirementSet="true" />
+ <Language Code="en-zw" InMinimumRequirementSet="true" />
+ <Language Code="en-hk" InMinimumRequirementSet="true" />
+ <Language Code="en-us" InMinimumRequirementSet="true" />
+ <Language Code="en-ca" InMinimumRequirementSet="true" />
+ <Language Code="et" InMinimumRequirementSet="true" />
+ <Language Code="et-ee" InMinimumRequirementSet="true" />
+ <Language Code="fil" InMinimumRequirementSet="true" />
+ <Language Code="fil-ph" InMinimumRequirementSet="true" />
+ <Language Code="fi" InMinimumRequirementSet="true" />
+ <Language Code="fi-fi" InMinimumRequirementSet="true" />
+ <Language Code="fr" InMinimumRequirementSet="true" />
+ <Language Code="fr-fr" InMinimumRequirementSet="true" />
+ <Language Code="fr-ca" InMinimumRequirementSet="true" />
+ <Language Code="fr-ch" InMinimumRequirementSet="true" />
+ <Language Code="fr-be" InMinimumRequirementSet="true" />
+ <Language Code="fr-lu" InMinimumRequirementSet="true" />
+ <Language Code="fr-mc" InMinimumRequirementSet="true" />
+ <Language Code="gl" InMinimumRequirementSet="true" />
+ <Language Code="gl-es" InMinimumRequirementSet="true" />
+ <Language Code="de" InMinimumRequirementSet="true" />
+ <Language Code="de-de" InMinimumRequirementSet="true" />
+ <Language Code="de-ch" InMinimumRequirementSet="true" />
+ <Language Code="de-at" InMinimumRequirementSet="true" />
+ <Language Code="de-li" InMinimumRequirementSet="true" />
+ <Language Code="de-lu" InMinimumRequirementSet="true" />
+ <Language Code="el" InMinimumRequirementSet="true" />
+ <Language Code="el-gr" InMinimumRequirementSet="true" />
+ <Language Code="ha-latn" InMinimumRequirementSet="true" />
+ <Language Code="ha-latn-ng" InMinimumRequirementSet="true" />
+ <Language Code="ha" InMinimumRequirementSet="true" />
+ <Language Code="he" InMinimumRequirementSet="true" />
+ <Language Code="he-il" InMinimumRequirementSet="true" />
+ <Language Code="hi" InMinimumRequirementSet="true" />
+ <Language Code="hi-in" InMinimumRequirementSet="true" />
+ <Language Code="hu" InMinimumRequirementSet="true" />
+ <Language Code="hu-hu" InMinimumRequirementSet="true" />
+ <Language Code="id" InMinimumRequirementSet="true" />
+ <Language Code="id-id" InMinimumRequirementSet="true" />
+ <Language Code="it" InMinimumRequirementSet="true" />
+ <Language Code="it-it" InMinimumRequirementSet="true" />
+ <Language Code="it-ch" InMinimumRequirementSet="true" />
+ <Language Code="ja" InMinimumRequirementSet="true" />
+ <Language Code="ja-jp" InMinimumRequirementSet="true" />
+ <Language Code="kk" InMinimumRequirementSet="true" />
+ <Language Code="kk-kz" InMinimumRequirementSet="true" />
+ <Language Code="ko" InMinimumRequirementSet="true" />
+ <Language Code="ko-kr" InMinimumRequirementSet="true" />
+ <Language Code="sr-latn" InMinimumRequirementSet="true" />
+ <Language Code="sr-latn-ba" InMinimumRequirementSet="true" />
+ <Language Code="sr-latn-cs" InMinimumRequirementSet="true" />
+ <Language Code="sr-latn-me" InMinimumRequirementSet="true" />
+ <Language Code="sr-latn-rs" InMinimumRequirementSet="true" />
+ <Language Code="sr" InMinimumRequirementSet="true" />
+ <Language Code="lv" InMinimumRequirementSet="true" />
+ <Language Code="lv-lv" InMinimumRequirementSet="true" />
+ <Language Code="lt" InMinimumRequirementSet="true" />
+ <Language Code="lt-lt" InMinimumRequirementSet="true" />
+ <Language Code="mk" InMinimumRequirementSet="true" />
+ <Language Code="mk-mk" InMinimumRequirementSet="true" />
+ <Language Code="ms" InMinimumRequirementSet="true" />
+ <Language Code="ms-my" InMinimumRequirementSet="true" />
+ <Language Code="ms-bn" InMinimumRequirementSet="true" />
+ <Language Code="nb" InMinimumRequirementSet="true" />
+ <Language Code="nb-no" InMinimumRequirementSet="true" />
+ <Language Code="fa" InMinimumRequirementSet="true" />
+ <Language Code="fa-ir" InMinimumRequirementSet="true" />
+ <Language Code="pl" InMinimumRequirementSet="true" />
+ <Language Code="pl-pl" InMinimumRequirementSet="true" />
+ <Language Code="pt" InMinimumRequirementSet="true" />
+ <Language Code="pt-pt" InMinimumRequirementSet="true" />
+ <Language Code="ro" InMinimumRequirementSet="true" />
+ <Language Code="ro-ro" InMinimumRequirementSet="true" />
+ <Language Code="ru" InMinimumRequirementSet="true" />
+ <Language Code="ru-ru" InMinimumRequirementSet="true" />
+ <Language Code="zh" InMinimumRequirementSet="true" />
+ <Language Code="zh-cn" InMinimumRequirementSet="true" />
+ <Language Code="zh-hans" InMinimumRequirementSet="true" />
+ <Language Code="zh-sg" InMinimumRequirementSet="true" />
+ <Language Code="sk" InMinimumRequirementSet="true" />
+ <Language Code="sk-sk" InMinimumRequirementSet="true" />
+ <Language Code="sl" InMinimumRequirementSet="true" />
+ <Language Code="sl-si" InMinimumRequirementSet="true" />
+ <Language Code="es" InMinimumRequirementSet="true" />
+ <Language Code="es-es" InMinimumRequirementSet="true" />
+ <Language Code="es-mx" InMinimumRequirementSet="true" />
+ <Language Code="es-ar" InMinimumRequirementSet="true" />
+ <Language Code="es-bo" InMinimumRequirementSet="true" />
+ <Language Code="es-cl" InMinimumRequirementSet="true" />
+ <Language Code="es-co" InMinimumRequirementSet="true" />
+ <Language Code="es-cr" InMinimumRequirementSet="true" />
+ <Language Code="es-do" InMinimumRequirementSet="true" />
+ <Language Code="es-ec" InMinimumRequirementSet="true" />
+ <Language Code="es-gt" InMinimumRequirementSet="true" />
+ <Language Code="es-hn" InMinimumRequirementSet="true" />
+ <Language Code="es-ni" InMinimumRequirementSet="true" />
+ <Language Code="es-pa" InMinimumRequirementSet="true" />
+ <Language Code="es-pe" InMinimumRequirementSet="true" />
+ <Language Code="es-pr" InMinimumRequirementSet="true" />
+ <Language Code="es-py" InMinimumRequirementSet="true" />
+ <Language Code="es-sv" InMinimumRequirementSet="true" />
+ <Language Code="es-us" InMinimumRequirementSet="true" />
+ <Language Code="es-uy" InMinimumRequirementSet="true" />
+ <Language Code="es-ve" InMinimumRequirementSet="true" />
+ <Language Code="sv" InMinimumRequirementSet="true" />
+ <Language Code="sv-fi" InMinimumRequirementSet="true" />
+ <Language Code="sv-se" InMinimumRequirementSet="true" />
+ <Language Code="th" InMinimumRequirementSet="true" />
+ <Language Code="th-th" InMinimumRequirementSet="true" />
+ <Language Code="zh-hant" InMinimumRequirementSet="true" />
+ <Language Code="zh-hk" InMinimumRequirementSet="true" />
+ <Language Code="zh-mo" InMinimumRequirementSet="true" />
+ <Language Code="zh-tw" InMinimumRequirementSet="true" />
+ <Language Code="tr" InMinimumRequirementSet="true" />
+ <Language Code="tr-tr" InMinimumRequirementSet="true" />
+ <Language Code="uk" InMinimumRequirementSet="true" />
+ <Language Code="uk-ua" InMinimumRequirementSet="true" />
+ <Language Code="uz-latn" InMinimumRequirementSet="true" />
+ <Language Code="uz-latn-uz" InMinimumRequirementSet="true" />
+ <Language Code="uz" InMinimumRequirementSet="true" />
+ <Language Code="vi" InMinimumRequirementSet="true" />
+ <Language Code="vi-vn" InMinimumRequirementSet="true" />
+ </SupportedLocales>
+ <ProductReservedInfo>
+ <MainPackageIdentityName>15661feldrocker.usergridsample</MainPackageIdentityName>
+ <ReservedNames>
+ <ReservedName>usergrid sample</ReservedName>
+ </ReservedNames>
+ </ProductReservedInfo>
+ <AccountPackageIdentityNames />
+ <PackageInfoList LandingUrl="https://dev.windowsphone.com/AppSubmission/AssociationLanding?windowsProductId=142f4403-3810-4c59-8236-0afe0b8472bf" />
+</StoreAssociation>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/122607d1/sdks/dotnet/samples/notifications/Usergrid.Notifications/Package.appxmanifest
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Package.appxmanifest b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Package.appxmanifest
new file mode 100644
index 0000000..a47ef82
--- /dev/null
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Package.appxmanifest
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest" xmlns:m3="http://schemas.microsoft.com/appx/2014/manifest" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest">
+ <Identity Name="15661feldrocker.usergridsample" Publisher="CN=AC3A1EB7-E4EA-48C0-9556-C37AA8BAE0CF" Version="1.1.0.0" />
+ <mp:PhoneIdentity PhoneProductId="c05b658a-0b41-4187-a6e4-ca186c2338de" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
+ <Properties>
+ <DisplayName>usergrid sample</DisplayName>
+ <PublisherDisplayName>feldrocker</PublisherDisplayName>
+ <Logo>Assets\StoreLogo.png</Logo>
+ </Properties>
+ <Prerequisites>
+ <OSMinVersion>6.3.1</OSMinVersion>
+ <OSMaxVersionTested>6.3.1</OSMaxVersionTested>
+ </Prerequisites>
+ <Resources>
+ <Resource Language="x-generate" />
+ </Resources>
+ <Applications>
+ <Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="Usergrid.Notifications.App">
+ <m3:VisualElements DisplayName="usergrid sample" Square150x150Logo="Assets\Logo.png" Square44x44Logo="Assets\SmallLogo.png" Description="Usergrid.Notifications" ForegroundText="light" BackgroundColor="transparent" ToastCapable="true">
+ <m3:DefaultTile Wide310x150Logo="Assets\WideLogo.png" Square71x71Logo="Assets\Square71x71Logo.png">
+ </m3:DefaultTile>
+ <m3:SplashScreen Image="Assets\SplashScreen.png" />
+ <m3:InitialRotationPreference>
+ <m3:Rotation Preference="portrait" />
+ </m3:InitialRotationPreference>
+ </m3:VisualElements>
+ </Application>
+ </Applications>
+ <Capabilities>
+ <Capability Name="internetClientServer" />
+ </Capabilities>
+</Package>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/122607d1/sdks/dotnet/samples/notifications/Usergrid.Notifications/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Properties/AssemblyInfo.cs b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..daf5838
--- /dev/null
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Properties/AssemblyInfo.cs
@@ -0,0 +1,29 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Usergrid.Notifications")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Usergrid.Notifications")]
+[assembly: AssemblyCopyright("Copyright © 2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: ComVisible(false)]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/122607d1/sdks/dotnet/samples/notifications/Usergrid.Notifications/Usergrid.Notifications.csproj
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Usergrid.Notifications.csproj b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Usergrid.Notifications.csproj
new file mode 100644
index 0000000..c811c83
--- /dev/null
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Usergrid.Notifications.csproj
@@ -0,0 +1,139 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}</ProjectGuid>
+ <OutputType>AppContainerExe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Usergrid.Notifications</RootNamespace>
+ <AssemblyName>Usergrid.Notifications</AssemblyName>
+ <DefaultLanguage>en-US</DefaultLanguage>
+ <TargetPlatformVersion>8.1</TargetPlatformVersion>
+ <MinimumVisualStudioVersion>12</MinimumVisualStudioVersion>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{76F1466A-8B6D-4E39-A767-685A06062A39};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <AppxAutoIncrementPackageRevision>True</AppxAutoIncrementPackageRevision>
+ <AppxBundlePlatforms>neutral</AppxBundlePlatforms>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_PHONE_APP</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE;NETFX_CORE;WINDOWS_PHONE_APP</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
+ <DebugSymbols>true</DebugSymbols>
+ <OutputPath>bin\ARM\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_PHONE_APP</DefineConstants>
+ <NoWarn>;2008</NoWarn>
+ <DebugType>full</DebugType>
+ <PlatformTarget>ARM</PlatformTarget>
+ <UseVSHostingProcess>false</UseVSHostingProcess>
+ <ErrorReport>prompt</ErrorReport>
+ <Prefer32Bit>true</Prefer32Bit>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
+ <OutputPath>bin\ARM\Release\</OutputPath>
+ <DefineConstants>TRACE;NETFX_CORE;WINDOWS_PHONE_APP</DefineConstants>
+ <Optimize>true</Optimize>
+ <NoWarn>;2008</NoWarn>
+ <DebugType>pdbonly</DebugType>
+ <PlatformTarget>ARM</PlatformTarget>
+ <UseVSHostingProcess>false</UseVSHostingProcess>
+ <ErrorReport>prompt</ErrorReport>
+ <Prefer32Bit>true</Prefer32Bit>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
+ <DebugSymbols>true</DebugSymbols>
+ <OutputPath>bin\x86\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_PHONE_APP</DefineConstants>
+ <NoWarn>;2008</NoWarn>
+ <DebugType>full</DebugType>
+ <PlatformTarget>x86</PlatformTarget>
+ <UseVSHostingProcess>false</UseVSHostingProcess>
+ <ErrorReport>prompt</ErrorReport>
+ <Prefer32Bit>true</Prefer32Bit>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
+ <OutputPath>bin\x86\Release\</OutputPath>
+ <DefineConstants>TRACE;NETFX_CORE;WINDOWS_PHONE_APP</DefineConstants>
+ <Optimize>true</Optimize>
+ <NoWarn>;2008</NoWarn>
+ <DebugType>pdbonly</DebugType>
+ <PlatformTarget>x86</PlatformTarget>
+ <UseVSHostingProcess>false</UseVSHostingProcess>
+ <ErrorReport>prompt</ErrorReport>
+ <Prefer32Bit>true</Prefer32Bit>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="App.xaml.cs">
+ <DependentUpon>App.xaml</DependentUpon>
+ </Compile>
+ <Compile Include="MainPage.xaml.cs">
+ <DependentUpon>MainPage.xaml</DependentUpon>
+ </Compile>
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Usergrid.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <AppxManifest Include="Package.appxmanifest">
+ <SubType>Designer</SubType>
+ </AppxManifest>
+ </ItemGroup>
+ <ItemGroup>
+ <Content Include="Assets\Logo.scale-240.png" />
+ <Content Include="Assets\SmallLogo.scale-240.png" />
+ <Content Include="Assets\SplashScreen.scale-240.png" />
+ <Content Include="Assets\Square71x71Logo.scale-240.png" />
+ <Content Include="Assets\StoreLogo.scale-240.png" />
+ <Content Include="Assets\WideLogo.scale-240.png" />
+ <None Include="Package.StoreAssociation.xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <ApplicationDefinition Include="App.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </ApplicationDefinition>
+ <Page Include="MainPage.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </Page>
+ </ItemGroup>
+ <ItemGroup>
+ <Reference Include="Newtonsoft.Json">
+ <HintPath>..\packages\Newtonsoft.Json.6.0.8\lib\portable-net40+sl5+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
+ </ItemGroup>
+ <PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '12.0' ">
+ <VisualStudioVersion>12.0</VisualStudioVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(TargetPlatformIdentifier)' == '' ">
+ <TargetPlatformIdentifier>WindowsPhoneApp</TargetPlatformIdentifier>
+ </PropertyGroup>
+ <Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/122607d1/sdks/dotnet/samples/notifications/Usergrid.Notifications/Usergrid.cs
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Usergrid.cs b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Usergrid.cs
new file mode 100644
index 0000000..cc715f8
--- /dev/null
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Usergrid.cs
@@ -0,0 +1,209 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Net;
+using System.IO;
+using System.Runtime.Serialization;
+using System.Runtime.Serialization.Json;
+using System.Text;
+using Newtonsoft.Json.Linq;
+using Newtonsoft.Json;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using Windows.Storage;
+using Windows.Networking.PushNotifications;
+
+namespace Usergrid.Notifications
+{
+ public class Usergrid : UsergridHttpClient
+ {
+ private string url;
+ private string token;
+ private HttpClient client;
+ private PushClient push;
+ private string managementUrl;
+
+ public Usergrid(string url, string org, string app)
+ {
+ string urlWithSlash = url.EndsWith("/",StringComparison.CurrentCulture) ? url : url+"/";
+ this.url = String.Format("{0}{1}/{2}/", urlWithSlash, org, app);
+ this.managementUrl = urlWithSlash + "management/";
+ this.client = new HttpClient();
+ push = new PushClient(this);
+ }
+
+ public async Task Authenticate(string user, string password, bool isManagement)
+ {
+ var url = "token";
+ var jsonObject = new JObject();
+ jsonObject.Add("username", user);
+ jsonObject.Add("password", password);
+ jsonObject.Add("grant_type", "password");
+ HttpResponseMessage response = await SendAsync(HttpMethod.Post,url, jsonObject, isManagement);
+
+ if (response.StatusCode == HttpStatusCode.OK)
+ {
+ JObject jsonResponse = await GetJsonResponse(response);
+ this.token = jsonResponse.GetValue("access_token").Value<String>();
+ client.DefaultRequestHeaders.Add("X-Authorization", token);
+ }
+ else
+ {
+ throw new Exception("Authentication failed");
+ }
+ }
+
+ public async Task<JObject> GetJsonResponse(HttpResponseMessage response)
+ {
+ JObject jsonResponse = null;
+ using (var stream = await response.Content.ReadAsStreamAsync())
+ {
+ using (var reader = new StreamReader(stream, Encoding.UTF8))
+ {
+ jsonResponse = JObject.Parse(reader.ReadToEnd());
+ }
+ }
+ return jsonResponse;
+ }
+
+ private HttpContent getJsonBody(Object jsonObject)
+ {
+ var content = new StringContent(JsonConvert.SerializeObject(jsonObject));
+ return content;
+ }
+ public Task<HttpResponseMessage> SendAsync(HttpMethod method, string url, object obj)
+ {
+ return SendAsync(method, url, obj, false);
+ }
+ public Task<HttpResponseMessage> SendAsync(HttpMethod method, string url, object obj, bool useManagementUrl)
+ {
+ HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Post, (useManagementUrl ? this.managementUrl : this.url) + url);
+ if(obj!=null)
+ message.Content = getJsonBody(obj);
+ message.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue( "application/json"));
+ return this.client.SendAsync(message);
+
+ }
+
+ public PushClient Push
+ {
+ get { return push; }
+ }
+
+
+ }
+
+ public interface UsergridHttpClient
+ {
+ Task<HttpResponseMessage>SendAsync(HttpMethod method,string url, object obj);
+ Task<JObject> GetJsonResponse(HttpResponseMessage response);
+
+ }
+ public class PushClient
+ {
+ private UsergridHttpClient usergrid;
+
+ public PushClient(UsergridHttpClient usergrid)
+ {
+ this.usergrid = usergrid;
+ }
+
+ public async Task<bool> SendNotification(string message)
+ {
+ if (DeviceId == null)
+ {
+ throw new Exception("Please call PushClient.RegisterDevice first.");
+ }
+ var jsonObject = new JObject();
+ var payloads = new JObject();
+ var payload = new JObject();
+ payload.Add("toast", new JValue(message));
+ payloads.Add("winphone", payload);
+ jsonObject.Add("payloads",payloads);
+ jsonObject.Add("debug", true);
+ var response = await usergrid.SendAsync(HttpMethod.Post,String.Format("devices/{0}/notifications",deviceId), jsonObject);
+ var status = response.StatusCode;
+ JObject jsonResponse = await usergrid.GetJsonResponse(response);
+ return (status == HttpStatusCode.OK);
+ }
+
+ public async Task RegisterDevice(string notifier)
+ {
+ this.Notifier = notifier;
+ var channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
+ var settings = ApplicationData.Current.LocalSettings;
+ if (!settings.Values.ContainsKey("currentDeviceId"))
+ {
+ Guid uuid = await registerDevice(notifier, channel.Uri);
+ settings.Values.Add("currentDeviceId", uuid);
+ this.DeviceId = uuid;
+ }
+ else
+ {
+ object tempId;
+ settings.Values.TryGetValue("currentDeviceId", out tempId);
+ this.DeviceId = Guid.Parse(tempId.ToString());
+ if (!await DeviceExists(DeviceId))
+ {
+ Guid uuid = await registerDevice(notifier, channel.Uri);
+ settings.Values["currentDeviceId"] = uuid;
+ this.DeviceId = uuid;
+ }
+
+ }
+
+
+ }
+
+ public async Task AddNotifier(string name, string sid, string apiKey)
+ {
+ JObject obj = new JObject();
+ obj.Add("name", new JValue(name));
+ obj.Add("sid", new JValue(sid));
+ obj.Add("provider", new JValue("windows"));
+ obj.Add("apiKey", new JValue(apiKey));
+ obj.Add("logging", new JValue(true));
+ HttpResponseMessage response = await usergrid.SendAsync(HttpMethod.Post, "notifiers", obj);
+
+ JObject jsonResponse = await usergrid.GetJsonResponse(response);
+ if (jsonResponse != null)
+ {
+ var body = jsonResponse.GetValue("entities").ToString();
+ }
+ }
+
+ public async Task<bool> DeviceExists(Guid deviceId)
+ {
+ HttpResponseMessage response = await usergrid.SendAsync(HttpMethod.Get, "devices/"+deviceId, null);
+ JObject jsonResponse = await usergrid.GetJsonResponse(response);
+ if (jsonResponse != null)
+ {
+ var body = jsonResponse.GetValue("entities");
+ return body!=null && body.Value<JArray>().Count > 0;
+ }
+ else { return false; }
+ }
+
+ private async Task<Guid> registerDevice(string notifier, string uri)
+ {
+ JObject obj = new JObject();
+ obj.Add(notifier + ".notifier.id", new JValue(uri));
+ HttpResponseMessage response = await usergrid.SendAsync(HttpMethod.Post, "devices/", obj);
+
+ JObject jsonResponse = await usergrid.GetJsonResponse(response);
+
+ if (response.StatusCode == HttpStatusCode.OK && jsonResponse != null)
+ {
+ var entity = jsonResponse.GetValue("entities").Value<JArray>()[0];
+ var uuid = Guid.Parse(entity.Value<String>("uuid"));
+ return uuid;
+ }
+ else { return Guid.Empty; }
+ }
+
+ public string Notifier { get; set; }
+ private Guid DeviceId { get; set; }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/122607d1/sdks/dotnet/samples/notifications/Usergrid.Notifications/packages.config
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/packages.config b/sdks/dotnet/samples/notifications/Usergrid.Notifications/packages.config
new file mode 100644
index 0000000..efaa424
--- /dev/null
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/packages.config
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="Newtonsoft.Json" version="6.0.8" targetFramework="wpa81" />
+</packages>
\ No newline at end of file
[07/25] incubator-usergrid git commit: roles/role fix
Posted by to...@apache.org.
roles/role fix
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/6dc62edf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/6dc62edf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/6dc62edf
Branch: refs/heads/USERGRID-273
Commit: 6dc62edfc0a625a070497acfa5ab6b21f53c9093
Parents: e4cb321
Author: Rod Simpson <ro...@apigee.com>
Authored: Wed Jan 21 17:58:33 2015 -0700
Committer: Rod Simpson <ro...@apigee.com>
Committed: Wed Jan 21 17:58:33 2015 -0700
----------------------------------------------------------------------
.../rest/applications/collection/groups/GroupResourceIT.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6dc62edf/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
index ed6876b..50e670e 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
@@ -272,7 +272,7 @@ public class GroupResourceIT extends AbstractRestIT {
this.refreshIndex();
//3. add role to the group
- Entity response = this.app().collection("role").entity(role).connection().collection("groups").entity(group).post();
+ Entity response = this.app().collection("roles").entity(role).connection().collection("groups").entity(group).post();
assertEquals(response.get("name"), groupName);
this.refreshIndex();
[14/25] incubator-usergrid git commit: add valid notification types
Posted by to...@apache.org.
add valid notification types
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/f6752246
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/f6752246
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/f6752246
Branch: refs/heads/USERGRID-273
Commit: f67522465788113e1f81a46a904f379052df9994
Parents: 506fd89
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Jan 23 16:23:24 2015 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Jan 23 16:23:24 2015 -0700
----------------------------------------------------------------------
.../org/apache/usergrid/services/notifications/wns/WNSAdapter.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f6752246/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java
index 6ea3839..9030fdd 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java
@@ -87,7 +87,7 @@ public class WNSAdapter implements ProviderAdapter {
}
service.pushBadge(providerId, badge);
break;
- default : throw new IllegalArgumentException(translatedNotification.getType()+" does not match a valid notification type.");
+ default : throw new IllegalArgumentException(translatedNotification.getType()+" does not match a valid notification type (toast,badge).");
}
}
tracker.completed();
[04/25] incubator-usergrid git commit: Beginnings of a REST test.
Posted by to...@apache.org.
Beginnings of a REST test.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/4384975f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/4384975f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/4384975f
Branch: refs/heads/USERGRID-273
Commit: 4384975fa91d2c7e5ffad06f9adf4a16855d3839
Parents: 7335f94
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Jan 20 16:30:53 2015 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Jan 20 16:30:53 2015 -0500
----------------------------------------------------------------------
.../rest/applications/ApplicationResource.java | 32 +++++++++---
.../applications/ApplicationDeleteTest.java | 54 ++++++++++++++++++++
2 files changed, 80 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4384975f/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java
index 6144940..6a3c94c 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java
@@ -38,6 +38,13 @@ import javax.ws.rs.core.PathSegment;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
+import org.apache.usergrid.persistence.Entity;
+import org.apache.usergrid.persistence.exceptions.EntityNotFoundException;
+import org.apache.usergrid.rest.ApiResponse;
+import org.apache.usergrid.rest.security.annotations.RequireOrganizationAccess;
+import org.apache.usergrid.services.ServiceAction;
+import org.apache.usergrid.services.ServiceResults;
+import org.apache.usergrid.services.assets.data.AssetUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Scope;
@@ -495,15 +502,28 @@ public class ApplicationResource extends ServiceResource {
@DELETE
- @RequireApplicationAccess
+ @RequireOrganizationAccess
@Override
- public JSONWithPadding executeDelete( @Context UriInfo ui,
- @QueryParam("callback") @DefaultValue("callback") String callback )
- throws Exception {
+ public JSONWithPadding executeDelete( @Context UriInfo ui,
+ @QueryParam("callback") @DefaultValue("callback") String callback ) throws Exception {
+
+ if ( applicationId == null ) {
+ throw new IllegalArgumentException("Application ID not specified in request");
+ }
+
+ ApplicationInfo app = management.getApplicationInfo( applicationId );
+ if ( app == null ) {
+ throw new EntityNotFoundException("Application ID " + applicationId + " not found");
+ }
+
+ emf.deleteApplication( applicationId );
- logger.debug( "ApplicationResource.executeDelete" );
+ ApiResponse response = createApiResponse();
+ response.setAction( "delete" );
+ response.setApplication( services.getApplication() );
+ response.setParams( ui.getQueryParameters() );
- throw new NotImplementedException( "Application delete is not allowed yet" );
+ return new JSONWithPadding( response, callback );
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4384975f/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationDeleteTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationDeleteTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationDeleteTest.java
new file mode 100644
index 0000000..e74b324
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationDeleteTest.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.usergrid.rest.applications;
+
+
+import org.apache.usergrid.rest.AbstractRestIT;
+import org.apache.usergrid.rest.TestContextSetup;
+import org.junit.Rule;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class ApplicationDeleteTest extends AbstractRestIT {
+ private static final Logger log = LoggerFactory.getLogger(ApplicationDeleteTest.class);
+
+ @Rule
+ public TestContextSetup context = new TestContextSetup( this );
+
+ @Test
+ public void testBasicOperation() throws Exception {
+
+ // create a user
+
+ // crete an organization
+
+ // create an application
+
+ // create a collection with two entities
+
+ // test that we can query those entities
+
+ // delete the application
+
+ // test that we cannot delete the application a second time
+
+ // test that we can no longer query for those entities
+ }
+}
[10/25] incubator-usergrid git commit: moving files to own dir
Posted by to...@apache.org.
moving files to own dir
refactor for compile issues
adding badges
refactor interfaces
ignore nuget packages
documentation
remove excess methods
add multiple notifications
sanitizing code
change text
update uri
change data type
refactor properties in winphone client
changing names of variables
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/eb025c95
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/eb025c95
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/eb025c95
Branch: refs/heads/USERGRID-273
Commit: eb025c95ed011dd2af69865e9887d40c9461e7fb
Parents: 2d0d68c
Author: Shawn Feldman <sf...@apache.org>
Authored: Thu Jan 22 12:27:26 2015 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Jan 23 15:58:02 2015 -0700
----------------------------------------------------------------------
.gitignore | 1 +
portal/js/push/push-config.html | 6 +-
.../notifications/Usergrid.Notifications.sln | 40 ++++
.../Usergrid.Notifications/App.xaml | 22 +-
.../Usergrid.Notifications/App.xaml.cs | 21 +-
.../Client/EntityResponse.cs | 80 +++++++
.../Client/IUsergridClient.cs | 123 +++++++++++
.../Usergrid.Notifications/Client/PushClient.cs | 153 ++++++++++++++
.../Usergrid.Notifications/Client/Usergrid.cs | 120 +++++++++++
.../Usergrid.Notifications/MainPage.xaml | 32 ++-
.../Usergrid.Notifications/MainPage.xaml.cs | 98 ++++++---
.../Usergrid.Notifications/Package.appxmanifest | 23 +-
.../Usergrid.Notifications.csproj | 5 +-
.../Usergrid.Notifications/Usergrid.cs | 209 -------------------
.../Usergrid.Notifications/packages.config | 21 ++
.../notifications/packages/repositories.config | 4 +
.../impl/ApplicationQueueManagerImpl.java | 8 +-
.../wns/TranslatedNotification.java | 50 +++++
.../services/notifications/wns/WNSAdapter.java | 55 +++--
19 files changed, 805 insertions(+), 266 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/eb025c95/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 05c865c..522f674 100644
--- a/.gitignore
+++ b/.gitignore
@@ -84,3 +84,4 @@ portal/js/templates.js
/stack/core/src/main/java/org/apache/usergrid/persistence/query/tree/QueryFilterParser.java
!/stack/corepersistence/common/src/test/resources/usergrid-UNIT.properties
*.iml
+sdks/dotnet/samples/notifications/packages/*
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/eb025c95/portal/js/push/push-config.html
----------------------------------------------------------------------
diff --git a/portal/js/push/push-config.html b/portal/js/push/push-config.html
index 8dbdf38..8cacab0 100644
--- a/portal/js/push/push-config.html
+++ b/portal/js/push/push-config.html
@@ -165,7 +165,7 @@
<br>
A Notifier allows App Services to connect to and deliver a message to a communication provider such as
Windows Notifications Service (WNS). Copy and paste your API key to create a bridge between your app
- and GCM for push notifications on Android devices..
+ and WNS for push notifications on windows devices..
<br><br>
For more help: see our <a href="#!/getting-started/setup" class="notifications-links">getting started page</a> page.
@@ -189,10 +189,12 @@
</div>
<div class="control-group">
- <strong>API Key </strong>
+ <strong>Secret </strong>
<div >
<input ng-model="notifier.winNotifierAPISecret" id="win-secret-value" required type="text" class="span6" autocomplete="off" ug-validate/>
</div>
+ <br/>
+ Secret will not be returned in other api calls for security reasons.
</div>
<div class="control-group">
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/eb025c95/sdks/dotnet/samples/notifications/Usergrid.Notifications.sln
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications.sln b/sdks/dotnet/samples/notifications/Usergrid.Notifications.sln
new file mode 100644
index 0000000..5474b5b
--- /dev/null
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications.sln
@@ -0,0 +1,40 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2013
+VisualStudioVersion = 12.0.31101.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Usergrid.Notifications", "Usergrid.Notifications\Usergrid.Notifications.csproj", "{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Debug|ARM = Debug|ARM
+ Debug|x86 = Debug|x86
+ Release|Any CPU = Release|Any CPU
+ Release|ARM = Release|ARM
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
+ {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|ARM.ActiveCfg = Debug|ARM
+ {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|ARM.Build.0 = Debug|ARM
+ {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|ARM.Deploy.0 = Debug|ARM
+ {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|x86.ActiveCfg = Debug|x86
+ {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|x86.Build.0 = Debug|x86
+ {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|x86.Deploy.0 = Debug|x86
+ {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|Any CPU.Build.0 = Release|Any CPU
+ {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|Any CPU.Deploy.0 = Release|Any CPU
+ {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|ARM.ActiveCfg = Release|ARM
+ {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|ARM.Build.0 = Release|ARM
+ {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|ARM.Deploy.0 = Release|ARM
+ {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|x86.ActiveCfg = Release|x86
+ {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|x86.Build.0 = Release|x86
+ {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|x86.Deploy.0 = Release|x86
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/eb025c95/sdks/dotnet/samples/notifications/Usergrid.Notifications/App.xaml
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/App.xaml b/sdks/dotnet/samples/notifications/Usergrid.Notifications/App.xaml
index 8a36359..486a2fd 100644
--- a/sdks/dotnet/samples/notifications/Usergrid.Notifications/App.xaml
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/App.xaml
@@ -3,5 +3,25 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Usergrid.Notifications">
-
+<!--
+ /*
+ *
+ * * Licensed to the Apache Software Foundation (ASF) under one or more
+ * * contributor license agreements. The ASF licenses this file to You
+ * * under the Apache License, Version 2.0 (the "License"); you may not
+ * * use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License. For additional information regarding
+ * * copyright in this work, please see the NOTICE file in the top level
+ * * directory of this distribution.
+ *
+ */
+ -->
</Application>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/eb025c95/sdks/dotnet/samples/notifications/Usergrid.Notifications/App.xaml.cs
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/App.xaml.cs b/sdks/dotnet/samples/notifications/Usergrid.Notifications/App.xaml.cs
index 9bf62ac..eb079fb 100644
--- a/sdks/dotnet/samples/notifications/Usergrid.Notifications/App.xaml.cs
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/App.xaml.cs
@@ -1,4 +1,23 @@
-using System;
+/*
+ *
+ * * Licensed to the Apache Software Foundation (ASF) under one or more
+ * * contributor license agreements. The ASF licenses this file to You
+ * * under the Apache License, Version 2.0 (the "License"); you may not
+ * * use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License. For additional information regarding
+ * * copyright in this work, please see the NOTICE file in the top level
+ * * directory of this distribution.
+ *
+ */
+using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/eb025c95/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/EntityResponse.cs
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/EntityResponse.cs b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/EntityResponse.cs
new file mode 100644
index 0000000..0be267a
--- /dev/null
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/EntityResponse.cs
@@ -0,0 +1,80 @@
+/*
+ *
+ * * Licensed to the Apache Software Foundation (ASF) under one or more
+ * * contributor license agreements. The ASF licenses this file to You
+ * * under the Apache License, Version 2.0 (the "License"); you may not
+ * * use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License. For additional information regarding
+ * * copyright in this work, please see the NOTICE file in the top level
+ * * directory of this distribution.
+ *
+ */
+
+using Newtonsoft.Json.Linq;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Usergrid.Notifications.Client
+{
+ public class EntityResponse : JObject
+ {
+ private HttpResponseMessage response;
+
+ private EntityResponse(HttpResponseMessage response, JObject jObject)
+ : base()
+ {
+ this.response = response;
+ parseResponse(jObject);
+ }
+
+ private void parseResponse(JObject jobject)
+ {
+ foreach (var kv in jobject)
+ {
+ this[kv.Key] = kv.Value;
+ }
+ }
+
+ public HttpStatusCode Status
+ {
+ get { return this.response.StatusCode; }
+ }
+
+ public static async Task<EntityResponse> Parse(HttpResponseMessage httpResponseMessage)
+ {
+ JObject jobject;
+
+ using (var stream = await httpResponseMessage.Content.ReadAsStreamAsync())
+ {
+ using (var reader = new StreamReader(stream, Encoding.UTF8))
+ {
+ jobject = JObject.Parse(reader.ReadToEnd());
+ }
+ }
+
+ return new EntityResponse(httpResponseMessage, jobject);
+ }
+
+ public bool StatusIsOk
+ {
+ get
+ {
+ return this.Status == HttpStatusCode.OK;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/eb025c95/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/IUsergridClient.cs
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/IUsergridClient.cs b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/IUsergridClient.cs
new file mode 100644
index 0000000..3f4fb82
--- /dev/null
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/IUsergridClient.cs
@@ -0,0 +1,123 @@
+/*
+ *
+ * * Licensed to the Apache Software Foundation (ASF) under one or more
+ * * contributor license agreements. The ASF licenses this file to You
+ * * under the Apache License, Version 2.0 (the "License"); you may not
+ * * use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License. For additional information regarding
+ * * copyright in this work, please see the NOTICE file in the top level
+ * * directory of this distribution.
+ *
+ */
+
+using Newtonsoft.Json.Linq;
+using System;
+using System.Net.Http;
+using System.Threading.Tasks;
+using Windows.Networking.PushNotifications;
+namespace Usergrid.Notifications.Client
+{
+ /// <summary>
+ /// encapsulates usergrid calls, use UsergridFactory
+ /// </summary>
+ public interface IUsergridClient
+ {
+ /// <summary>
+ /// Authenticate your calls
+ /// </summary>
+ /// <param name="user"></param>
+ /// <param name="password"></param>
+ /// <param name="isManagement"></param>
+ /// <returns></returns>
+ Task Authenticate(string user, string password, bool isManagement);
+ /// <summary>
+ /// Send a message
+ /// </summary>
+ /// <param name="method"></param>
+ /// <param name="url"></param>
+ /// <param name="obj"></param>
+ /// <returns></returns>
+ Task<EntityResponse> SendAsync(HttpMethod method, string url, object obj);
+ /// <summary>
+ /// Send a message
+ /// </summary>
+ /// <param name="method"></param>
+ /// <param name="url"></param>
+ /// <param name="obj"></param>
+ /// <param name="useManagementUrl"></param>
+ /// <returns></returns>
+ Task<EntityResponse> SendAsync(HttpMethod method, string url, object obj, bool useManagementUrl);
+ /// <summary>
+ /// Reference the push client, you should call register before using
+ /// </summary>
+ IPushClient Push { get; }
+
+ Exception LastException { get; }
+
+ }
+
+ /// <summary>
+ /// Only show http calls
+ /// </summary>
+ public interface IUsergridHttpClient
+ {
+ /// <summary>
+ /// Send Http call async
+ /// </summary>
+ /// <param name="method"></param>
+ /// <param name="url"></param>
+ /// <param name="obj"></param>
+ /// <param name="useManagementUrl">use management endpoint</param>
+ /// <returns></returns>
+ Task<EntityResponse> SendAsync(HttpMethod method, string url, object obj, bool useManagementUrl);
+ /// <summary>
+ /// send Http call async
+ /// </summary>
+ /// <param name="method"></param>
+ /// <param name="url"></param>
+ /// <param name="obj"></param>
+ /// <returns></returns>
+ Task<EntityResponse> SendAsync(HttpMethod method, string url, object obj);
+ }
+
+ /// <summary>
+ /// Push client, call register
+ /// </summary>
+ public interface IPushClient
+ {
+ /// <summary>
+ /// the notifier you are currently using
+ /// </summary>
+ string Notifier { get; set; }
+
+ /// <summary>
+ /// Device id in usergrid
+ /// </summary>
+ Guid DeviceId { get; set; }
+ /// <summary>
+ /// send a toast
+ /// </summary>
+ /// <param name="message"></param>
+ /// <returns></returns>
+ Task<bool> SendToast(string message);
+
+ /// <summary>
+ /// Send a badge update
+ /// </summary>
+ /// <param name="message"></param>
+ /// <returns></returns>
+ Task<bool> SendBadge<T>(T message);
+
+ Exception LastException { get; }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/eb025c95/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/PushClient.cs
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/PushClient.cs b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/PushClient.cs
new file mode 100644
index 0000000..8668626
--- /dev/null
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/PushClient.cs
@@ -0,0 +1,153 @@
+/*
+ *
+ * * Licensed to the Apache Software Foundation (ASF) under one or more
+ * * contributor license agreements. The ASF licenses this file to You
+ * * under the Apache License, Version 2.0 (the "License"); you may not
+ * * use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License. For additional information regarding
+ * * copyright in this work, please see the NOTICE file in the top level
+ * * directory of this distribution.
+ *
+ */
+using Newtonsoft.Json.Linq;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.Http;
+using System.Text;
+using System.Threading.Tasks;
+using Windows.Networking.PushNotifications;
+using Windows.Storage;
+
+namespace Usergrid.Notifications.Client
+{
+ public class PushClient : IPushClient
+ {
+ const string DEVICE_KEY = "currentDeviceId";
+ private IUsergridHttpClient usergrid;
+ private ApplicationDataContainer settings;
+ private PushNotificationChannel channel;
+
+ public PushClient(IUsergridHttpClient usergrid, string notifier)
+ {
+ this.usergrid = usergrid;
+ this.settings = ApplicationData.Current.LocalSettings;
+ this.Notifier = notifier;
+ this.init().ContinueWith(t =>
+ {
+ LastException = t.Exception;
+ }
+ );
+ }
+
+
+ public async Task<bool> SendToast(string message)
+ {
+ if (DeviceId == null)
+ {
+ throw new Exception("Please call PushClient.RegisterDevice first.");
+ }
+ var jsonObject = new JObject();
+ var payloads = new JObject();
+ var payload = new JObject();
+ payload.Add("toast", new JValue(message));
+ payloads.Add(Notifier, payload);
+ jsonObject.Add("payloads", payloads);
+ jsonObject.Add("debug", true);
+ var jsonResponse = await usergrid.SendAsync(HttpMethod.Post, String.Format("devices/{0}/notifications", this.DeviceId), jsonObject);
+ return jsonResponse.StatusIsOk;
+ }
+
+ public async Task<bool> SendBadge<T>(T message)
+ {
+ if (DeviceId == null)
+ {
+ throw new Exception("Please call PushClient.RegisterDevice first.");
+ }
+ var jsonObject = new JObject();
+ var payloads = new JObject();
+ var payload = new JObject();
+ payload.Add("badge", new JValue(message));
+ payloads.Add(Notifier, payload);
+ jsonObject.Add("payloads", payloads);
+ jsonObject.Add("debug", true);
+ var jsonResponse = await usergrid.SendAsync(HttpMethod.Post, String.Format("devices/{0}/notifications", this.DeviceId), jsonObject);
+ return jsonResponse.StatusIsOk;
+ }
+
+ private async Task init()
+ {
+ channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync().AsTask<PushNotificationChannel>();
+ if (settings.Values[DEVICE_KEY] == null)
+ {
+ Guid uuid = await registerDevice(true);
+ settings.Values.Add(DEVICE_KEY, uuid);
+ this.DeviceId = uuid;
+ }
+ else
+ {
+ object tempId;
+ settings.Values.TryGetValue(DEVICE_KEY, out tempId);
+ this.DeviceId = Guid.Parse(tempId.ToString());
+ var device = await GetDevice(DeviceId);
+ if (device == null)
+ {
+ Guid uuid = await registerDevice(true);
+ settings.Values[DEVICE_KEY] = uuid;
+ this.DeviceId = uuid;
+ }
+ else
+ {
+ await registerDevice(false);
+ }
+ }
+ }
+
+
+ private async Task<JToken> GetDevice(Guid deviceId)
+ {
+ var jsonResponse = await usergrid.SendAsync(HttpMethod.Get, "devices/" + deviceId, null);
+
+ if (jsonResponse.StatusIsOk)
+ {
+ var body = jsonResponse.GetValue("entities");
+ return body != null && body.Value<JArray>().Count > 0 ? body.Value<JArray>()[0] : null;
+ }
+ else { return null; }
+ }
+
+ private async Task<Guid> registerDevice(bool isNew)
+ {
+ JObject obj = new JObject();
+ obj.Add(Notifier + ".notifier.id", new JValue(channel.Uri));
+ var jsonResponse = await usergrid.SendAsync(
+ (isNew ? HttpMethod.Post : HttpMethod.Put),
+ "devices/" + (isNew ? "" : this.DeviceId.ToString()),
+ obj
+ );
+
+ if (jsonResponse.StatusIsOk)
+ {
+ var entity = jsonResponse.GetValue("entities").Value<JArray>()[0];
+ var uuid = Guid.Parse(entity.Value<String>("uuid"));
+ return uuid;
+ }
+ else {
+ return Guid.Empty;
+ }
+ }
+
+ public string Notifier { get; set; }
+ public Guid DeviceId { get; set; }
+ public Exception LastException { get; set; }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/eb025c95/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/Usergrid.cs
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/Usergrid.cs b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/Usergrid.cs
new file mode 100644
index 0000000..cd0330d
--- /dev/null
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/Usergrid.cs
@@ -0,0 +1,120 @@
+/*
+ *
+ * * Licensed to the Apache Software Foundation (ASF) under one or more
+ * * contributor license agreements. The ASF licenses this file to You
+ * * under the Apache License, Version 2.0 (the "License"); you may not
+ * * use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License. For additional information regarding
+ * * copyright in this work, please see the NOTICE file in the top level
+ * * directory of this distribution.
+ *
+ */
+
+using System;
+using System.Threading.Tasks;
+using System.Net;
+using Newtonsoft.Json.Linq;
+using Newtonsoft.Json;
+using System.Net.Http;
+using System.Net.Http.Headers;
+
+namespace Usergrid.Notifications.Client
+{
+
+ /// <summary>
+ /// Usergrid client
+ /// </summary>
+
+ public class Usergrid : IUsergridHttpClient, IUsergridClient
+ {
+ private string appUrl;
+ private string token;
+ private HttpClient client;
+ private IPushClient push;
+ private string managementUrl;
+
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <param name="serverUrl"></param>
+ /// <param name="org"></param>
+ /// <param name="app"></param>
+ /// <param name="channel"></param>
+ internal Usergrid(string serverUrl, string org, string app, string notifier)
+ {
+ string serverUrlWithSlash = serverUrl.EndsWith("/", StringComparison.CurrentCulture) ? serverUrl : serverUrl + "/";
+ this.appUrl = String.Format("{0}{1}/{2}/", serverUrlWithSlash, org, app);
+ this.managementUrl = serverUrlWithSlash + "management/";
+ this.client = new HttpClient();
+ this.push = new PushClient(this,notifier);
+ }
+
+ public async Task Authenticate(string user, string password, bool isManagement)
+ {
+ var jsonObject = new JObject();
+ jsonObject.Add("username", user);
+ jsonObject.Add("password", password);
+ jsonObject.Add("grant_type", "password");
+
+ var response = await SendAsync(HttpMethod.Post,"token", jsonObject, isManagement);
+
+ if (response.StatusIsOk)
+ {
+ this.token = response.GetValue("access_token").Value<String>();
+ client.DefaultRequestHeaders.Add("X-Authorization", token);
+ }
+ else
+ {
+ throw new Exception("Authentication failed: "+response.ToString());
+ }
+ }
+
+ private async Task<EntityResponse> GetJsonResponse(HttpResponseMessage response)
+ {
+ return await EntityResponse.Parse(response);
+ }
+
+ public async Task<EntityResponse> SendAsync(HttpMethod method, string url, object obj)
+ {
+ return await SendAsync(method, url, obj, false);
+ }
+
+ public async Task<EntityResponse> SendAsync(HttpMethod method, string url, object obj, bool useManagementUrl)
+ {
+ HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Post, (useManagementUrl ? this.managementUrl : this.appUrl) + url);
+ if (obj != null)
+ {
+ message.Content = getJsonBody(obj);
+ }
+ message.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue( "application/json"));
+ var response = await this.client.SendAsync(message);
+ return await EntityResponse.Parse(response);
+ }
+
+ public IPushClient Push
+ {
+ get { return push; }
+ }
+
+ private HttpContent getJsonBody(Object jsonObject)
+ {
+ return new StringContent(JsonConvert.SerializeObject(jsonObject));
+ }
+
+
+ public Exception LastException
+ {
+ get;
+ set;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/eb025c95/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml b/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml
index 3e0affd..f22c8b6 100644
--- a/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml
@@ -7,14 +7,32 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
-
+ <!--
+ /*
+ *
+ * * Licensed to the Apache Software Foundation (ASF) under one or more
+ * * contributor license agreements. The ASF licenses this file to You
+ * * under the Apache License, Version 2.0 (the "License"); you may not
+ * * use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License. For additional information regarding
+ * * copyright in this work, please see the NOTICE file in the top level
+ * * directory of this distribution.
+ *
+ */
+ -->
<Grid>
- <TextBox x:Name="pushText" HorizontalAlignment="Left" Margin="75,46,0,0" TextWrapping="Wrap" Text="Push Text" VerticalAlignment="Top" Width="261" TextChanged="pushText_TextChanged"/>
- <Button Content="Send" HorizontalAlignment="Left" Margin="146,121,0,0" VerticalAlignment="Top" Click="Button_Click"/>
- <TextBox x:Name="NotifierName" HorizontalAlignment="Left" Margin="75,210,0,0" TextWrapping="Wrap" Text="Notifier Name" VerticalAlignment="Top" Width="261"/>
- <TextBox x:Name="Api_Key" HorizontalAlignment="Left" Margin="75,276,0,0" TextWrapping="Wrap" Text="Sid" VerticalAlignment="Top" Width="261"/>
- <TextBox x:Name="Sid" HorizontalAlignment="Left" Margin="75,348,0,0" TextWrapping="Wrap" Text="Api Key" VerticalAlignment="Top" Width="261"/>
- <Button x:Name="AddNotifierButton" Content="Add Notifier" HorizontalAlignment="Left" Margin="146,405,0,0" VerticalAlignment="Top" Click="AddNotifierButton_Click"/>
+ <TextBox x:Name="pushText" HorizontalAlignment="Left" Margin="46,10,0,0" TextWrapping="Wrap" Text="Push Text" VerticalAlignment="Top" Width="261" TextChanged="pushText_TextChanged"/>
+ <Button x:Name="SendToast" Content="Toast" HorizontalAlignment="Left" Margin="114,88,0,0" VerticalAlignment="Top" Click="Button_Click" Width="39"/>
+ <Button x:Name="Badge" Content="Badge" HorizontalAlignment="Left" Margin="114,157,0,0" VerticalAlignment="Top" Click="Badge_Click"/>
+ <TextBlock x:Name="Result" HorizontalAlignment="Left" Margin="46,295,0,0" TextWrapping="Wrap" Text="Did it work? " VerticalAlignment="Top" Height="49" Width="261" FontSize="25" SelectionChanged="Result_SelectionChanged"/>
</Grid>
</Page>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/eb025c95/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml.cs
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml.cs b/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml.cs
index 882838d..7e03c79 100644
--- a/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml.cs
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml.cs
@@ -1,18 +1,27 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Runtime.InteropServices.WindowsRuntime;
-using Windows.Foundation;
-using Windows.Foundation.Collections;
-using Windows.Networking.PushNotifications;
-using Windows.Storage;
+/*
+ *
+ * * Licensed to the Apache Software Foundation (ASF) under one or more
+ * * contributor license agreements. The ASF licenses this file to You
+ * * under the Apache License, Version 2.0 (the "License"); you may not
+ * * use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License. For additional information regarding
+ * * copyright in this work, please see the NOTICE file in the top level
+ * * directory of this distribution.
+ *
+ */
+using System;
+using System.Threading.Tasks;
+using Usergrid.Notifications.Client;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
-using Windows.UI.Xaml.Controls.Primitives;
-using Windows.UI.Xaml.Data;
-using Windows.UI.Xaml.Input;
-using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=391641
@@ -24,33 +33,38 @@ namespace Usergrid.Notifications
/// </summary>
public sealed partial class MainPage : Page
{
- private Usergrid usergrid;
+ private IUsergridClient usergrid;
private string serverUrl;
private string org;
private string app;
private string notifier;
- private string apiKey;
- private string secret;
- private Guid deviceId;
+ private string user;
+ private string password;
public MainPage()
{
this.InitializeComponent();
- var myIp = "10.0.1.20";
- serverUrl = "http://" + myIp + ":8080";
+ //TODO: change me to your server
+ serverUrl = "http://10.0.1.20:8080";
+ //TODO: change me to your org
org = "mobile";
+ //TODO: change me to your app
app = "sandbox";
+ //TODO: change me to your notifier name
notifier = "winphone";
+ //TODO: change me to your user
+ user = "superuser";
+ //TODO: change me to your password
+ password = "test";
this.NavigationCacheMode = NavigationCacheMode.Required;
- this.setup();
+ this.setup().ContinueWith(t => {
+ LastException = t.Exception;
+ });
}
- private async void setup()
+ private async Task setup()
{
- usergrid = new Usergrid(serverUrl, org, app);
- await this.usergrid.Authenticate("superuser", "test", true);
- await usergrid.Push.RegisterDevice(notifier);
-
-
+ usergrid = new Client.Usergrid(serverUrl, org, app, notifier);
+ await usergrid.Authenticate(user, password, true);
}
/// <summary>
@@ -68,22 +82,46 @@ namespace Usergrid.Notifications
// If you are using the NavigationHelper provided by some templates,
// this event is handled for you.
}
+
+ private void pushText_TextChanged(object sender, TextChangedEventArgs e)
+ {
+
+ }
private async void Button_Click(object sender, RoutedEventArgs e)
{
+ Result.Text = "Sending....";
var message = this.pushText.Text;
- await usergrid.Push.SendNotification(deviceId,message);
+ if (await usergrid.Push.SendToast(message))
+ {
+ Result.Text = "It did! :)";
+ }
+ else
+ {
+ Result.Text = "It did not! :(";
+ }
}
- private void pushText_TextChanged(object sender, TextChangedEventArgs e)
+ private async void Badge_Click(object sender, RoutedEventArgs e)
{
+ Result.Text = "Sending....";
+ if (await usergrid.Push.SendBadge<int>(new Random().Next(1,100)))
+ {
+ Result.Text = "It did! :)";
+ }
+ else
+ {
+ Result.Text = "It did not! :(";
+ }
}
- private async void AddNotifierButton_Click(object sender, RoutedEventArgs e)
+ private void Result_SelectionChanged(object sender, RoutedEventArgs e)
{
- await usergrid.Push.AddNotifier(NotifierName.Text,Sid.Text,Api_Key.Text);
+
}
+
+ public AggregateException LastException { get; set; }
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/eb025c95/sdks/dotnet/samples/notifications/Usergrid.Notifications/Package.appxmanifest
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Package.appxmanifest b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Package.appxmanifest
index a47ef82..03165e6 100644
--- a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Package.appxmanifest
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Package.appxmanifest
@@ -1,6 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest" xmlns:m3="http://schemas.microsoft.com/appx/2014/manifest" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest">
- <Identity Name="15661feldrocker.usergridsample" Publisher="CN=AC3A1EB7-E4EA-48C0-9556-C37AA8BAE0CF" Version="1.1.0.0" />
+ <!--
+ /*
+ *
+ * * Licensed to the Apache Software Foundation (ASF) under one or more
+ * * contributor license agreements. The ASF licenses this file to You
+ * * under the Apache License, Version 2.0 (the "License"); you may not
+ * * use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License. For additional information regarding
+ * * copyright in this work, please see the NOTICE file in the top level
+ * * directory of this distribution.
+ *
+ */
+ -->
+ <Identity Name="15661feldrocker.usergridsample" Publisher="CN=AC3A1EB7-E4EA-48C0-9556-C37AA8BAE0CF" Version="1.1.0.1" />
<mp:PhoneIdentity PhoneProductId="c05b658a-0b41-4187-a6e4-ca186c2338de" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>usergrid sample</DisplayName>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/eb025c95/sdks/dotnet/samples/notifications/Usergrid.Notifications/Usergrid.Notifications.csproj
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Usergrid.Notifications.csproj b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Usergrid.Notifications.csproj
index c811c83..f5ec3fa 100644
--- a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Usergrid.Notifications.csproj
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Usergrid.Notifications.csproj
@@ -84,11 +84,14 @@
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
+ <Compile Include="Client\EntityResponse.cs" />
+ <Compile Include="Client\IUsergridClient.cs" />
+ <Compile Include="Client\PushClient.cs" />
<Compile Include="MainPage.xaml.cs">
<DependentUpon>MainPage.xaml</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="Usergrid.cs" />
+ <Compile Include="Client\Usergrid.cs" />
</ItemGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/eb025c95/sdks/dotnet/samples/notifications/Usergrid.Notifications/Usergrid.cs
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Usergrid.cs b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Usergrid.cs
deleted file mode 100644
index cc715f8..0000000
--- a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Usergrid.cs
+++ /dev/null
@@ -1,209 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-using System.Net;
-using System.IO;
-using System.Runtime.Serialization;
-using System.Runtime.Serialization.Json;
-using System.Text;
-using Newtonsoft.Json.Linq;
-using Newtonsoft.Json;
-using System.Net.Http;
-using System.Net.Http.Headers;
-using Windows.Storage;
-using Windows.Networking.PushNotifications;
-
-namespace Usergrid.Notifications
-{
- public class Usergrid : UsergridHttpClient
- {
- private string url;
- private string token;
- private HttpClient client;
- private PushClient push;
- private string managementUrl;
-
- public Usergrid(string url, string org, string app)
- {
- string urlWithSlash = url.EndsWith("/",StringComparison.CurrentCulture) ? url : url+"/";
- this.url = String.Format("{0}{1}/{2}/", urlWithSlash, org, app);
- this.managementUrl = urlWithSlash + "management/";
- this.client = new HttpClient();
- push = new PushClient(this);
- }
-
- public async Task Authenticate(string user, string password, bool isManagement)
- {
- var url = "token";
- var jsonObject = new JObject();
- jsonObject.Add("username", user);
- jsonObject.Add("password", password);
- jsonObject.Add("grant_type", "password");
- HttpResponseMessage response = await SendAsync(HttpMethod.Post,url, jsonObject, isManagement);
-
- if (response.StatusCode == HttpStatusCode.OK)
- {
- JObject jsonResponse = await GetJsonResponse(response);
- this.token = jsonResponse.GetValue("access_token").Value<String>();
- client.DefaultRequestHeaders.Add("X-Authorization", token);
- }
- else
- {
- throw new Exception("Authentication failed");
- }
- }
-
- public async Task<JObject> GetJsonResponse(HttpResponseMessage response)
- {
- JObject jsonResponse = null;
- using (var stream = await response.Content.ReadAsStreamAsync())
- {
- using (var reader = new StreamReader(stream, Encoding.UTF8))
- {
- jsonResponse = JObject.Parse(reader.ReadToEnd());
- }
- }
- return jsonResponse;
- }
-
- private HttpContent getJsonBody(Object jsonObject)
- {
- var content = new StringContent(JsonConvert.SerializeObject(jsonObject));
- return content;
- }
- public Task<HttpResponseMessage> SendAsync(HttpMethod method, string url, object obj)
- {
- return SendAsync(method, url, obj, false);
- }
- public Task<HttpResponseMessage> SendAsync(HttpMethod method, string url, object obj, bool useManagementUrl)
- {
- HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Post, (useManagementUrl ? this.managementUrl : this.url) + url);
- if(obj!=null)
- message.Content = getJsonBody(obj);
- message.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue( "application/json"));
- return this.client.SendAsync(message);
-
- }
-
- public PushClient Push
- {
- get { return push; }
- }
-
-
- }
-
- public interface UsergridHttpClient
- {
- Task<HttpResponseMessage>SendAsync(HttpMethod method,string url, object obj);
- Task<JObject> GetJsonResponse(HttpResponseMessage response);
-
- }
- public class PushClient
- {
- private UsergridHttpClient usergrid;
-
- public PushClient(UsergridHttpClient usergrid)
- {
- this.usergrid = usergrid;
- }
-
- public async Task<bool> SendNotification(string message)
- {
- if (DeviceId == null)
- {
- throw new Exception("Please call PushClient.RegisterDevice first.");
- }
- var jsonObject = new JObject();
- var payloads = new JObject();
- var payload = new JObject();
- payload.Add("toast", new JValue(message));
- payloads.Add("winphone", payload);
- jsonObject.Add("payloads",payloads);
- jsonObject.Add("debug", true);
- var response = await usergrid.SendAsync(HttpMethod.Post,String.Format("devices/{0}/notifications",deviceId), jsonObject);
- var status = response.StatusCode;
- JObject jsonResponse = await usergrid.GetJsonResponse(response);
- return (status == HttpStatusCode.OK);
- }
-
- public async Task RegisterDevice(string notifier)
- {
- this.Notifier = notifier;
- var channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
- var settings = ApplicationData.Current.LocalSettings;
- if (!settings.Values.ContainsKey("currentDeviceId"))
- {
- Guid uuid = await registerDevice(notifier, channel.Uri);
- settings.Values.Add("currentDeviceId", uuid);
- this.DeviceId = uuid;
- }
- else
- {
- object tempId;
- settings.Values.TryGetValue("currentDeviceId", out tempId);
- this.DeviceId = Guid.Parse(tempId.ToString());
- if (!await DeviceExists(DeviceId))
- {
- Guid uuid = await registerDevice(notifier, channel.Uri);
- settings.Values["currentDeviceId"] = uuid;
- this.DeviceId = uuid;
- }
-
- }
-
-
- }
-
- public async Task AddNotifier(string name, string sid, string apiKey)
- {
- JObject obj = new JObject();
- obj.Add("name", new JValue(name));
- obj.Add("sid", new JValue(sid));
- obj.Add("provider", new JValue("windows"));
- obj.Add("apiKey", new JValue(apiKey));
- obj.Add("logging", new JValue(true));
- HttpResponseMessage response = await usergrid.SendAsync(HttpMethod.Post, "notifiers", obj);
-
- JObject jsonResponse = await usergrid.GetJsonResponse(response);
- if (jsonResponse != null)
- {
- var body = jsonResponse.GetValue("entities").ToString();
- }
- }
-
- public async Task<bool> DeviceExists(Guid deviceId)
- {
- HttpResponseMessage response = await usergrid.SendAsync(HttpMethod.Get, "devices/"+deviceId, null);
- JObject jsonResponse = await usergrid.GetJsonResponse(response);
- if (jsonResponse != null)
- {
- var body = jsonResponse.GetValue("entities");
- return body!=null && body.Value<JArray>().Count > 0;
- }
- else { return false; }
- }
-
- private async Task<Guid> registerDevice(string notifier, string uri)
- {
- JObject obj = new JObject();
- obj.Add(notifier + ".notifier.id", new JValue(uri));
- HttpResponseMessage response = await usergrid.SendAsync(HttpMethod.Post, "devices/", obj);
-
- JObject jsonResponse = await usergrid.GetJsonResponse(response);
-
- if (response.StatusCode == HttpStatusCode.OK && jsonResponse != null)
- {
- var entity = jsonResponse.GetValue("entities").Value<JArray>()[0];
- var uuid = Guid.Parse(entity.Value<String>("uuid"));
- return uuid;
- }
- else { return Guid.Empty; }
- }
-
- public string Notifier { get; set; }
- private Guid DeviceId { get; set; }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/eb025c95/sdks/dotnet/samples/notifications/Usergrid.Notifications/packages.config
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/packages.config b/sdks/dotnet/samples/notifications/Usergrid.Notifications/packages.config
index efaa424..2a3ff3c 100644
--- a/sdks/dotnet/samples/notifications/Usergrid.Notifications/packages.config
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/packages.config
@@ -1,4 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
+ <!--
+ /*
+ *
+ * * Licensed to the Apache Software Foundation (ASF) under one or more
+ * * contributor license agreements. The ASF licenses this file to You
+ * * under the Apache License, Version 2.0 (the "License"); you may not
+ * * use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License. For additional information regarding
+ * * copyright in this work, please see the NOTICE file in the top level
+ * * directory of this distribution.
+ *
+ */
+ -->
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="wpa81" />
</packages>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/eb025c95/sdks/dotnet/samples/notifications/packages/repositories.config
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/packages/repositories.config b/sdks/dotnet/samples/notifications/packages/repositories.config
new file mode 100644
index 0000000..deb9991
--- /dev/null
+++ b/sdks/dotnet/samples/notifications/packages/repositories.config
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<repositories>
+ <repository path="..\Usergrid.Notifications\packages.config" />
+</repositories>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/eb025c95/stack/services/src/main/java/org/apache/usergrid/services/notifications/impl/ApplicationQueueManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/impl/ApplicationQueueManagerImpl.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/impl/ApplicationQueueManagerImpl.java
index c8c5165..8cc3450 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/impl/ApplicationQueueManagerImpl.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/impl/ApplicationQueueManagerImpl.java
@@ -396,15 +396,19 @@ public class ApplicationQueueManagerImpl implements ApplicationQueueManager {
/**
- * Call the adapter with the notifier
+ * Validates that a notifier and adapter exists to send notifications to;
+ * {"winphone":"mymessage","apple":"mymessage"}
+ * TODO: document this method better
*/
private Map<String, Object> translatePayloads(Map<String, Object> payloads, Map<Object, ProviderAdapter> notifierMap) throws Exception {
Map<String, Object> translatedPayloads = new HashMap<String, Object>( payloads.size());
for (Map.Entry<String, Object> entry : payloads.entrySet()) {
String payloadKey = entry.getKey().toLowerCase();
Object payloadValue = entry.getValue();
+ //look for adapter from payload map
ProviderAdapter providerAdapter = notifierMap.get(payloadKey);
if (providerAdapter != null) {
+ //translate payload to usable information
Object translatedPayload = payloadValue != null ? providerAdapter.translatePayload(payloadValue) : null;
if (translatedPayload != null) {
translatedPayloads.put(payloadKey, translatedPayload);
@@ -520,4 +524,4 @@ public class ApplicationQueueManagerImpl implements ApplicationQueueManager {
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/eb025c95/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/TranslatedNotification.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/TranslatedNotification.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/TranslatedNotification.java
new file mode 100644
index 0000000..9e702b7
--- /dev/null
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/TranslatedNotification.java
@@ -0,0 +1,50 @@
+/*
+ *
+ * * Licensed to the Apache Software Foundation (ASF) under one or more
+ * * contributor license agreements. The ASF licenses this file to You
+ * * under the Apache License, Version 2.0 (the "License"); you may not
+ * * use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License. For additional information regarding
+ * * copyright in this work, please see the NOTICE file in the top level
+ * * directory of this distribution.
+ *
+ */
+
+package org.apache.usergrid.services.notifications.wns;
+
+import org.apache.usergrid.persistence.model.entity.Entity;
+
+import java.io.Serializable;
+import java.util.HashMap;
+
+/**
+ * Classy class class.
+ */
+public class TranslatedNotification extends HashMap implements Serializable {
+
+ public TranslatedNotification() {
+ super();
+ }
+
+ public TranslatedNotification(Object message, String type) {
+ super();
+ this.put("message",message);
+ this.put("type" , type);
+ }
+
+ public Object getMessage() {
+ return get("message");
+ }
+
+ public String getType() {
+ return get("type").toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/eb025c95/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java
index b331e86..0ba2db3 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java
@@ -21,9 +21,11 @@
package org.apache.usergrid.services.notifications.wns;
import ar.com.fernandospr.wns.WnsService;
-import ar.com.fernandospr.wns.exceptions.WnsException;
+import ar.com.fernandospr.wns.model.WnsBadge;
import ar.com.fernandospr.wns.model.WnsToast;
+import ar.com.fernandospr.wns.model.builders.WnsBadgeBuilder;
import ar.com.fernandospr.wns.model.builders.WnsToastBuilder;
+import com.sun.jersey.api.client.ClientHandlerException;
import org.apache.usergrid.persistence.EntityManager;
import org.apache.usergrid.persistence.entities.Notification;
import org.apache.usergrid.persistence.entities.Notifier;
@@ -31,11 +33,11 @@ import org.apache.usergrid.services.ServicePayload;
import org.apache.usergrid.services.notifications.ConnectionException;
import org.apache.usergrid.services.notifications.ProviderAdapter;
import org.apache.usergrid.services.notifications.TaskTracker;
-import org.mortbay.util.ajax.JSON;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.HashMap;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
/**
@@ -59,17 +61,34 @@ public class WNSAdapter implements ProviderAdapter {
public void testConnection() throws ConnectionException {
WnsToast toast = new WnsToastBuilder().bindingTemplateToastText01("test").build();
try{
- service.pushToast("ms-app://s-1-15-2-2411381248-444863693-3819932088-4077691928-1194867744-112853457-373132695",toast);
- }catch (Exception e){
- LOG.error(e.toString());
+ //this fails every time due to jax error which is ok
+ service.pushToast("s-1-15-2-2411381248-444863693-3819932088-4077691928-1194867744-112853457-373132695",toast);
+ }catch (ClientHandlerException e){
+ LOG.info("Windows Phone notifier added: "+e.toString());
}
}
@Override
public void sendNotification(String providerId, Object payload, Notification notification, TaskTracker tracker) throws Exception {
try {
- WnsToast toast = new WnsToastBuilder().bindingTemplateToastText01(payload.toString()).build();
- service.pushToast(providerId, toast);
+ List<TranslatedNotification> translatedNotifications = ( List<TranslatedNotification>) payload;
+ for(TranslatedNotification translatedNotification : translatedNotifications) {
+ switch (translatedNotification.getType()) {
+ case "toast":
+ WnsToast toast = new WnsToastBuilder().bindingTemplateToastText01(translatedNotification.getMessage().toString()).build();
+ service.pushToast(providerId, toast);
+ break;
+ case "badge":
+ WnsBadge badge;
+ if (translatedNotification.getMessage() instanceof Integer) {
+ badge = new WnsBadgeBuilder().value((Integer) translatedNotification.getMessage()).build();
+ } else {
+ badge = new WnsBadgeBuilder().value(translatedNotification.getMessage().toString()).build();
+ }
+ service.pushBadge(providerId, badge);
+ break;
+ }
+ }
tracker.completed();
} catch (Exception e) {
tracker.failed(0,e.toString());
@@ -89,17 +108,28 @@ public class WNSAdapter implements ProviderAdapter {
@Override
public Object translatePayload(Object payload) throws Exception {
- String toast = "";
+ //TODO: allow for badges and toasts at same time
+ List<TranslatedNotification> translatedNotifications = new ArrayList<>();
if (payload instanceof Map) {
- toast = ((Map<String, Object>) payload).get("toast").toString();
+ //{payloads:{winphone:{toast:"mymessage",badge:1}}}
+ Map<String, Object> map = (Map<String, Object>) payload;
+ if (map.containsKey("toast")) {
+ translatedNotifications.add(new TranslatedNotification(map.get("toast").toString(), "toast"));
+ }
+ if (map.containsKey("badge")) {
+ translatedNotifications.add(new TranslatedNotification(map.get("badge"), "badge"));
+ }
+
} else {
+ //{payloads:{winphone:"mymessage"}}
+ //make it a toast if its just a string
if (payload instanceof String) {
- toast = (String) payload;
+ translatedNotifications.add(new TranslatedNotification( (String) payload,"toast"));
}else{
throw new IllegalArgumentException("format is messed up");
}
}
- return toast;
+ return translatedNotifications;
}
@Override
@@ -128,4 +158,5 @@ public class WNSAdapter implements ProviderAdapter {
return notifier;
}
+
}
[19/25] incubator-usergrid git commit: fixed double slash bug in data
explorer in admin portal
Posted by to...@apache.org.
fixed double slash bug in data explorer in admin portal
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/373248be
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/373248be
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/373248be
Branch: refs/heads/USERGRID-273
Commit: 373248bed240df43e3e769b60a425dbbc9f61c07
Parents: 6dc62ed
Author: Rod Simpson <ro...@apigee.com>
Authored: Tue Jan 27 13:24:35 2015 -0600
Committer: Rod Simpson <ro...@apigee.com>
Committed: Tue Jan 27 13:24:35 2015 -0600
----------------------------------------------------------------------
portal/js/global/ug-service.js | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/373248be/portal/js/global/ug-service.js
----------------------------------------------------------------------
diff --git a/portal/js/global/ug-service.js b/portal/js/global/ug-service.js
index 3401060..c4e0d53 100644
--- a/portal/js/global/ug-service.js
+++ b/portal/js/global/ug-service.js
@@ -448,8 +448,9 @@ AppServices.Services.factory('ug', function(configuration, $rootScope, utility,
} else {
var queryPath = data.path;
- self.getCollection('query', queryPath, null,
- 'order by modified DESC', null);
+ //remove preceeding slash
+ queryPath = queryPath.replace(/^\//, '');
+ self.getCollection('query', queryPath, null, 'order by modified DESC', null);
}
});
[12/25] incubator-usergrid git commit: add default case to factory
Posted by to...@apache.org.
add default case to factory
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/20d905fc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/20d905fc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/20d905fc
Branch: refs/heads/USERGRID-273
Commit: 20d905fc4669dde104ae37263240932ca6a19ede
Parents: 69c3b0f
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Jan 23 16:14:36 2015 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Jan 23 16:14:36 2015 -0700
----------------------------------------------------------------------
.../usergrid/services/notifications/ProviderAdapterFactory.java | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/20d905fc/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapterFactory.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapterFactory.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapterFactory.java
index 652415b..9a48c35 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapterFactory.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapterFactory.java
@@ -20,6 +20,7 @@
package org.apache.usergrid.services.notifications;
+import com.sun.javafx.tools.ant.Application;
import org.apache.usergrid.persistence.EntityManager;
import org.apache.usergrid.persistence.entities.Notifier;
import org.apache.usergrid.services.notifications.apns.APNsAdapter;
@@ -40,6 +41,9 @@ public class ProviderAdapterFactory {
case "google" : adapter = new GCMAdapter(entityManager ,notifier); break;
case "windows" : adapter = new WNSAdapter(entityManager ,notifier); break;
case "noop" : adapter = new TestAdapter(notifier); break;
+ default: throw new IllegalArgumentException(notifier.getProvider()
+ + " did not match any known adapter, valid arguments are apple,google,windows" //ignore noop its internal
+ );
}
return adapter;