summaryrefslogtreecommitdiffstats
path: root/sandbox/sca-cloud-tutorial/store-assets
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sandbox/sca-cloud-tutorial/store-assets/META-INF/MANIFEST.MF18
-rw-r--r--sandbox/sca-cloud-tutorial/store-assets/pom.xml55
-rw-r--r--sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/Cart.java28
-rw-r--r--sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/Catalog.java27
-rw-r--r--sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/CatalogAggregatorImpl.java66
-rw-r--r--sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/CurrencyConverter.java31
-rw-r--r--sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/CurrencyConverterImpl.java43
-rw-r--r--sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/FruitsCatalogImpl.java36
-rw-r--r--sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/Item.java73
-rw-r--r--sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/ShoppingCart.java27
-rw-r--r--sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/ShoppingCartImpl.java109
-rw-r--r--sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/ShoppingCartManager.java114
-rw-r--r--sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/Total.java29
-rw-r--r--sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/VegetablesCatalogImpl.java52
-rw-r--r--sandbox/sca-cloud-tutorial/store-assets/src/main/resources/META-INF/sca-contribution.xml25
15 files changed, 0 insertions, 733 deletions
diff --git a/sandbox/sca-cloud-tutorial/store-assets/META-INF/MANIFEST.MF b/sandbox/sca-cloud-tutorial/store-assets/META-INF/MANIFEST.MF
deleted file mode 100644
index a03e301420..0000000000
--- a/sandbox/sca-cloud-tutorial/store-assets/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,18 +0,0 @@
-Manifest-Version: 1.0
-Export-Package: services
-Tool: Bnd-0.0.357
-Bundle-Name: Apache Tuscany SCA Cloud Store Tutorial Assets
-Created-By: 1.6.0_15 (Apple Inc.)
-Bundle-Vendor: The Apache Software Foundation
-Bundle-Version: 2.0.0
-Bnd-LastModified: 1256186081729
-Bundle-ManifestVersion: 2
-Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
-Bundle-Description: Apache Tuscany SCA Cloud API
-Import-Package: org.apache.tuscany.sca.cloud.data;version="2.0.0",
- org.apache.tuscany.sca.cloud.user;version="2.0.0",
- org.apache.tuscany.sca.data.collection;version="2.0.0",
- services
-Bundle-SymbolicName: org.apache.tuscany.sca.store.assets
-Bundle-DocURL: http://www.apache.org/
-
diff --git a/sandbox/sca-cloud-tutorial/store-assets/pom.xml b/sandbox/sca-cloud-tutorial/store-assets/pom.xml
deleted file mode 100644
index 7fb5fed85c..0000000000
--- a/sandbox/sca-cloud-tutorial/store-assets/pom.xml
+++ /dev/null
@@ -1,55 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * 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.
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-sca</artifactId>
- <version>2.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
- <artifactId>store-assets</artifactId>
- <version>2.0-SNAPSHOT</version>
- <name>Apache Tuscany SCA Cloud store common assets</name>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-sca-api</artifactId>
- <version>2.0-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-cloud-api</artifactId>
- <version>2.0-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-cloud-google</artifactId>
- <version>2.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
-
-</project>
diff --git a/sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/Cart.java b/sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/Cart.java
deleted file mode 100644
index 3fb5439bc3..0000000000
--- a/sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/Cart.java
+++ /dev/null
@@ -1,28 +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 services;
-
-import org.apache.tuscany.sca.data.collection.Collection;
-import org.oasisopen.sca.annotation.Remotable;
-
-@Remotable
-public interface Cart extends Collection<String, Item> {
-
-}
diff --git a/sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/Catalog.java b/sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/Catalog.java
deleted file mode 100644
index b8630370ad..0000000000
--- a/sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/Catalog.java
+++ /dev/null
@@ -1,27 +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 services;
-
-import org.oasisopen.sca.annotation.Remotable;
-
-@Remotable
-public interface Catalog {
- Item[] get();
-}
diff --git a/sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/CatalogAggregatorImpl.java b/sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/CatalogAggregatorImpl.java
deleted file mode 100644
index 1d4b8fedfa..0000000000
--- a/sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/CatalogAggregatorImpl.java
+++ /dev/null
@@ -1,66 +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 services;
-
-import org.oasisopen.sca.annotation.Property;
-import org.oasisopen.sca.annotation.Reference;
-import org.oasisopen.sca.annotation.Scope;
-import org.oasisopen.sca.annotation.Service;
-
-@Service(Catalog.class)
-@Scope("COMPOSITE")
-public class CatalogAggregatorImpl implements Catalog {
-
- @Property
- public String currencyCode = "USD";
-
- @Reference
- public CurrencyConverter currencyConverter;
-
- @Reference
- public Catalog fruitsCatalog;
-
- @Reference
- public Catalog vegetablesCatalog;
-
- public Item[] get() {
- String currencySymbol = currencyConverter.getCurrencySymbol(currencyCode);
-
- Item[] fruits = fruitsCatalog.get();
- Item[] vegetables = vegetablesCatalog.get();
-
- Item[] catalog = new Item[fruits.length + vegetables.length];
- int i =0;
- for (Item item: fruits) {
- double price = item.getPrice();
- price = currencyConverter.getConversion("USD", currencyCode, price);
- catalog[i++] = new Item(item.getName(), currencyCode, currencySymbol, price);
- }
-
- for (Item item: vegetables) {
- double price = item.getPrice();
- price = currencyConverter.getConversion("USD", currencyCode, price);
- catalog[i++] = new Item(item.getName(), currencyCode, currencySymbol, price);
- }
-
- return catalog;
- }
-
-}
diff --git a/sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/CurrencyConverter.java b/sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/CurrencyConverter.java
deleted file mode 100644
index 59435d9099..0000000000
--- a/sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/CurrencyConverter.java
+++ /dev/null
@@ -1,31 +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 services;
-
-import org.oasisopen.sca.annotation.Remotable;
-
-@Remotable
-public interface CurrencyConverter {
- public double getConversion(String fromCurrenycCode,
- String toCurrencyCode,
- double amount);
-
- public String getCurrencySymbol(String currencyCode);
-}
diff --git a/sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/CurrencyConverterImpl.java b/sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/CurrencyConverterImpl.java
deleted file mode 100644
index d185a2fe83..0000000000
--- a/sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/CurrencyConverterImpl.java
+++ /dev/null
@@ -1,43 +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 services;
-
-import org.oasisopen.sca.annotation.Service;
-
-@Service(CurrencyConverter.class)
-public class CurrencyConverterImpl implements CurrencyConverter {
- public double getConversion(String fromCurrencyCode,
- String toCurrencyCode,
- double amount) {
- if (toCurrencyCode.equals("USD"))
- return amount;
- else if (toCurrencyCode.equals("EUR"))
- return ((double)Math.round(amount * 0.7256 * 100)) /100;
- return 0;
- }
-
- public String getCurrencySymbol(String currencyCode) {
- if (currencyCode.equals("USD"))
- return "$";
- else if (currencyCode.equals("EUR"))
- return "E"; //"€";
- return "?";
- }
-}
diff --git a/sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/FruitsCatalogImpl.java b/sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/FruitsCatalogImpl.java
deleted file mode 100644
index c480991ef7..0000000000
--- a/sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/FruitsCatalogImpl.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package services;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.oasisopen.sca.annotation.Init;
-import org.oasisopen.sca.annotation.Property;
-import org.oasisopen.sca.annotation.Reference;
-import org.oasisopen.sca.annotation.Scope;
-import org.oasisopen.sca.annotation.Service;
-
-@Service(Catalog.class)
-@Scope("COMPOSITE")
-public class FruitsCatalogImpl implements Catalog {
- @Property
- public String currencyCode = "USD";
-
- @Reference
- public CurrencyConverter currencyConverter;
-
- private List<Item> catalog = new ArrayList<Item>();
-
- @Init
- public void init() {
- String currencySymbol = currencyConverter.getCurrencySymbol(currencyCode);
- catalog.add(new Item("Apple", currencyCode, currencySymbol, currencyConverter.getConversion("USD", currencyCode, 2.99)));
- catalog.add(new Item("Orange", currencyCode, currencySymbol, currencyConverter.getConversion("USD", currencyCode, 3.55)));
- catalog.add(new Item("Pear", currencyCode, currencySymbol, currencyConverter.getConversion("USD", currencyCode, 1.55)));
- }
-
- public Item[] get() {
- Item[] catalogArray = new Item[catalog.size()];
- catalog.toArray(catalogArray);
- return catalogArray;
- }
-}
diff --git a/sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/Item.java b/sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/Item.java
deleted file mode 100644
index c4397835ba..0000000000
--- a/sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/Item.java
+++ /dev/null
@@ -1,73 +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 services;
-
-import java.io.Serializable;
-
-public class Item implements Serializable {
- private static final long serialVersionUID = -5847326138627338217L;
-
- private String name;
- private String currencyCode;
- private String currencySymbol;
- private double price;
-
- public Item() {
- }
-
- public Item(String name, String currencyCode, String currencySymbol, double price) {
- this.name = name;
- this.currencyCode = currencyCode;
- this.currencySymbol = currencySymbol;
- this.price = price;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getCurrencyCode() {
- return this.currencyCode;
- }
-
- public void setCurrencyCode(String currencyCode) {
- this.currencyCode = currencyCode;
- }
-
- public String getCurrencySymbol() {
- return this.currencySymbol;
- }
-
- public void setCurrencySymbol(String currencySymbol) {
- this.currencySymbol = currencySymbol;
- }
-
- public double getPrice() {
- return price;
- }
-
- public void setPrice(double price) {
- this.price = price;
- }
-}
diff --git a/sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/ShoppingCart.java b/sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/ShoppingCart.java
deleted file mode 100644
index e4d590484c..0000000000
--- a/sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/ShoppingCart.java
+++ /dev/null
@@ -1,27 +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 services;
-
-import org.oasisopen.sca.annotation.Remotable;
-
-@Remotable
-public interface ShoppingCart extends Cart, Total{
-
-}
diff --git a/sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/ShoppingCartImpl.java b/sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/ShoppingCartImpl.java
deleted file mode 100644
index febcc3a78f..0000000000
--- a/sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/ShoppingCartImpl.java
+++ /dev/null
@@ -1,109 +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 services;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.logging.Logger;
-
-import org.apache.tuscany.sca.data.collection.Entry;
-import org.apache.tuscany.sca.data.collection.NotFoundException;
-import org.oasisopen.sca.annotation.Scope;
-
-@Scope("COMPOSITE")
-public class ShoppingCartImpl implements ShoppingCart {
- private static final Logger log = Logger.getLogger(ShoppingCartImpl.class.getName());
-
- //private DatastoreDocumentServiceImpl cart = new DatastoreDocumentServiceImpl();
- private Map<String, Item> cart = new HashMap<String, Item>();
-
- public Entry<String, Item>[] getAll() {
- Entry<String, Item>[] entries = new Entry[cart.size()];
- int i = 0;
- for (Map.Entry<String, Item> e: cart.entrySet()) {
- entries[i++] = new Entry<String, Item>(e.getKey(), e.getValue());
- }
- return entries;
- }
-
- public Item get(String key) throws NotFoundException {
- Item item = cart.get(key);
- if (item == null) {
- throw new NotFoundException(key);
- } else {
- return item;
- }
- }
-
- public String post(String key, Item item) {
- if (key == null || key.length() == 0) {
- key ="cart-" + UUID.randomUUID().toString();
- }
- cart.put(key, item);
- return key;
- }
-
- public void put(String key, Item item) throws NotFoundException {
- if (!cart.containsKey(key)) {
- throw new NotFoundException(key);
- }
- cart.put(key, item);
- }
-
- public void delete(String key) throws NotFoundException {
- if (key == null || key.equals("")) {
- cart.clear();
- } else {
- Item item = cart.remove(key);
- if (item == null)
- throw new NotFoundException(key);
- }
- }
-
- public Entry<String, Item>[] query(String queryString) {
- List<Entry<String, Item>> entries = new ArrayList<Entry<String,Item>>();
- if (queryString.startsWith("name=")) {
- String name = queryString.substring(5);
- for (Map.Entry<String, Item> e: cart.entrySet()) {
- Item item = e.getValue();
- if (item.getName().equals(name)) {
- entries.add(new Entry<String, Item>(e.getKey(), e.getValue()));
- }
- }
- }
- return entries.toArray(new Entry[entries.size()]);
- }
-
- public String getTotal() {
- double total = 0;
- String currencySymbol = "";
- if (!cart.isEmpty()) {
- Item item = cart.values().iterator().next();
- currencySymbol = item.getCurrencySymbol();
- }
- for (Item item : cart.values()) {
- total += item.getPrice();
- }
- return currencySymbol + String.valueOf(total);
- }
-}
diff --git a/sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/ShoppingCartManager.java b/sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/ShoppingCartManager.java
deleted file mode 100644
index be2c9216c8..0000000000
--- a/sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/ShoppingCartManager.java
+++ /dev/null
@@ -1,114 +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 services;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-import java.util.logging.Logger;
-
-import org.apache.tuscany.sca.cloud.user.User;
-import org.apache.tuscany.sca.cloud.user.UserService;
-import org.apache.tuscany.sca.data.collection.Entry;
-import org.apache.tuscany.sca.data.collection.NotFoundException;
-import org.oasisopen.sca.annotation.Reference;
-import org.oasisopen.sca.annotation.Scope;
-
-@Scope("COMPOSITE")
-public class ShoppingCartManager implements ShoppingCart {
- private static final Logger log = Logger.getLogger(ShoppingCartManager.class.getName());
- private static String ANONYMOUS = "anonymous";
-
- private Map<String, ShoppingCart> carts = new HashMap<String, ShoppingCart>();
-
- @Reference
- private UserService userService;
-
- public Entry<String, Item>[] getAll() {
- return getUserShoppingCart().getAll();
- }
-
- public Item get(String key) throws NotFoundException {
- return getUserShoppingCart().get(key);
- }
-
- public String post(String key, Item item) {
- if (key == null || key.length() == 0) {
- key = this.generateItemKey();
- }
- return getUserShoppingCart().post(key, item);
- }
-
- public void put(String key, Item item) throws NotFoundException {
- getUserShoppingCart().put(key,item);
- }
-
- public Entry<String, Item>[] query(String queryString) {
- return getUserShoppingCart().query(queryString);
- }
-
- public void delete(String key) throws NotFoundException {
- this.getUserShoppingCart().delete(key);
- }
-
- public String getTotal() {
- return this.getUserShoppingCart().getTotal();
- }
-
- /**
- * Utility functions
- */
-
-
- private ShoppingCart getUserShoppingCart() {
- String key = getCartKey();
- ShoppingCart userCart = carts.get(key);
- if(userCart == null) {
- userCart = new ShoppingCartImpl();
- carts.put(key, userCart);
- }
- return userCart;
- }
-
- private String getUserId() {
- String userId = null;
- if(userService != null) {
- try {
- User user = userService.getCurrentUser();
- userId = user.getUserId();
- } catch(Exception e) {
- //ignore
- e.printStackTrace();
- }
- }
- if(userId == null || userId.length() == 0) {
- userId = ANONYMOUS;
- }
- return userId;
- }
- private String getCartKey() {
- String cartKey = "cart-" + this.getUserId();
- return cartKey;
- }
- private String generateItemKey() {
- String itemKey = getCartKey() + "-item-" + UUID.randomUUID().toString();
- return itemKey;
- }
-}
diff --git a/sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/Total.java b/sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/Total.java
deleted file mode 100644
index b77cc1c7ac..0000000000
--- a/sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/Total.java
+++ /dev/null
@@ -1,29 +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 services;
-
-import org.oasisopen.sca.annotation.Remotable;
-
-@Remotable
-public interface Total {
-
- String getTotal();
-
-}
diff --git a/sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/VegetablesCatalogImpl.java b/sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/VegetablesCatalogImpl.java
deleted file mode 100644
index e7ae507dd4..0000000000
--- a/sandbox/sca-cloud-tutorial/store-assets/src/main/java/services/VegetablesCatalogImpl.java
+++ /dev/null
@@ -1,52 +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 services;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.oasisopen.sca.annotation.Init;
-import org.oasisopen.sca.annotation.Property;
-import org.oasisopen.sca.annotation.Reference;
-
-public class VegetablesCatalogImpl implements Catalog {
-
- @Property
- public String currencyCode = "USD";
-
- @Reference
- public CurrencyConverter currencyConverter;
-
- private List<Item> catalog = new ArrayList<Item>();
-
- @Init
- public void init() {
- String currencySymbol = currencyConverter.getCurrencySymbol(currencyCode);
- catalog.add(new Item("Broccoli", currencyCode, currencySymbol, currencyConverter.getConversion("USD", currencyCode, 2.99)));
- catalog.add(new Item("Asparagus", currencyCode, currencySymbol, currencyConverter.getConversion("USD", currencyCode, 3.55)));
- catalog.add(new Item("Cauliflower", currencyCode, currencySymbol, currencyConverter.getConversion("USD", currencyCode, 1.55)));
- }
-
- public Item[] get() {
- Item[] catalogArray = new Item[catalog.size()];
- catalog.toArray(catalogArray);
- return catalogArray;
- }
-}
diff --git a/sandbox/sca-cloud-tutorial/store-assets/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sca-cloud-tutorial/store-assets/src/main/resources/META-INF/sca-contribution.xml
deleted file mode 100644
index 10a449c56b..0000000000
--- a/sandbox/sca-cloud-tutorial/store-assets/src/main/resources/META-INF/sca-contribution.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * 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.
--->
-<contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
- xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
- xmlns:store="http://store">
-
- <export.java package="services" />
-</contribution> \ No newline at end of file