diff options
Diffstat (limited to '')
3 files changed, 0 insertions, 269 deletions
diff --git a/sandbox/sca-cloud-tutorial/cloud-google/src/main/java/org/apache/tuscany/sca/cloud/data/impl/DatastoreDocumentServiceImpl.java b/sandbox/sca-cloud-tutorial/cloud-google/src/main/java/org/apache/tuscany/sca/cloud/data/impl/DatastoreDocumentServiceImpl.java deleted file mode 100644 index 05a11f0338..0000000000 --- a/sandbox/sca-cloud-tutorial/cloud-google/src/main/java/org/apache/tuscany/sca/cloud/data/impl/DatastoreDocumentServiceImpl.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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.tuscany.sca.cloud.data.impl; - -import java.util.UUID; - -import org.apache.tuscany.sca.cloud.data.DocumentService; -import org.apache.tuscany.sca.data.collection.Entry; -import org.apache.tuscany.sca.data.collection.NotFoundException; -import org.oasisopen.sca.annotation.Init; - -import com.google.appengine.api.datastore.DatastoreService; -import com.google.appengine.api.datastore.DatastoreServiceFactory; -import com.google.appengine.api.datastore.Entity; -import com.google.appengine.api.datastore.EntityNotFoundException; -import com.google.appengine.api.datastore.Key; -import com.google.appengine.api.datastore.KeyFactory; - -public class DatastoreDocumentServiceImpl implements DocumentService<Key, Entity> { - private DatastoreService googleDataStoreService; - - @Init - public void init() { - googleDataStoreService = DatastoreServiceFactory.getDatastoreService(); - } - - public Entry<Key, Entity>[] getAll() { - throw new UnsupportedOperationException(); - } - - public Entity get(Key key) throws NotFoundException { - Entity entity = null; - - try { - entity = googleDataStoreService.get(key); - } catch(EntityNotFoundException nf) { - throw new NotFoundException(nf); - } - - return entity; - } - - - public Key post(Key key, Entity entity) { - - if( key == null ) { - key = KeyFactory.createKey("key", UUID.randomUUID().toString()); - } - - return googleDataStoreService.put(entity); - } - - public void put(Key key, Entity entity) throws NotFoundException { - if( get(key) == null) { - throw new NotFoundException("Could not find entity with key '" + key.toString() +"'"); - } - - googleDataStoreService.put(entity); - } - - public void delete(Key key) throws NotFoundException { - googleDataStoreService.delete(key); - - } - - public void delete(Key... keys) throws NotFoundException { - googleDataStoreService.delete(keys); - - } - - public Entry<Key, Entity>[] query(String query) { - throw new UnsupportedOperationException(); - } - -} diff --git a/sandbox/sca-cloud-tutorial/cloud-google/src/main/java/org/apache/tuscany/sca/cloud/data/impl/MemcacheDocumentServiceImpl.java b/sandbox/sca-cloud-tutorial/cloud-google/src/main/java/org/apache/tuscany/sca/cloud/data/impl/MemcacheDocumentServiceImpl.java deleted file mode 100644 index 890747f4aa..0000000000 --- a/sandbox/sca-cloud-tutorial/cloud-google/src/main/java/org/apache/tuscany/sca/cloud/data/impl/MemcacheDocumentServiceImpl.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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.tuscany.sca.cloud.data.impl; - -import java.util.UUID; - -import org.apache.tuscany.sca.cloud.data.DocumentService; -import org.apache.tuscany.sca.data.collection.Entry; -import org.apache.tuscany.sca.data.collection.NotFoundException; -import org.oasisopen.sca.annotation.Init; -import org.oasisopen.sca.annotation.Property; - -import com.google.appengine.api.memcache.Expiration; -import com.google.appengine.api.memcache.MemcacheService; -import com.google.appengine.api.memcache.MemcacheServiceFactory; - -public class MemcacheDocumentServiceImpl implements DocumentService<Object, Object> { - private MemcacheService googleMemecacheService; - - @Property(required=false) - protected Expiration defaultExpiration = Expiration.byDeltaSeconds(3600); // 1hr - - @Init - public void init() { - googleMemecacheService = MemcacheServiceFactory.getMemcacheService(); - } - - public Entry<Object, Object>[] getAll() { - throw new UnsupportedOperationException(); - } - - public Object get(Object key) throws NotFoundException { - Object entity = null; - - entity = googleMemecacheService.get(key); - - if(entity == null) { - throw new NotFoundException("Could not find object with key '" + key.toString() + "'"); - } - - return entity; - } - - public Object post(Object key, Object entity) { - if( key == null ) { - key = UUID.randomUUID().toString(); - } - - googleMemecacheService.put(key, entity, defaultExpiration); - - return entity; - } - - public void put(Object key, Object entity) throws NotFoundException { - if( get(key) == null) { - throw new NotFoundException("Could not find entity with key '" + key.toString() +"'"); - } - - googleMemecacheService.put(key, entity, defaultExpiration); - } - - public void delete(Object key) throws NotFoundException { - googleMemecacheService.delete(key); - } - - public void delete(Object... keys) throws NotFoundException { - googleMemecacheService.delete(keys); - } - - public Entry<Object, Object>[] query(String query) { - throw new UnsupportedOperationException(); - } -} diff --git a/sandbox/sca-cloud-tutorial/cloud-google/src/main/java/org/apache/tuscany/sca/cloud/user/impl/GoogleUserService.java b/sandbox/sca-cloud-tutorial/cloud-google/src/main/java/org/apache/tuscany/sca/cloud/user/impl/GoogleUserService.java deleted file mode 100644 index bb449b22d3..0000000000 --- a/sandbox/sca-cloud-tutorial/cloud-google/src/main/java/org/apache/tuscany/sca/cloud/user/impl/GoogleUserService.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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.tuscany.sca.cloud.user.impl; - -import org.apache.tuscany.sca.cloud.user.User; -import org.apache.tuscany.sca.cloud.user.UserContext; -import org.apache.tuscany.sca.cloud.user.UserService; -import org.oasisopen.sca.annotation.Init; -import org.oasisopen.sca.annotation.Scope; -import org.oasisopen.sca.annotation.Service; - -import com.google.appengine.api.users.UserServiceFactory; - -@Service(UserService.class) -@Scope("COMPOSITE") -public class GoogleUserService implements UserService { - private com.google.appengine.api.users.UserService googleUerService; - - @Init - public void init() { - googleUerService = UserServiceFactory.getUserService(); - } - - - public User getCurrentUser() { - return fromGoogleUser(googleUerService.getCurrentUser()); - } - - public boolean isUserAdmin() { - //FIXME handle via roles from tuscany user api - throw new UnsupportedOperationException("Not supported yet"); - } - - public boolean isUserLoggedIn() { - return googleUerService.isUserLoggedIn(); - } - - public UserContext getUserContext(String destinationURL, String authDomain) { - return new UserContext (getCurrentUser(), - isUserLoggedIn(), - createLoginURL(destinationURL, authDomain), - createLogoutURL(destinationURL, authDomain)); - } - - public String createLoginURL(String destinationURL, String authDomain) { - if(authDomain != null && authDomain.length() > 0) { - return googleUerService.createLoginURL(destinationURL, authDomain); - } else { - return googleUerService.createLoginURL(destinationURL); - } - } - - public String createLogoutURL(String destinationURL, String authDomain) { - if(authDomain != null && authDomain.length() > 0) { - return googleUerService.createLogoutURL(destinationURL, authDomain); - } else { - return googleUerService.createLogoutURL(destinationURL); - } - } - - private static User fromGoogleUser(com.google.appengine.api.users.User googleUser) { - if(googleUser != null) { - return new User(googleUser.getUserId(), googleUser.getNickname(), googleUser.getEmail()); - } - - return new User(null, null, null); - } - - -} |