From 211c686bc6d05d8d05e5490b9a9f612619461abc Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Thu, 8 Jul 2010 06:38:07 +0000 Subject: More changes to get both single and mass dynamic virtual hosting working with HTTP and HTTPS. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@961589 13f79535-47bb-0310-9956-ffa450edef68 --- sca-cpp/trunk/samples/store-cpp/ssl-start | 4 +- sca-cpp/trunk/samples/store-java/ssl-start | 4 +- sca-cpp/trunk/samples/store-nosql/ssl-start | 4 +- sca-cpp/trunk/samples/store-python/ssl-start | 4 +- sca-cpp/trunk/samples/store-python/uec2-start | 4 +- sca-cpp/trunk/samples/store-scheme/ssl-start | 4 +- sca-cpp/trunk/samples/store-sql/ssl-start | 4 +- sca-cpp/trunk/samples/store-vhost/Makefile.am | 2 +- .../samples/store-vhost/currency-converter.py | 29 ----- .../store-vhost/domains/jane/currency-converter.py | 29 +++++ .../store-vhost/domains/jane/fruits-catalog.py | 30 +++++ .../store-vhost/domains/jane/shopping-cart.py | 75 +++++++++++ .../store-vhost/domains/jane/store.composite | 69 +++++++++++ .../samples/store-vhost/domains/jane/store.py | 40 ++++++ .../store-vhost/domains/joe/currency-converter.py | 29 +++++ .../store-vhost/domains/joe/fruits-catalog.py | 30 +++++ .../store-vhost/domains/joe/shopping-cart.py | 75 +++++++++++ .../store-vhost/domains/joe/store.composite | 69 +++++++++++ .../trunk/samples/store-vhost/domains/joe/store.py | 40 ++++++ .../trunk/samples/store-vhost/fruits-catalog.py | 30 ----- .../trunk/samples/store-vhost/htdocs/index.html | 137 ++------------------- sca-cpp/trunk/samples/store-vhost/server-test | 6 +- sca-cpp/trunk/samples/store-vhost/shopping-cart.py | 75 ----------- sca-cpp/trunk/samples/store-vhost/ssl-start | 18 +-- sca-cpp/trunk/samples/store-vhost/start | 6 +- sca-cpp/trunk/samples/store-vhost/store.composite | 69 ----------- sca-cpp/trunk/samples/store-vhost/store.py | 40 ------ sca-cpp/trunk/samples/store-vhost/uec2-start | 18 +-- 28 files changed, 535 insertions(+), 409 deletions(-) delete mode 100644 sca-cpp/trunk/samples/store-vhost/currency-converter.py create mode 100644 sca-cpp/trunk/samples/store-vhost/domains/jane/currency-converter.py create mode 100644 sca-cpp/trunk/samples/store-vhost/domains/jane/fruits-catalog.py create mode 100644 sca-cpp/trunk/samples/store-vhost/domains/jane/shopping-cart.py create mode 100644 sca-cpp/trunk/samples/store-vhost/domains/jane/store.composite create mode 100644 sca-cpp/trunk/samples/store-vhost/domains/jane/store.py create mode 100644 sca-cpp/trunk/samples/store-vhost/domains/joe/currency-converter.py create mode 100644 sca-cpp/trunk/samples/store-vhost/domains/joe/fruits-catalog.py create mode 100644 sca-cpp/trunk/samples/store-vhost/domains/joe/shopping-cart.py create mode 100644 sca-cpp/trunk/samples/store-vhost/domains/joe/store.composite create mode 100644 sca-cpp/trunk/samples/store-vhost/domains/joe/store.py delete mode 100644 sca-cpp/trunk/samples/store-vhost/fruits-catalog.py delete mode 100644 sca-cpp/trunk/samples/store-vhost/shopping-cart.py delete mode 100644 sca-cpp/trunk/samples/store-vhost/store.composite delete mode 100644 sca-cpp/trunk/samples/store-vhost/store.py (limited to 'sca-cpp/trunk/samples') diff --git a/sca-cpp/trunk/samples/store-cpp/ssl-start b/sca-cpp/trunk/samples/store-cpp/ssl-start index 9cb5b88974..87622e48b0 100755 --- a/sca-cpp/trunk/samples/store-cpp/ssl-start +++ b/sca-cpp/trunk/samples/store-cpp/ssl-start @@ -17,8 +17,8 @@ # specific language governing permissions and limitations # under the License. -../../modules/http/httpd-ca-conf tmp localhost -../../modules/http/httpd-cert-conf tmp localhost +../../modules/http/ssl-ca-conf tmp localhost +../../modules/http/ssl-cert-conf tmp localhost ../../modules/http/httpd-conf tmp localhost 8090 htdocs ../../modules/http/httpd-ssl-conf tmp localhost 8453 htdocs ../../modules/server/server-conf tmp diff --git a/sca-cpp/trunk/samples/store-java/ssl-start b/sca-cpp/trunk/samples/store-java/ssl-start index ec44ba1ac0..2573e5189a 100755 --- a/sca-cpp/trunk/samples/store-java/ssl-start +++ b/sca-cpp/trunk/samples/store-java/ssl-start @@ -17,8 +17,8 @@ # specific language governing permissions and limitations # under the License. -../../modules/http/httpd-ca-conf tmp localhost -../../modules/http/httpd-cert-conf tmp localhost +../../modules/http/ssl-ca-conf tmp localhost +../../modules/http/ssl-cert-conf tmp localhost ../../modules/http/httpd-conf tmp localhost 8090 htdocs ../../modules/http/httpd-ssl-conf tmp localhost 8453 htdocs ../../modules/server/server-conf tmp diff --git a/sca-cpp/trunk/samples/store-nosql/ssl-start b/sca-cpp/trunk/samples/store-nosql/ssl-start index b18a8e4af1..9dd9ce11bb 100755 --- a/sca-cpp/trunk/samples/store-nosql/ssl-start +++ b/sca-cpp/trunk/samples/store-nosql/ssl-start @@ -17,8 +17,8 @@ # specific language governing permissions and limitations # under the License. -../../modules/http/httpd-ca-conf tmp localhost -../../modules/http/httpd-cert-conf tmp localhost +../../modules/http/ssl-ca-conf tmp localhost +../../modules/http/ssl-cert-conf tmp localhost ../../modules/http/httpd-conf tmp localhost 8090 htdocs ../../modules/http/httpd-ssl-conf tmp localhost 8453 htdocs ../../modules/server/server-conf tmp diff --git a/sca-cpp/trunk/samples/store-python/ssl-start b/sca-cpp/trunk/samples/store-python/ssl-start index 1e70d6edfb..fa3efcbe14 100755 --- a/sca-cpp/trunk/samples/store-python/ssl-start +++ b/sca-cpp/trunk/samples/store-python/ssl-start @@ -17,8 +17,8 @@ # specific language governing permissions and limitations # under the License. -../../modules/http/httpd-ca-conf tmp localhost -../../modules/http/httpd-cert-conf tmp localhost +../../modules/http/ssl-ca-conf tmp localhost +../../modules/http/ssl-cert-conf tmp localhost ../../modules/http/httpd-conf tmp localhost 8090 htdocs ../../modules/http/httpd-ssl-conf tmp localhost 8453 htdocs ../../modules/server/server-conf tmp diff --git a/sca-cpp/trunk/samples/store-python/uec2-start b/sca-cpp/trunk/samples/store-python/uec2-start index 2e59815637..57f8c5ef22 100755 --- a/sca-cpp/trunk/samples/store-python/uec2-start +++ b/sca-cpp/trunk/samples/store-python/uec2-start @@ -28,8 +28,8 @@ fi sudo ../../ubuntu/ip-redirect 80 8090 sudo ../../ubuntu/ip-redirect 443 8453 -../../modules/http/httpd-ca-conf tmp $host -../../modules/http/httpd-cert-conf tmp $host +../../modules/http/ssl-ca-conf tmp $host +../../modules/http/ssl-cert-conf tmp $host ../../modules/http/httpd-conf tmp $host 8090/80 htdocs ../../modules/http/httpd-ssl-conf tmp $host 8453/443 htdocs ../../modules/server/server-conf tmp diff --git a/sca-cpp/trunk/samples/store-scheme/ssl-start b/sca-cpp/trunk/samples/store-scheme/ssl-start index 14b85f5342..5060137cd5 100755 --- a/sca-cpp/trunk/samples/store-scheme/ssl-start +++ b/sca-cpp/trunk/samples/store-scheme/ssl-start @@ -17,8 +17,8 @@ # specific language governing permissions and limitations # under the License. -../../modules/http/httpd-ca-conf tmp localhost -../../modules/http/httpd-cert-conf tmp localhost +../../modules/http/ssl-ca-conf tmp localhost +../../modules/http/ssl-cert-conf tmp localhost ../../modules/http/httpd-conf tmp localhost 8090 htdocs ../../modules/http/httpd-ssl-conf tmp localhost 8453 htdocs ../../modules/server/server-conf tmp diff --git a/sca-cpp/trunk/samples/store-sql/ssl-start b/sca-cpp/trunk/samples/store-sql/ssl-start index 8e27d31a2e..ea60c527c4 100755 --- a/sca-cpp/trunk/samples/store-sql/ssl-start +++ b/sca-cpp/trunk/samples/store-sql/ssl-start @@ -17,8 +17,8 @@ # specific language governing permissions and limitations # under the License. -../../modules/http/httpd-ca-conf tmp localhost -../../modules/http/httpd-cert-conf tmp localhost +../../modules/http/ssl-ca-conf tmp localhost +../../modules/http/ssl-cert-conf tmp localhost ../../modules/http/httpd-conf tmp localhost 8090 htdocs ../../modules/http/httpd-ssl-conf tmp localhost 8453 htdocs ../../modules/server/server-conf tmp diff --git a/sca-cpp/trunk/samples/store-vhost/Makefile.am b/sca-cpp/trunk/samples/store-vhost/Makefile.am index 61933afd35..8623f468fb 100644 --- a/sca-cpp/trunk/samples/store-vhost/Makefile.am +++ b/sca-cpp/trunk/samples/store-vhost/Makefile.am @@ -20,7 +20,7 @@ if WANT_PYTHON dist_sample_SCRIPTS = start stop ssl-start uec2-start sampledir = $(prefix)/samples/store-vhost -nobase_dist_sample_DATA = currency-converter.py fruits-catalog.py shopping-cart.py store.py store.composite htdocs/*.html htdocs/domains/joe/*.html htdocs/domains/jane/*.html +nobase_dist_sample_DATA = htdocs/*.html htdocs/domains/*/*.html domains/*/*.py domains/*/*.composite dist_noinst_SCRIPTS = server-test #TESTS = server-test diff --git a/sca-cpp/trunk/samples/store-vhost/currency-converter.py b/sca-cpp/trunk/samples/store-vhost/currency-converter.py deleted file mode 100644 index 2fded8f616..0000000000 --- a/sca-cpp/trunk/samples/store-vhost/currency-converter.py +++ /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. - -# Currency converter implementation - -def convert(fr, to, amount): - if to == "EUR": - return amount * 0.70 - return amount - -def symbol(currency): - if currency == "EUR": - return "E" - return "$" - diff --git a/sca-cpp/trunk/samples/store-vhost/domains/jane/currency-converter.py b/sca-cpp/trunk/samples/store-vhost/domains/jane/currency-converter.py new file mode 100644 index 0000000000..2fded8f616 --- /dev/null +++ b/sca-cpp/trunk/samples/store-vhost/domains/jane/currency-converter.py @@ -0,0 +1,29 @@ +# 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. + +# Currency converter implementation + +def convert(fr, to, amount): + if to == "EUR": + return amount * 0.70 + return amount + +def symbol(currency): + if currency == "EUR": + return "E" + return "$" + diff --git a/sca-cpp/trunk/samples/store-vhost/domains/jane/fruits-catalog.py b/sca-cpp/trunk/samples/store-vhost/domains/jane/fruits-catalog.py new file mode 100644 index 0000000000..3d108f42eb --- /dev/null +++ b/sca-cpp/trunk/samples/store-vhost/domains/jane/fruits-catalog.py @@ -0,0 +1,30 @@ +# 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. + +# Catalog implementation + +def getcatalog(converter, currencyCode): + code = currencyCode() + def convert(price): + return converter("convert", "USD", code, price) + symbol = converter("symbol", code) + return ( + (("'javaClass", "services.Item"), ("'name", "Passion"), ("'currencyCode", code), ("'currencySymbol", symbol), ("'price", convert(2.99))), + (("'javaClass", "services.Item"), ("'name", "Mango"), ("'currencyCode", code), ("'currencySymbol", symbol), ("'price", convert(3.55))), + (("'javaClass", "services.Item"), ("'name", "Pineapple"), ("'currencyCode", code), ("'currencySymbol", symbol), ("'price", convert(1.55))) + ) + diff --git a/sca-cpp/trunk/samples/store-vhost/domains/jane/shopping-cart.py b/sca-cpp/trunk/samples/store-vhost/domains/jane/shopping-cart.py new file mode 100644 index 0000000000..405adb85bf --- /dev/null +++ b/sca-cpp/trunk/samples/store-vhost/domains/jane/shopping-cart.py @@ -0,0 +1,75 @@ +# 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. + +# Shopping cart implementation +import uuid +import sys + +cartId = "1234" + +# Get the shopping cart from the cache +# Return an empty cart if not found +def getcart(id, cache): + cart = cache("get", (id,)) + if cart is None: + return () + return cart + +# Post a new item to the cart, create a new cart if necessary +def post(collection, item, cache): + id = str(uuid.uuid1()) + cart = ((item[0], id, item[2]),) + getcart(cartId, cache) + cache("put", (cartId,), cart) + return (id,) + + +# Find an item in the cart +def find(id, cart): + if cart == (): + return ("Item", "0", ()) + elif id == cart[0][1]: + return cart[0] + else: + return find(id, cart[1:]) + +# Get items from the cart +def get(id, cache): + if id == (): + return ("Your Cart", cartId) + getcart(cartId, cache) + return find(id[0], getcart(cartId, cache)) + +# Delete items from the cart +def delete(id, cache): + if id == (): + return cache("delete", (cartId,)) + return True + +# Return the price of an item +def price(item): + return float(filter(lambda x: x[0] == "'price", item[2])[0][1]) + +# Sum the prices of a list of items +def sum(items): + if items == (): + return 0 + return price(items[0]) + sum(items[1:]) + +# Return the total price of the items in the cart +def gettotal(cache): + cart = getcart(cartId, cache) + return sum(cart) + diff --git a/sca-cpp/trunk/samples/store-vhost/domains/jane/store.composite b/sca-cpp/trunk/samples/store-vhost/domains/jane/store.composite new file mode 100644 index 0000000000..893b4f0ed4 --- /dev/null +++ b/sca-cpp/trunk/samples/store-vhost/domains/jane/store.composite @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + USD + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-cpp/trunk/samples/store-vhost/domains/jane/store.py b/sca-cpp/trunk/samples/store-vhost/domains/jane/store.py new file mode 100644 index 0000000000..0b4e0f72fd --- /dev/null +++ b/sca-cpp/trunk/samples/store-vhost/domains/jane/store.py @@ -0,0 +1,40 @@ +# 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. + +# Store implementation + +def post(item, catalog, shoppingCart, shoppingTotal): + return shoppingCart("post", item) + +def getall(catalog, shoppingCart, shoppingTotal): + return shoppingCart("getall") + +def get(id, catalog, shoppingCart, shoppingTotal): + return shoppingCart("get", id) + +def getcatalog(catalog, shoppingCart, shoppingTotal): + return catalog("getcatalog") + +def gettotal(catalog, shoppingCart, shoppingTotal): + return shoppingCart("gettotal") + +def deleteall(catalog, shoppingCart, shoppingTotal): + return shoppingCart("deleteall") + +def delete(id, catalog, shoppingCart, shoppingTotal): + return shoppingCart("delete", id) + diff --git a/sca-cpp/trunk/samples/store-vhost/domains/joe/currency-converter.py b/sca-cpp/trunk/samples/store-vhost/domains/joe/currency-converter.py new file mode 100644 index 0000000000..2fded8f616 --- /dev/null +++ b/sca-cpp/trunk/samples/store-vhost/domains/joe/currency-converter.py @@ -0,0 +1,29 @@ +# 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. + +# Currency converter implementation + +def convert(fr, to, amount): + if to == "EUR": + return amount * 0.70 + return amount + +def symbol(currency): + if currency == "EUR": + return "E" + return "$" + diff --git a/sca-cpp/trunk/samples/store-vhost/domains/joe/fruits-catalog.py b/sca-cpp/trunk/samples/store-vhost/domains/joe/fruits-catalog.py new file mode 100644 index 0000000000..2a6d726fdc --- /dev/null +++ b/sca-cpp/trunk/samples/store-vhost/domains/joe/fruits-catalog.py @@ -0,0 +1,30 @@ +# 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. + +# Catalog implementation + +def getcatalog(converter, currencyCode): + code = currencyCode() + def convert(price): + return converter("convert", "USD", code, price) + symbol = converter("symbol", code) + return ( + (("'javaClass", "services.Item"), ("'name", "Apple"), ("'currencyCode", code), ("'currencySymbol", symbol), ("'price", convert(2.99))), + (("'javaClass", "services.Item"), ("'name", "Orange"), ("'currencyCode", code), ("'currencySymbol", symbol), ("'price", convert(3.55))), + (("'javaClass", "services.Item"), ("'name", "Pear"), ("'currencyCode", code), ("'currencySymbol", symbol), ("'price", convert(1.55))) + ) + diff --git a/sca-cpp/trunk/samples/store-vhost/domains/joe/shopping-cart.py b/sca-cpp/trunk/samples/store-vhost/domains/joe/shopping-cart.py new file mode 100644 index 0000000000..405adb85bf --- /dev/null +++ b/sca-cpp/trunk/samples/store-vhost/domains/joe/shopping-cart.py @@ -0,0 +1,75 @@ +# 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. + +# Shopping cart implementation +import uuid +import sys + +cartId = "1234" + +# Get the shopping cart from the cache +# Return an empty cart if not found +def getcart(id, cache): + cart = cache("get", (id,)) + if cart is None: + return () + return cart + +# Post a new item to the cart, create a new cart if necessary +def post(collection, item, cache): + id = str(uuid.uuid1()) + cart = ((item[0], id, item[2]),) + getcart(cartId, cache) + cache("put", (cartId,), cart) + return (id,) + + +# Find an item in the cart +def find(id, cart): + if cart == (): + return ("Item", "0", ()) + elif id == cart[0][1]: + return cart[0] + else: + return find(id, cart[1:]) + +# Get items from the cart +def get(id, cache): + if id == (): + return ("Your Cart", cartId) + getcart(cartId, cache) + return find(id[0], getcart(cartId, cache)) + +# Delete items from the cart +def delete(id, cache): + if id == (): + return cache("delete", (cartId,)) + return True + +# Return the price of an item +def price(item): + return float(filter(lambda x: x[0] == "'price", item[2])[0][1]) + +# Sum the prices of a list of items +def sum(items): + if items == (): + return 0 + return price(items[0]) + sum(items[1:]) + +# Return the total price of the items in the cart +def gettotal(cache): + cart = getcart(cartId, cache) + return sum(cart) + diff --git a/sca-cpp/trunk/samples/store-vhost/domains/joe/store.composite b/sca-cpp/trunk/samples/store-vhost/domains/joe/store.composite new file mode 100644 index 0000000000..893b4f0ed4 --- /dev/null +++ b/sca-cpp/trunk/samples/store-vhost/domains/joe/store.composite @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + USD + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-cpp/trunk/samples/store-vhost/domains/joe/store.py b/sca-cpp/trunk/samples/store-vhost/domains/joe/store.py new file mode 100644 index 0000000000..0b4e0f72fd --- /dev/null +++ b/sca-cpp/trunk/samples/store-vhost/domains/joe/store.py @@ -0,0 +1,40 @@ +# 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. + +# Store implementation + +def post(item, catalog, shoppingCart, shoppingTotal): + return shoppingCart("post", item) + +def getall(catalog, shoppingCart, shoppingTotal): + return shoppingCart("getall") + +def get(id, catalog, shoppingCart, shoppingTotal): + return shoppingCart("get", id) + +def getcatalog(catalog, shoppingCart, shoppingTotal): + return catalog("getcatalog") + +def gettotal(catalog, shoppingCart, shoppingTotal): + return shoppingCart("gettotal") + +def deleteall(catalog, shoppingCart, shoppingTotal): + return shoppingCart("deleteall") + +def delete(id, catalog, shoppingCart, shoppingTotal): + return shoppingCart("delete", id) + diff --git a/sca-cpp/trunk/samples/store-vhost/fruits-catalog.py b/sca-cpp/trunk/samples/store-vhost/fruits-catalog.py deleted file mode 100644 index 2a6d726fdc..0000000000 --- a/sca-cpp/trunk/samples/store-vhost/fruits-catalog.py +++ /dev/null @@ -1,30 +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. - -# Catalog implementation - -def getcatalog(converter, currencyCode): - code = currencyCode() - def convert(price): - return converter("convert", "USD", code, price) - symbol = converter("symbol", code) - return ( - (("'javaClass", "services.Item"), ("'name", "Apple"), ("'currencyCode", code), ("'currencySymbol", symbol), ("'price", convert(2.99))), - (("'javaClass", "services.Item"), ("'name", "Orange"), ("'currencyCode", code), ("'currencySymbol", symbol), ("'price", convert(3.55))), - (("'javaClass", "services.Item"), ("'name", "Pear"), ("'currencyCode", code), ("'currencySymbol", symbol), ("'price", convert(1.55))) - ) - diff --git a/sca-cpp/trunk/samples/store-vhost/htdocs/index.html b/sca-cpp/trunk/samples/store-vhost/htdocs/index.html index c27e54f753..e0239392ff 100644 --- a/sca-cpp/trunk/samples/store-vhost/htdocs/index.html +++ b/sca-cpp/trunk/samples/store-vhost/htdocs/index.html @@ -19,139 +19,16 @@ Store - - - - - - +

Store

-
-

Catalog

-
-
-
- -
-
- -

Your Shopping Cart

-
-
-
-
-
- - -(feed) -
-
+

For this sample to work, add the sample domain to your /etc/hosts as follows:
+127.0.0.1 sca-store.com jane.sca-store.com joe.sca-store.com

+ +

+

Jane's store at jane.sca-store.com +
Joe's store at joe.sca-store.com

diff --git a/sca-cpp/trunk/samples/store-vhost/server-test b/sca-cpp/trunk/samples/store-vhost/server-test index 26efd14c0e..1ed4b55df0 100755 --- a/sca-cpp/trunk/samples/store-vhost/server-test +++ b/sca-cpp/trunk/samples/store-vhost/server-test @@ -25,11 +25,11 @@ curl_prefix=`cat $here/../../modules/http/curl.prefix` ./start sleep 2 -# For this test to work, add the following line to your etc/hosts -127.0.0.1 jane.store.com joe.store.com +# For this test to work, add the test domain to your etc/hosts as follows: +# 127.0.0.1 sca-store.com jane.sca-store.com joe.sca-store.com # Test HTTP GET -$curl_prefix/bin/curl http://jane.store.com:8090/ 2>/dev/null >tmp/jane.html +$curl_prefix/bin/curl http://jane.sca-store.com:8090/ 2>/dev/null >tmp/jane.html diff tmp/jane.html htdocs/domains/jane/index.html rc=$? diff --git a/sca-cpp/trunk/samples/store-vhost/shopping-cart.py b/sca-cpp/trunk/samples/store-vhost/shopping-cart.py deleted file mode 100644 index 405adb85bf..0000000000 --- a/sca-cpp/trunk/samples/store-vhost/shopping-cart.py +++ /dev/null @@ -1,75 +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. - -# Shopping cart implementation -import uuid -import sys - -cartId = "1234" - -# Get the shopping cart from the cache -# Return an empty cart if not found -def getcart(id, cache): - cart = cache("get", (id,)) - if cart is None: - return () - return cart - -# Post a new item to the cart, create a new cart if necessary -def post(collection, item, cache): - id = str(uuid.uuid1()) - cart = ((item[0], id, item[2]),) + getcart(cartId, cache) - cache("put", (cartId,), cart) - return (id,) - - -# Find an item in the cart -def find(id, cart): - if cart == (): - return ("Item", "0", ()) - elif id == cart[0][1]: - return cart[0] - else: - return find(id, cart[1:]) - -# Get items from the cart -def get(id, cache): - if id == (): - return ("Your Cart", cartId) + getcart(cartId, cache) - return find(id[0], getcart(cartId, cache)) - -# Delete items from the cart -def delete(id, cache): - if id == (): - return cache("delete", (cartId,)) - return True - -# Return the price of an item -def price(item): - return float(filter(lambda x: x[0] == "'price", item[2])[0][1]) - -# Sum the prices of a list of items -def sum(items): - if items == (): - return 0 - return price(items[0]) + sum(items[1:]) - -# Return the total price of the items in the cart -def gettotal(cache): - cart = getcart(cartId, cache) - return sum(cart) - diff --git a/sca-cpp/trunk/samples/store-vhost/ssl-start b/sca-cpp/trunk/samples/store-vhost/ssl-start index 1e70d6edfb..368a664674 100755 --- a/sca-cpp/trunk/samples/store-vhost/ssl-start +++ b/sca-cpp/trunk/samples/store-vhost/ssl-start @@ -17,16 +17,20 @@ # specific language governing permissions and limitations # under the License. -../../modules/http/httpd-ca-conf tmp localhost -../../modules/http/httpd-cert-conf tmp localhost -../../modules/http/httpd-conf tmp localhost 8090 htdocs -../../modules/http/httpd-ssl-conf tmp localhost 8453 htdocs +# For this sample to work, add the sample domain to your /etc/hosts as follows: +# 127.0.0.1 sca-store.com jane.sca-store.com joe.sca-store.com + +../../modules/http/ssl-ca-conf tmp sca-store.com +../../modules/http/ssl-cert-conf tmp sca-store.com server +../../modules/http/ssl-cert-conf tmp *.sca-store.com vhost +../../modules/http/httpd-conf tmp sca-store.com 8090 htdocs vhost +../../modules/http/httpd-ssl-conf tmp sca-store.com 8453 htdocs vhost ../../modules/server/server-conf tmp ../../modules/python/python-conf tmp cat >>tmp/conf/httpd.conf <>tmp/conf/httpd.conf < - - - - - - - - - - - - - - - - USD - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sca-cpp/trunk/samples/store-vhost/store.py b/sca-cpp/trunk/samples/store-vhost/store.py deleted file mode 100644 index 0b4e0f72fd..0000000000 --- a/sca-cpp/trunk/samples/store-vhost/store.py +++ /dev/null @@ -1,40 +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. - -# Store implementation - -def post(item, catalog, shoppingCart, shoppingTotal): - return shoppingCart("post", item) - -def getall(catalog, shoppingCart, shoppingTotal): - return shoppingCart("getall") - -def get(id, catalog, shoppingCart, shoppingTotal): - return shoppingCart("get", id) - -def getcatalog(catalog, shoppingCart, shoppingTotal): - return catalog("getcatalog") - -def gettotal(catalog, shoppingCart, shoppingTotal): - return shoppingCart("gettotal") - -def deleteall(catalog, shoppingCart, shoppingTotal): - return shoppingCart("deleteall") - -def delete(id, catalog, shoppingCart, shoppingTotal): - return shoppingCart("delete", id) - diff --git a/sca-cpp/trunk/samples/store-vhost/uec2-start b/sca-cpp/trunk/samples/store-vhost/uec2-start index 2e59815637..ddf70975ef 100755 --- a/sca-cpp/trunk/samples/store-vhost/uec2-start +++ b/sca-cpp/trunk/samples/store-vhost/uec2-start @@ -21,23 +21,25 @@ if [ "$1" != "" ]; then host=$1 else - host="localhost" + # Default to dummy test domain + host="sca-store.com" fi # Ports 80, 443, 8090, 8453 need to be open sudo ../../ubuntu/ip-redirect 80 8090 sudo ../../ubuntu/ip-redirect 443 8453 -../../modules/http/httpd-ca-conf tmp $host -../../modules/http/httpd-cert-conf tmp $host -../../modules/http/httpd-conf tmp $host 8090/80 htdocs -../../modules/http/httpd-ssl-conf tmp $host 8453/443 htdocs +../../modules/http/ssl-ca-conf tmp $host +../../modules/http/ssl-cert-conf tmp $host server +../../modules/http/ssl-cert-conf tmp "*.$host" vhost +../../modules/http/httpd-conf tmp $host 8090/80 htdocs vhost +../../modules/http/httpd-ssl-conf tmp $host 8453/443 htdocs vhost ../../modules/server/server-conf tmp ../../modules/python/python-conf tmp cat >>tmp/conf/httpd.conf <