Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Huge initial commit (broken)

  • Loading branch information...
commit c750e1bd09838d4b133bea089019d64a8ae3cd9d 0 parents
@kborchers authored
Showing with 85,035 additions and 0 deletions.
  1. +26 −0 .forge_settings
  2. +99 −0 pom.xml
  3. +87 −0 src/main/java/com/example/aerogearjournal/Routes.java
  4. +99 −0 src/main/java/com/example/aerogearjournal/model/Note.java
  5. +140 −0 src/main/java/com/example/aerogearjournal/rest/NoteEndpoint.java
  6. +15 −0 src/main/resources/META-INF/persistence.xml
  7. +2 −0  src/main/resources/META-INF/validation.xml
  8. +553 −0 src/main/webapp/.htaccess
  9. +157 −0 src/main/webapp/404.html
  10. +6 −0 src/main/webapp/WEB-INF/beans.xml
  11. +11 −0 src/main/webapp/WEB-INF/web.xml
  12. +2,250 −0 src/main/webapp/components/aerogear/aerogear.js
  13. +4 −0 src/main/webapp/components/angular-mocks/README.md
  14. +1,764 −0 src/main/webapp/components/angular-mocks/angular-mocks.js
  15. +7 −0 src/main/webapp/components/angular-mocks/angular-mocks.min.js
  16. +17 −0 src/main/webapp/components/angular-mocks/component.json
  17. +4 −0 src/main/webapp/components/angular-sanitize/README.md
  18. +535 −0 src/main/webapp/components/angular-sanitize/angular-sanitize.js
  19. +13 −0 src/main/webapp/components/angular-sanitize/angular-sanitize.min.js
  20. +17 −0 src/main/webapp/components/angular-sanitize/component.json
  21. +4 −0 src/main/webapp/components/angular-scenario/README.md
  22. +26,195 −0 src/main/webapp/components/angular-scenario/angular-scenario.js
  23. +17 −0 src/main/webapp/components/angular-scenario/component.json
  24. +6 −0 src/main/webapp/components/angular-scenario/jstd-scenario-adapter-config.js
  25. +185 −0 src/main/webapp/components/angular-scenario/jstd-scenario-adapter.js
  26. +14,735 −0 src/main/webapp/components/angular/angular.js
  27. +161 −0 src/main/webapp/components/angular/angular.min.js
  28. +14 −0 src/main/webapp/components/angular/component.json
  29. +2 −0  src/main/webapp/components/es5-shim/.gitignore
  30. +93 −0 src/main/webapp/components/es5-shim/CHANGES
  31. +25 −0 src/main/webapp/components/es5-shim/CONTRIBUTORS.md
  32. +19 −0 src/main/webapp/components/es5-shim/LICENSE
  33. +161 −0 src/main/webapp/components/es5-shim/README.md
  34. +55 −0 src/main/webapp/components/es5-shim/component.json
  35. +386 −0 src/main/webapp/components/es5-shim/es5-sham.js
  36. +7 −0 src/main/webapp/components/es5-shim/es5-sham.min.js
  37. +981 −0 src/main/webapp/components/es5-shim/es5-shim.js
  38. +17 −0 src/main/webapp/components/es5-shim/es5-shim.min.js
  39. +2 −0  src/main/webapp/components/es5-shim/minify
  40. +55 −0 src/main/webapp/components/es5-shim/package.json
  41. +59 −0 src/main/webapp/components/es5-shim/tests/helpers/h-kill.js
  42. +34 −0 src/main/webapp/components/es5-shim/tests/helpers/h-matchers.js
  43. +3 −0  src/main/webapp/components/es5-shim/tests/helpers/h.js
  44. +62 −0 src/main/webapp/components/es5-shim/tests/index.html
  45. +190 −0 src/main/webapp/components/es5-shim/tests/lib/jasmine-html.js
  46. +166 −0 src/main/webapp/components/es5-shim/tests/lib/jasmine.css
  47. +2,477 −0 src/main/webapp/components/es5-shim/tests/lib/jasmine.js
  48. BIN  src/main/webapp/components/es5-shim/tests/lib/jasmine_favicon.png
  49. +478 −0 src/main/webapp/components/es5-shim/tests/lib/json2.js
  50. +1,144 −0 src/main/webapp/components/es5-shim/tests/spec/s-array.js
  51. +149 −0 src/main/webapp/components/es5-shim/tests/spec/s-date.js
  52. +147 −0 src/main/webapp/components/es5-shim/tests/spec/s-function.js
  53. +84 −0 src/main/webapp/components/es5-shim/tests/spec/s-object.js
  54. +24 −0 src/main/webapp/components/es5-shim/tests/spec/s-string.js
  55. +11,092 −0 src/main/webapp/components/jquery-mobile/jquery.mobile-1.3.0.js
  56. +14 −0 src/main/webapp/components/jquery/component.json
  57. +23 −0 src/main/webapp/components/jquery/composer.json
  58. +9,472 −0 src/main/webapp/components/jquery/jquery.js
  59. +2 −0  src/main/webapp/components/jquery/jquery.min.js
  60. +6 −0 src/main/webapp/components/json3/.gitmodules
  61. +7 −0 src/main/webapp/components/json3/.npmignore
  62. +20 −0 src/main/webapp/components/json3/LICENSE
  63. +124 −0 src/main/webapp/components/json3/README.md
  64. +213 −0 src/main/webapp/components/json3/build.js
  65. +8 −0 src/main/webapp/components/json3/component.json
  66. +154 −0 src/main/webapp/components/json3/index.html
  67. +137 −0 src/main/webapp/components/json3/jsl.conf
  68. +783 −0 src/main/webapp/components/json3/lib/json3.js
  69. +17 −0 src/main/webapp/components/json3/lib/json3.min.js
  70. +30 −0 src/main/webapp/components/json3/package.json
  71. BIN  src/main/webapp/components/json3/page/background.png
  72. BIN  src/main/webapp/components/json3/page/logo.png
  73. +19 −0 src/main/webapp/components/json3/page/page.html
  74. +143 −0 src/main/webapp/components/json3/page/style.css
  75. +60 −0 src/main/webapp/components/json3/test/test_browser.html
  76. +539 −0 src/main/webapp/components/json3/test/test_json3.js
  77. BIN  src/main/webapp/components/json3/vendor/closure-compiler.jar
  78. +974 −0 src/main/webapp/components/json3/vendor/curl.js
  79. +4,874 −0 src/main/webapp/components/json3/vendor/prototype.js
  80. +1,998 −0 src/main/webapp/components/json3/vendor/require.js
  81. +27 −0 src/main/webapp/components/sockjs/sockjs-0.3.4.min.js
  82. +189 −0 src/main/webapp/components/vertx/vertxbus.js
  83. BIN  src/main/webapp/favicon.ico
  84. +43 −0 src/main/webapp/index.html
  85. +3 −0  src/main/webapp/robots.txt
  86. +12 −0 src/main/webapp/scripts/scripts.js
  87. BIN  src/main/webapp/styles/images/ajax-loader.gif
  88. BIN  src/main/webapp/styles/images/arrow.png
  89. BIN  src/main/webapp/styles/images/icons-18-black.png
  90. BIN  src/main/webapp/styles/images/icons-18-white.png
  91. BIN  src/main/webapp/styles/images/icons-36-black.png
  92. BIN  src/main/webapp/styles/images/icons-36-white.png
  93. +2 −0  src/main/webapp/styles/jquery.mobile-1.3.0.min.css
  94. +61 −0 src/main/webapp/styles/main.css
  95. +6 −0 src/main/webapp/views/addNote.html
  96. +1 −0  src/main/webapp/views/main.html
  97. +22 −0 src/main/webapp/views/notes.html
  98. +15 −0 target/classes/META-INF/persistence.xml
  99. +2 −0  target/classes/META-INF/validation.xml
26 .forge_settings
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<configuration>
+<rootpath>/rest</rootpath>
+<org>
+<jboss>
+<forge>
+<scaffold>
+<html5>
+<Html5Scaffold_targetDir>/</Html5Scaffold_targetDir>
+</html5>
+</scaffold>
+</forge>
+</jboss>
+</org>
+<jboss-as>
+<as7>
+<configured>PROJECT</configured>
+<jboss-home>/Users/krisborchers/git-repo/ ~/jboss-as-7.1.1.Final</jboss-home>
+</as7>
+</jboss-as>
+<forge>
+<analytics>
+<enabled>false</enabled>
+</analytics>
+</forge>
+</configuration>
99 pom.xml
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>com.example.aerogearjournal</groupId>
+ <artifactId>aerogear-journal</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>war</packaging>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.spec</groupId>
+ <artifactId>jboss-javaee-6.0</artifactId>
+ <version>3.0.2.Final</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.hibernate.javax.persistence</groupId>
+ <artifactId>hibernate-jpa-2.0-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.validation</groupId>
+ <artifactId>validation-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.spec.javax.servlet</groupId>
+ <artifactId>jboss-servlet-api_3.0_spec</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.spec.javax.ws.rs</groupId>
+ <artifactId>jboss-jaxrs-api_1.1_spec</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.spec.javax.transaction</groupId>
+ <artifactId>jboss-transaction-api_1.1_spec</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.spec.javax.ejb</groupId>
+ <artifactId>jboss-ejb-api_3.1_spec</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.enterprise</groupId>
+ <artifactId>cdi-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.spec.javax.annotation</groupId>
+ <artifactId>jboss-annotations-api_1.1_spec</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.aerogear</groupId>
+ <artifactId>aerogear-controller</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>com.ning</groupId>
+ <artifactId>async-http-client</artifactId>
+ <version>1.7.12</version>
+ </dependency>
+ </dependencies>
+ <repositories>
+ <repository>
+ <id>JBOSS_NEXUS</id>
+ <url>http://repository.jboss.org/nexus/content/groups/public</url>
+ </repository>
+ </repositories>
+ <build>
+ <finalName>aerogear-journal</finalName>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.3.2</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ <encoding>UTF-8</encoding>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.1.1</version>
+ <configuration>
+ <failOnMissingWebXml>false</failOnMissingWebXml>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
87 src/main/java/com/example/aerogearjournal/Routes.java
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2012, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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 com.example.aerogearjournal;
+
+import com.example.aerogearjournal.model.Note;
+import com.example.aerogearjournal.rest.NoteEndpoint;
+
+import org.jboss.aerogear.controller.router.AbstractRoutingModule;
+import org.jboss.aerogear.controller.router.MediaType;
+import org.jboss.aerogear.controller.router.RequestMethod;
+import static org.jboss.aerogear.controller.router.parameter.Parameter.*;
+import org.jboss.aerogear.controller.router.rest.pagination.Paginated;
+import org.jboss.aerogear.controller.router.rest.pagination.PaginationInfo;
+
+public class Routes extends AbstractRoutingModule
+{
+
+ @Override
+ public void configuration() throws Exception
+ {
+
+ route()
+ .from("/notes")
+ .on(RequestMethod.GET)
+ .consumes(JSON)
+ .produces(JSON)
+ .to(NoteEndpoint.class).listAll(param(PaginationInfo.class));
+ route()
+ .from("/notes")
+ .on(RequestMethod.POST)
+ .consumes(JSON)
+ .produces(JSON)
+ .to(NoteEndpoint.class).create(param(Note.class));
+ route()
+ .from("/notes/{id}")
+ .on(RequestMethod.DELETE)
+ .consumes(JSON)
+ .produces(JSON)
+ .to(NoteEndpoint.class).deleteById(param("id", Long.class));
+ route()
+ .from("/notes/{id}")
+ .on(RequestMethod.GET)
+ .consumes(JSON)
+ .produces(JSON)
+ .to(NoteEndpoint.class).findById(param("id", Long.class));
+ route()
+ .from("/notes/{id}")
+ .on(RequestMethod.PUT)
+ .consumes(JSON)
+ .produces(JSON)
+ .to(NoteEndpoint.class).update(param("id", Long.class), param(Note.class));
+
+ }
+
+ private Long parseLong(String param)
+ {
+ Long parsedLong = null;
+ try
+ {
+ parsedLong = Long.getLong(param);
+ }
+ catch (NumberFormatException e)
+ {
+ //TODO
+ }
+ finally
+ {
+ return parsedLong;
+ }
+ }
+
+}
99 src/main/java/com/example/aerogearjournal/model/Note.java
@@ -0,0 +1,99 @@
+package com.example.aerogearjournal.model;
+
+import javax.persistence.Entity;
+import java.io.Serializable;
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Column;
+import javax.persistence.Version;
+import java.lang.Override;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@Entity
+@XmlRootElement
+public class Note implements Serializable
+{
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(name = "id", updatable = false, nullable = false)
+ private Long id = null;
+ @Version
+ @Column(name = "version")
+ private int version = 0;
+
+ @Column
+ private String note;
+
+ public Long getId()
+ {
+ return this.id;
+ }
+
+ public void setId(final Long id)
+ {
+ this.id = id;
+ }
+
+ public int getVersion()
+ {
+ return this.version;
+ }
+
+ public void setVersion(final int version)
+ {
+ this.version = version;
+ }
+
+ @Override
+ public boolean equals(Object that)
+ {
+ if (this == that)
+ {
+ return true;
+ }
+ if (that == null)
+ {
+ return false;
+ }
+ if (getClass() != that.getClass())
+ {
+ return false;
+ }
+ if (id != null)
+ {
+ return id.equals(((Note) that).id);
+ }
+ return super.equals(that);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ if (id != null)
+ {
+ return id.hashCode();
+ }
+ return super.hashCode();
+ }
+
+ public String getNote()
+ {
+ return this.note;
+ }
+
+ public void setNote(final String note)
+ {
+ this.note = note;
+ }
+
+ @Override
+ public String toString()
+ {
+ String result = getClass().getSimpleName() + " ";
+ if (note != null && !note.trim().isEmpty())
+ result += "note: " + note;
+ return result;
+ }
+}
140 src/main/java/com/example/aerogearjournal/rest/NoteEndpoint.java
@@ -0,0 +1,140 @@
+package com.example.aerogearjournal.rest;
+
+import java.util.List;
+
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.UriBuilder;
+import com.example.aerogearjournal.model.Note;
+import org.jboss.aerogear.controller.router.rest.pagination.Paginated;
+import org.jboss.aerogear.controller.router.rest.pagination.PaginationInfo;
+import com.ning.http.client.*;
+import java.util.concurrent.Future;
+
+/**
+ *
+ */
+@Stateless
+@Path("/notes")
+public class NoteEndpoint
+{
+ @PersistenceContext
+ private EntityManager em;
+
+ @POST
+ @Consumes("application/json")
+ public Response create(Note entity)
+ {
+ em.persist(entity);
+
+ try {
+ AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
+
+ Future<com.ning.http.client.Response> f =
+ asyncHttpClient.preparePost("http://localhost:7777/sender/broadcast/5199f94d-e19e-4565-8243-59fdc396f052")
+ .addHeader("Content-Type", "application/json")
+ .setBody("{\"key\":\"blah\", \"alert\":\"add\"}").execute();
+
+ com.ning.http.client.Response resp = f.get();
+ // LOGGER..... :)
+ System.out.println(resp);
+
+ // clean up, the resources.......
+ asyncHttpClient.close();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return Response.created(UriBuilder.fromResource(NoteEndpoint.class).path(String.valueOf(entity.getId())).build()).build();
+ }
+
+ @DELETE
+ @Path("/{id:[0-9][0-9]*}")
+ public Response deleteById(@PathParam("id") Long id)
+ {
+ Note entity = em.find(Note.class, id);
+ if (entity == null)
+ {
+ return Response.status(Status.NOT_FOUND).build();
+ }
+ em.remove(entity);
+
+ try {
+ AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
+
+ Future<com.ning.http.client.Response> f =
+ asyncHttpClient.preparePost("http://localhost:7777/sender/broadcast/5199f94d-e19e-4565-8243-59fdc396f052")
+ .addHeader("Content-Type", "application/json")
+ .setBody("{\"key\":\"blah\", \"alert\":\"delete\"}").execute();
+
+ com.ning.http.client.Response resp = f.get();
+ // LOGGER..... :)
+ System.out.println(resp);
+
+ // clean up, the resources.......
+ asyncHttpClient.close();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return Response.noContent().build();
+ }
+
+ @GET
+ @Path("/{id:[0-9][0-9]*}")
+ @Produces("application/json")
+ public Response findById(@PathParam("id") Long id)
+ {
+ Note entity = em.find(Note.class, id);
+ if (entity == null)
+ {
+ return Response.status(Status.NOT_FOUND).build();
+ }
+ return Response.ok(entity).build();
+ }
+
+ @Paginated
+ public List<Note> listAll(final PaginationInfo paginationInfo)
+ {
+ return getNotes(paginationInfo.getOffset(), paginationInfo.getLimit());
+ }
+
+ private List<Note> getNotes(final int offset, final int limit) {
+ return em.createQuery("FROM Note", Note.class)
+ .setFirstResult(offset)
+ .setMaxResults(limit)
+ .getResultList();
+ }
+
+ @PUT
+ @Path("/{id:[0-9][0-9]*}")
+ @Consumes("application/json")
+ public Response update(@PathParam("id") Long id, Note entity)
+ {
+ entity.setId(id);
+ entity = em.merge(entity);
+
+ try {
+ AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
+
+ Future<com.ning.http.client.Response> f =
+ asyncHttpClient.preparePost("http://localhost:7777/sender/broadcast/5199f94d-e19e-4565-8243-59fdc396f052")
+ .addHeader("Content-Type", "application/json")
+ .setBody("{\"key\":\"blah\", \"alert\":\"update\"}").execute();
+
+ com.ning.http.client.Response resp = f.get();
+ // LOGGER..... :)
+ System.out.println(resp);
+
+ // clean up, the resources.......
+ asyncHttpClient.close();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return Response.noContent().build();
+ }
+}
15 src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+ <persistence-unit name="forge-default" transaction-type="JTA">
+ <description>Forge Persistence Unit</description>
+ <provider>org.hibernate.ejb.HibernatePersistence</provider>
+ <jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>
+ <exclude-unlisted-classes>false</exclude-unlisted-classes>
+ <properties>
+ <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+ <property name="hibernate.show_sql" value="true"/>
+ <property name="hibernate.format_sql" value="true"/>
+ <property name="hibernate.transaction.flush_before_completion" value="true"/>
+ </properties>
+ </persistence-unit>
+</persistence>
2  src/main/resources/META-INF/validation.xml
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<validation-config xmlns="http://jboss.org/xml/ns/javax/validation/configuration" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
553 src/main/webapp/.htaccess
@@ -0,0 +1,553 @@
+# Apache configuration file
+# httpd.apache.org/docs/2.2/mod/quickreference.html
+
+# Note .htaccess files are an overhead, this logic should be in your Apache
+# config if possible: httpd.apache.org/docs/2.2/howto/htaccess.html
+
+# Techniques in here adapted from all over, including:
+# Kroc Camen: camendesign.com/.htaccess
+# perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/
+# Sample .htaccess file of CMS MODx: modxcms.com
+
+
+# ----------------------------------------------------------------------
+# Better website experience for IE users
+# ----------------------------------------------------------------------
+
+# Force the latest IE version, in various cases when it may fall back to IE7 mode
+# github.com/rails/rails/commit/123eb25#commitcomment-118920
+# Use ChromeFrame if it's installed for a better experience for the poor IE folk
+
+<IfModule mod_headers.c>
+ Header set X-UA-Compatible "IE=Edge,chrome=1"
+ # mod_headers can't match by content-type, but we don't want to send this header on *everything*...
+ <FilesMatch "\.(js|css|gif|png|jpe?g|pdf|xml|oga|ogg|m4a|ogv|mp4|m4v|webm|svg|svgz|eot|ttf|otf|woff|ico|webp|appcache|manifest|htc|crx|oex|xpi|safariextz|vcf)$" >
+ Header unset X-UA-Compatible
+ </FilesMatch>
+</IfModule>
+
+
+# ----------------------------------------------------------------------
+# Cross-domain AJAX requests
+# ----------------------------------------------------------------------
+
+# Serve cross-domain Ajax requests, disabled by default.
+# enable-cors.org
+# code.google.com/p/html5security/wiki/CrossOriginRequestSecurity
+
+# <IfModule mod_headers.c>
+# Header set Access-Control-Allow-Origin "*"
+# </IfModule>
+
+
+# ----------------------------------------------------------------------
+# CORS-enabled images (@crossorigin)
+# ----------------------------------------------------------------------
+
+# Send CORS headers if browsers request them; enabled by default for images.
+# developer.mozilla.org/en/CORS_Enabled_Image
+# blog.chromium.org/2011/07/using-cross-domain-images-in-webgl-and.html
+# hacks.mozilla.org/2011/11/using-cors-to-load-webgl-textures-from-cross-domain-images/
+# wiki.mozilla.org/Security/Reviews/crossoriginAttribute
+
+<IfModule mod_setenvif.c>
+ <IfModule mod_headers.c>
+ # mod_headers, y u no match by Content-Type?!
+ <FilesMatch "\.(gif|png|jpe?g|svg|svgz|ico|webp)$">
+ SetEnvIf Origin ":" IS_CORS
+ Header set Access-Control-Allow-Origin "*" env=IS_CORS
+ </FilesMatch>
+ </IfModule>
+</IfModule>
+
+
+# ----------------------------------------------------------------------
+# Webfont access
+# ----------------------------------------------------------------------
+
+# Allow access from all domains for webfonts.
+# Alternatively you could only whitelist your
+# subdomains like "subdomain.example.com".
+
+<IfModule mod_headers.c>
+ <FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css)$">
+ Header set Access-Control-Allow-Origin "*"
+ </FilesMatch>
+</IfModule>
+
+
+# ----------------------------------------------------------------------
+# Proper MIME type for all files
+# ----------------------------------------------------------------------
+
+# JavaScript
+# Normalize to standard type (it's sniffed in IE anyways)
+# tools.ietf.org/html/rfc4329#section-7.2
+AddType application/javascript js jsonp
+AddType application/json json
+
+# Audio
+AddType audio/ogg oga ogg
+AddType audio/mp4 m4a f4a f4b
+
+# Video
+AddType video/ogg ogv
+AddType video/mp4 mp4 m4v f4v f4p
+AddType video/webm webm
+AddType video/x-flv flv
+
+# SVG
+# Required for svg webfonts on iPad
+# twitter.com/FontSquirrel/status/14855840545
+AddType image/svg+xml svg svgz
+AddEncoding gzip svgz
+
+# Webfonts
+AddType application/vnd.ms-fontobject eot
+AddType application/x-font-ttf ttf ttc
+AddType font/opentype otf
+AddType application/x-font-woff woff
+
+# Assorted types
+AddType image/x-icon ico
+AddType image/webp webp
+AddType text/cache-manifest appcache manifest
+AddType text/x-component htc
+AddType application/xml rss atom xml rdf
+AddType application/x-chrome-extension crx
+AddType application/x-opera-extension oex
+AddType application/x-xpinstall xpi
+AddType application/octet-stream safariextz
+AddType application/x-web-app-manifest+json webapp
+AddType text/x-vcard vcf
+AddType application/x-shockwave-flash swf
+AddType text/vtt vtt
+
+
+# ----------------------------------------------------------------------
+# Allow concatenation from within specific js and css files
+# ----------------------------------------------------------------------
+
+# e.g. Inside of script.combined.js you could have
+# <!--#include file="libs/jquery-1.5.0.min.js" -->
+# <!--#include file="plugins/jquery.idletimer.js" -->
+# and they would be included into this single file.
+
+# This is not in use in the boilerplate as it stands. You may
+# choose to use this technique if you do not have a build process.
+
+#<FilesMatch "\.combined\.js$">
+# Options +Includes
+# AddOutputFilterByType INCLUDES application/javascript application/json
+# SetOutputFilter INCLUDES
+#</FilesMatch>
+
+#<FilesMatch "\.combined\.css$">
+# Options +Includes
+# AddOutputFilterByType INCLUDES text/css
+# SetOutputFilter INCLUDES
+#</FilesMatch>
+
+
+# ----------------------------------------------------------------------
+# Gzip compression
+# ----------------------------------------------------------------------
+
+<IfModule mod_deflate.c>
+
+ # Force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
+ <IfModule mod_setenvif.c>
+ <IfModule mod_headers.c>
+ SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
+ RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
+ </IfModule>
+ </IfModule>
+
+ # HTML, TXT, CSS, JavaScript, JSON, XML, HTC:
+ <IfModule filter_module>
+ FilterDeclare COMPRESS
+ FilterProvider COMPRESS DEFLATE resp=Content-Type $text/html
+ FilterProvider COMPRESS DEFLATE resp=Content-Type $text/css
+ FilterProvider COMPRESS DEFLATE resp=Content-Type $text/plain
+ FilterProvider COMPRESS DEFLATE resp=Content-Type $text/xml
+ FilterProvider COMPRESS DEFLATE resp=Content-Type $text/x-component
+ FilterProvider COMPRESS DEFLATE resp=Content-Type $application/javascript
+ FilterProvider COMPRESS DEFLATE resp=Content-Type $application/json
+ FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xml
+ FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xhtml+xml
+ FilterProvider COMPRESS DEFLATE resp=Content-Type $application/rss+xml
+ FilterProvider COMPRESS DEFLATE resp=Content-Type $application/atom+xml
+ FilterProvider COMPRESS DEFLATE resp=Content-Type $application/vnd.ms-fontobject
+ FilterProvider COMPRESS DEFLATE resp=Content-Type $image/svg+xml
+ FilterProvider COMPRESS DEFLATE resp=Content-Type $image/x-icon
+ FilterProvider COMPRESS DEFLATE resp=Content-Type $application/x-font-ttf
+ FilterProvider COMPRESS DEFLATE resp=Content-Type $font/opentype
+ FilterChain COMPRESS
+ FilterProtocol COMPRESS DEFLATE change=yes;byteranges=no
+ </IfModule>
+
+ <IfModule !mod_filter.c>
+ # Legacy versions of Apache
+ AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
+ AddOutputFilterByType DEFLATE application/javascript
+ AddOutputFilterByType DEFLATE text/xml application/xml text/x-component
+ AddOutputFilterByType DEFLATE application/xhtml+xml application/rss+xml application/atom+xml
+ AddOutputFilterByType DEFLATE image/x-icon image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype
+ </IfModule>
+
+</IfModule>
+
+
+# ----------------------------------------------------------------------
+# Expires headers (for better cache control)
+# ----------------------------------------------------------------------
+
+# These are pretty far-future expires headers.
+# They assume you control versioning with filename-based cache busting
+# Additionally, consider that outdated proxies may miscache
+# www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/
+
+# If you don't use filenames to version, lower the CSS and JS to something like
+# "access plus 1 week".
+
+<IfModule mod_expires.c>
+ ExpiresActive on
+
+# Perhaps better to whitelist expires rules? Perhaps.
+ ExpiresDefault "access plus 1 month"
+
+# cache.appcache needs re-requests in FF 3.6 (thanks Remy ~Introducing HTML5)
+ ExpiresByType text/cache-manifest "access plus 0 seconds"
+
+# Your document html
+ ExpiresByType text/html "access plus 0 seconds"
+
+# Data
+ ExpiresByType text/xml "access plus 0 seconds"
+ ExpiresByType application/xml "access plus 0 seconds"
+ ExpiresByType application/json "access plus 0 seconds"
+
+# Feed
+ ExpiresByType application/rss+xml "access plus 1 hour"
+ ExpiresByType application/atom+xml "access plus 1 hour"
+
+# Favicon (cannot be renamed)
+ ExpiresByType image/x-icon "access plus 1 week"
+
+# Media: images, video, audio
+ ExpiresByType image/gif "access plus 1 month"
+ ExpiresByType image/png "access plus 1 month"
+ ExpiresByType image/jpeg "access plus 1 month"
+ ExpiresByType video/ogg "access plus 1 month"
+ ExpiresByType audio/ogg "access plus 1 month"
+ ExpiresByType video/mp4 "access plus 1 month"
+ ExpiresByType video/webm "access plus 1 month"
+
+# HTC files (css3pie)
+ ExpiresByType text/x-component "access plus 1 month"
+
+# Webfonts
+ ExpiresByType application/x-font-ttf "access plus 1 month"
+ ExpiresByType font/opentype "access plus 1 month"
+ ExpiresByType application/x-font-woff "access plus 1 month"
+ ExpiresByType image/svg+xml "access plus 1 month"
+ ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
+
+# CSS and JavaScript
+ ExpiresByType text/css "access plus 1 year"
+ ExpiresByType application/javascript "access plus 1 year"
+
+</IfModule>
+
+
+# ----------------------------------------------------------------------
+# Prevent mobile network providers from modifying your site
+# ----------------------------------------------------------------------
+
+# The following header prevents modification of your code over 3G on some
+# European providers.
+# This is the official 'bypass' suggested by O2 in the UK.
+
+# <IfModule mod_headers.c>
+# Header set Cache-Control "no-transform"
+# </IfModule>
+
+
+# ----------------------------------------------------------------------
+# ETag removal
+# ----------------------------------------------------------------------
+
+# FileETag None is not enough for every server.
+<IfModule mod_headers.c>
+ Header unset ETag
+</IfModule>
+
+# Since we're sending far-future expires, we don't need ETags for
+# static content.
+# developer.yahoo.com/performance/rules.html#etags
+FileETag None
+
+
+# ----------------------------------------------------------------------
+# Stop screen flicker in IE on CSS rollovers
+# ----------------------------------------------------------------------
+
+# The following directives stop screen flicker in IE on CSS rollovers - in
+# combination with the "ExpiresByType" rules for images (see above).
+
+# BrowserMatch "MSIE" brokenvary=1
+# BrowserMatch "Mozilla/4.[0-9]{2}" brokenvary=1
+# BrowserMatch "Opera" !brokenvary
+# SetEnvIf brokenvary 1 force-no-vary
+
+
+# ----------------------------------------------------------------------
+# Set Keep-Alive Header
+# ----------------------------------------------------------------------
+
+# Keep-Alive allows the server to send multiple requests through one
+# TCP-connection. Be aware of possible disadvantages of this setting. Turn on
+# if you serve a lot of static content.
+
+# <IfModule mod_headers.c>
+# Header set Connection Keep-Alive
+# </IfModule>
+
+
+# ----------------------------------------------------------------------
+# Cookie setting from iframes
+# ----------------------------------------------------------------------
+
+# Allow cookies to be set from iframes (for IE only)
+# If needed, specify a path or regex in the Location directive.
+
+# <IfModule mod_headers.c>
+# Header set P3P "policyref=\"/w3c/p3p.xml\", CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\""
+# </IfModule>
+
+
+# ----------------------------------------------------------------------
+# Start rewrite engine
+# ----------------------------------------------------------------------
+
+# Turning on the rewrite engine is necessary for the following rules and
+# features. FollowSymLinks must be enabled for this to work.
+
+# Some cloud hosting services require RewriteBase to be set: goo.gl/HOcPN
+# If using the h5bp in a subdirectory, use `RewriteBase /foo` instead where
+# 'foo' is your directory.
+
+# If your web host doesn't allow the FollowSymlinks option, you may need to
+# comment it out and use `Options +SymLinksOfOwnerMatch`, but be aware of the
+# performance impact: http://goo.gl/Mluzd
+
+<IfModule mod_rewrite.c>
+ Options +FollowSymlinks
+# Options +SymLinksIfOwnerMatch
+ Options +FollowSymlinks
+ RewriteEngine On
+# RewriteBase /
+</IfModule>
+
+
+# ----------------------------------------------------------------------
+# Suppress or force the "www." at the beginning of URLs
+# ----------------------------------------------------------------------
+
+# The same content should never be available under two different URLs -
+# especially not with and without "www." at the beginning, since this can cause
+# SEO problems (duplicate content). That's why you should choose one of the
+# alternatives and redirect the other one.
+
+# By default option 1 (no "www.") is activated.
+# no-www.org/faq.php?q=class_b
+
+# If you'd prefer to use option 2, just comment out all option 1 lines
+# and uncomment option 2.
+
+# IMPORTANT: NEVER USE BOTH RULES AT THE SAME TIME!
+
+# ----------------------------------------------------------------------
+
+# Option 1:
+# Rewrite "www.example.com -> example.com".
+
+<IfModule mod_rewrite.c>
+ RewriteCond %{HTTPS} !=on
+ RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
+ RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
+</IfModule>
+
+# ----------------------------------------------------------------------
+
+# Option 2:
+# Rewrite "example.com -> www.example.com".
+# Be aware that the following rule might not be a good idea if you use "real"
+# subdomains for certain parts of your website.
+
+# <IfModule mod_rewrite.c>
+# RewriteCond %{HTTPS} !=on
+# RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
+# RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
+# </IfModule>
+
+
+# ----------------------------------------------------------------------
+# Built-in filename-based cache busting
+# ----------------------------------------------------------------------
+
+# If you're not using the build script to manage your filename version revving,
+# you might want to consider enabling this, which will route requests for
+# /css/style.20110203.css to /css/style.css
+
+# To understand why this is important and a better idea than all.css?v1231,
+# read: github.com/h5bp/html5-boilerplate/wiki/cachebusting
+
+# <IfModule mod_rewrite.c>
+# RewriteCond %{REQUEST_FILENAME} !-f
+# RewriteCond %{REQUEST_FILENAME} !-d
+# RewriteRule ^(.+)\.(\d+)\.(js|css|png|jpg|gif)$ $1.$3 [L]
+# </IfModule>
+
+
+# ----------------------------------------------------------------------
+# Prevent SSL cert warnings
+# ----------------------------------------------------------------------
+
+# Rewrite secure requests properly to prevent SSL cert warnings, e.g. prevent
+# https://www.example.com when your cert only allows https://secure.example.com
+
+# <IfModule mod_rewrite.c>
+# RewriteCond %{SERVER_PORT} !^443
+# RewriteRule ^ https://example-domain-please-change-me.com%{REQUEST_URI} [R=301,L]
+# </IfModule>
+
+
+# ----------------------------------------------------------------------
+# Prevent 404 errors for non-existing redirected folders
+# ----------------------------------------------------------------------
+
+# without -MultiViews, Apache will give a 404 for a rewrite if a folder of the
+# same name does not exist.
+# webmasterworld.com/apache/3808792.htm
+
+Options -MultiViews
+
+
+# ----------------------------------------------------------------------
+# Custom 404 page
+# ----------------------------------------------------------------------
+
+# You can add custom pages to handle 500 or 403 pretty easily, if you like.
+# If you are hosting your site in subdirectory, adjust this accordingly
+# e.g. ErrorDocument 404 /subdir/404.html
+ErrorDocument 404 /404.html
+
+
+# ----------------------------------------------------------------------
+# UTF-8 encoding
+# ----------------------------------------------------------------------
+
+# Use UTF-8 encoding for anything served text/plain or text/html
+AddDefaultCharset utf-8
+
+# Force UTF-8 for a number of file formats
+AddCharset utf-8 .atom .css .js .json .rss .vtt .xml
+
+
+# ----------------------------------------------------------------------
+# A little more security
+# ----------------------------------------------------------------------
+
+# To avoid displaying the exact version number of Apache being used, add the
+# following to httpd.conf (it will not work in .htaccess):
+# ServerTokens Prod
+
+# "-Indexes" will have Apache block users from browsing folders without a
+# default document Usually you should leave this activated, because you
+# shouldn't allow everybody to surf through every folder on your server (which
+# includes rather private places like CMS system folders).
+<IfModule mod_autoindex.c>
+ Options -Indexes
+</IfModule>
+
+# Block access to "hidden" directories or files whose names begin with a
+# period. This includes directories used by version control systems such as
+# Subversion or Git.
+<IfModule mod_rewrite.c>
+ RewriteCond %{SCRIPT_FILENAME} -d [OR]
+ RewriteCond %{SCRIPT_FILENAME} -f
+ RewriteRule "(^|/)\." - [F]
+</IfModule>
+
+# Block access to backup and source files. These files may be left by some
+# text/html editors and pose a great security danger, when anyone can access
+# them.
+<FilesMatch "(\.(bak|config|sql|fla|psd|ini|log|sh|inc|swp|dist)|~)$">
+ Order allow,deny
+ Deny from all
+ Satisfy All
+</FilesMatch>
+
+# If your server is not already configured as such, the following directive
+# should be uncommented in order to set PHP's register_globals option to OFF.
+# This closes a major security hole that is abused by most XSS (cross-site
+# scripting) attacks. For more information: http://php.net/register_globals
+#
+# IF REGISTER_GLOBALS DIRECTIVE CAUSES 500 INTERNAL SERVER ERRORS:
+#
+# Your server does not allow PHP directives to be set via .htaccess. In that
+# case you must make this change in your php.ini file instead. If you are
+# using a commercial web host, contact the administrators for assistance in
+# doing this. Not all servers allow local php.ini files, and they should
+# include all PHP configurations (not just this one), or you will effectively
+# reset everything to PHP defaults. Consult www.php.net for more detailed
+# information about setting PHP directives.
+
+# php_flag register_globals Off
+
+# Rename session cookie to something else, than PHPSESSID
+# php_value session.name sid
+
+# Disable magic quotes (This feature has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0.)
+# php_flag magic_quotes_gpc Off
+
+# Do not show you are using PHP
+# Note: Move this line to php.ini since it won't work in .htaccess
+# php_flag expose_php Off
+
+# Level of log detail - log all errors
+# php_value error_reporting -1
+
+# Write errors to log file
+# php_flag log_errors On
+
+# Do not display errors in browser (production - Off, development - On)
+# php_flag display_errors Off
+
+# Do not display startup errors (production - Off, development - On)
+# php_flag display_startup_errors Off
+
+# Format errors in plain text
+# Note: Leave this setting 'On' for xdebug's var_dump() output
+# php_flag html_errors Off
+
+# Show multiple occurrence of error
+# php_flag ignore_repeated_errors Off
+
+# Show same errors from different sources
+# php_flag ignore_repeated_source Off
+
+# Size limit for error messages
+# php_value log_errors_max_len 1024
+
+# Don't precede error with string (doesn't accept empty string, use whitespace if you need)
+# php_value error_prepend_string " "
+
+# Don't prepend to error (doesn't accept empty string, use whitespace if you need)
+# php_value error_append_string " "
+
+# Increase cookie security
+<IfModule php5_module>
+ php_value session.cookie_httponly true
+</IfModule>
157 src/main/webapp/404.html
@@ -0,0 +1,157 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <title>Page Not Found :(</title>
+ <style>
+ ::-moz-selection {
+ background: #b3d4fc;
+ text-shadow: none;
+ }
+
+ ::selection {
+ background: #b3d4fc;
+ text-shadow: none;
+ }
+
+ html {
+ padding: 30px 10px;
+ font-size: 20px;
+ line-height: 1.4;
+ color: #737373;
+ background: #f0f0f0;
+ -webkit-text-size-adjust: 100%;
+ -ms-text-size-adjust: 100%;
+ }
+
+ html,
+ input {
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
+ }
+
+ body {
+ max-width: 500px;
+ _width: 500px;
+ padding: 30px 20px 50px;
+ border: 1px solid #b3b3b3;
+ border-radius: 4px;
+ margin: 0 auto;
+ box-shadow: 0 1px 10px #a7a7a7, inset 0 1px 0 #fff;
+ background: #fcfcfc;
+ }
+
+ h1 {
+ margin: 0 10px;
+ font-size: 50px;
+ text-align: center;
+ }
+
+ h1 span {
+ color: #bbb;
+ }
+
+ h3 {
+ margin: 1.5em 0 0.5em;
+ }
+
+ p {
+ margin: 1em 0;
+ }
+
+ ul {
+ padding: 0 0 0 40px;
+ margin: 1em 0;
+ }
+
+ .container {
+ max-width: 380px;
+ _width: 380px;
+ margin: 0 auto;
+ }
+
+ /* google search */
+
+ #goog-fixurl ul {
+ list-style: none;
+ padding: 0;
+ margin: 0;
+ }
+
+ #goog-fixurl form {
+ margin: 0;
+ }
+
+ #goog-wm-qt,
+ #goog-wm-sb {
+ border: 1px solid #bbb;
+ font-size: 16px;
+ line-height: normal;
+ vertical-align: top;
+ color: #444;
+ border-radius: 2px;
+ }
+
+ #goog-wm-qt {
+ width: 220px;
+ height: 20px;
+ padding: 5px;
+ margin: 5px 10px 0 0;
+ box-shadow: inset 0 1px 1px #ccc;
+ }
+
+ #goog-wm-sb {
+ display: inline-block;
+ height: 32px;
+ padding: 0 10px;
+ margin: 5px 0 0;
+ white-space: nowrap;
+ cursor: pointer;
+ background-color: #f5f5f5;
+ background-image: -webkit-linear-gradient(rgba(255,255,255,0), #f1f1f1);
+ background-image: -moz-linear-gradient(rgba(255,255,255,0), #f1f1f1);
+ background-image: -ms-linear-gradient(rgba(255,255,255,0), #f1f1f1);
+ background-image: -o-linear-gradient(rgba(255,255,255,0), #f1f1f1);
+ -webkit-appearance: none;
+ -moz-appearance: none;
+ appearance: none;
+ *overflow: visible;
+ *display: inline;
+ *zoom: 1;
+ }
+
+ #goog-wm-sb:hover,
+ #goog-wm-sb:focus {
+ border-color: #aaa;
+ box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
+ background-color: #f8f8f8;
+ }
+
+ #goog-wm-qt:hover,
+ #goog-wm-qt:focus {
+ border-color: #105cb6;
+ outline: 0;
+ color: #222;
+ }
+
+ input::-moz-focus-inner {
+ padding: 0;
+ border: 0;
+ }
+ </style>
+ </head>
+ <body>
+ <div class="container">
+ <h1>Not found <span>:(</span></h1>
+ <p>Sorry, but the page you were trying to view does not exist.</p>
+ <p>It looks like this was the result of either:</p>
+ <ul>
+ <li>a mistyped address</li>
+ <li>an out-of-date link</li>
+ </ul>
+ <script>
+ var GOOG_FIXURL_LANG = (navigator.language || '').slice(0,2),GOOG_FIXURL_SITE = location.host;
+ </script>
+ <script src="http://linkhelp.clients.google.com/tbproxy/lh/wm/fixurl.js"></script>
+ </div>
+ </body>
+</html>
6 src/main/webapp/WEB-INF/beans.xml
@@ -0,0 +1,6 @@
+<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+
+</beans>
11 src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
+ <display-name>aerogear-journal</display-name>
+ <session-config>
+ <session-timeout>30</session-timeout>
+ </session-config>
+ <servlet-mapping>
+ <servlet-name>javax.ws.rs.core.Application</servlet-name>
+ <url-pattern>/rest/*</url-pattern>
+ </servlet-mapping>
+</web-app>
2,250 src/main/webapp/components/aerogear/aerogear.js
@@ -0,0 +1,2250 @@
+/*! AeroGear JavaScript Library - v1.0.0-M3 - 2013-03-28
+* https://github.com/aerogear/aerogear-js
+* JBoss, Home of Professional Open Source
+* Copyright Red Hat, Inc., and individual contributors
+*
+* Licensed 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.
+*/
+/**
+ The AeroGear namespace provides a way to encapsulate the library's properties and methods away from the global namespace
+ @namespace
+ */
+var AeroGear = {};
+
+/**
+ AeroGear.Core is a base for all of the library modules to extend. It is not to be instantiated and will throw an error when attempted
+ @class
+ @private
+ */
+AeroGear.Core = function() {
+ // Prevent instantiation of this base class
+ if ( this instanceof AeroGear.Core ) {
+ throw "Invalid instantiation of base class AeroGear.Core";
+ }
+
+ /**
+ This function is used internally by pipeline, datamanager, etc. to add a new Object (pipe, store, etc.) to the respective collection.
+ @method
+ @param {String|Array|Object} config - This can be a variety of types specifying how to create the object
+ @returns {Object} The object containing the collection that was updated
+ */
+ this.add = function ( config ) {
+ var i,
+ current,
+ collection = this[ this.collectionName ] || {};
+
+ if ( !config ) {
+ return this;
+ } else if ( typeof config === "string" ) {
+ // config is a string so use default adapter type
+ collection[ config ] = AeroGear[ this.lib ].adapters[ this.type ]( config );
+ } else if ( AeroGear.isArray( config ) ) {
+ // config is an array so loop through each item in the array
+ for ( i = 0; i < config.length; i++ ) {
+ current = config[ i ];
+
+ if ( typeof current === "string" ) {
+ collection[ current ] = AeroGear[ this.lib ].adapters[ this.type ]( current );
+ } else {
+ collection[ current.name ] = AeroGear[ this.lib ].adapters[ current.type || this.type ]( current.name, current.settings || {} );
+ }
+ }
+ } else {
+ // config is an object so use that signature
+ collection[ config.name ] = AeroGear[ this.lib ].adapters[ config.type || this.type ]( config.name, config.settings || {} );
+ }
+
+ // reset the collection instance
+ this[ this.collectionName ] = collection;
+
+ return this;
+ };
+ /**
+ This function is used internally by pipeline, datamanager, etc. to remove an Object (pipe, store, etc.) from the respective collection.
+ @method
+ @param {String|String[]|Object[]|Object} config - This can be a variety of types specifying how to remove the object
+ @returns {Object} The object containing the collection that was updated
+ */
+ this.remove = function( config ) {
+ var i,
+ current,
+ collection = this[ this.collectionName ] || {};
+
+ if ( typeof config === "string" ) {
+ // config is a string so delete that item by name
+ delete collection[ config ];
+ } else if ( AeroGear.isArray( config ) ) {
+ // config is an array so loop through each item in the array
+ for ( i = 0; i < config.length; i++ ) {
+ current = config[ i ];
+
+ if ( typeof current === "string" ) {
+ delete collection[ current ];
+ } else {
+ delete collection[ current.name ];
+ }
+ }
+ } else if ( config ) {
+ // config is an object so use that signature
+ delete collection[ config.name ];
+ }
+
+ // reset the collection instance
+ this[ this.collectionName ] = collection;
+
+ return this;
+ };
+};
+
+/**
+ Utility function to test if an object is an Array
+ @private
+ @method
+ @param {Object} obj - This can be any object to test
+*/
+AeroGear.isArray = function( obj ) {
+ return ({}).toString.call( obj ) === "[object Array]";
+};
+
+// node-uuid/uuid.js
+//
+// Copyright (c) 2010 Robert Kieffer
+// Dual licensed under the MIT and GPL licenses.
+// Documentation and details at https://github.com/broofa/node-uuid
+(function() {
+ var _global = this;
+
+ // Unique ID creation requires a high quality random # generator, but
+ // Math.random() does not guarantee "cryptographic quality". So we feature
+ // detect for more robust APIs, normalizing each method to return 128-bits
+ // (16 bytes) of random data.
+ var mathRNG, nodeRNG, whatwgRNG;
+
+ // Math.random()-based RNG. All platforms, very fast, unknown quality
+ var _rndBytes = new Array(16);
+ mathRNG = function() {
+ var r, b = _rndBytes, i = 0;
+
+ for (var i = 0, r; i < 16; i++) {
+ if ((i & 0x03) == 0) r = Math.random() * 0x100000000;
+ b[i] = r >>> ((i & 0x03) << 3) & 0xff;
+ }
+
+ return b;
+ }
+
+ // WHATWG crypto-based RNG - http://wiki.whatwg.org/wiki/Crypto
+ // WebKit only (currently), moderately fast, high quality
+ if (_global.crypto && crypto.getRandomValues) {
+ var _rnds = new Uint32Array(4);
+ whatwgRNG = function() {
+ crypto.getRandomValues(_rnds);
+
+ for (var c = 0 ; c < 16; c++) {
+ _rndBytes[c] = _rnds[c >> 2] >>> ((c & 0x03) * 8) & 0xff;
+ }
+ return _rndBytes;
+ }
+ }
+
+ // Node.js crypto-based RNG - http://nodejs.org/docs/v0.6.2/api/crypto.html
+ // Node.js only, moderately fast, high quality
+ try {
+ var _rb = require('crypto').randomBytes;
+ nodeRNG = _rb && function() {
+ return _rb(16);
+ };
+ } catch (e) {}
+
+ // Select RNG with best quality
+ var _rng = nodeRNG || whatwgRNG || mathRNG;
+
+ // Buffer class to use
+ var BufferClass = typeof(Buffer) == 'function' ? Buffer : Array;
+
+ // Maps for number <-> hex string conversion
+ var _byteToHex = [];
+ var _hexToByte = {};
+ for (var i = 0; i < 256; i++) {
+ _byteToHex[i] = (i + 0x100).toString(16).substr(1);
+ _hexToByte[_byteToHex[i]] = i;
+ }
+
+ // **`parse()` - Parse a UUID into it's component bytes**
+ function parse(s, buf, offset) {
+ var i = (buf && offset) || 0, ii = 0;
+
+ buf = buf || [];
+ s.toLowerCase().replace(/[0-9a-f]{2}/g, function(byte) {
+ if (ii < 16) { // Don't overflow!
+ buf[i + ii++] = _hexToByte[byte];
+ }
+ });
+
+ // Zero out remaining bytes if string was short
+ while (ii < 16) {
+ buf[i + ii++] = 0;
+ }
+
+ return buf;
+ }
+
+ // **`unparse()` - Convert UUID byte array (ala parse()) into a string**
+ function unparse(buf, offset) {
+ var i = offset || 0, bth = _byteToHex;
+ return bth[buf[i++]] + bth[buf[i++]] +
+ bth[buf[i++]] + bth[buf[i++]] + '-' +
+ bth[buf[i++]] + bth[buf[i++]] + '-' +
+ bth[buf[i++]] + bth[buf[i++]] + '-' +
+ bth[buf[i++]] + bth[buf[i++]] + '-' +
+ bth[buf[i++]] + bth[buf[i++]] +
+ bth[buf[i++]] + bth[buf[i++]] +
+ bth[buf[i++]] + bth[buf[i++]];
+ }
+
+ // **`v1()` - Generate time-based UUID**
+ //
+ // Inspired by https://github.com/LiosK/UUID.js
+ // and http://docs.python.org/library/uuid.html
+
+ // random #'s we need to init node and clockseq
+ var _seedBytes = _rng();
+
+ // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
+ var _nodeId = [
+ _seedBytes[0] | 0x01,
+ _seedBytes[1], _seedBytes[2], _seedBytes[3], _seedBytes[4], _seedBytes[5]
+ ];
+
+ // Per 4.2.2, randomize (14 bit) clockseq
+ var _clockseq = (_seedBytes[6] << 8 | _seedBytes[7]) & 0x3fff;
+
+ // Previous uuid creation time
+ var _lastMSecs = 0, _lastNSecs = 0;
+
+ // See https://github.com/broofa/node-uuid for API details
+ function v1(options, buf, offset) {
+ var i = buf && offset || 0;
+ var b = buf || [];
+
+ options = options || {};
+
+ var clockseq = options.clockseq != null ? options.clockseq : _clockseq;
+
+ // UUID timestamps are 100 nano-second units since the Gregorian epoch,
+ // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so
+ // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
+ // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
+ var msecs = options.msecs != null ? options.msecs : new Date().getTime();
+
+ // Per 4.2.1.2, use count of uuid's generated during the current clock
+ // cycle to simulate higher resolution clock
+ var nsecs = options.nsecs != null ? options.nsecs : _lastNSecs + 1;
+
+ // Time since last uuid creation (in msecs)
+ var dt = (msecs - _lastMSecs) + (nsecs - _lastNSecs)/10000;
+
+ // Per 4.2.1.2, Bump clockseq on clock regression
+ if (dt < 0 && options.clockseq == null) {
+ clockseq = clockseq + 1 & 0x3fff;
+ }
+
+ // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
+ // time interval
+ if ((dt < 0 || msecs > _lastMSecs) && options.nsecs == null) {
+ nsecs = 0;
+ }
+
+ // Per 4.2.1.2 Throw error if too many uuids are requested
+ if (nsecs >= 10000) {
+ throw new Error('uuid.v1(): Can\'t create more than 10M uuids/sec');
+ }
+
+ _lastMSecs = msecs;
+ _lastNSecs = nsecs;
+ _clockseq = clockseq;
+
+ // Per 4.1.4 - Convert from unix epoch to Gregorian epoch
+ msecs += 12219292800000;
+
+ // `time_low`
+ var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
+ b[i++] = tl >>> 24 & 0xff;
+ b[i++] = tl >>> 16 & 0xff;
+ b[i++] = tl >>> 8 & 0xff;
+ b[i++] = tl & 0xff;
+
+ // `time_mid`
+ var tmh = (msecs / 0x100000000 * 10000) & 0xfffffff;
+ b[i++] = tmh >>> 8 & 0xff;
+ b[i++] = tmh & 0xff;
+
+ // `time_high_and_version`
+ b[i++] = tmh >>> 24 & 0xf | 0x10; // include version
+ b[i++] = tmh >>> 16 & 0xff;
+
+ // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
+ b[i++] = clockseq >>> 8 | 0x80;
+
+ // `clock_seq_low`
+ b[i++] = clockseq & 0xff;
+
+ // `node`
+ var node = options.node || _nodeId;
+ for (var n = 0; n < 6; n++) {
+ b[i + n] = node[n];
+ }
+
+ return buf ? buf : unparse(b);
+ }
+
+ // **`v4()` - Generate random UUID**
+
+ // See https://github.com/broofa/node-uuid for API details
+ function v4(options, buf, offset) {
+ // Deprecated - 'format' argument, as supported in v1.2
+ var i = buf && offset || 0;
+
+ if (typeof(options) == 'string') {
+ buf = options == 'binary' ? new BufferClass(16) : null;
+ options = null;
+ }
+ options = options || {};
+
+ var rnds = options.random || (options.rng || _rng)();
+
+ // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
+ rnds[6] = (rnds[6] & 0x0f) | 0x40;
+ rnds[8] = (rnds[8] & 0x3f) | 0x80;
+
+ // Copy bytes to buffer, if provided
+ if (buf) {
+ for (var ii = 0; ii < 16; ii++) {
+ buf[i + ii] = rnds[ii];
+ }
+ }
+
+ return buf || unparse(rnds);
+ }
+
+ // Export public API
+ var uuid = v4;
+ uuid.v1 = v1;
+ uuid.v4 = v4;
+ uuid.parse = parse;
+ uuid.unparse = unparse;
+ uuid.BufferClass = BufferClass;
+
+ // Export RNG options
+ uuid.mathRNG = mathRNG;
+ uuid.nodeRNG = nodeRNG;
+ uuid.whatwgRNG = whatwgRNG;
+
+ if (typeof(module) != 'undefined') {
+ // Play nice with node.js
+ module.exports = uuid;
+ } else {
+ // Play nice with browsers
+ var _previousRoot = _global.uuid;
+
+ // **`noConflict()` - (browser only) to reset global 'uuid' var**
+ uuid.noConflict = function() {
+ _global.uuid = _previousRoot;
+ return uuid;
+ }
+ _global.uuid = uuid;
+ }
+}());
+
+(function( AeroGear, $, undefined ) {
+ /**
+ The AeroGear.Pipeline provides a persistence API that is protocol agnostic and does not depend on any certain data model. Through the use of adapters, this library provides common methods like read, save and delete that will just work.
+ @class
+ @augments AeroGear.Core
+ @param {String|Array|Object} [config] - A configuration for the pipe(s) being created along with the Pipeline. If an object or array containing objects is used, the objects can have the following properties:
+ @param {String} config.name - the name that the pipe will later be referenced by
+ @param {String} [config.type="rest"] - the type of pipe as determined by the adapter used
+ @param {String} [config.recordId="id"] - the identifier used to denote the unique id for each record in the data associated with this pipe
+ @param {Object} [config.settings={}] - the settings to be passed to the adapter
+ @returns {Object} pipeline - The created Pipeline containing any pipes that may have been created
+ @example
+ // Create an empty Pipeline
+ var pl = AeroGear.Pipeline();
+
+ // Create a single pipe using the default adapter
+ var pl2 = AeroGear.Pipeline( "tasks" );
+
+ // Create multiple pipes using the default adapter
+ var pl3 = AeroGear.Pipeline( [ "tasks", "projects" ] );
+ */
+ AeroGear.Pipeline = function( config ) {
+ // Allow instantiation without using new
+ if ( !( this instanceof AeroGear.Pipeline ) ) {
+ return new AeroGear.Pipeline( config );
+ }
+
+ // Super constructor
+ AeroGear.Core.call( this );
+
+ this.lib = "Pipeline";
+ this.type = config ? config.type || "Rest" : "Rest";
+
+ /**
+ The name used to reference the collection of pipe instances created from the adapters
+ @memberOf AeroGear.Pipeline
+ @type Object
+ @default pipes
+ */
+ this.collectionName = "pipes";
+
+ this.add( config );
+ };
+
+ AeroGear.Pipeline.prototype = AeroGear.Core;
+ AeroGear.Pipeline.constructor = AeroGear.Pipeline;
+
+ /**
+ The adapters object is provided so that adapters can be added to the AeroGear.Pipeline namespace dynamically and still be accessible to the add method
+ @augments AeroGear.Pipeline
+ */
+ AeroGear.Pipeline.adapters = {};
+})( AeroGear, jQuery );
+
+(function( AeroGear, $, uuid, undefined ) {
+ /**
+ The REST adapter is the default type used when creating a new pipe. It uses jQuery.ajax to communicate with the server. By default, the RESTful endpoint used by this pipe is the app's current context, followed by the pipe name. For example, if the app is running on http://mysite.com/myApp, then a pipe named `tasks` would use http://mysite.com/myApp/tasks as its REST endpoint.
+ @constructs AeroGear.Pipeline.adapters.Rest
+ @param {String} pipeName - the name used to reference this particular pipe
+ @param {String} [type="Rest"] - the name used to reference this particular pipe
+ @param {Object} [settings={}] - the settings to be passed to the adapter
+ @param {Object} [settings.authenticator=null] - the AeroGear.auth object used to pass credentials to a secure endpoint
+ @param {String} [settings.baseURL] - defines the base URL to use for an endpoint
+ @param {String} [settings.endpoint=pipename] - overrides the default naming of the endpoint which uses the pipeName
+ @param {Object|Boolean} [settings.pageConfig] - an object containing the current paging configuration, true to use all defaults or false/undefined to not use paging
+ @param {String} [settings.pageConfig.metadataLocation="webLinking"] - indicates whether paging information is received from the response "header", the response "body" or via RFC 5988 "webLinking", which is the default.
+ @param {String} [settings.pageConfig.previousIdentifier="previous"] - the name of the prev link header, content var or web link rel
+ @param {String} [settings.pageConfig.nextIdentifier="next"] - the name of the next link header, content var or web link rel
+ @param {Function} [settings.pageConfig.parameterProvider] - a function for handling custom parameter placement within header and body based paging - for header paging, the function receives a jqXHR object and for body paging, the function receives the JSON formatted body as an object. the function should then return an object containing keys named for the previous/nextIdentifier options and whos values are either a map of parameters and values or a properly formatted query string
+ @param {String} [settings.recordId="id"] - the name of the field used to uniquely identify a "record" in the data
+ @param {Number} [settings.timeout=60] - the amount of time, in seconds, to wait before timing out a connection and firing the complete callback for that request
+ @returns {Object} The created pipe
+ */
+ AeroGear.Pipeline.adapters.Rest = function( pipeName, settings ) {
+ // Allow instantiation without using new
+ if ( !( this instanceof AeroGear.Pipeline.adapters.Rest ) ) {
+ return new AeroGear.Pipeline.adapters.Rest( pipeName, settings );
+ }
+
+ settings = settings || {};
+
+ // Private Instance vars
+ var endpoint = settings.endpoint || pipeName,
+ ajaxSettings = {
+ // use the pipeName as the default rest endpoint
+ url: settings.baseURL ? settings.baseURL + endpoint : endpoint,
+ contentType: "application/json",
+ dataType: "json"
+ },
+ recordId = settings.recordId || "id",
+ authenticator = settings.authenticator || null,
+ type = "Rest",
+ pageConfig = settings.pageConfig,
+ timeout = settings.timeout ? settings.timeout * 1000 : 60000;
+
+ // Privileged Methods
+ /**
+ Adds the auth token to the headers and returns the modified version of the settings
+ @private
+ @augments Rest
+ @param {Object} settings - the settings object that will have the auth identifier added
+ @returns {Object} Settings extended with auth identifier
+ */
+ this.addAuthIdentifier = function( settings ) {
+ return authenticator ? authenticator.addAuthIdentifier( settings ) : settings;
+ };
+
+ /**
+ Removes the stored token effectively telling the client it must re-authenticate with the server
+ @private
+ @augments Rest
+ */
+ this.deauthorize = function() {
+ if ( authenticator ) {
+ authenticator.deauthorize();
+ }
+ };
+
+ /**
+ Returns the value of the private ajaxSettings var
+ @private
+ @augments Rest
+ @returns {Object}
+ */
+ this.getAjaxSettings = function() {
+ return ajaxSettings;
+ };
+
+ /**
+ Returns the value of the private recordId var
+ @private
+ @augments Rest
+ @returns {String}
+ */
+ this.getRecordId = function() {
+ return recordId;
+ };
+
+ /**
+ Returns the value of the private timeout var
+ @private
+ @augments Rest
+ @returns {Number}
+ */
+ this.getTimeout = function() {
+ return timeout;
+ };
+
+ /**
+ Returns the value of the private pageConfig var
+ @private
+ @augments Rest
+ @returns {Object}
+ */
+ this.getPageConfig = function() {
+ return pageConfig;
+ };
+
+ /**
+ Updates the value of the private pageConfig var with only the items specified in newConfig unless the reset option is specified
+ @private
+ @augments Rest
+ */
+ this.updatePageConfig = function( newConfig, reset ) {
+ if ( reset ) {
+ pageConfig = {};
+ pageConfig.metadataLocation = newConfig.metadataLocation ? newConfig.metadataLocation : "webLinking";
+ pageConfig.previousIdentifier = newConfig.previousIdentifier ? newConfig.previousIdentifier : "previous";
+ pageConfig.nextIdentifier = newConfig.nextIdentifier ? newConfig.nextIdentifier : "next";
+ pageConfig.parameterProvider = newConfig.parameterProvider ? newConfig.parameterProvider : null;
+ } else {
+ $.extend( pageConfig, newConfig );
+ }
+ };
+
+ // Set pageConfig defaults
+ if ( pageConfig ) {
+ this.updatePageConfig( pageConfig, true );
+ }
+
+ // Paging Helpers
+ this.webLinkingPageParser = function( jqXHR ) {
+ var linkAr, linksAr, currentLink, params, paramAr, identifier,
+ query = {};
+
+ linksAr = jqXHR.getResponseHeader( "Link" ).split( "," );
+ for ( var link in linksAr ) {
+ linkAr = linksAr[ link ].trim().split( ";" );
+ for ( var item in linkAr ) {
+ currentLink = linkAr[ item ].trim();
+ if ( currentLink.indexOf( "<" ) === 0 && currentLink.lastIndexOf( ">" ) === linkAr[ item ].length - 1 ) {
+ params = currentLink.substr( 1, currentLink.length - 2 ).split( "?" )[ 1 ];
+ } else if ( currentLink.indexOf( "rel=" ) === 0 ) {
+ if ( currentLink.indexOf( pageConfig.previousIdentifier ) >= 0 ) {
+ identifier = pageConfig.previousIdentifier;
+ } else if ( currentLink.indexOf( pageConfig.nextIdentifier ) >= 0 ) {
+ identifier = pageConfig.nextIdentifier;
+ }
+ }
+ }
+
+ if( identifier ) {
+ query[ identifier ] = params;
+ identifier = undefined;
+ }
+ }
+
+ return query;
+ };
+
+ this.headerPageParser = function( jqXHR ) {
+ var previousQueryString = jqXHR.getResponseHeader( pageConfig.previousIdentifier ),
+ nextQueryString = jqXHR.getResponseHeader( pageConfig.nextIdentifier ),
+ pagingMetadata = {},
+ query = {};
+
+ if ( pageConfig.parameterProvider ) {
+ pagingMetadata = pageConfig.parameterProvider( jqXHR );
+ query[ pageConfig.previousIdentifier ] = pagingMetadata[ pageConfig.previousIdentifier ];
+ query[ pageConfig.nextIdentifier ] = pagingMetadata[ pageConfig.nextIdentifier ];
+ } else {
+ query[ pageConfig.previousIdentifier ] = previousQueryString ? previousQueryString.split( "?" )[ 1 ] : null;
+ query[ pageConfig.nextIdentifier ] = nextQueryString ? nextQueryString.split( "?" )[ 1 ] : null;
+ }
+
+ return query;
+ };
+
+ this.bodyPageParser = function( body ) {
+ var query = {},
+ pagingMetadata = {};
+
+ if ( pageConfig.parameterProvider ) {
+ pagingMetadata = pageConfig.parameterProvider( body );
+
+ query[ pageConfig.previousIdentifier ] = pagingMetadata[ pageConfig.previousIdentifier ];
+ query[ pageConfig.nextIdentifier ] = pagingMetadata[ pageConfig.nextIdentifier ];
+ } else {
+ query[ pageConfig.previousIdentifier ] = body[ pageConfig.previousIdentifier ];
+ query[ pageConfig.nextIdentifier ] = body[ pageConfig.nextIdentifier ];
+ }
+
+ return query;
+ };
+
+ this.formatJSONError = function( xhr ) {
+ if ( this.getAjaxSettings().dataType === "json" ) {
+ try {
+ xhr.responseJSON = JSON.parse( xhr.responseText );
+ } catch( error ) {
+ // Response was not JSON formatted
+ }
+ }
+ return xhr;
+ };
+ };
+
+ // Public Methods
+ /**
+ Reads data from the specified endpoint
+ @param {Object} [options={}] - Additional options
+ @param {Function} [options.complete] - a callback to be called when the result of the request to the server is complete, regardless of success
+ @param {Function} [options.error] - a callback to be called when the request to the server results in an error
+ @param {Object} [options.id] - the value to append to the endpoint URL, should be the same as the pipelines recordId
+ @param {Mixed} [options.jsonp] - Turns jsonp on/off for reads, Set to true, or an object with options
+ @param {String} [options.jsonp.callback] - Override the callback function name in a jsonp request. This value will be used instead of 'callback' in the 'callback=?' part of the query string in the url
+ @param {String} [options.jsonp.customCallback] - Specify the callback function name for a JSONP request. This value will be used instead of the random name automatically generated by jQuery
+ @param {Number} [options.limitValue=10] - the maximum number of results the server should return when using a paged pipe
+ @param {String} [options.offsetValue="0"] - the offset of the first element that should be included in the returned collection when using a paged pipe
+ @param {Object|Boolean} [options.paging] - this object can be used to overwrite the default paging parameters to request data from other pages or completely customize the paging functionality, leaving undefined will cause paging to use defaults, setting to false will turn off paging and request all data for this single read request
+ @param {Object} [options.query] - a hash of key/value pairs that can be passed to the server as additional information for use when determining what data to return
+ @param {Object} [options.statusCode] - a collection of status codes and callbacks to fire when the request to the server returns on of those codes. For more info see the statusCode option on the <a href="http://api.jquery.com/jQuery.ajax/">jQuery.ajax page</a>.
+ @param {Function} [options.success] - a callback to be called when the result of the request to the server is successful
+ @returns {Object} The jqXHR created by jQuery.ajax. To cancel the request, simply call the abort() method of the jqXHR object which will then trigger the error and complete callbacks for this request. For more info, see the <a href="http://api.jquery.com/jQuery.ajax/">jQuery.ajax page</a>.
+ @example
+ var myPipe = AeroGear.Pipeline( "tasks" ).pipes[ 0 ];
+
+ // Get a set of key/value pairs of all data on the server associated with this pipe
+ var allData = myPipe.read();
+
+ // A data object can be passed to filter the data and in the case of REST,
+ // this object is converted to query string parameters which the server can use.
+ // The values would be determined by what the server is expecting
+ var filteredData = myPipe.read({
+ query: {
+ limit: 10,
+ date: "2012-08-01"
+ ...
+ }
+ });
+ */
+ AeroGear.Pipeline.adapters.Rest.prototype.read = function( options ) {
+ var url, success, error, extraOptions,
+ that = this,
+ recordId = this.getRecordId(),
+ ajaxSettings = this.getAjaxSettings(),
+ pageConfig = this.getPageConfig();
+
+ options = options ? options : {};
+ options.query = options.query ? options.query : {};
+
+ if ( options[ recordId ] ) {
+ url = ajaxSettings.url + "/" + options[ recordId ];
+ } else {
+ url = ajaxSettings.url;
+ }
+
+ // Handle paging
+ if ( pageConfig && options.paging !== false ) {
+ // Set custom paging to defaults if not used
+ if ( !options.paging ) {
+ options.paging = {
+ offset: options.offsetValue || 0,
+ limit: options.limitValue || 10
+ };
+ }
+
+ // Apply paging to request
+ options.query = options.query || {};
+ for ( var item in options.paging ) {
+ options.query[ item ] = options.paging[ item ];
+ }
+ }
+
+ success = function( data, textStatus, jqXHR ) {
+ var paramMap;
+
+ // Generate paged response
+ if ( pageConfig && options.paging !== false ) {
+ paramMap = that[ pageConfig.metadataLocation + "PageParser" ]( pageConfig.metadataLocation === "body" ? data : jqXHR );
+
+ [ "previous", "next" ].forEach( function( element ) {
+ data[ element ] = (function( pipe, parameters, options ) {
+ return function( callbacks ) {
+ options.paging = true;
+ options.offsetValue = options.limitValue = undefined;
+ options.query = parameters;
+ options.success = callbacks && callbacks.success ? callbacks.success : options.success;
+ options.error = callbacks && callbacks.error ? callbacks.error : options.error;
+
+ return pipe.read( options );
+ };
+ })( that, paramMap[ pageConfig[ element + "Identifier" ] ], options );
+ });
+ }
+
+ if ( options.success ) {
+ options.success.apply( this, arguments );
+ }
+ };
+ error = function( jqXHR, textStatus, errorThrown ) {
+ jqXHR = that.formatJSONError( jqXHR );
+ if ( options.error ) {
+ options.error.apply( this, arguments );
+ }
+ };
+ extraOptions = {
+ type: "GET",
+ data: options.query,
+ success: success,
+ error: error,
+ url: url,
+ statusCode: options.statusCode,
+ complete: options.complete,
+ headers: options.headers,
+ timeout: this.getTimeout()
+ };
+
+ if( options.jsonp ) {
+ extraOptions.dataType = "jsonp";
+ extraOptions.jsonp = options.jsonp.callback ? options.jsonp.callback : "callback";
+ if( options.jsonp.customCallback ) {
+ extraOptions.jsonpCallback = options.jsonp.customCallback;
+ }
+ }
+
+ return $.ajax( this.addAuthIdentifier( $.extend( {}, this.getAjaxSettings(), extraOptions ) ) );
+ };
+
+ /**
+ Save data asynchronously to the server. If this is a new object (doesn't have a record identifier provided by the server), the data is created on the server (POST) and then that record is sent back to the client including the new server-assigned id, otherwise, the data on the server is updated (PUT).
+ @param {Object} data - For new data, this will be an object representing the data to be saved to the server. For updating data, a hash of key/value pairs one of which must be the `recordId` you set during creation of the pipe representing the identifier the server will use to update this record and then any other number of pairs representing the data. The data object is then stringified and passed to the server to be processed.
+ @param {Object} [options={}] - Additional options
+ @param {Function} [options.complete] - a callback to be called when the result of the request to the server is complete, regardless of success
+ @param {Function} [options.error] - a callback to be called when the request to the server results in an error
+ @param {Object} [options.statusCode] - a collection of status codes and callbacks to fire when the request to the server returns on of those codes. For more info see the statusCode option on the <a href="http://api.jquery.com/jQuery.ajax/">jQuery.ajax page</a>.
+ @param {Function} [options.success] - a callback to be called when the result of the request to the server is successful
+ @returns {Object} The jqXHR created by jQuery.ajax. To cancel the request, simply call the abort() method of the jqXHR object which will then trigger the error and complete callbacks for this request. For more info, see the <a href="http://api.jquery.com/jQuery.ajax/">jQuery.ajax page</a>.
+ @example
+ var myPipe = AeroGear.Pipeline( "tasks" ).pipes[ 0 ];
+
+ // Store a new task
+ myPipe.save({
+ title: "Created Task",
+ date: "2012-07-13",
+ ...
+ });
+
+ // Pass a success and error callback, in this case using the REST pipe and jQuery.ajax so the functions take the same parameters.
+ myPipe.save({
+ title: "Another Created Task",
+ date: "2012-07-13",
+ ...
+ },
+ {
+ success: function( data, textStatus, jqXHR ) {
+ console.log( "Success" );
+ },
+ error: function( jqXHR, textStatus, errorThrown ) {
+ console.log( "Error" );
+ }
+ });
+
+ // Update an existing piece of data
+ var toUpdate = myPipe.data[ 0 ];
+ toUpdate.data.title = "Updated Task";
+ myPipe.save( toUpdate );
+ */
+ AeroGear.Pipeline.adapters.Rest.prototype.save = function( data, options ) {
+ var that = this,
+ recordId = this.getRecordId(),
+ ajaxSettings = this.getAjaxSettings(),
+ type,
+ url,
+ success,
+ error,
+ extraOptions;
+
+ data = data || {};
+ options = options || {};
+ type = data[ recordId ] ? "PUT" : "POST";
+
+ if ( data[ recordId ] ) {
+ url = ajaxSettings.url + "/" + data[ recordId ];
+ } else {
+ url = ajaxSettings.url;
+ }
+
+ success = function( data, textStatus, jqXHR ) {
+ if ( options.success ) {
+ options.success.apply( this, arguments );
+ }
+ };
+ error = function( jqXHR, textStatus, errorThrown ) {
+ jqXHR = that.formatJSONError( jqXHR );
+ if ( options.error ) {
+ options.error.apply( this, arguments );
+ }
+ };
+ extraOptions = $.extend( {}, ajaxSettings, {
+ data: data,
+ type: type,
+ url: url,
+ success: success,
+ error: error,
+ statusCode: options.statusCode,
+ complete: options.complete,
+ headers: options.headers,
+ timeout: this.getTimeout()
+ });
+
+ // Stringify data if we actually want to POST/PUT JSON data
+ if ( extraOptions.contentType === "application/json" && extraOptions.data && typeof extraOptions.data !== "string" ) {
+ extraOptions.data = JSON.stringify( extraOptions.data );
+ }
+
+ return $.ajax( this.addAuthIdentifier( $.extend( {}, this.getAjaxSettings(), extraOptions ) ) );
+ };
+
+ /**
+ Remove data asynchronously from the server. Passing nothing will inform the server to remove all data at this pipe's endpoint.
+ @param {String|Object} [data] - A variety of objects can be passed to specify the item(s) to remove
+ @param {Object} [options={}] - Additional options
+ @param {Function} [options.complete] - a callback to be called when the result of the request to the server is complete, regardless of success
+ @param {Function} [options.error] - a callback to be called when the request to the server results in an error
+ @param {Object} [options.statusCode] - a collection of status codes and callbacks to fire when the request to the server returns on of those codes. For more info see the statusCode option on the <a href="http://api.jquery.com/jQuery.ajax/">jQuery.ajax page</a>.
+ @param {Function} [options.success] - a callback to be called when the result of the request to the server is successful
+ @returns {Object} The jqXHR created by jQuery.ajax. To cancel the request, simply call the abort() method of the jqXHR object which will then trigger the error and complete callbacks for this request. For more info, see the <a href="http://api.jquery.com/jQuery.ajax/">jQuery.ajax page</a>.
+ @example
+ var myPipe = AeroGear.Pipeline( "tasks" ).pipes[ 0 ];
+
+ // Store a new task
+ myPipe.save({
+ title: "Created Task"
+ });
+
+ // Store another new task
+ myPipe.save({
+ title: "Another Created Task"
+ });
+
+ // Store one more new task
+ myPipe.save({
+ title: "And Another Created Task"
+ });
+
+ // Remove a particular item from the server by its id
+ var toRemove = myPipe.data[ 0 ];
+ myPipe.remove( toRemove.id );
+
+ // Remove an item from the server using the data object
+ toRemove = myPipe.data[ 0 ];
+ myPipe.remove( toRemove );
+
+ // Delete all remaining data from the server associated with this pipe
+ myPipe.remove();
+ */
+ AeroGear.Pipeline.adapters.Rest.prototype.remove = function( toRemove, options ) {
+ var that = this,