Skip to content

Commit

Permalink
Extracted environmente setup out of the examples
Browse files Browse the repository at this point in the history
Now there is a third example that setups env for both
image upload and product update examples.
  • Loading branch information
flbulgarelli committed Apr 20, 2011
1 parent cb77260 commit 89b02e3
Show file tree
Hide file tree
Showing 10 changed files with 379 additions and 93 deletions.
13 changes: 6 additions & 7 deletions example-search-product-and-update-media/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Magento Search and Upload Demo
==============================

INTRODUCTION
This is minimalistic a demo about adding media - images - to a product, and searching products. This demo covers the creation and search of products, and
This is minimalistic a demo about adding media - images - to a product, and searching products. This demo covers search of products and
upload of images.

HOW TO DEMO:
Expand All @@ -11,12 +11,11 @@ HOW TO DEMO:
b. magentoPassword This is the password of your Magento account
c. magentoAddress This is the url of your Magento server
d. s3AccessKey This is the access key of your Amazon Account
e. s3.secetKey. This is the secret key of your Amazon Account
f. s3.bucketName. This is a test bucket from where images where being uploaded to Magento
2. Run the "SetupS3ImageFlow", "SetupS3BucketFlow" and "SetupMagentoFlow" only once, in order to create a bucket, an image and some products
a. You can verify the product creations going to the Magento admin console, and then Catalog -> Manage Products. The new products should be listed there
3. Run the "MainFlow". This will search for products by keyword and add an image downloaded from S3
a. You can verify the content upload by simply going to the Magento Admin Console, and then Catalog -> Mange Product -> Generic Usb Mouse -> Images
e. s3SecetKey. This is the secret key of your Amazon Account
f. s3BucketName. This is a test bucket from where images where being uploaded to Magento
2. Run the "MainFlow" from the MagentoFunctionalTestDriver, or deploy the example in a Mule Container and hit
localhost:9092/magento-demo-search-product-and-update-media This will search for products by keyword and add an image downloaded from S3
a. You can verify the content upload by simply going to the Magento Admin Console, and then Catalog -> Mange Product -> Generic Usb Mouse -> Images

HOW IT WORKS:
- The MainFlow searches for products with meta keyword 'technology'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,62 +42,22 @@
Downloads an Image from an S3 server, an uploads it to the magento server as
a product image
</description>
<message-properties-transformer scope="session">
<message-properties-transformer scope="invocation">
<add-message-property key="sku" value="#[ognl:get('sku')]" />
<add-message-property key="filename" value="#[ognl:get('sku') + '.jpg']" />
</message-properties-transformer>
<s3:get-object-content bucketName="${s3.bucketName}" key="#[header:session:filename]" />
<s3:get-object-content bucketName="${s3.bucketName}" key="#[variable:filename]" />
<magento:create-product-attribute-media
content="#[payload]"
mimeType="JPEG"
productSku="#[header:session:sku]"/>
productSku="#[variable:sku]"/>
</flow>

<flow name="MainFlow">
<description>Searches Products by keyword, and updates their images</description>
<http:inbound-endpoint host="localhost" port="9090" path="magento-demo-search-product-and-update-media" />
<http:inbound-endpoint host="localhost" port="9092" path="magento-demo-search-product-and-update-media" />
<flow-ref name="SearchProducts"/>
<logger level="ERROR" message="#[payload]"/>
<collection-splitter/>
<flow-ref name="UploadMedia"/>
</flow>

<flow name="SetupMagentoFlow">
<description>Creates some products in Magento for testing.</description>
<http:inbound-endpoint host="localhost" port="9090" path="magento-demo-setup" />
<magento:create-product set="4" sku="A04569"
type="simple">
<magento:attributes>
<magento:attribute key="name" value="Blue Oak Chair"/>
<magento:attribute key="status" value="1" />
</magento:attributes>
</magento:create-product>
<magento:create-product set="4" sku="FF0AS489"
type="simple">
<magento:attributes>
<magento:attribute key="name" value="Levis Jeans"/>
<magento:attribute key="status" value="1" />
</magento:attributes>
</magento:create-product>
<magento:create-product set="4" sku="1029H" type="simple">
<magento:attributes>
<magento:attribute key="name" value="Generic USB Mouse"/>
<magento:attribute key="status" value="1" />
<magento:attribute key="meta_keyword" value="technology" />
</magento:attributes>
</magento:create-product>
</flow>

<flow name="SetupS3BucketFlow">
<description>Creates a bucket in S3 for testing</description>
<logger level="ERROR" message="${s3.bucketName}"/>
<s3:create-bucket bucketName="${s3.bucketName}" />
</flow>

<flow name="SetupS3ImageFlow">
<description>Uploads an usb mouse image to s3</description>
<outbound-endpoint address="http://www.zumbrovalley.net/ArcadeOptics/trackball/ms009s_top.jpg" />
<s3:create-object content="#[payload]" bucketName="${s3.bucketName}" key="1029H.jpg" acl="PUBLIC_READ" />
</flow>

</mule>
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

import java.util.Collections;

import org.slf4j.LoggerFactory;

public class MagentoFunctionalTestDriver extends FunctionalTestCase
{

Expand Down
23 changes: 23 additions & 0 deletions example-setup/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Magento Search and Upload Demo
==============================

INTRODUCTION
This example setups environment in order to be able to run media upload and price update examples.

HOW TO DEMO:
1. Set the following environment variables:
a. magentoUsername This is the username of your Magento Account
b. magentoPassword This is the password of your Magento account
c. magentoAddress This is the url of your Magento server
d. s3AccessKey This is the access key of your Amazon Account
e. s3SecetKey. This is the secret key of your Amazon Account
f. s3BucketName. This is a test bucket from where images where being uploaded to Magento
2. Run the different setup flows from the MagentoFunctionalTestDriver, or deploy it an a Mule Container:
a. CreatePriceUpdatesFlow: Creates some price update document in the mongodb. Alternatively, hit
http://localhost:9090/magento-demo-setup-create-price-updates
b. CreateProductsFlow: creates some products in Magento. Alternatively, you can hit
http://localhost:9090/magento-demo-setup-create-products in order to run it.
c. CreateS3BucketFlow and UploadS3ImageFlow: Creates a bucket and uploads an image to it. Alternatively,
hit http://localhost:9090/magento-demo-setup-create-bucket and http://magento-demo-setup-upload-s3-image, respectively


164 changes: 164 additions & 0 deletions example-setup/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.mule.demos</groupId>
<artifactId>mule-magento-demo-setup</artifactId>
<packaging>mule</packaging>
<name>Mule Magento Demo Setup</name>
<version>1.0</version>

<properties>
<muleVersion>3.1.0</muleVersion>
<ibeansVersion>1.1</ibeansVersion>
<mule.magento.version>1.1-SNAPSHOT</mule.magento.version>
<mule.s3.version>1.0</mule.s3.version>
</properties>

<description>Example that setups magento, s3 and mongo environment for the rest of magento examples</description>

<build>
<defaultGoal>install</defaultGoal>
<finalName>${artifactId}</finalName>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.0-beta-1</version>
<executions>
<execution>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireProperty>
<property>env.MULE_HOME</property>
<message>You must set MULE_HOME before building the demo.</message>
</requireProperty>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
<encoding>ISO-8859-1</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.mule.tools</groupId>
<artifactId>maven-mule-plugin</artifactId>
<version>1.5</version>
<extensions>true</extensions>
<configuration>
<inclusions>
<inclusion>
<groupId>org.mule.modules</groupId>
<artifactId>mule-module-magento</artifactId>
</inclusion>
<inclusion>
<groupId>org.mule.modules</groupId>
<artifactId>mule-module-s3</artifactId>
</inclusion>
<inclusion>
<groupId>org.mule.transports</groupId>
<artifactId>mule-transport-mongodb</artifactId>
</inclusion>
</inclusions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>package-example</id>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<copy file="${project.build.directory}/${artifactId}.zip"
todir="${env.MULE_HOME}/apps" overwrite="true" />
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>mule-module-magento</artifactId>
<version>${mule.magento.version}</version>
</dependency>
<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>mule-module-s3</artifactId>
<version>${mule.s3.version}</version>
</dependency>
<dependency>
<groupId>org.mule.transports</groupId>
<artifactId>mule-transport-mongodb</artifactId>
<version>3.1.0.1</version>
</dependency>
<dependency>
<groupId>org.mule.tests</groupId>
<artifactId>mule-tests-functional</artifactId>
<version>${muleVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ibeans</groupId>
<artifactId>ibeans-support</artifactId>
<version>${ibeansVersion}</version>
</dependency>
<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>mule-module-ognl</artifactId>
<version>${muleVersion}</version>
</dependency>
<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>mule-module-ibeans</artifactId>
<version>${muleVersion}</version>
</dependency>
<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>mule-module-scripting</artifactId>
<version>${muleVersion}</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>muleforge-repo</id>
<name>MuleForge Repository</name>
<url>http://repository.muleforge.org</url>
<layout>default</layout>
</repository>
<repository>
<id>codehaus-repo</id>
<name>Codehaus Repository</name>
<url>http://dist.codehaus.org/mule/dependencies/maven2</url>
<layout>default</layout>
</repository>
<repository>
<id>ibeans-repo</id>
<name>iBeans Repository</name>
<url>http://repository.ibeans.muleforge.org</url>
<layout>default</layout>
</repository>
</repositories>
</project>

96 changes: 96 additions & 0 deletions example-setup/src/main/app/mule-config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Mule Magento Cloud Connector
Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com
The software in this package is published under the terms of the CPAL v1.0
license, a copy of which has been included with this distribution in the
LICENSE.txt file.
-->

<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:magento="http://www.mulesoft.org/schema/mule/magento"
xmlns:s3="http://www.mulesoft.org/schema/mule/s3"
xmlns:json="http://www.mulesoft.org/schema/mule/json"
xmlns:mongodb="http://www.mulesoft.org/schema/mule/mongodb"
xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.mulesoft.org/schema/mule/magento http://www.mulesoft.org/schema/mule/magento/1.1-SNAPSHOT/mule-magento.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.1/mule.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/3.1/mule-json.xsd
http://www.mulesoft.org/schema/mule/s3 http://www.mulesoft.org/schema/mule/s3/1.0/mule-s3.xsd
http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/3.1/mule-scripting.xsd
http://www.mulesoft.org/schema/mule/mongodb http://www.mulesoft.org/schema/mule/mongodb/3.1/mule-mongodb.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/3.0/mule-http.xsd">

<magento:config name="MagentoTest" username="${magentoUsername}" password="${magentoPassword}" address="${magentoAddress}" />
<s3:config accessKey="${s3AccessKey}" secretKey="${s3SecretKey}" />
<mongodb:connector name="mongodb" database="${mongoDatabase}" hostname="${mongoHostname}" />

<flow name="CreatePriceUpdatesFlow">
<description>Creates some price update document in the mongodb</description>
<http:inbound-endpoint host="localhost" port="9090"
path="magento-demo-setup-create-price-updates" />
<scripting:component>
<scripting:script engine="groovy">
return [ "{ \"sku\": \"A04569\", \"price\": 8963}", "{ \"sku\": \"FF0AS489\", \"price\": 150 }", "{ \"sku\": \"1029H\", \"price \": 9863 }" ]
</scripting:script>
</scripting:component>
<collection-splitter/>
<mongodb:outbound-endpoint collection="priceUpdates"/>
</flow>

<flow name="CreateProductsFlow">
<description>Creates some products in Magento for testing.
</description>
<http:inbound-endpoint host="localhost" port="9090"
path="magento-demo-setup-create-products" />
<magento:create-product set="4" sku="A04569"
type="simple">
<magento:attributes>
<magento:attribute key="name" value="Blue Oak Chair" />
<magento:attribute key="status" value="1" />
</magento:attributes>
</magento:create-product>
<magento:create-product set="4" sku="FF0AS489"
type="simple">
<magento:attributes>
<magento:attribute key="name" value="Levis Jeans" />
<magento:attribute key="status" value="1" />
</magento:attributes>
</magento:create-product>
<magento:create-product set="4" sku="1029H"
type="simple">
<magento:attributes>
<magento:attribute key="name" value="Generic USB Mouse" />
<magento:attribute key="status" value="1" />
<magento:attribute key="meta_keyword" value="technology" />
</magento:attributes>
</magento:create-product>
</flow>

<flow name="CreateS3BucketFlow">
<description>Creates a bucket in S3 for testing</description>
<http:inbound-endpoint host="localhost" port="9090"
path="magento-demo-setup-create-bucket" />
<s3:create-bucket bucketName="${s3.bucketName}" />
</flow>

<flow name="UploadS3ImageFlow">
<description>Uploads an USB mouse image to s3</description>
<http:inbound-endpoint host="localhost" port="9090"
path="magento-demo-setup-upload-s3-image" />
<outbound-endpoint
address="http://www.zumbrovalley.net/ArcadeOptics/trackball/ms009s_top.jpg" />
<s3:create-object content="#[payload]" bucketName="${s3.bucketName}"
key="1029H.jpg" acl="PUBLIC_READ" />
</flow>

</mule>
Loading

0 comments on commit 89b02e3

Please sign in to comment.