killbill-memoizeit
Changes
account/pom.xml 2(+1 -1)
api/pom.xml 2(+1 -1)
beatrix/pom.xml 2(+1 -1)
beatrix/src/test/java/org/killbill/billing/beatrix/integration/overdue/TestBillingAlignment.java 12(+0 -12)
beatrix/src/test/java/org/killbill/billing/beatrix/integration/overdue/TestOverdueIntegration.java 109(+56 -53)
beatrix/src/test/java/org/killbill/billing/beatrix/integration/overdue/TestOverdueWithSubscriptionCancellation.java 4(+2 -2)
beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegrationInvoiceWithRepairLogic.java 105(+50 -55)
beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegrationWithDifferentBillingPeriods.java 43(+20 -23)
catalog/pom.xml 2(+1 -1)
currency/pom.xml 2(+1 -1)
entitlement/pom.xml 2(+1 -1)
invoice/pom.xml 2(+1 -1)
invoice/src/test/java/org/killbill/billing/invoice/generator/TestDefaultInvoiceGenerator.java 10(+5 -5)
jaxrs/pom.xml 6(+5 -1)
jaxrs/src/main/java/org/killbill/billing/jaxrs/json/HostedPaymentPageFormDescriptorJson.java 2(+2 -0)
junction/pom.xml 2(+1 -1)
NEWS 7(+7 -0)
overdue/pom.xml 2(+1 -1)
payment/pom.xml 2(+1 -1)
payment/src/main/java/org/killbill/billing/payment/control/InvoicePaymentControlPluginApi.java 15(+8 -7)
payment/src/main/java/org/killbill/billing/payment/core/PluginControlledPaymentProcessor.java 52(+34 -18)
payment/src/main/java/org/killbill/billing/payment/core/sm/PluginControlledPaymentAutomatonRunner.java 13(+7 -6)
payment/src/main/java/org/killbill/billing/payment/core/sm/RetryablePaymentStateContext.java 19(+10 -9)
payment/src/main/java/org/killbill/billing/payment/core/sm/RetryCompletionOperationCallback.java 2(+1 -1)
payment/src/main/java/org/killbill/billing/payment/provider/DefaultNoOpPaymentControlProviderPlugin.java 9(+5 -4)
payment/src/main/java/org/killbill/billing/payment/provider/DefaultPaymentControlProviderPlugin.java 9(+5 -4)
payment/src/main/java/org/killbill/billing/payment/retry/DefaultPriorPaymentControlResult.java 22(+20 -2)
payment/src/test/java/org/killbill/billing/payment/core/sm/MockRetryablePaymentAutomatonRunner.java 7(+5 -2)
payment/src/test/java/org/killbill/billing/payment/provider/MockPaymentControlProviderPlugin.java 9(+5 -4)
pom.xml 4(+2 -2)
profiles/killbill/pom.xml 10(+9 -1)
profiles/killbill/src/main/java/org/killbill/billing/server/filters/ResponseCorsFilter.java 50(+50 -0)
profiles/killbill/src/main/java/org/killbill/billing/server/listeners/KillbillGuiceListener.java 36(+32 -4)
profiles/killbill/src/main/java/org/killbill/billing/server/modules/KillbillServerModule.java 6(+6 -0)
profiles/killbill/src/main/java/org/killbill/billing/server/modules/KillBillShiroWebModule.java 20(+19 -1)
profiles/killbill/src/main/webapp/api.html 147(+147 -0)
profiles/killbill/src/main/webapp/css/reset.css 125(+125 -0)
profiles/killbill/src/main/webapp/css/screen.css 1224(+1224 -0)
profiles/killbill/src/main/webapp/lib/handlebars-1.0.0.js 2278(+2278 -0)
profiles/killbill/src/main/webapp/lib/shred.bundle.js 2765(+2765 -0)
profiles/killbill/src/main/webapp/lib/swagger.js 1665(+1665 -0)
profiles/killbill/src/main/webapp/lib/swagger-client.js 1382(+1382 -0)
profiles/killpay/pom.xml 2(+1 -1)
profiles/killpay/src/main/webapp/api.html 147(+147 -0)
profiles/killpay/src/main/webapp/css/reset.css 125(+125 -0)
profiles/killpay/src/main/webapp/css/screen.css 1224(+1224 -0)
profiles/killpay/src/main/webapp/lib/handlebars-1.0.0.js 2278(+2278 -0)
profiles/killpay/src/main/webapp/lib/shred.bundle.js 2765(+2765 -0)
profiles/killpay/src/main/webapp/lib/swagger.js 1665(+1665 -0)
profiles/killpay/src/main/webapp/lib/swagger-client.js 1382(+1382 -0)
profiles/pom.xml 2(+1 -1)
subscription/pom.xml 2(+1 -1)
tenant/pom.xml 2(+1 -1)
usage/pom.xml 2(+1 -1)
util/pom.xml 2(+1 -1)
Details
account/pom.xml 2(+1 -1)
diff --git a/account/pom.xml b/account/pom.xml
index df72944..c62dfa7 100644
--- a/account/pom.xml
+++ b/account/pom.xml
@@ -19,7 +19,7 @@
<parent>
<artifactId>killbill</artifactId>
<groupId>org.kill-bill.billing</groupId>
- <version>0.11.13-SNAPSHOT</version>
+ <version>0.11.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-account</artifactId>
api/pom.xml 2(+1 -1)
diff --git a/api/pom.xml b/api/pom.xml
index 7b2283a..9245fee 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -19,7 +19,7 @@
<parent>
<artifactId>killbill</artifactId>
<groupId>org.kill-bill.billing</groupId>
- <version>0.11.13-SNAPSHOT</version>
+ <version>0.11.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-internal-api</artifactId>
beatrix/pom.xml 2(+1 -1)
diff --git a/beatrix/pom.xml b/beatrix/pom.xml
index 419b85a..f0d059d 100644
--- a/beatrix/pom.xml
+++ b/beatrix/pom.xml
@@ -19,7 +19,7 @@
<parent>
<artifactId>killbill</artifactId>
<groupId>org.kill-bill.billing</groupId>
- <version>0.11.13-SNAPSHOT</version>
+ <version>0.11.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-beatrix</artifactId>
diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/overdue/TestBillingAlignment.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/overdue/TestBillingAlignment.java
index d052b6c..4301dfd 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/overdue/TestBillingAlignment.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/overdue/TestBillingAlignment.java
@@ -64,17 +64,5 @@ public class TestBillingAlignment extends TestIntegrationBase {
//
// Change plan to annual that has been configured to have a 'SubscriptionBase' billing alignment
changeEntitlementAndCheckForCompletion(bpEntitlement, "Shotgun", BillingPeriod.ANNUAL, null, NextEvent.CHANGE, NextEvent.INVOICE);
-
-
- /*
-
- | 64e17f77-fcdd-4c87-8543-1a64d957460c | FIXED | 2012-04-01 | NULL | 0.0000 | NULL | shotgun-monthly |
- | 07924bfa-cc9b-46dc-ad22-a9a39830a128 | RECURRING | 2012-05-01 | 2012-06-01 | 249.9500 | 249.9500 | shotgun-monthly |
- | 92c1e86b-284a-4d33-a920-3cbc6e05f7e6 | RECURRING | 2012-05-01 | 2012-05-04 | 24.2000 | 249.9500 | shotgun-monthly |
- | 92c1e86b-284a-4d33-a920-3cbc6e05f7e6 | RECURRING | 2012-05-04 | 2012-06-01 | 183.6000 | 2399.9500 | shotgun-annual |
- | 07924bfa-cc9b-46dc-ad22-a9a39830a128 | REPAIR_ADJ | 2012-05-01 | 2012-06-01 | -249.9500 | NULL | NULL |
- | 07924bfa-cc9b-46dc-ad22-a9a39830a128 | CBA_ADJ | 2012-05-04 | 2012-05-04 | 249.9500 | NULL | NULL |
- | 92c1e86b-284a-4d33-a920-3cbc6e05f7e6 | CBA_ADJ | 2012-05-04 | 2012-05-04 | -207.8000 | NULL | NULL |
- */
}
}
diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/overdue/TestOverdueIntegration.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/overdue/TestOverdueIntegration.java
index 29202ee..d202719 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/overdue/TestOverdueIntegration.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/overdue/TestOverdueIntegration.java
@@ -120,7 +120,7 @@ public class TestOverdueIntegration extends TestOverdueBase {
return configXml;
}
- @Test(groups = "slow", description = "Test overdue stages and return to clear prior to CTD", enabled=false)
+ @Test(groups = "slow", description = "Test overdue stages and return to clear prior to CTD", enabled = false)
public void testOverdueStages1() throws Exception {
clock.setTime(new DateTime(2012, 5, 1, 0, 3, 42, 0));
@@ -187,14 +187,16 @@ public class TestOverdueIntegration extends TestOverdueBase {
allowPaymentsAndResetOverdueToClearByPayingAllUnpaidInvoices(false);
invoiceChecker.checkInvoice(account.getId(), 3, callContext,
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 30), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 30), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")));
+
+ invoiceChecker.checkInvoice(account.getId(), 4, callContext,
new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 10), new LocalDate(2012, 7, 23), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-104.82")),
new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 23), new LocalDate(2012, 7, 23), InvoiceItemType.CBA_ADJ, new BigDecimal("104.82")));
// Add 10 days to generate next invoice. We verify that we indeed have a notification for nextBillingDate
addDaysAndCheckForCompletion(10, NextEvent.INVOICE, NextEvent.PAYMENT);
- invoiceChecker.checkInvoice(account.getId(), 4, callContext,
+ invoiceChecker.checkInvoice(account.getId(), 5, callContext,
// Item for the upgraded recurring plan
new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 31), new LocalDate(2012, 8, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
new ExpectedInvoiceItemCheck(new LocalDate(2012, 8, 2), new LocalDate(2012, 8, 2), InvoiceItemType.CBA_ADJ, new BigDecimal("-104.82")));
@@ -205,7 +207,7 @@ public class TestOverdueIntegration extends TestOverdueBase {
assertEquals(invoiceUserApi.getAccountBalance(account.getId(), callContext).compareTo(BigDecimal.ZERO), 0);
}
- @Test(groups = "slow", description = "Test overdue stages and return to clear on CTD", enabled=false)
+ @Test(groups = "slow", description = "Test overdue stages and return to clear on CTD", enabled = false)
public void testOverdueStages2() throws Exception {
clock.setTime(new DateTime(2012, 5, 1, 0, 3, 42, 0));
@@ -282,19 +284,20 @@ public class TestOverdueIntegration extends TestOverdueBase {
invoiceChecker.checkInvoice(account.getId(), 3, callContext,
// New invoice for the partial period since we unblocked on the 1st and so are missing the 31 july
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 30), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 10), new LocalDate(2012, 7, 31), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-169.32")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 31), new LocalDate(2012, 7, 31), InvoiceItemType.CBA_ADJ, new BigDecimal("169.32")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 30), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")));
invoiceChecker.checkInvoice(account.getId(), 4, callContext,
// New invoice for the partial period since we unblocked on the 1st and so are missing the 31 july
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 31), new LocalDate(2012, 8, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 31), new LocalDate(2012, 7, 31), InvoiceItemType.CBA_ADJ, new BigDecimal("-169.32")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 31), new LocalDate(2012, 8, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")));
+
+ invoiceChecker.checkInvoice(account.getId(), 5, callContext,
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 10), new LocalDate(2012, 7, 31), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-169.32")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 31), new LocalDate(2012, 7, 31), InvoiceItemType.CBA_ADJ, new BigDecimal("169.32")));
// Move one month ahead, and check if we get the next invoice
addDaysAndCheckForCompletion(31, NextEvent.INVOICE, NextEvent.PAYMENT);
- invoiceChecker.checkInvoice(account.getId(), 5, callContext,
+ invoiceChecker.checkInvoice(account.getId(), 6, callContext,
// New invoice for the partial period since we unblocked on the 1st and so are missing the 31 july
new ExpectedInvoiceItemCheck(new LocalDate(2012, 8, 31), new LocalDate(2012, 9, 30), InvoiceItemType.RECURRING, new BigDecimal("249.95")));
@@ -302,7 +305,7 @@ public class TestOverdueIntegration extends TestOverdueBase {
assertEquals(invoiceUserApi.getAccountBalance(account.getId(), callContext).compareTo(BigDecimal.ZERO), 0);
}
- @Test(groups = "slow", description = "Test overdue stages and return to clear after CTD", enabled=false)
+ @Test(groups = "slow", description = "Test overdue stages and return to clear after CTD", enabled = false)
public void testOverdueStages3() throws Exception {
clock.setTime(new DateTime(2012, 5, 1, 0, 3, 42, 0));
@@ -382,14 +385,14 @@ public class TestOverdueIntegration extends TestOverdueBase {
invoiceChecker.checkInvoice(account.getId(), 3, callContext,
// New invoice for the partial period since we unblocked on the 1st and so are missing the 31 july
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 30), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 10), new LocalDate(2012, 7, 31), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-169.32")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 8, 1), new LocalDate(2012, 8, 1), InvoiceItemType.CBA_ADJ, new BigDecimal("169.32")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 30), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")));
invoiceChecker.checkInvoice(account.getId(), 4, callContext,
// New invoice for the partial period since we unblocked on the 1st and so are missing the 31 july
new ExpectedInvoiceItemCheck(new LocalDate(2012, 8, 1), new LocalDate(2012, 8, 31), InvoiceItemType.RECURRING, new BigDecimal("241.89")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 8, 1), new LocalDate(2012, 8, 1), InvoiceItemType.CBA_ADJ, new BigDecimal("-169.32")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 10), new LocalDate(2012, 7, 31), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-169.32")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 8, 1), new LocalDate(2012, 8, 1), InvoiceItemType.CBA_ADJ, new BigDecimal("-72.57")));
+
// Move one month ahead, and check if we get the next invoice
addDaysAndCheckForCompletion(30, NextEvent.INVOICE, NextEvent.PAYMENT);
@@ -406,7 +409,7 @@ public class TestOverdueIntegration extends TestOverdueBase {
// This test is similar to the previous one except that instead of moving the clock to check we will get the next invoice
// at the end, we carry a change of plan.
//
- @Test(groups = "slow", description = "Test overdue stages and follow with an immediate change of plan", enabled=false)
+ @Test(groups = "slow", description = "Test overdue stages and follow with an immediate change of plan", enabled = false)
public void testOverdueStagesFollowedWithImmediateChange1() throws Exception {
clock.setTime(new DateTime(2012, 5, 1, 0, 3, 42, 0));
@@ -469,26 +472,27 @@ public class TestOverdueIntegration extends TestOverdueBase {
allowPaymentsAndResetOverdueToClearByPayingAllUnpaidInvoices(false);
invoiceChecker.checkInvoice(account.getId(), 3, callContext,
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 30), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 30), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")));
+
+ invoiceChecker.checkInvoice(account.getId(), 4, callContext,
new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 10), new LocalDate(2012, 7, 23), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-104.82")),
new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 23), new LocalDate(2012, 7, 23), InvoiceItemType.CBA_ADJ, new BigDecimal("104.82")));
// Do an upgrade now
checkChangePlanWithOverdueState(baseEntitlement, false, false);
- invoiceChecker.checkRepairedInvoice(account.getId(), 3, callContext,
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 30), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 10), new LocalDate(2012, 7, 23), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-104.82")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 23), new LocalDate(2012, 7, 23), InvoiceItemType.CBA_ADJ, new BigDecimal("104.82")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 23), new LocalDate(2012, 7, 31), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-64.50")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 23), new LocalDate(2012, 7, 23), InvoiceItemType.CBA_ADJ, new BigDecimal("64.50")));
-
invoiceChecker.checkInvoice(account.getId(), 4, callContext,
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 10), new LocalDate(2012, 7, 23), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-104.82")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 23), new LocalDate(2012, 7, 23), InvoiceItemType.CBA_ADJ, new BigDecimal("104.82")));
+
+
+
+
+ invoiceChecker.checkInvoice(account.getId(), 5, callContext,
// Item for the upgraded recurring plan
new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 23), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("154.83")),
- // Repair for upgrade
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 23), new LocalDate(2012, 7, 23), InvoiceItemType.CBA_ADJ, new BigDecimal("-154.83")));
-
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 23), new LocalDate(2012, 7, 31), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-64.50")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 23), new LocalDate(2012, 7, 23), InvoiceItemType.CBA_ADJ, new BigDecimal("-90.33")));
invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 7, 31), callContext);
// Verify the account balance:
@@ -545,7 +549,9 @@ public class TestOverdueIntegration extends TestOverdueBase {
invoiceChecker.checkInvoice(account.getId(), 2, callContext,
// New invoice for the part that was unblocked up to the BCD
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 31), new LocalDate(2013, 5, 31), InvoiceItemType.RECURRING, new BigDecimal("2399.95")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 31), new LocalDate(2013, 5, 31), InvoiceItemType.RECURRING, new BigDecimal("2399.95")));
+
+ invoiceChecker.checkInvoice(account.getId(), 3, callContext,
new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 10), new LocalDate(2012, 7, 23), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-85.4588")),
new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 31), new LocalDate(2013, 5, 31), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-1998.9012")),
new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 23), new LocalDate(2012, 7, 23), InvoiceItemType.CBA_ADJ, new BigDecimal("2084.36")));
@@ -553,27 +559,25 @@ public class TestOverdueIntegration extends TestOverdueBase {
// Move to 2012, 7, 31 and Make a change of plan
addDaysAndCheckForCompletion(8, NextEvent.INVOICE, NextEvent.PAYMENT);
- invoiceChecker.checkInvoice(account.getId(), 3, callContext,
+ invoiceChecker.checkInvoice(account.getId(), 4, callContext,
// New invoice for the part that was unblocked up to the BCD
new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 31), new LocalDate(2013, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("2399.95")));
checkChangePlanWithOverdueState(baseEntitlement, false, false);
- invoiceChecker.checkRepairedInvoice(account.getId(), 3, callContext,
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 31), new LocalDate(2013, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("2399.95")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 31), new LocalDate(2013, 7, 31), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-2399.95")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 31), new LocalDate(2012, 7, 31), InvoiceItemType.CBA_ADJ, new BigDecimal("2399.95")));
+ invoiceChecker.checkRepairedInvoice(account.getId(), 4, callContext,
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 31), new LocalDate(2013, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("2399.95")));
- invoiceChecker.checkInvoice(account.getId(), 4, callContext,
+ invoiceChecker.checkInvoice(account.getId(), 5, callContext,
// Item for the upgraded recurring plan
new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 31), new LocalDate(2012, 8, 31), InvoiceItemType.RECURRING, new BigDecimal("599.95")),
- // Credits consumed
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 31), new LocalDate(2012, 7, 31), InvoiceItemType.CBA_ADJ, new BigDecimal("-599.95")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 31), new LocalDate(2013, 7, 31), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-2399.95")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 31), new LocalDate(2012, 7, 31), InvoiceItemType.CBA_ADJ, new BigDecimal("1800")));
invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 8, 31), callContext);
assertEquals(invoiceUserApi.getAccountBalance(account.getId(), callContext).compareTo(new BigDecimal("-1800")), 0);
}
- @Test(groups = "slow", description = "Test overdue stages with missing payment method", enabled=false)
+ @Test(groups = "slow", description = "Test overdue stages with missing payment method", enabled = false)
public void testOverdueStateIfNoPaymentMethod() throws Exception {
// This test is similar to the previous one - but there is no default payment method on the account, so there
// won't be any payment retry
@@ -644,7 +648,9 @@ public class TestOverdueIntegration extends TestOverdueBase {
invoiceChecker.checkInvoice(account.getId(), 3, callContext,
// Item for the upgraded recurring plan
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 30), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 30), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")));
+
+ invoiceChecker.checkInvoice(account.getId(), 4, callContext,
new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 15), new LocalDate(2012, 7, 25), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-80.63")),
new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 25), new LocalDate(2012, 7, 25), InvoiceItemType.CBA_ADJ, new BigDecimal("80.63")));
@@ -652,23 +658,20 @@ public class TestOverdueIntegration extends TestOverdueBase {
checkChangePlanWithOverdueState(baseEntitlement, false, false);
- invoiceChecker.checkRepairedInvoice(account.getId(), 3, callContext,
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 30), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 15), new LocalDate(2012, 7, 25), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-80.63")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 25), new LocalDate(2012, 7, 25), InvoiceItemType.CBA_ADJ, new BigDecimal("80.63")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 25), new LocalDate(2012, 7, 31), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-48.38")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 25), new LocalDate(2012, 7, 25), InvoiceItemType.CBA_ADJ, new BigDecimal("48.38")));
-
invoiceChecker.checkInvoice(account.getId(), 4, callContext,
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 15), new LocalDate(2012, 7, 25), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-80.63")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 25), new LocalDate(2012, 7, 25), InvoiceItemType.CBA_ADJ, new BigDecimal("80.63")));
+
+ invoiceChecker.checkInvoice(account.getId(), 5, callContext,
new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 25), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("116.12")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 25), new LocalDate(2012, 7, 25), InvoiceItemType.CBA_ADJ, new BigDecimal("-116.12")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 25), new LocalDate(2012, 7, 31), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-48.38")));
invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 7, 31), callContext);
assertEquals(invoiceUserApi.getAccountBalance(account.getId(), callContext).compareTo(new BigDecimal("-12.89")), 0);
}
- @Test(groups = "slow", description = "Test overdue from non paid external charge", enabled=false)
+ @Test(groups = "slow", description = "Test overdue from non paid external charge", enabled = false)
public void testShouldBeInOverdueAfterExternalCharge() throws Exception {
clock.setTime(new DateTime(2012, 5, 1, 0, 3, 42, 0));
@@ -712,7 +715,7 @@ public class TestOverdueIntegration extends TestOverdueBase {
checkODState(DefaultBlockingState.CLEAR_STATE_NAME);
}
- @Test(groups = "slow", description = "Test overdue after refund with no adjustment", enabled=false)
+ @Test(groups = "slow", description = "Test overdue after refund with no adjustment", enabled = false)
public void testShouldBeInOverdueAfterRefundWithoutAdjustment() throws Exception {
clock.setTime(new DateTime(2012, 5, 1, 0, 3, 42, 0));
@@ -755,7 +758,7 @@ public class TestOverdueIntegration extends TestOverdueBase {
checkChangePlanWithOverdueState(baseEntitlement, true, true);
}
- @Test(groups = "slow", description = "Test overdue after chargeback", enabled=false)
+ @Test(groups = "slow", description = "Test overdue after chargeback", enabled = false)
public void testShouldBeInOverdueAfterChargeback() throws Exception {
clock.setTime(new DateTime(2012, 5, 1, 0, 3, 42, 0));
@@ -799,7 +802,7 @@ public class TestOverdueIntegration extends TestOverdueBase {
checkChangePlanWithOverdueState(baseEntitlement, true, true);
}
- @Test(groups = "slow", description = "Test overdue clear after external payment", enabled=false)
+ @Test(groups = "slow", description = "Test overdue clear after external payment", enabled = false)
public void testOverdueStateShouldClearAfterExternalPayment() throws Exception {
clock.setTime(new DateTime(2012, 5, 1, 0, 3, 42, 0));
@@ -845,7 +848,7 @@ public class TestOverdueIntegration extends TestOverdueBase {
checkODState(DefaultBlockingState.CLEAR_STATE_NAME);
}
- @Test(groups = "slow", description = "Test overdue clear after item adjustment", enabled=false)
+ @Test(groups = "slow", description = "Test overdue clear after item adjustment", enabled = false)
public void testOverdueStateShouldClearAfterCreditOrInvoiceItemAdjustment() throws Exception {
clock.setTime(new DateTime(2012, 5, 1, 0, 3, 42, 0));
@@ -956,9 +959,9 @@ public class TestOverdueIntegration extends TestOverdueBase {
createPaymentAndCheckForCompletion(account, invoice, NextEvent.PAYMENT);
} else {
if (extraInvoice) {
- createPaymentAndCheckForCompletion(account, invoice, NextEvent.BLOCK, NextEvent.TAG, NextEvent.INVOICE_ADJUSTMENT, NextEvent.PAYMENT, NextEvent.INVOICE, NextEvent.PAYMENT);
+ createPaymentAndCheckForCompletion(account, invoice, NextEvent.BLOCK, NextEvent.TAG, NextEvent.PAYMENT, NextEvent.INVOICE, NextEvent.INVOICE, NextEvent.PAYMENT);
} else {
- createPaymentAndCheckForCompletion(account, invoice, NextEvent.BLOCK, NextEvent.TAG, NextEvent.INVOICE_ADJUSTMENT, NextEvent.PAYMENT);
+ createPaymentAndCheckForCompletion(account, invoice, NextEvent.BLOCK, NextEvent.TAG, NextEvent.INVOICE, NextEvent.PAYMENT);
}
}
}
diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/overdue/TestOverdueWithSubscriptionCancellation.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/overdue/TestOverdueWithSubscriptionCancellation.java
index 952d549..dc706e9 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/overdue/TestOverdueWithSubscriptionCancellation.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/overdue/TestOverdueWithSubscriptionCancellation.java
@@ -97,7 +97,7 @@ public class TestOverdueWithSubscriptionCancellation extends TestOverdueBase {
// DAY 36 -- RIGHT AFTER OD1 (two block events, for the cancellation and the OD1 state)
// One BLOCK event is for the overdue state transition
// The 2 other BLOCK are for the entitlement blocking states for both base plan and addOn2
- addDaysAndCheckForCompletion(6, NextEvent.BLOCK, NextEvent.BLOCK, NextEvent.BLOCK, NextEvent.CANCEL, NextEvent.CANCEL, NextEvent.INVOICE_ADJUSTMENT);
+ addDaysAndCheckForCompletion(6, NextEvent.BLOCK, NextEvent.BLOCK, NextEvent.BLOCK, NextEvent.CANCEL, NextEvent.CANCEL, NextEvent.INVOICE);
// Should be in OD1
checkODState("OD1");
@@ -143,7 +143,7 @@ public class TestOverdueWithSubscriptionCancellation extends TestOverdueBase {
// DAY 36 -- RIGHT AFTER OD1 (two block events, for the cancellation and the OD1 state)
// One BLOCK event is for the overdue state transition
// The 2 other BLOCK are for the entitlement blocking states for both base plan and baseEntitlement3
- addDaysAndCheckForCompletion(6, NextEvent.BLOCK, NextEvent.BLOCK, NextEvent.BLOCK, NextEvent.CANCEL, NextEvent.CANCEL, NextEvent.INVOICE_ADJUSTMENT, NextEvent.INVOICE_ADJUSTMENT);
+ addDaysAndCheckForCompletion(6, NextEvent.BLOCK, NextEvent.BLOCK, NextEvent.BLOCK, NextEvent.CANCEL, NextEvent.CANCEL, NextEvent.INVOICE, NextEvent.INVOICE);
// Should be in OD1
checkODState("OD1");
diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestBundleTransfer.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestBundleTransfer.java
index 29efba3..6a203b5 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestBundleTransfer.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestBundleTransfer.java
@@ -202,20 +202,24 @@ public class TestBundleTransfer extends TestIntegrationBase {
busHandler.pushExpectedEvent(NextEvent.CANCEL);
busHandler.pushExpectedEvent(NextEvent.TRANSFER);
busHandler.pushExpectedEvent(NextEvent.INVOICE);
- busHandler.pushExpectedEvent(NextEvent.INVOICE_ADJUSTMENT);
+ busHandler.pushExpectedEvent(NextEvent.INVOICE);
busHandler.pushExpectedEvent(NextEvent.PAYMENT);
transferApi.transferBundle(account.getId(), newAccount.getId(), "externalKey", clock.getUTCNow(), false, true, callContext);
assertListenerStatus();
List<Invoice> invoices = invoiceUserApi.getInvoicesByAccount(account.getId(), callContext);
- assertEquals(invoices.size(), 2);
+ assertEquals(invoices.size(), 3);
- // CHECK OLD ACCOUNTS ITEMS
+ // CHECK OLD AND NEW ACCOUNTS ITEMS
ImmutableList<ExpectedInvoiceItemCheck> toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 5, 9), InvoiceItemType.RECURRING, new BigDecimal("66.65")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 5, 9), InvoiceItemType.RECURRING, new BigDecimal("66.65")));
+ invoiceChecker.checkInvoice(invoices.get(1).getId(), callContext, toBeChecked);
+
+
+ toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 3), new LocalDate(2012, 5, 9), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-49.99")),
new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 3), new LocalDate(2012, 5, 3), InvoiceItemType.CBA_ADJ, new BigDecimal("49.99")));
- invoiceChecker.checkInvoice(invoices.get(1).getId(), callContext, toBeChecked);
+ invoiceChecker.checkInvoice(invoices.get(2).getId(), callContext, toBeChecked);
// CHECK NEW ACCOUNT ITEMS
invoices = invoiceUserApi.getInvoicesByAccount(newAccount.getId(), callContext);
@@ -277,14 +281,16 @@ public class TestBundleTransfer extends TestIntegrationBase {
final DateTime now = clock.getUTCNow();
final LocalDate transferDay = now.toLocalDate();
- busHandler.pushExpectedEvents(NextEvent.CANCEL, NextEvent.CANCEL, NextEvent.BLOCK, NextEvent.BLOCK, NextEvent.TRANSFER, NextEvent.TRANSFER, NextEvent.INVOICE_ADJUSTMENT, NextEvent.INVOICE, NextEvent.PAYMENT);
+ busHandler.pushExpectedEvents(NextEvent.CANCEL, NextEvent.CANCEL, NextEvent.BLOCK, NextEvent.BLOCK, NextEvent.TRANSFER, NextEvent.TRANSFER, NextEvent.INVOICE, NextEvent.INVOICE, NextEvent.PAYMENT);
final UUID newBundleId = entitlementApi.transferEntitlements(account.getId(), newAccount.getId(), bundleExternalKey, transferDay, callContext);
assertListenerStatus();
- // Check the last invoice on the old account
+ // Check the last 2 invoices on the old account
invoiceChecker.checkInvoice(account.getId(), 4, callContext,
new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 1), new LocalDate(2012, 7, 1), InvoiceItemType.RECURRING, new BigDecimal("999.95")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 1), new LocalDate(2012, 7, 1), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 1), new LocalDate(2012, 7, 1), InvoiceItemType.RECURRING, new BigDecimal("249.95")));
+
+ invoiceChecker.checkInvoice(account.getId(), 5, callContext,
new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 1), new LocalDate(2012, 7, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-999.95")),
new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 1), new LocalDate(2012, 7, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-249.95")),
new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 1), new LocalDate(2012, 6, 1), InvoiceItemType.CBA_ADJ, new BigDecimal("1249.90")));
diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegration.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegration.java
index 885a8e0..11e9f1b 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegration.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegration.java
@@ -81,14 +81,18 @@ public class TestIntegration extends TestIntegrationBase {
// CANCEL BP ON THE SAME DAY (we should have two cancellations, BP and AO)
// There is no invoice created as we only adjust the previous invoice.
//
- cancelEntitlementAndCheckForCompletion(bpSubscription, clock.getUTCNow(), NextEvent.BLOCK, NextEvent.BLOCK, NextEvent.CANCEL, NextEvent.CANCEL, NextEvent.INVOICE_ADJUSTMENT);
+ cancelEntitlementAndCheckForCompletion(bpSubscription, clock.getUTCNow(), NextEvent.BLOCK, NextEvent.BLOCK, NextEvent.CANCEL, NextEvent.CANCEL, NextEvent.INVOICE);
invoiceChecker.checkInvoice(account.getId(), 2,
- callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 4, 1), new LocalDate(2012, 5, 1), InvoiceItemType.RECURRING, new BigDecimal("399.95")),
+ callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 4, 1), new LocalDate(2012, 5, 1), InvoiceItemType.RECURRING, new BigDecimal("399.95")));
+
+ invoiceChecker.checkInvoice(account.getId(), 3,
+ callContext,
// The second invoice should be adjusted for the AO (we paid for the full period) and since we paid we should also see a CBA
new ExpectedInvoiceItemCheck(new LocalDate(2012, 4, 1), new LocalDate(2012, 5, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-399.95")),
new ExpectedInvoiceItemCheck(new LocalDate(2012, 4, 1), new LocalDate(2012, 4, 1), InvoiceItemType.CBA_ADJ, new BigDecimal("399.95")));
checkNoMoreInvoiceToGenerate(account);
+
}
@Test(groups = "slow")
@@ -534,12 +538,14 @@ public class TestIntegration extends TestIntegrationBase {
// PAUSE THE ENTITLEMENT
DefaultEntitlement entitlement = (DefaultEntitlement) entitlementApi.getEntitlementForId(baseEntitlement.getId(), callContext);
busHandler.pushExpectedEvents(NextEvent.PAUSE, NextEvent.BLOCK);
- busHandler.pushExpectedEvent(NextEvent.INVOICE_ADJUSTMENT);
+ busHandler.pushExpectedEvent(NextEvent.INVOICE);
entitlementApi.pause(entitlement.getBundleId(), clock.getUTCNow().toLocalDate(), callContext);
assertListenerStatus();
invoiceChecker.checkInvoice(account.getId(), 2, callContext,
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 3, 2), new LocalDate(2012, 4, 2), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 3, 2), new LocalDate(2012, 4, 2), InvoiceItemType.RECURRING, new BigDecimal("249.95")));
+
+ invoiceChecker.checkInvoice(account.getId(), 3, callContext,
new ExpectedInvoiceItemCheck(new LocalDate(2012, 3, 4), new LocalDate(2012, 4, 2), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-233.82")),
new ExpectedInvoiceItemCheck(new LocalDate(2012, 3, 4), new LocalDate(2012, 3, 4), InvoiceItemType.CBA_ADJ, new BigDecimal("233.82")));
@@ -554,7 +560,7 @@ public class TestIntegration extends TestIntegrationBase {
entitlementApi.resume(entitlement.getBundleId(), clock.getUTCNow().toLocalDate(), callContext);
assertListenerStatus();
- invoiceChecker.checkInvoice(account.getId(), 3, callContext,
+ invoiceChecker.checkInvoice(account.getId(), 4, callContext,
new ExpectedInvoiceItemCheck(new LocalDate(2012, 4, 5), new LocalDate(2012, 5, 2), InvoiceItemType.RECURRING, new BigDecimal("224.96")),
new ExpectedInvoiceItemCheck(new LocalDate(2012, 4, 5), new LocalDate(2012, 4, 5), InvoiceItemType.CBA_ADJ, new BigDecimal("-224.96")));
diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegrationBase.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegrationBase.java
index ada01fe..02c99b0 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegrationBase.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegrationBase.java
@@ -128,8 +128,8 @@ public class TestIntegrationBase extends BeatrixTestSuiteWithEmbeddedDB {
}
@Override
- public String getPaymentControlPluginName() {
- return InvoicePaymentControlPluginApi.PLUGIN_NAME;
+ public List<String> getPaymentControlPluginNames() {
+ return ImmutableList.<String>of(InvoicePaymentControlPluginApi.PLUGIN_NAME);
}
};
@@ -140,8 +140,8 @@ public class TestIntegrationBase extends BeatrixTestSuiteWithEmbeddedDB {
}
@Override
- public String getPaymentControlPluginName() {
- return InvoicePaymentControlPluginApi.PLUGIN_NAME;
+ public List<String> getPaymentControlPluginNames() {
+ return ImmutableList.<String>of(InvoicePaymentControlPluginApi.PLUGIN_NAME);
}
};
diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegrationInvoiceWithRepairLogic.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegrationInvoiceWithRepairLogic.java
index d721b15..29229a4 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegrationInvoiceWithRepairLogic.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegrationInvoiceWithRepairLogic.java
@@ -127,7 +127,7 @@ public class TestIntegrationInvoiceWithRepairLogic extends TestIntegrationBase {
//
// Force a plan change
//
- changeEntitlementAndCheckForCompletion(bpEntitlement, "Blowdart", term, BillingActionPolicy.IMMEDIATE, NextEvent.CHANGE, NextEvent.INVOICE, NextEvent.INVOICE_ADJUSTMENT);
+ changeEntitlementAndCheckForCompletion(bpEntitlement, "Blowdart", term, BillingActionPolicy.IMMEDIATE, NextEvent.CHANGE, NextEvent.INVOICE);
invoices = invoiceUserApi.getInvoicesByAccount(account.getId(), callContext);
assertEquals(invoices.size(), 3);
@@ -139,16 +139,15 @@ public class TestIntegrationInvoiceWithRepairLogic extends TestIntegrationBase {
new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 6, 1), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 2), new LocalDate(2012, 5, 2), InvoiceItemType.ITEM_ADJ, new BigDecimal("-10")),
// TODO PIERRE The cba start_date/end_date are created using the callcontext
- new ExpectedInvoiceItemCheck(callContext.getCreatedDate().toLocalDate(), callContext.getCreatedDate().toLocalDate(), InvoiceItemType.CBA_ADJ, new BigDecimal("10")),
- // The pro-rated piece is ~ 249.95 - (249.95 / 31) ~ 241.88. However we adjusted the item so max available amount is 249.95 - 10 = 239.95.
- // So we consume all of it since max amount is less than 241.88.
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 2), new LocalDate(2012, 6, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-239.95")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 2), new LocalDate(2012, 5, 2), InvoiceItemType.CBA_ADJ, new BigDecimal("239.95")));
+ new ExpectedInvoiceItemCheck(callContext.getCreatedDate().toLocalDate(), callContext.getCreatedDate().toLocalDate(), InvoiceItemType.CBA_ADJ, new BigDecimal("10")));
invoiceChecker.checkInvoice(invoices.get(1).getId(), callContext, toBeChecked);
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 2), new LocalDate(2012, 6, 1), InvoiceItemType.RECURRING, new BigDecimal("9.63")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 2), new LocalDate(2012, 5, 2), InvoiceItemType.CBA_ADJ, new BigDecimal("-9.63")));
+ // The pro-rated piece is ~ 249.95 - (249.95 / 31) ~ 241.88. However we adjusted the item so max available amount is 249.95 - 10 = 239.95.
+ // So we consume all of it since max amount is less than 241.88.
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 2), new LocalDate(2012, 6, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-239.95")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 2), new LocalDate(2012, 5, 2), InvoiceItemType.CBA_ADJ, new BigDecimal("230.32")));
invoiceChecker.checkInvoice(invoices.get(2).getId(), callContext, toBeChecked);
checkNoMoreInvoiceToGenerate(account);
@@ -227,7 +226,7 @@ public class TestIntegrationInvoiceWithRepairLogic extends TestIntegrationBase {
//
// Move the clock to 2012-05-07
clock.addDays(5);
- changeEntitlementAndCheckForCompletion(bpEntitlement, "Blowdart", term, BillingActionPolicy.IMMEDIATE, NextEvent.CHANGE, NextEvent.INVOICE, NextEvent.INVOICE_ADJUSTMENT);
+ changeEntitlementAndCheckForCompletion(bpEntitlement, "Blowdart", term, BillingActionPolicy.IMMEDIATE, NextEvent.CHANGE, NextEvent.INVOICE);
invoices = invoiceUserApi.getInvoicesByAccount(account.getId(), callContext);
assertEquals(invoices.size(), 4);
@@ -241,14 +240,13 @@ public class TestIntegrationInvoiceWithRepairLogic extends TestIntegrationBase {
invoiceChecker.checkInvoice(invoices.get(1).getId(), callContext, toBeChecked);
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 6, 1), InvoiceItemType.RECURRING, new BigDecimal("599.95")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 7), new LocalDate(2012, 6, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-483.83")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 7), new LocalDate(2012, 5, 7), InvoiceItemType.CBA_ADJ, new BigDecimal("483.83")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 6, 1), InvoiceItemType.RECURRING, new BigDecimal("599.95")));
invoiceChecker.checkInvoice(invoices.get(2).getId(), callContext, toBeChecked);
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 7), new LocalDate(2012, 6, 1), InvoiceItemType.RECURRING, new BigDecimal("8.02")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 7), new LocalDate(2012, 5, 7), InvoiceItemType.CBA_ADJ, new BigDecimal("-8.02")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 7), new LocalDate(2012, 6, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-483.83")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 7), new LocalDate(2012, 5, 7), InvoiceItemType.CBA_ADJ, new BigDecimal("475.81")));
invoiceChecker.checkInvoice(invoices.get(3).getId(), callContext, toBeChecked);
//
@@ -256,7 +254,7 @@ public class TestIntegrationInvoiceWithRepairLogic extends TestIntegrationBase {
//
// Move the clock to 2012-05-08
clock.addDays(1);
- changeEntitlementAndCheckForCompletion(bpEntitlement, "Pistol", term, BillingActionPolicy.IMMEDIATE, NextEvent.CHANGE, NextEvent.INVOICE, NextEvent.INVOICE_ADJUSTMENT);
+ changeEntitlementAndCheckForCompletion(bpEntitlement, "Pistol", term, BillingActionPolicy.IMMEDIATE, NextEvent.CHANGE, NextEvent.INVOICE);
invoices = invoiceUserApi.getInvoicesByAccount(account.getId(), callContext);
assertEquals(invoices.size(), 5);
@@ -270,21 +268,19 @@ public class TestIntegrationInvoiceWithRepairLogic extends TestIntegrationBase {
invoiceChecker.checkInvoice(invoices.get(1).getId(), callContext, toBeChecked);
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 6, 1), InvoiceItemType.RECURRING, new BigDecimal("599.95")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 7), new LocalDate(2012, 6, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-483.83")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 7), new LocalDate(2012, 5, 7), InvoiceItemType.CBA_ADJ, new BigDecimal("483.83")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 6, 1), InvoiceItemType.RECURRING, new BigDecimal("599.95")));
invoiceChecker.checkInvoice(invoices.get(2).getId(), callContext, toBeChecked);
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 7), new LocalDate(2012, 6, 1), InvoiceItemType.RECURRING, new BigDecimal("8.02")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 7), new LocalDate(2012, 5, 7), InvoiceItemType.CBA_ADJ, new BigDecimal("-8.02")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 8), new LocalDate(2012, 6, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-7.70")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 8), new LocalDate(2012, 5, 8), InvoiceItemType.CBA_ADJ, new BigDecimal("7.70")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 7), new LocalDate(2012, 6, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-483.83")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 7), new LocalDate(2012, 5, 7), InvoiceItemType.CBA_ADJ, new BigDecimal("475.81")));
invoiceChecker.checkInvoice(invoices.get(3).getId(), callContext, toBeChecked);
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 8), new LocalDate(2012, 6, 1), InvoiceItemType.RECURRING, new BigDecimal("23.19")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 8), new LocalDate(2012, 5, 8), InvoiceItemType.CBA_ADJ, new BigDecimal("-23.19")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 8), new LocalDate(2012, 6, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-7.70")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 8), new LocalDate(2012, 5, 8), InvoiceItemType.CBA_ADJ, new BigDecimal("-15.49")));
invoiceChecker.checkInvoice(invoices.get(4).getId(), callContext, toBeChecked);
//
@@ -307,21 +303,19 @@ public class TestIntegrationInvoiceWithRepairLogic extends TestIntegrationBase {
invoiceChecker.checkInvoice(invoices.get(1).getId(), callContext, toBeChecked);
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 6, 1), InvoiceItemType.RECURRING, new BigDecimal("599.95")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 7), new LocalDate(2012, 6, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-483.83")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 7), new LocalDate(2012, 5, 7), InvoiceItemType.CBA_ADJ, new BigDecimal("483.83")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 6, 1), InvoiceItemType.RECURRING, new BigDecimal("599.95")));
invoiceChecker.checkInvoice(invoices.get(2).getId(), callContext, toBeChecked);
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 7), new LocalDate(2012, 6, 1), InvoiceItemType.RECURRING, new BigDecimal("8.02")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 7), new LocalDate(2012, 5, 7), InvoiceItemType.CBA_ADJ, new BigDecimal("-8.02")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 8), new LocalDate(2012, 6, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-7.70")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 8), new LocalDate(2012, 5, 8), InvoiceItemType.CBA_ADJ, new BigDecimal("7.70")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 7), new LocalDate(2012, 6, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-483.83")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 7), new LocalDate(2012, 5, 7), InvoiceItemType.CBA_ADJ, new BigDecimal("475.81")));
invoiceChecker.checkInvoice(invoices.get(3).getId(), callContext, toBeChecked);
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 8), new LocalDate(2012, 6, 1), InvoiceItemType.RECURRING, new BigDecimal("23.19")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 8), new LocalDate(2012, 5, 8), InvoiceItemType.CBA_ADJ, new BigDecimal("-23.19")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 8), new LocalDate(2012, 6, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-7.70")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 8), new LocalDate(2012, 5, 8), InvoiceItemType.CBA_ADJ, new BigDecimal("-15.49")));
invoiceChecker.checkInvoice(invoices.get(4).getId(), callContext, toBeChecked);
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
@@ -349,21 +343,19 @@ public class TestIntegrationInvoiceWithRepairLogic extends TestIntegrationBase {
invoiceChecker.checkInvoice(invoices.get(1).getId(), callContext, toBeChecked);
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 6, 1), InvoiceItemType.RECURRING, new BigDecimal("599.95")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 7), new LocalDate(2012, 6, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-483.83")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 7), new LocalDate(2012, 5, 7), InvoiceItemType.CBA_ADJ, new BigDecimal("483.83")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 6, 1), InvoiceItemType.RECURRING, new BigDecimal("599.95")));
invoiceChecker.checkInvoice(invoices.get(2).getId(), callContext, toBeChecked);
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 7), new LocalDate(2012, 6, 1), InvoiceItemType.RECURRING, new BigDecimal("8.02")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 7), new LocalDate(2012, 5, 7), InvoiceItemType.CBA_ADJ, new BigDecimal("-8.02")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 8), new LocalDate(2012, 6, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-7.70")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 8), new LocalDate(2012, 5, 8), InvoiceItemType.CBA_ADJ, new BigDecimal("7.70")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 7), new LocalDate(2012, 6, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-483.83")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 7), new LocalDate(2012, 5, 7), InvoiceItemType.CBA_ADJ, new BigDecimal("475.81")));
invoiceChecker.checkInvoice(invoices.get(3).getId(), callContext, toBeChecked);
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 8), new LocalDate(2012, 6, 1), InvoiceItemType.RECURRING, new BigDecimal("23.19")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 8), new LocalDate(2012, 5, 8), InvoiceItemType.CBA_ADJ, new BigDecimal("-23.19")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 8), new LocalDate(2012, 6, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-7.70")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 8), new LocalDate(2012, 5, 8), InvoiceItemType.CBA_ADJ, new BigDecimal("-15.49")));
invoiceChecker.checkInvoice(invoices.get(4).getId(), callContext, toBeChecked);
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
@@ -417,7 +409,7 @@ public class TestIntegrationInvoiceWithRepairLogic extends TestIntegrationBase {
//
// FORCE AN IMMEDIATE CHANGE OF THE BILLING PERIOD
//
- bpEntitlement = changeEntitlementAndCheckForCompletion(bpEntitlement, productName, BillingPeriod.MONTHLY, BillingActionPolicy.IMMEDIATE, NextEvent.CHANGE, NextEvent.INVOICE, NextEvent.INVOICE_ADJUSTMENT);
+ bpEntitlement = changeEntitlementAndCheckForCompletion(bpEntitlement, productName, BillingPeriod.MONTHLY, BillingActionPolicy.IMMEDIATE, NextEvent.CHANGE, NextEvent.INVOICE);
assertEquals(bpEntitlement.getSubscriptionBase().getCurrentPlan().getRecurringBillingPeriod(), BillingPeriod.MONTHLY);
@@ -425,14 +417,13 @@ public class TestIntegrationInvoiceWithRepairLogic extends TestIntegrationBase {
assertEquals(invoices.size(), 3);
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2013, 5, 1), InvoiceItemType.RECURRING, new BigDecimal("2399.95")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2013, 5, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-2399.95")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 5, 1), InvoiceItemType.CBA_ADJ, new BigDecimal("2399.95")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2013, 5, 1), InvoiceItemType.RECURRING, new BigDecimal("2399.95")));
invoiceChecker.checkInvoice(invoices.get(1).getId(), callContext, toBeChecked);
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 6, 1), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 5, 1), InvoiceItemType.CBA_ADJ, new BigDecimal("-249.95")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2013, 5, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-2399.95")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 5, 1), InvoiceItemType.CBA_ADJ, new BigDecimal("2150.")));
invoiceChecker.checkInvoice(invoices.get(2).getId(), callContext, toBeChecked);
busHandler.pushExpectedEvents(NextEvent.INVOICE);
@@ -443,14 +434,13 @@ public class TestIntegrationInvoiceWithRepairLogic extends TestIntegrationBase {
assertEquals(invoices.size(), 4);
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2013, 5, 1), InvoiceItemType.RECURRING, new BigDecimal("2399.95")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2013, 5, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-2399.95")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 5, 1), InvoiceItemType.CBA_ADJ, new BigDecimal("2399.95")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2013, 5, 1), InvoiceItemType.RECURRING, new BigDecimal("2399.95")));
invoiceChecker.checkInvoice(invoices.get(1).getId(), callContext, toBeChecked);
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 6, 1), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 5, 1), InvoiceItemType.CBA_ADJ, new BigDecimal("-249.95")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2013, 5, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-2399.95")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 5, 1), InvoiceItemType.CBA_ADJ, new BigDecimal("2150.")));
invoiceChecker.checkInvoice(invoices.get(2).getId(), callContext, toBeChecked);
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
@@ -466,14 +456,13 @@ public class TestIntegrationInvoiceWithRepairLogic extends TestIntegrationBase {
assertEquals(invoices.size(), 5);
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2013, 5, 1), InvoiceItemType.RECURRING, new BigDecimal("2399.95")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2013, 5, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-2399.95")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 5, 1), InvoiceItemType.CBA_ADJ, new BigDecimal("2399.95")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2013, 5, 1), InvoiceItemType.RECURRING, new BigDecimal("2399.95")));
invoiceChecker.checkInvoice(invoices.get(1).getId(), callContext, toBeChecked);
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 6, 1), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 5, 1), InvoiceItemType.CBA_ADJ, new BigDecimal("-249.95")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2013, 5, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-2399.95")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 5, 1), InvoiceItemType.CBA_ADJ, new BigDecimal("2150.")));
invoiceChecker.checkInvoice(invoices.get(2).getId(), callContext, toBeChecked);
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
@@ -524,17 +513,20 @@ public class TestIntegrationInvoiceWithRepairLogic extends TestIntegrationBase {
// Move clock to 2013-09-17
clock.addDays(30);
- busHandler.pushExpectedEvents(NextEvent.BLOCK, NextEvent.CANCEL, NextEvent.INVOICE_ADJUSTMENT);
+ busHandler.pushExpectedEvents(NextEvent.BLOCK, NextEvent.CANCEL, NextEvent.INVOICE);
bpEntitlement.cancelEntitlementWithPolicyOverrideBillingPolicy(EntitlementActionPolicy.IMMEDIATE, BillingActionPolicy.IMMEDIATE, callContext);
assertListenerStatus();
invoices = invoiceUserApi.getInvoicesByAccount(account.getId(), callContext);
- assertEquals(invoices.size(), 2);
+ assertEquals(invoices.size(), 3);
+ toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
+ new ExpectedInvoiceItemCheck(new LocalDate(2013, 8, 18), new LocalDate(2014, 8, 18), InvoiceItemType.RECURRING, new BigDecimal("2399.95")));
+ invoiceChecker.checkInvoice(invoices.get(1).getId(), callContext, toBeChecked);
+
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
- new ExpectedInvoiceItemCheck(new LocalDate(2013, 8, 18), new LocalDate(2014, 8, 18), InvoiceItemType.RECURRING, new BigDecimal("2399.95")),
new ExpectedInvoiceItemCheck(new LocalDate(2013, 9, 17), new LocalDate(2014, 8, 18), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-2202.69")),
new ExpectedInvoiceItemCheck(new LocalDate(2013, 9, 17), new LocalDate(2013, 9, 17), InvoiceItemType.CBA_ADJ, new BigDecimal("2202.69")));
- invoiceChecker.checkInvoice(invoices.get(1).getId(), callContext, toBeChecked);
+ invoiceChecker.checkInvoice(invoices.get(2).getId(), callContext, toBeChecked);
//
// ITEM ADJUSTMENT PRIOR TO DOING THE REPAIR
@@ -592,17 +584,20 @@ public class TestIntegrationInvoiceWithRepairLogic extends TestIntegrationBase {
// Move clock to 2013-09-17
clock.addDays(30);
- busHandler.pushExpectedEvents(NextEvent.BLOCK, NextEvent.CANCEL, NextEvent.INVOICE_ADJUSTMENT);
+ busHandler.pushExpectedEvents(NextEvent.BLOCK, NextEvent.CANCEL, NextEvent.INVOICE);
bpEntitlement.cancelEntitlementWithPolicyOverrideBillingPolicy(EntitlementActionPolicy.IMMEDIATE, BillingActionPolicy.IMMEDIATE, callContext);
assertListenerStatus();
invoices = invoiceUserApi.getInvoicesByAccount(account.getId(), callContext);
- assertEquals(invoices.size(), 2);
+ assertEquals(invoices.size(), 3);
+ toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
+ new ExpectedInvoiceItemCheck(new LocalDate(2013, 8, 18), new LocalDate(2014, 8, 18), InvoiceItemType.RECURRING, new BigDecimal("2399.95")));
+ invoiceChecker.checkInvoice(invoices.get(1).getId(), callContext, toBeChecked);
+
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
- new ExpectedInvoiceItemCheck(new LocalDate(2013, 8, 18), new LocalDate(2014, 8, 18), InvoiceItemType.RECURRING, new BigDecimal("2399.95")),
new ExpectedInvoiceItemCheck(new LocalDate(2013, 9, 17), new LocalDate(2014, 8, 18), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-2202.69")),
new ExpectedInvoiceItemCheck(new LocalDate(2013, 9, 17), new LocalDate(2013, 9, 17), InvoiceItemType.CBA_ADJ, new BigDecimal("2202.69")));
- invoiceChecker.checkInvoice(invoices.get(1).getId(), callContext, toBeChecked);
+ invoiceChecker.checkInvoice(invoices.get(2).getId(), callContext, toBeChecked);
//
// ITEM ADJUSTMENT PRIOR TO DOING THE REPAIR
diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegrationWithDifferentBillingPeriods.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegrationWithDifferentBillingPeriods.java
index 5334bfb..4cb1f2a 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegrationWithDifferentBillingPeriods.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegrationWithDifferentBillingPeriods.java
@@ -80,20 +80,18 @@ public class TestIntegrationWithDifferentBillingPeriods extends TestIntegrationB
//
clock.addDays(10);
- changeEntitlementAndCheckForCompletion(bpEntitlement, productName, BillingPeriod.ANNUAL, BillingActionPolicy.IMMEDIATE, NextEvent.CHANGE, NextEvent.INVOICE, NextEvent.INVOICE_ADJUSTMENT, NextEvent.PAYMENT);
+ changeEntitlementAndCheckForCompletion(bpEntitlement, productName, BillingPeriod.ANNUAL, BillingActionPolicy.IMMEDIATE, NextEvent.CHANGE, NextEvent.INVOICE, NextEvent.PAYMENT);
invoices = invoiceUserApi.getInvoicesByAccount(account.getId(), callContext);
assertEquals(invoices.size(), 3);
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 6, 1), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 12), new LocalDate(2012, 5, 12), InvoiceItemType.CBA_ADJ, new BigDecimal("161.26")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 12), new LocalDate(2012, 6, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-161.26")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 6, 1), InvoiceItemType.RECURRING, new BigDecimal("249.95")));
invoiceChecker.checkInvoice(invoices.get(1).getId(), callContext, toBeChecked);
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 12), new LocalDate(2013, 5, 1), InvoiceItemType.RECURRING, new BigDecimal("2327.62")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 12), new LocalDate(2012, 5, 12), InvoiceItemType.CBA_ADJ, new BigDecimal("-161.26")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 12), new LocalDate(2012, 6, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-161.26")));
invoiceChecker.checkInvoice(invoices.get(2).getId(), callContext, toBeChecked);
checkNoMoreInvoiceToGenerate(account);
@@ -137,20 +135,18 @@ public class TestIntegrationWithDifferentBillingPeriods extends TestIntegrationB
//
clock.addDays(10);
- changeEntitlementAndCheckForCompletion(bpEntitlement, productName, BillingPeriod.QUARTERLY, BillingActionPolicy.IMMEDIATE, NextEvent.CHANGE, NextEvent.INVOICE, NextEvent.INVOICE_ADJUSTMENT, NextEvent.PAYMENT);
+ changeEntitlementAndCheckForCompletion(bpEntitlement, productName, BillingPeriod.QUARTERLY, BillingActionPolicy.IMMEDIATE, NextEvent.CHANGE, NextEvent.INVOICE, NextEvent.PAYMENT);
invoices = invoiceUserApi.getInvoicesByAccount(account.getId(), callContext);
assertEquals(invoices.size(), 3);
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 6, 1), InvoiceItemType.RECURRING, new BigDecimal("29.95")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 12), new LocalDate(2012, 5, 12), InvoiceItemType.CBA_ADJ, new BigDecimal("19.32")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 12), new LocalDate(2012, 6, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-19.32")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 6, 1), InvoiceItemType.RECURRING, new BigDecimal("29.95")));
invoiceChecker.checkInvoice(invoices.get(1).getId(), callContext, toBeChecked);
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 12), new LocalDate(2012, 8, 1), InvoiceItemType.RECURRING, new BigDecimal("61.59")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 12), new LocalDate(2012, 5, 12), InvoiceItemType.CBA_ADJ, new BigDecimal("-19.32")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 12), new LocalDate(2012, 6, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-19.32")));
invoiceChecker.checkInvoice(invoices.get(2).getId(), callContext, toBeChecked);
// Move to 1020-08-01
@@ -200,18 +196,21 @@ public class TestIntegrationWithDifferentBillingPeriods extends TestIntegrationB
// 2012-5-12
clock.addDays(10);
- busHandler.pushExpectedEvents(NextEvent.PAUSE, NextEvent.BLOCK, NextEvent.INVOICE_ADJUSTMENT);
+ busHandler.pushExpectedEvents(NextEvent.PAUSE, NextEvent.BLOCK, NextEvent.INVOICE);
entitlementApi.pause(bpEntitlement.getBundleId(), clock.getUTCNow().toLocalDate(), callContext);
assertListenerStatus();
List<Invoice> invoices = invoiceUserApi.getInvoicesByAccount(account.getId(), callContext);
- assertEquals(invoices.size(), 2);
+ assertEquals(invoices.size(), 3);
ImmutableList<ExpectedInvoiceItemCheck> toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2013, 5, 1), InvoiceItemType.RECURRING, new BigDecimal("2399.95")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2013, 5, 1), InvoiceItemType.RECURRING, new BigDecimal("2399.95")));
+ invoiceChecker.checkInvoice(invoices.get(1).getId(), callContext, toBeChecked);
+
+ toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 12), new LocalDate(2012, 5, 12), InvoiceItemType.CBA_ADJ, new BigDecimal("2327.62")),
new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 12), new LocalDate(2013, 5, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-2327.62")));
- invoiceChecker.checkInvoice(invoices.get(1).getId(), callContext, toBeChecked);
+ invoiceChecker.checkInvoice(invoices.get(2).getId(), callContext, toBeChecked);
// 2012-6-4
clock.addDays(23);
@@ -221,23 +220,23 @@ public class TestIntegrationWithDifferentBillingPeriods extends TestIntegrationB
assertListenerStatus();
invoices = invoiceUserApi.getInvoicesByAccount(account.getId(), callContext);
- assertEquals(invoices.size(), 3);
+ assertEquals(invoices.size(), 4);
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 4), new LocalDate(2013, 6, 1), InvoiceItemType.RECURRING, new BigDecimal("2380.22")),
new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 4), new LocalDate(2012, 6, 4), InvoiceItemType.CBA_ADJ, new BigDecimal("-2327.62")));
- invoiceChecker.checkInvoice(invoices.get(2).getId(), callContext, toBeChecked);
+ invoiceChecker.checkInvoice(invoices.get(3).getId(), callContext, toBeChecked);
busHandler.pushExpectedEvents(NextEvent.INVOICE, NextEvent.PAYMENT);
clock.addYears(1);
assertListenerStatus();
invoices = invoiceUserApi.getInvoicesByAccount(account.getId(), callContext);
- assertEquals(invoices.size(), 4);
+ assertEquals(invoices.size(), 5);
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
new ExpectedInvoiceItemCheck(new LocalDate(2013, 6, 1), new LocalDate(2014, 6, 1), InvoiceItemType.RECURRING, new BigDecimal("2399.95")));
- invoiceChecker.checkInvoice(invoices.get(3).getId(), callContext, toBeChecked);
+ invoiceChecker.checkInvoice(invoices.get(4).getId(), callContext, toBeChecked);
checkNoMoreInvoiceToGenerate(account);
}
@@ -288,7 +287,7 @@ public class TestIntegrationWithDifferentBillingPeriods extends TestIntegrationB
assertListenerStatus();
- busHandler.pushExpectedEvents(NextEvent.TAG, NextEvent.INVOICE, NextEvent.PAYMENT, NextEvent.INVOICE_ADJUSTMENT);
+ busHandler.pushExpectedEvents(NextEvent.TAG, NextEvent.INVOICE, NextEvent.PAYMENT);
tagUserApi.removeTag(account.getId(), ObjectType.ACCOUNT, ControlTagType.AUTO_INVOICING_OFF.getId(), callContext);
assertListenerStatus();
@@ -297,14 +296,12 @@ public class TestIntegrationWithDifferentBillingPeriods extends TestIntegrationB
ImmutableList<ExpectedInvoiceItemCheck> toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2013, 5, 1), InvoiceItemType.RECURRING, new BigDecimal("2399.95")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 4), new LocalDate(2012, 6, 4), InvoiceItemType.CBA_ADJ, new BigDecimal("2327.62")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 12), new LocalDate(2013, 5, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-2327.62")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2013, 5, 1), InvoiceItemType.RECURRING, new BigDecimal("2399.95")));
invoiceChecker.checkInvoice(invoices.get(1).getId(), callContext, toBeChecked);
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 4), new LocalDate(2013, 6, 1), InvoiceItemType.RECURRING, new BigDecimal("2380.22")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 4), new LocalDate(2012, 6, 4), InvoiceItemType.CBA_ADJ, new BigDecimal("-2327.62")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 12), new LocalDate(2013, 5, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-2327.62")));
invoiceChecker.checkInvoice(invoices.get(2).getId(), callContext, toBeChecked);
busHandler.pushExpectedEvents(NextEvent.INVOICE, NextEvent.PAYMENT);
diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestSubscription.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestSubscription.java
index c48e416..8c73b48 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestSubscription.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestSubscription.java
@@ -79,39 +79,38 @@ public class TestSubscription extends TestIntegrationBase {
//
// FORCE AN IMMEDIATE CHANGE OF THE BILLING PERIOD
//
- changeEntitlementAndCheckForCompletion(bpEntitlement, productName, BillingPeriod.MONTHLY, BillingActionPolicy.IMMEDIATE, NextEvent.CHANGE, NextEvent.INVOICE, NextEvent.INVOICE_ADJUSTMENT);
+ changeEntitlementAndCheckForCompletion(bpEntitlement, productName, BillingPeriod.MONTHLY, BillingActionPolicy.IMMEDIATE, NextEvent.CHANGE, NextEvent.INVOICE);
invoices = invoiceUserApi.getInvoicesByAccount(account.getId(), callContext);
assertEquals(invoices.size(), 3);
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2013, 5, 1), InvoiceItemType.RECURRING, new BigDecimal("2399.95")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 11), new LocalDate(2013, 5, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-2334.20")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 11), new LocalDate(2012, 5, 11), InvoiceItemType.CBA_ADJ, new BigDecimal("2334.20")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2013, 5, 1), InvoiceItemType.RECURRING, new BigDecimal("2399.95")));
invoiceChecker.checkInvoice(invoices.get(1).getId(), callContext, toBeChecked);
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 11), new LocalDate(2012, 6, 1), InvoiceItemType.RECURRING, new BigDecimal("169.32")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 11), new LocalDate(2012, 5, 11), InvoiceItemType.CBA_ADJ, new BigDecimal("-169.32")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 11), new LocalDate(2013, 5, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-2334.20")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 11), new LocalDate(2012, 5, 11), InvoiceItemType.CBA_ADJ, new BigDecimal("2164.88")));
invoiceChecker.checkInvoice(invoices.get(2).getId(), callContext, toBeChecked);
//
// FORCE ANOTHER CHANGE
//
- changeEntitlementAndCheckForCompletion(bpEntitlement, productName, BillingPeriod.ANNUAL, BillingActionPolicy.IMMEDIATE, NextEvent.CHANGE, NextEvent.INVOICE, NextEvent.INVOICE_ADJUSTMENT);
+ changeEntitlementAndCheckForCompletion(bpEntitlement, productName, BillingPeriod.ANNUAL, BillingActionPolicy.IMMEDIATE, NextEvent.CHANGE, NextEvent.INVOICE);
invoices = invoiceUserApi.getInvoicesByAccount(account.getId(), callContext);
assertEquals(invoices.size(), 4);
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 11), new LocalDate(2012, 6, 1), InvoiceItemType.RECURRING, new BigDecimal("169.32")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 11), new LocalDate(2012, 5, 11), InvoiceItemType.CBA_ADJ, new BigDecimal("-169.32")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 11), new LocalDate(2012, 6, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-169.32")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 11), new LocalDate(2012, 5, 11), InvoiceItemType.CBA_ADJ, new BigDecimal("169.32")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 11), new LocalDate(2013, 5, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-2334.20")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 11), new LocalDate(2012, 5, 11), InvoiceItemType.CBA_ADJ, new BigDecimal("2164.88")));
invoiceChecker.checkInvoice(invoices.get(2).getId(), callContext, toBeChecked);
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 11), new LocalDate(2013, 5, 1), InvoiceItemType.RECURRING, new BigDecimal("2334.20")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 11), new LocalDate(2012, 5, 11), InvoiceItemType.CBA_ADJ, new BigDecimal("-2334.20")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 11), new LocalDate(2012, 6, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-169.32")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 11), new LocalDate(2012, 5, 11), InvoiceItemType.CBA_ADJ, new BigDecimal("-2164.88")));
invoiceChecker.checkInvoice(invoices.get(3).getId(), callContext, toBeChecked);
checkNoMoreInvoiceToGenerate(account);
@@ -156,18 +155,16 @@ public class TestSubscription extends TestIntegrationBase {
// FORCE AN IMMEDIATE CHANGE TO TEST THE CHANGE_OF_PLAN ALIGNMENT
// (Note that, the catalog is configured to use CHANGE_OF_PLAN when moving to that plan and Not CHANGE_OF_PRICELIST which has not been implement;
// this is a bit misleading since we are changing pricelist, but in that case pricelist change has no effect)
- changeEntitlementAndCheckForCompletion(bpEntitlement, "Assault-Rifle", BillingPeriod.ANNUAL, "rescue", BillingActionPolicy.IMMEDIATE, NextEvent.CHANGE, NextEvent.INVOICE, NextEvent.INVOICE_ADJUSTMENT, NextEvent.PAYMENT);
+ changeEntitlementAndCheckForCompletion(bpEntitlement, "Assault-Rifle", BillingPeriod.ANNUAL, "rescue", BillingActionPolicy.IMMEDIATE, NextEvent.CHANGE, NextEvent.INVOICE, NextEvent.PAYMENT);
invoices = invoiceUserApi.getInvoicesByAccount(account.getId(), callContext);
assertEquals(invoices.size(), 3);
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2013, 5, 1), InvoiceItemType.RECURRING, new BigDecimal("2399.95")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 11), new LocalDate(2013, 5, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-2334.20")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 11), new LocalDate(2012, 5, 11), InvoiceItemType.CBA_ADJ, new BigDecimal("2334.20")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2013, 5, 1), InvoiceItemType.RECURRING, new BigDecimal("2399.95")));
invoiceChecker.checkInvoice(invoices.get(1).getId(), callContext, toBeChecked);
toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 11), new LocalDate(2013, 5, 1), InvoiceItemType.RECURRING, new BigDecimal("5835.57")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 11), new LocalDate(2012, 5, 11), InvoiceItemType.CBA_ADJ, new BigDecimal("-2334.20")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 11), new LocalDate(2013, 5, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-2334.20")));
invoiceChecker.checkInvoice(invoices.get(2).getId(), callContext, toBeChecked);
checkNoMoreInvoiceToGenerate(account);
diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestWithTaxItems.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestWithTaxItems.java
index 43a8a9b..15fe6a1 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestWithTaxItems.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestWithTaxItems.java
@@ -147,18 +147,16 @@ public class TestWithTaxItems extends TestIntegrationBase {
testInvoicePluginApi.addTaxItem();
// Remove AUTO_INVOICING_OFF => Invoice + Payment
- remove_AUTO_INVOICING_OFF_Tag(account.getId(), NextEvent.INVOICE_ADJUSTMENT, NextEvent.INVOICE, NextEvent.PAYMENT);
+ remove_AUTO_INVOICING_OFF_Tag(account.getId(), NextEvent.INVOICE, NextEvent.PAYMENT);
invoiceChecker.checkInvoice(account.getId(), 2, callContext,
new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 6, 1), InvoiceItemType.RECURRING, new BigDecimal("29.95")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 6, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-29.95")),
new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 6, 1), InvoiceItemType.RECURRING, new BigDecimal("2.95")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 6, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-2.95")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 5, 1), InvoiceItemType.CBA_ADJ, new BigDecimal("32.90")),
new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), null, InvoiceItemType.TAX, new BigDecimal("1.0")));
invoiceChecker.checkInvoice(account.getId(), 3, callContext,
new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 6, 1), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 5, 1), InvoiceItemType.CBA_ADJ, new BigDecimal("-32.90")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 6, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-29.95")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 6, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-2.95")),
new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), null, InvoiceItemType.TAX, new BigDecimal("1.0")));
// Add AUTO_INVOICING_OFF and change to a higher plan on the same day
@@ -171,18 +169,18 @@ public class TestWithTaxItems extends TestIntegrationBase {
testInvoicePluginApi.addTaxItem();
// Remove AUTO_INVOICING_OFF => Invoice + Payment
- remove_AUTO_INVOICING_OFF_Tag(account.getId(), NextEvent.INVOICE_ADJUSTMENT, NextEvent.INVOICE, NextEvent.PAYMENT);
+ remove_AUTO_INVOICING_OFF_Tag(account.getId(), NextEvent.INVOICE, NextEvent.PAYMENT);
+
invoiceChecker.checkInvoice(account.getId(), 3, callContext,
new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 6, 1), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 6, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-249.95")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 5, 1), InvoiceItemType.CBA_ADJ, new BigDecimal("-32.90")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 5, 1), InvoiceItemType.CBA_ADJ, new BigDecimal("249.95")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 6, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-29.95")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 6, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-2.95")),
new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), null, InvoiceItemType.TAX, new BigDecimal("1.0")));
invoiceChecker.checkInvoice(account.getId(), 4, callContext,
new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 6, 1), InvoiceItemType.RECURRING, new BigDecimal("599.95")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 5, 1), InvoiceItemType.CBA_ADJ, new BigDecimal("-249.95")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 6, 1), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-249.95")),
new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), null, InvoiceItemType.TAX, new BigDecimal("1.0")));
}
catalog/pom.xml 2(+1 -1)
diff --git a/catalog/pom.xml b/catalog/pom.xml
index 92bec23..96342b3 100644
--- a/catalog/pom.xml
+++ b/catalog/pom.xml
@@ -19,7 +19,7 @@
<parent>
<artifactId>killbill</artifactId>
<groupId>org.kill-bill.billing</groupId>
- <version>0.11.13-SNAPSHOT</version>
+ <version>0.11.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-catalog</artifactId>
currency/pom.xml 2(+1 -1)
diff --git a/currency/pom.xml b/currency/pom.xml
index 34ecbb4..2766fe3 100644
--- a/currency/pom.xml
+++ b/currency/pom.xml
@@ -19,7 +19,7 @@
<parent>
<artifactId>killbill</artifactId>
<groupId>org.kill-bill.billing</groupId>
- <version>0.11.13-SNAPSHOT</version>
+ <version>0.11.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-currency</artifactId>
entitlement/pom.xml 2(+1 -1)
diff --git a/entitlement/pom.xml b/entitlement/pom.xml
index 9da026f..aed13ff 100644
--- a/entitlement/pom.xml
+++ b/entitlement/pom.xml
@@ -19,7 +19,7 @@
<parent>
<artifactId>killbill</artifactId>
<groupId>org.kill-bill.billing</groupId>
- <version>0.11.13-SNAPSHOT</version>
+ <version>0.11.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-entitlement</artifactId>
invoice/pom.xml 2(+1 -1)
diff --git a/invoice/pom.xml b/invoice/pom.xml
index 6c34fef..7a76859 100644
--- a/invoice/pom.xml
+++ b/invoice/pom.xml
@@ -19,7 +19,7 @@
<parent>
<artifactId>killbill</artifactId>
<groupId>org.kill-bill.billing</groupId>
- <version>0.11.13-SNAPSHOT</version>
+ <version>0.11.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-invoice</artifactId>
diff --git a/invoice/src/main/java/org/killbill/billing/invoice/dao/CBADao.java b/invoice/src/main/java/org/killbill/billing/invoice/dao/CBADao.java
index 82848fc..1c80b11 100644
--- a/invoice/src/main/java/org/killbill/billing/invoice/dao/CBADao.java
+++ b/invoice/src/main/java/org/killbill/billing/invoice/dao/CBADao.java
@@ -29,6 +29,7 @@ import org.killbill.billing.entity.EntityPersistenceException;
import org.killbill.billing.util.entity.dao.EntitySqlDao;
import org.killbill.billing.util.entity.dao.EntitySqlDaoWrapperFactory;
+import com.google.common.base.Preconditions;
import com.google.common.collect.Ordering;
public class CBADao {
@@ -55,7 +56,50 @@ public class CBADao {
return cba;
}
- public void doCBAComplexity(final UUID accountId, final EntitySqlDaoWrapperFactory<EntitySqlDao> entitySqlDaoWrapperFactory, final InternalCallContext context) throws EntityPersistenceException, InvoiceApiException {
+ // We expect a clean up to date invoice, with all the items except the cba, that we will compute in that method
+ public InvoiceItemModelDao computeCBAComplexity(final InvoiceModelDao invoice, final EntitySqlDaoWrapperFactory<EntitySqlDao> entitySqlDaoWrapperFactory, final InternalCallContext context) throws EntityPersistenceException, InvoiceApiException {
+
+ final BigDecimal balance = InvoiceModelDaoHelper.getBalance(invoice);
+
+ // Current balance is negative, we need to generate a credit (positive CBA amount).
+ if (balance.compareTo(BigDecimal.ZERO) < 0) {
+ return new InvoiceItemModelDao(new CreditBalanceAdjInvoiceItem(invoice.getId(), invoice.getAccountId(), context.getCreatedDate().toLocalDate(), balance.negate(), invoice.getCurrency()));
+
+ // Current balance is positive, we need to use some of the existing if available (negative CBA amount)
+ } else if (balance.compareTo(BigDecimal.ZERO) > 0) {
+
+ final List<InvoiceModelDao> allInvoices = invoiceDaoHelper.getAllInvoicesByAccountFromTransaction(entitySqlDaoWrapperFactory, context);
+ final BigDecimal accountCBA = getAccountCBAFromTransaction(allInvoices);
+ if (accountCBA.compareTo(BigDecimal.ZERO) <= 0) {
+ return null;
+ }
+ final BigDecimal positiveCreditAmount = accountCBA.compareTo(balance) > 0 ? balance : accountCBA;
+ return new InvoiceItemModelDao(new CreditBalanceAdjInvoiceItem(invoice.getId(), invoice.getAccountId(), context.getCreatedDate().toLocalDate(), positiveCreditAmount.negate(), invoice.getCurrency()));
+ } else {
+ // 0 balance, nothing to do.
+ return null;
+ }
+ }
+
+ // We expect a clean up to date invoice, with all the items except the CBA, that we will compute in that method
+ public void addCBAComplexityFromTransaction(final InvoiceModelDao invoice, final EntitySqlDaoWrapperFactory<EntitySqlDao> entitySqlDaoWrapperFactory, final InternalCallContext context) throws EntityPersistenceException, InvoiceApiException {
+ final InvoiceItemModelDao cbaItem = computeCBAComplexity(invoice, entitySqlDaoWrapperFactory, context);
+ if (cbaItem != null) {
+ final InvoiceItemSqlDao transInvoiceItemDao = entitySqlDaoWrapperFactory.become(InvoiceItemSqlDao.class);
+ transInvoiceItemDao.create(cbaItem, context);
+ }
+ }
+
+ // We let the code below rehydrate the invoice before we can add the CBA item
+ public void addCBAComplexityFromTransaction(final UUID invoiceId, final EntitySqlDaoWrapperFactory<EntitySqlDao> entitySqlDaoWrapperFactory, final InternalCallContext context) throws EntityPersistenceException, InvoiceApiException {
+
+ final InvoiceSqlDao transInvoiceDao = entitySqlDaoWrapperFactory.become(InvoiceSqlDao.class);
+ final InvoiceModelDao invoice = transInvoiceDao.getById(invoiceId.toString(), context);
+ invoiceDaoHelper.populateChildren(invoice, entitySqlDaoWrapperFactory, context);
+ addCBAComplexityFromTransaction(invoice, entitySqlDaoWrapperFactory, context);
+ }
+
+ public void addCBAComplexityFromTransaction(final EntitySqlDaoWrapperFactory<EntitySqlDao> entitySqlDaoWrapperFactory, final InternalCallContext context) throws EntityPersistenceException, InvoiceApiException {
List<InvoiceModelDao> invoiceItemModelDaos = invoiceDaoHelper.getAllInvoicesByAccountFromTransaction(entitySqlDaoWrapperFactory, context);
for (InvoiceModelDao cur : invoiceItemModelDaos) {
diff --git a/invoice/src/main/java/org/killbill/billing/invoice/dao/DefaultInvoiceDao.java b/invoice/src/main/java/org/killbill/billing/invoice/dao/DefaultInvoiceDao.java
index 1f574e0..d128afd 100644
--- a/invoice/src/main/java/org/killbill/billing/invoice/dao/DefaultInvoiceDao.java
+++ b/invoice/src/main/java/org/killbill/billing/invoice/dao/DefaultInvoiceDao.java
@@ -228,7 +228,7 @@ public class DefaultInvoiceDao extends EntityDaoBase<InvoiceModelDao, Invoice, I
transInvoiceItemSqlDao.create(invoiceItemModelDao, context);
}
- cbaDao.doCBAComplexity(invoice.getAccountId(), entitySqlDaoWrapperFactory, context);
+ cbaDao.addCBAComplexityFromTransaction(invoice, entitySqlDaoWrapperFactory, context);
notifyOfFutureBillingEvents(entitySqlDaoWrapperFactory, invoice.getAccountId(), callbackDateTimePerSubscriptions, context.getUserToken());
}
@@ -401,11 +401,8 @@ public class DefaultInvoiceDao extends EntityDaoBase<InvoiceModelDao, Invoice, I
// Retrieve invoice after the Refund
final InvoiceModelDao invoice = transInvoiceDao.getById(payment.getInvoiceId().toString(), context);
- if (invoice != null) {
- invoiceDaoHelper.populateChildren(invoice, entitySqlDaoWrapperFactory, context);
- } else {
- throw new IllegalStateException("Invoice shouldn't be null for payment " + payment.getId());
- }
+ Preconditions.checkState(invoice != null, "Invoice shouldn't be null for payment " + payment.getId());
+ invoiceDaoHelper.populateChildren(invoice, entitySqlDaoWrapperFactory, context);
final BigDecimal invoiceBalanceAfterRefund = InvoiceModelDaoHelper.getBalance(invoice);
final InvoiceItemSqlDao transInvoiceItemDao = entitySqlDaoWrapperFactory.become(InvoiceItemSqlDao.class);
@@ -422,6 +419,7 @@ public class DefaultInvoiceDao extends EntityDaoBase<InvoiceModelDao, Invoice, I
null, null, null, null, null, null, context.getCreatedDate().toLocalDate(), null,
requestedPositiveAmountToAdjust.negate(), null, invoice.getCurrency(), null);
transInvoiceItemDao.create(adjItem, context);
+ invoice.addInvoiceItem(adjItem);
}
} else if (isInvoiceAdjusted) {
// Invoice item adjustment
@@ -431,10 +429,11 @@ public class DefaultInvoiceDao extends EntityDaoBase<InvoiceModelDao, Invoice, I
invoice.getCurrency(), context.getCreatedDate().toLocalDate(),
context);
transInvoiceItemDao.create(item, context);
+ invoice.addInvoiceItem(item);
}
}
- cbaDao.doCBAComplexity(invoice.getAccountId(), entitySqlDaoWrapperFactory, context);
+ cbaDao.addCBAComplexityFromTransaction(invoice, entitySqlDaoWrapperFactory, context);
// Notify the bus since the balance of the invoice changed
notifyBusOfInvoiceAdjustment(entitySqlDaoWrapperFactory, invoice.getId(), invoice.getAccountId(), context.getUserToken(), context);
@@ -488,7 +487,7 @@ public class DefaultInvoiceDao extends EntityDaoBase<InvoiceModelDao, Invoice, I
// Notify the bus since the balance of the invoice changed
final UUID accountId = transactional.getAccountIdFromInvoicePaymentId(chargeBack.getId().toString(), context);
- cbaDao.doCBAComplexity(accountId, entitySqlDaoWrapperFactory, context);
+ cbaDao.addCBAComplexityFromTransaction(payment.getInvoiceId(), entitySqlDaoWrapperFactory, context);
notifyBusOfInvoiceAdjustment(entitySqlDaoWrapperFactory, payment.getInvoiceId(), accountId, context.getUserToken(), context);
@@ -498,6 +497,18 @@ public class DefaultInvoiceDao extends EntityDaoBase<InvoiceModelDao, Invoice, I
}
@Override
+ public InvoiceItemModelDao doCBAComplexity(final InvoiceModelDao invoice, final InternalCallContext context) throws InvoiceApiException {
+ return transactionalSqlDao.execute(InvoiceApiException.class, new EntitySqlDaoTransactionWrapper<InvoiceItemModelDao>() {
+ @Override
+ public InvoiceItemModelDao inTransaction(final EntitySqlDaoWrapperFactory<EntitySqlDao> entitySqlDaoWrapperFactory) throws Exception {
+ final InvoiceItemModelDao cbaNewItem = cbaDao.computeCBAComplexity(invoice, entitySqlDaoWrapperFactory, context);
+ return cbaNewItem;
+ }
+ });
+ }
+
+
+ @Override
public BigDecimal getRemainingAmountPaid(final UUID invoicePaymentId, final InternalTenantContext context) {
return transactionalSqlDao.execute(new EntitySqlDaoTransactionWrapper<BigDecimal>() {
@Override
@@ -643,7 +654,7 @@ public class DefaultInvoiceDao extends EntityDaoBase<InvoiceModelDao, Invoice, I
changedInvoices.add(invoiceIdForExternalCharge);
}
- cbaDao.doCBAComplexity(accountId, entitySqlDaoWrapperFactory, context);
+ cbaDao.addCBAComplexityFromTransaction(entitySqlDaoWrapperFactory, context);
// Notify the bus since the balance of the invoice changed
// TODO should we post an InvoiceCreationInternalEvent event instead? Note! This will trigger a payment (see InvoiceHandler)
@@ -694,7 +705,7 @@ public class DefaultInvoiceDao extends EntityDaoBase<InvoiceModelDao, Invoice, I
currency, null);
invoiceDaoHelper.insertItem(entitySqlDaoWrapperFactory, credit, context);
- cbaDao.doCBAComplexity(accountId, entitySqlDaoWrapperFactory, context);
+ cbaDao.addCBAComplexityFromTransaction(invoiceIdForCredit, entitySqlDaoWrapperFactory, context);
// Notify the bus since the balance of the invoice changed
notifyBusOfInvoiceAdjustment(entitySqlDaoWrapperFactory, invoiceId, accountId, context.getUserToken(), context);
@@ -715,7 +726,7 @@ public class DefaultInvoiceDao extends EntityDaoBase<InvoiceModelDao, Invoice, I
currency, effectiveDate, context);
invoiceDaoHelper.insertItem(entitySqlDaoWrapperFactory, invoiceItemAdjustment, context);
- cbaDao.doCBAComplexity(accountId, entitySqlDaoWrapperFactory, context);
+ cbaDao.addCBAComplexityFromTransaction(invoiceId, entitySqlDaoWrapperFactory, context);
notifyBusOfInvoiceAdjustment(entitySqlDaoWrapperFactory, invoiceId, accountId, context.getUserToken(), context);
@@ -822,7 +833,7 @@ public class DefaultInvoiceDao extends EntityDaoBase<InvoiceModelDao, Invoice, I
@Override
public Void inTransaction(final EntitySqlDaoWrapperFactory<EntitySqlDao> entitySqlDaoWrapperFactory) throws Exception {
// In theory we should only have to call useExistingCBAFromTransaction but just to be safe we also check for credit generation
- cbaDao.doCBAComplexity(accountId, entitySqlDaoWrapperFactory, context);
+ cbaDao.addCBAComplexityFromTransaction(entitySqlDaoWrapperFactory, context);
return null;
}
});
diff --git a/invoice/src/main/java/org/killbill/billing/invoice/dao/InvoiceDao.java b/invoice/src/main/java/org/killbill/billing/invoice/dao/InvoiceDao.java
index 69cdf91..b350b42 100644
--- a/invoice/src/main/java/org/killbill/billing/invoice/dao/InvoiceDao.java
+++ b/invoice/src/main/java/org/killbill/billing/invoice/dao/InvoiceDao.java
@@ -28,10 +28,13 @@ import org.joda.time.LocalDate;
import org.killbill.billing.callcontext.InternalCallContext;
import org.killbill.billing.callcontext.InternalTenantContext;
import org.killbill.billing.catalog.api.Currency;
+import org.killbill.billing.entity.EntityPersistenceException;
import org.killbill.billing.invoice.api.Invoice;
import org.killbill.billing.invoice.api.InvoiceApiException;
import org.killbill.billing.util.entity.Pagination;
import org.killbill.billing.util.entity.dao.EntityDao;
+import org.killbill.billing.util.entity.dao.EntitySqlDao;
+import org.killbill.billing.util.entity.dao.EntitySqlDaoWrapperFactory;
public interface InvoiceDao extends EntityDao<InvoiceModelDao, Invoice, InvoiceApiException> {
@@ -66,18 +69,20 @@ public interface InvoiceDao extends EntityDao<InvoiceModelDao, Invoice, InvoiceA
InvoicePaymentModelDao postChargeback(UUID paymentId, BigDecimal amount, Currency currency, InternalCallContext context) throws InvoiceApiException;
- /**
- * Create a refund.
- *
- * @param paymentId payment associated with that refund
- * @param amount amount to refund
- * @param isInvoiceAdjusted whether the refund should trigger an invoice or invoice item adjustment
- * @param invoiceItemIdsWithAmounts invoice item ids and associated amounts to adjust
- * @param transactionExternalKey transaction refund externalKey
- * @param context the call callcontext
- * @return the created invoice payment object associated with this refund
- * @throws InvoiceApiException
- */
+ InvoiceItemModelDao doCBAComplexity(InvoiceModelDao invoice, InternalCallContext context) throws InvoiceApiException;
+
+ /**
+ * Create a refund.
+ *
+ * @param paymentId payment associated with that refund
+ * @param amount amount to refund
+ * @param isInvoiceAdjusted whether the refund should trigger an invoice or invoice item adjustment
+ * @param invoiceItemIdsWithAmounts invoice item ids and associated amounts to adjust
+ * @param transactionExternalKey transaction refund externalKey
+ * @param context the call callcontext
+ * @return the created invoice payment object associated with this refund
+ * @throws InvoiceApiException
+ */
InvoicePaymentModelDao createRefund(UUID paymentId, BigDecimal amount, boolean isInvoiceAdjusted, Map<UUID, BigDecimal> invoiceItemIdsWithAmounts,
String transactionExternalKey, InternalCallContext context) throws InvoiceApiException;
diff --git a/invoice/src/main/java/org/killbill/billing/invoice/dao/InvoiceModelDao.java b/invoice/src/main/java/org/killbill/billing/invoice/dao/InvoiceModelDao.java
index ae3cce6..cd7aa45 100644
--- a/invoice/src/main/java/org/killbill/billing/invoice/dao/InvoiceModelDao.java
+++ b/invoice/src/main/java/org/killbill/billing/invoice/dao/InvoiceModelDao.java
@@ -77,6 +77,10 @@ public class InvoiceModelDao extends EntityModelDaoBase implements EntityModelDa
this.invoiceItems.addAll(invoiceItems);
}
+ public void addInvoiceItem(final InvoiceItemModelDao invoiceItem) {
+ this.invoiceItems.add(invoiceItem);
+ }
+
public List<InvoiceItemModelDao> getInvoiceItems() {
return invoiceItems;
}
diff --git a/invoice/src/main/java/org/killbill/billing/invoice/generator/DefaultInvoiceGenerator.java b/invoice/src/main/java/org/killbill/billing/invoice/generator/DefaultInvoiceGenerator.java
index 66eb264..ccd7440 100644
--- a/invoice/src/main/java/org/killbill/billing/invoice/generator/DefaultInvoiceGenerator.java
+++ b/invoice/src/main/java/org/killbill/billing/invoice/generator/DefaultInvoiceGenerator.java
@@ -177,7 +177,7 @@ public class DefaultInvoiceGenerator implements InvoiceGenerator {
private List<InvoiceItem> generateInAdvanceInvoiceItems(final UUID accountId, final UUID invoiceId, final BillingEventSet eventSet,
@Nullable final List<Invoice> existingInvoices, final LocalDate targetDate,
final Currency targetCurrency) throws InvoiceApiException {
- final AccountItemTree accountItemTree = new AccountItemTree(accountId);
+ final AccountItemTree accountItemTree = new AccountItemTree(accountId, invoiceId);
if (existingInvoices != null) {
for (final Invoice invoice : existingInvoices) {
for (final InvoiceItem item : invoice.getInvoiceItems()) {
diff --git a/invoice/src/main/java/org/killbill/billing/invoice/InvoiceDispatcher.java b/invoice/src/main/java/org/killbill/billing/invoice/InvoiceDispatcher.java
index 03449af..edc9b8a 100644
--- a/invoice/src/main/java/org/killbill/billing/invoice/InvoiceDispatcher.java
+++ b/invoice/src/main/java/org/killbill/billing/invoice/InvoiceDispatcher.java
@@ -51,17 +51,16 @@ import org.killbill.billing.invoice.api.InvoiceApiException;
import org.killbill.billing.invoice.api.InvoiceItem;
import org.killbill.billing.invoice.api.InvoiceItemType;
import org.killbill.billing.invoice.api.InvoiceNotifier;
-import org.killbill.billing.invoice.api.InvoicePayment;
import org.killbill.billing.invoice.api.user.DefaultInvoiceAdjustmentEvent;
import org.killbill.billing.invoice.api.user.DefaultInvoiceCreationEvent;
import org.killbill.billing.invoice.api.user.DefaultNullInvoiceEvent;
import org.killbill.billing.invoice.dao.InvoiceDao;
import org.killbill.billing.invoice.dao.InvoiceItemModelDao;
import org.killbill.billing.invoice.dao.InvoiceModelDao;
-import org.killbill.billing.invoice.dao.InvoicePaymentModelDao;
import org.killbill.billing.invoice.generator.InvoiceGenerator;
import org.killbill.billing.invoice.model.DefaultInvoice;
import org.killbill.billing.invoice.model.FixedPriceInvoiceItem;
+import org.killbill.billing.invoice.model.InvoiceItemFactory;
import org.killbill.billing.invoice.model.RecurringInvoiceItem;
import org.killbill.billing.invoice.plugin.api.InvoicePluginApi;
import org.killbill.billing.junction.BillingEventSet;
@@ -203,7 +202,9 @@ public class InvoiceDispatcher {
final LocalDate targetDate = dateAndTimeZoneContext != null ? dateAndTimeZoneContext.computeTargetDate(targetDateTime) : null;
final Invoice invoice = targetDate != null ? generator.generateInvoice(accountId, billingEvents, invoices, targetDate, targetCurrency, context) : null;
- boolean isRealInvoiceWithItems = false;
+ //
+ // If invoice comes back null, there is nothing new to generate, we can bail early
+ //
if (invoice == null) {
log.info("Generated null invoice for accountId {} and targetDate {} (targetDateTime {})", new Object[]{accountId, targetDate, targetDateTime});
if (!dryRun) {
@@ -211,75 +212,87 @@ public class InvoiceDispatcher {
context.getAccountRecordId(), context.getTenantRecordId(), context.getUserToken());
postEvent(event, accountId, context);
}
- } else {
- if (!dryRun) {
- // Ask external invoice plugins if additional items (tax, etc) shall be added to the invoice
- final List<InvoicePluginApi> invoicePlugins = this.getInvoicePlugins();
- final CallContext callContext = buildCallContext(context);
- for (final InvoicePluginApi invoicePlugin : invoicePlugins) {
- final List<InvoiceItem> items = invoicePlugin.getAdditionalInvoiceItems(invoice, ImmutableList.<PluginProperty>of(), callContext);
- if (items != null) {
- for (final InvoiceItem item : items) {
- if (InvoiceItemType.EXTERNAL_CHARGE.equals(item.getInvoiceItemType()) || InvoiceItemType.TAX.equals(item.getInvoiceItemType())) {
- invoice.addInvoiceItem(item);
- } else {
- log.warn("Ignoring invoice item of type {} from InvoicePluginApi {}: {}", item.getInvoiceItemType(), invoicePlugin, item);
- }
- }
- }
- }
+ return invoice;
+ }
+
+ // Generate missing credit (> 0 for generation and < 0 for use) prior we call the plugin
+ final InvoiceItem cbaItem = computeCBAOnExistingInvoice(invoice, context);
+ if (cbaItem != null) {
+ invoice.addInvoiceItem(cbaItem);
+ }
- // Extract the set of invoiceId for which we see items that don't belong to current generated invoice
- final Set<UUID> adjustedUniqueOtherInvoiceId = new TreeSet<UUID>();
- adjustedUniqueOtherInvoiceId.addAll(Collections2.transform(invoice.getInvoiceItems(), new Function<InvoiceItem, UUID>() {
- @Nullable
- @Override
- public UUID apply(@Nullable final InvoiceItem input) {
- return input.getInvoiceId();
+ //
+ // Ask external invoice plugins if additional items (tax, etc) shall be added to the invoice
+ //
+ final List<InvoicePluginApi> invoicePlugins = this.getInvoicePlugins();
+ final CallContext callContext = buildCallContext(context);
+ for (final InvoicePluginApi invoicePlugin : invoicePlugins) {
+ final List<InvoiceItem> items = invoicePlugin.getAdditionalInvoiceItems(invoice, ImmutableList.<PluginProperty>of(), callContext);
+ if (items != null) {
+ for (final InvoiceItem item : items) {
+ if (InvoiceItemType.EXTERNAL_CHARGE.equals(item.getInvoiceItemType()) || InvoiceItemType.TAX.equals(item.getInvoiceItemType())) {
+ invoice.addInvoiceItem(item);
+ } else {
+ log.warn("Ignoring invoice item of type {} from InvoicePluginApi {}: {}", item.getInvoiceItemType(), invoicePlugin, item);
}
- }));
- isRealInvoiceWithItems = adjustedUniqueOtherInvoiceId.remove(invoice.getId());
-
- if (isRealInvoiceWithItems) {
- log.info("Generated invoice {} with {} items for accountId {} and targetDate {} (targetDateTime {})", new Object[]{invoice.getId(), invoice.getNumberOfItems(), accountId, targetDate, targetDateTime});
- } else {
- final Joiner joiner = Joiner.on(",");
- final String adjustedInvoices = joiner.join(adjustedUniqueOtherInvoiceId.toArray(new UUID[adjustedUniqueOtherInvoiceId.size()]));
- log.info("Adjusting existing invoices {} with {} items for accountId {} and targetDate {} (targetDateTime {})", new Object[]{adjustedInvoices, invoice.getNumberOfItems(),
- accountId, targetDate, targetDateTime});
}
+ }
+ }
- final InvoiceModelDao invoiceModelDao = new InvoiceModelDao(invoice);
- final List<InvoiceItemModelDao> invoiceItemModelDaos = ImmutableList.<InvoiceItemModelDao>copyOf(Collections2.transform(invoice.getInvoiceItems(),
- new Function<InvoiceItem, InvoiceItemModelDao>() {
- @Override
- public InvoiceItemModelDao apply(final InvoiceItem input) {
- return new InvoiceItemModelDao(input);
- }
- }));
-
- final Map<UUID, List<DateTime>> callbackDateTimePerSubscriptions = createNextFutureNotificationDate(invoiceItemModelDaos, billingEvents.getUsages(), dateAndTimeZoneContext);
- invoiceDao.createInvoice(invoiceModelDao, invoiceItemModelDaos, isRealInvoiceWithItems, callbackDateTimePerSubscriptions, context);
-
- final List<InvoiceItem> fixedPriceInvoiceItems = invoice.getInvoiceItems(FixedPriceInvoiceItem.class);
- final List<InvoiceItem> recurringInvoiceItems = invoice.getInvoiceItems(RecurringInvoiceItem.class);
- setChargedThroughDates(dateAndTimeZoneContext, fixedPriceInvoiceItems, recurringInvoiceItems, context);
-
- final List<InvoiceInternalEvent> events = new ArrayList<InvoiceInternalEvent>();
- if (isRealInvoiceWithItems) {
- events.add(new DefaultInvoiceCreationEvent(invoice.getId(), invoice.getAccountId(),
- invoice.getBalance(), invoice.getCurrency(),
- context.getAccountRecordId(), context.getTenantRecordId(), context.getUserToken()));
- }
- for (final UUID cur : adjustedUniqueOtherInvoiceId) {
- final InvoiceAdjustmentInternalEvent event = new DefaultInvoiceAdjustmentEvent(cur, invoice.getAccountId(),
- context.getAccountRecordId(), context.getTenantRecordId(), context.getUserToken());
- events.add(event);
+ boolean isRealInvoiceWithItems = false;
+ if (!dryRun) {
+
+ // Extract the set of invoiceId for which we see items that don't belong to current generated invoice
+ final Set<UUID> adjustedUniqueOtherInvoiceId = new TreeSet<UUID>();
+ adjustedUniqueOtherInvoiceId.addAll(Collections2.transform(invoice.getInvoiceItems(), new Function<InvoiceItem, UUID>() {
+ @Nullable
+ @Override
+ public UUID apply(@Nullable final InvoiceItem input) {
+ return input.getInvoiceId();
}
+ }));
+ isRealInvoiceWithItems = adjustedUniqueOtherInvoiceId.remove(invoice.getId());
+
+ if (isRealInvoiceWithItems) {
+ log.info("Generated invoice {} with {} items for accountId {} and targetDate {} (targetDateTime {})", new Object[]{invoice.getId(), invoice.getNumberOfItems(), accountId, targetDate, targetDateTime});
+ } else {
+ final Joiner joiner = Joiner.on(",");
+ final String adjustedInvoices = joiner.join(adjustedUniqueOtherInvoiceId.toArray(new UUID[adjustedUniqueOtherInvoiceId.size()]));
+ log.info("Adjusting existing invoices {} with {} items for accountId {} and targetDate {} (targetDateTime {})", new Object[]{adjustedInvoices, invoice.getNumberOfItems(),
+ accountId, targetDate, targetDateTime});
+ }
- for (final InvoiceInternalEvent event : events) {
- postEvent(event, accountId, context);
- }
+ // Transformation to Invoice -> InvoiceModelDao
+ final InvoiceModelDao invoiceModelDao = new InvoiceModelDao(invoice);
+ final List<InvoiceItemModelDao> invoiceItemModelDaos = ImmutableList.copyOf(Collections2.transform(invoice.getInvoiceItems(),
+ new Function<InvoiceItem, InvoiceItemModelDao>() {
+ @Override
+ public InvoiceItemModelDao apply(final InvoiceItem input) {
+ return new InvoiceItemModelDao(input);
+ }
+ }));
+
+ final Map<UUID, List<DateTime>> callbackDateTimePerSubscriptions = createNextFutureNotificationDate(invoiceItemModelDaos, billingEvents.getUsages(), dateAndTimeZoneContext);
+ invoiceDao.createInvoice(invoiceModelDao, invoiceItemModelDaos, isRealInvoiceWithItems, callbackDateTimePerSubscriptions, context);
+
+ final List<InvoiceItem> fixedPriceInvoiceItems = invoice.getInvoiceItems(FixedPriceInvoiceItem.class);
+ final List<InvoiceItem> recurringInvoiceItems = invoice.getInvoiceItems(RecurringInvoiceItem.class);
+ setChargedThroughDates(dateAndTimeZoneContext, fixedPriceInvoiceItems, recurringInvoiceItems, context);
+
+ final List<InvoiceInternalEvent> events = new ArrayList<InvoiceInternalEvent>();
+ if (isRealInvoiceWithItems) {
+ events.add(new DefaultInvoiceCreationEvent(invoice.getId(), invoice.getAccountId(),
+ invoice.getBalance(), invoice.getCurrency(),
+ context.getAccountRecordId(), context.getTenantRecordId(), context.getUserToken()));
+ }
+ for (final UUID cur : adjustedUniqueOtherInvoiceId) {
+ final InvoiceAdjustmentInternalEvent event = new DefaultInvoiceAdjustmentEvent(cur, invoice.getAccountId(),
+ context.getAccountRecordId(), context.getTenantRecordId(), context.getUserToken());
+ events.add(event);
+ }
+
+ for (final InvoiceInternalEvent event : events) {
+ postEvent(event, accountId, context);
}
}
@@ -296,6 +309,21 @@ public class InvoiceDispatcher {
}
}
+ private InvoiceItem computeCBAOnExistingInvoice(final Invoice invoice, final InternalCallContext context) throws InvoiceApiException {
+ // Transformation to Invoice -> InvoiceModelDao
+ final InvoiceModelDao invoiceModelDao = new InvoiceModelDao(invoice);
+ final List<InvoiceItemModelDao> invoiceItemModelDaos = ImmutableList.copyOf(Collections2.transform(invoice.getInvoiceItems(),
+ new Function<InvoiceItem, InvoiceItemModelDao>() {
+ @Override
+ public InvoiceItemModelDao apply(final InvoiceItem input) {
+ return new InvoiceItemModelDao(input);
+ }
+ }));
+ invoiceModelDao.addInvoiceItems(invoiceItemModelDaos);
+ final InvoiceItemModelDao cbaItem = invoiceDao.doCBAComplexity(invoiceModelDao, context);
+ return cbaItem != null ? InvoiceItemFactory.fromModelDao(cbaItem) : null;
+ }
+
private TenantContext buildTenantContext(final InternalTenantContext context) {
return context.toTenantContext(nonEntityDao.retrieveIdFromObject(context.getTenantRecordId(), ObjectType.TENANT, controllerDispatcher.getCacheController(CacheType.OBJECT_ID)));
}
diff --git a/invoice/src/main/java/org/killbill/billing/invoice/tree/AccountItemTree.java b/invoice/src/main/java/org/killbill/billing/invoice/tree/AccountItemTree.java
index e005d56..75369f8 100644
--- a/invoice/src/main/java/org/killbill/billing/invoice/tree/AccountItemTree.java
+++ b/invoice/src/main/java/org/killbill/billing/invoice/tree/AccountItemTree.java
@@ -48,14 +48,16 @@ import com.google.common.collect.Iterables;
public class AccountItemTree {
private final UUID accountId;
+ private final UUID targetInvoiceId;
private final Map<UUID, SubscriptionItemTree> subscriptionItemTree;
private final List<InvoiceItem> allExistingItems;
private List<InvoiceItem> pendingItemAdj;
private boolean isBuilt;
- public AccountItemTree(final UUID accountId) {
+ public AccountItemTree(final UUID accountId, final UUID targetInvoiceId) {
this.accountId = accountId;
+ this.targetInvoiceId = targetInvoiceId;
this.subscriptionItemTree = new HashMap<UUID, SubscriptionItemTree>();
this.isBuilt = false;
this.allExistingItems = new LinkedList<InvoiceItem>();
@@ -123,7 +125,7 @@ public class AccountItemTree {
}
if (!subscriptionItemTree.containsKey(subscriptionId)) {
- subscriptionItemTree.put(subscriptionId, new SubscriptionItemTree(subscriptionId));
+ subscriptionItemTree.put(subscriptionId, new SubscriptionItemTree(subscriptionId, targetInvoiceId));
}
final SubscriptionItemTree tree = subscriptionItemTree.get(subscriptionId);
tree.addItem(existingItem);
@@ -145,7 +147,7 @@ public class AccountItemTree {
final UUID subscriptionId = getSubscriptionId(item, null);
SubscriptionItemTree tree = subscriptionItemTree.get(subscriptionId);
if (tree == null) {
- tree = new SubscriptionItemTree(subscriptionId);
+ tree = new SubscriptionItemTree(subscriptionId, targetInvoiceId);
subscriptionItemTree.put(subscriptionId, tree);
}
tree.mergeProposedItem(item);
diff --git a/invoice/src/main/java/org/killbill/billing/invoice/tree/Item.java b/invoice/src/main/java/org/killbill/billing/invoice/tree/Item.java
index b93fb74..4899f0c 100644
--- a/invoice/src/main/java/org/killbill/billing/invoice/tree/Item.java
+++ b/invoice/src/main/java/org/killbill/billing/invoice/tree/Item.java
@@ -45,6 +45,7 @@ public class Item {
private final UUID accountId;
private final UUID bundleId;
private final UUID subscriptionId;
+ private final UUID targetInvoiceId;
private final UUID invoiceId;
private final String planName;
private final String phaseName;
@@ -71,6 +72,7 @@ public class Item {
this.accountId = item.accountId;
this.bundleId = item.bundleId;
this.subscriptionId = item.subscriptionId;
+ this.targetInvoiceId = item.targetInvoiceId;
this.invoiceId = item.invoiceId;
this.planName = item.planName;
this.phaseName = item.phaseName;
@@ -88,11 +90,12 @@ public class Item {
this.action = action;
}
- public Item(final InvoiceItem item, final ItemAction action) {
+ public Item(final InvoiceItem item, final UUID targetInvoiceId, final ItemAction action) {
this.id = item.getId();
this.accountId = item.getAccountId();
this.bundleId = item.getBundleId();
this.subscriptionId = item.getSubscriptionId();
+ this.targetInvoiceId = targetInvoiceId;
this.invoiceId = item.getInvoiceId();
this.planName = item.getPlanName();
this.phaseName = item.getPhaseName();
@@ -129,7 +132,7 @@ public class Item {
final BigDecimal maxAvailableAmountAfterAdj = amount.subtract(adjustedAmount);
final BigDecimal maxAvailableAmountForRepair = maxAvailableAmountAfterAdj.subtract(currentRepairedAmount);
final BigDecimal positiveAmountForRepair = positiveAmount.compareTo(maxAvailableAmountForRepair) <= 0 ? positiveAmount : maxAvailableAmountForRepair;
- return positiveAmountForRepair.compareTo(BigDecimal.ZERO) > 0 ? new RepairAdjInvoiceItem(invoiceId, accountId, newStartDate, newEndDate, KillBillMoney.of(positiveAmountForRepair.negate(), currency), currency, linkedId) : null;
+ return positiveAmountForRepair.compareTo(BigDecimal.ZERO) > 0 ? new RepairAdjInvoiceItem(targetInvoiceId, accountId, newStartDate, newEndDate, KillBillMoney.of(positiveAmountForRepair.negate(), currency), currency, linkedId) : null;
}
}
diff --git a/invoice/src/main/java/org/killbill/billing/invoice/tree/ItemsInterval.java b/invoice/src/main/java/org/killbill/billing/invoice/tree/ItemsInterval.java
index ff15213..07b571c 100644
--- a/invoice/src/main/java/org/killbill/billing/invoice/tree/ItemsInterval.java
+++ b/invoice/src/main/java/org/killbill/billing/invoice/tree/ItemsInterval.java
@@ -39,15 +39,17 @@ import com.google.common.collect.Lists;
*/
public class ItemsInterval {
+ private final UUID targetInvoiceId;
private final NodeInterval interval;
private LinkedList<Item> items;
- public ItemsInterval(final NodeInterval interval) {
- this(interval, null);
+ public ItemsInterval(final NodeInterval interval, final UUID targetInvoiceId) {
+ this(interval, targetInvoiceId, null);
}
- public ItemsInterval(final NodeInterval interval, final Item initialItem) {
+ public ItemsInterval(final NodeInterval interval, final UUID targetInvoiceId, final Item initialItem) {
this.interval = interval;
+ this.targetInvoiceId = targetInvoiceId;
this.items = Lists.newLinkedList();
if (initialItem != null) {
items.add(initialItem);
@@ -232,7 +234,7 @@ public class ItemsInterval {
return null;
}
- final Item result = new Item(item.toProratedInvoiceItem(startDate, endDate), item.getAction());
+ final Item result = new Item(item.toProratedInvoiceItem(startDate, endDate), targetInvoiceId, item.getAction());
if (item.getAction() == ItemAction.CANCEL && result != null) {
item.incrementCurrentRepairedAmount(result.getAmount());
}
diff --git a/invoice/src/main/java/org/killbill/billing/invoice/tree/ItemsNodeInterval.java b/invoice/src/main/java/org/killbill/billing/invoice/tree/ItemsNodeInterval.java
index c215a5c..a2c5d51 100644
--- a/invoice/src/main/java/org/killbill/billing/invoice/tree/ItemsNodeInterval.java
+++ b/invoice/src/main/java/org/killbill/billing/invoice/tree/ItemsNodeInterval.java
@@ -34,15 +34,18 @@ import com.google.common.base.Preconditions;
public class ItemsNodeInterval extends NodeInterval {
+ private final UUID targetInvoiceId;
private ItemsInterval items;
- public ItemsNodeInterval() {
- this.items = new ItemsInterval(this);
+ public ItemsNodeInterval(final UUID targetInvoiceId) {
+ this.items = new ItemsInterval(this, targetInvoiceId);
+ this.targetInvoiceId = targetInvoiceId;
}
- public ItemsNodeInterval(final NodeInterval parent, final Item item) {
+ public ItemsNodeInterval(final NodeInterval parent, final UUID targetInvoiceId, final Item item) {
super(parent, item.getStartDate(), item.getEndDate());
- this.items = new ItemsInterval(this, item);
+ this.items = new ItemsInterval(this, targetInvoiceId, item);
+ this.targetInvoiceId = targetInvoiceId;
}
@JsonIgnore
diff --git a/invoice/src/main/java/org/killbill/billing/invoice/tree/SubscriptionItemTree.java b/invoice/src/main/java/org/killbill/billing/invoice/tree/SubscriptionItemTree.java
index 2c0671b..2824c20 100644
--- a/invoice/src/main/java/org/killbill/billing/invoice/tree/SubscriptionItemTree.java
+++ b/invoice/src/main/java/org/killbill/billing/invoice/tree/SubscriptionItemTree.java
@@ -43,13 +43,12 @@ import com.google.common.collect.Ordering;
*/
public class SubscriptionItemTree {
- private boolean isBuilt;
-
+ private final UUID targetInvoiceId;
private final UUID subscriptionId;
- private ItemsNodeInterval root;
+ private ItemsNodeInterval root;
+ private boolean isBuilt;
private List<Item> items;
-
private List<InvoiceItem> existingFixedItems;
private Map<LocalDate, InvoiceItem> remainingFixedItems;
private List<InvoiceItem> pendingItemAdj;
@@ -74,9 +73,10 @@ public class SubscriptionItemTree {
}
};
- public SubscriptionItemTree(final UUID subscriptionId) {
+ public SubscriptionItemTree(final UUID subscriptionId, final UUID targetInvoiceId) {
this.subscriptionId = subscriptionId;
- this.root = new ItemsNodeInterval();
+ this.targetInvoiceId = targetInvoiceId;
+ this.root = new ItemsNodeInterval(targetInvoiceId);
this.items = new LinkedList<Item>();
this.existingFixedItems = new LinkedList<InvoiceItem>();
this.remainingFixedItems = new HashMap<LocalDate, InvoiceItem>();
@@ -108,10 +108,10 @@ public class SubscriptionItemTree {
if (!isBuilt) {
build();
}
- root = new ItemsNodeInterval();
+ root = new ItemsNodeInterval(targetInvoiceId);
for (Item item : items) {
Preconditions.checkState(item.getAction() == ItemAction.ADD);
- root.addExistingItem(new ItemsNodeInterval(root, new Item(item, reverse ? ItemAction.CANCEL : ItemAction.ADD)));
+ root.addExistingItem(new ItemsNodeInterval(root, targetInvoiceId, new Item(item, reverse ? ItemAction.CANCEL : ItemAction.ADD)));
}
items.clear();
isBuilt = false;
@@ -133,11 +133,11 @@ public class SubscriptionItemTree {
Preconditions.checkState(!isBuilt);
switch (invoiceItem.getInvoiceItemType()) {
case RECURRING:
- root.addExistingItem(new ItemsNodeInterval(root, new Item(invoiceItem, ItemAction.ADD)));
+ root.addExistingItem(new ItemsNodeInterval(root, targetInvoiceId, new Item(invoiceItem, targetInvoiceId, ItemAction.ADD)));
break;
case REPAIR_ADJ:
- root.addExistingItem(new ItemsNodeInterval(root, new Item(invoiceItem, ItemAction.CANCEL)));
+ root.addExistingItem(new ItemsNodeInterval(root, targetInvoiceId, new Item(invoiceItem, targetInvoiceId, ItemAction.CANCEL)));
break;
case FIXED:
@@ -163,9 +163,9 @@ public class SubscriptionItemTree {
Preconditions.checkState(!isBuilt);
switch (invoiceItem.getInvoiceItemType()) {
case RECURRING:
- final boolean result = root.addProposedItem(new ItemsNodeInterval(root, new Item(invoiceItem, ItemAction.ADD)));
+ final boolean result = root.addProposedItem(new ItemsNodeInterval(root, targetInvoiceId, new Item(invoiceItem, targetInvoiceId, ItemAction.ADD)));
if (!result) {
- items.add(new Item(invoiceItem, ItemAction.ADD));
+ items.add(new Item(invoiceItem, targetInvoiceId, ItemAction.ADD));
}
break;
diff --git a/invoice/src/test/java/org/killbill/billing/invoice/dao/MockInvoiceDao.java b/invoice/src/test/java/org/killbill/billing/invoice/dao/MockInvoiceDao.java
index 98e1e20..db40324 100644
--- a/invoice/src/test/java/org/killbill/billing/invoice/dao/MockInvoiceDao.java
+++ b/invoice/src/test/java/org/killbill/billing/invoice/dao/MockInvoiceDao.java
@@ -269,6 +269,12 @@ public class MockInvoiceDao extends MockEntityDaoBase<InvoiceModelDao, Invoice,
}
@Override
+ public InvoiceItemModelDao doCBAComplexity(final InvoiceModelDao invoice, final InternalCallContext context) throws InvoiceApiException {
+ // Do nothing unless we need it..
+ return null;
+ }
+
+ @Override
public BigDecimal getRemainingAmountPaid(final UUID invoicePaymentId, final InternalTenantContext context) {
throw new UnsupportedOperationException();
}
diff --git a/invoice/src/test/java/org/killbill/billing/invoice/dao/TestInvoiceDao.java b/invoice/src/test/java/org/killbill/billing/invoice/dao/TestInvoiceDao.java
index 08c30dc..7345e13 100644
--- a/invoice/src/test/java/org/killbill/billing/invoice/dao/TestInvoiceDao.java
+++ b/invoice/src/test/java/org/killbill/billing/invoice/dao/TestInvoiceDao.java
@@ -1131,10 +1131,10 @@ public class TestInvoiceDao extends InvoiceTestSuiteWithEmbeddedDB {
invoiceUtil.createInvoice(invoice2, true, context);
final InvoiceModelDao savedInvoice1 = invoiceDao.getById(invoice1.getId(), context);
- assertEquals(InvoiceModelDaoHelper.getBalance(savedInvoice1), KillBillMoney.of(FIVE, savedInvoice1.getCurrency()));
+ assertEquals(InvoiceModelDaoHelper.getBalance(savedInvoice1), KillBillMoney.of(TEN, savedInvoice1.getCurrency()));
final InvoiceModelDao savedInvoice2 = invoiceDao.getById(invoice2.getId(), context);
- assertEquals(InvoiceModelDaoHelper.getBalance(savedInvoice2), KillBillMoney.of(TEN, savedInvoice2.getCurrency()));
+ assertEquals(InvoiceModelDaoHelper.getBalance(savedInvoice2), KillBillMoney.of(FIVE, savedInvoice2.getCurrency()));
}
@Test(groups = "slow")
diff --git a/invoice/src/test/java/org/killbill/billing/invoice/generator/TestDefaultInvoiceGenerator.java b/invoice/src/test/java/org/killbill/billing/invoice/generator/TestDefaultInvoiceGenerator.java
index 33a14d3..43bbfec 100644
--- a/invoice/src/test/java/org/killbill/billing/invoice/generator/TestDefaultInvoiceGenerator.java
+++ b/invoice/src/test/java/org/killbill/billing/invoice/generator/TestDefaultInvoiceGenerator.java
@@ -451,7 +451,7 @@ public class TestDefaultInvoiceGenerator extends InvoiceTestSuiteNoDB {
// on 4/29/2011, cancel SubscriptionBase 1
events.add(createBillingEvent(subscriptionId1, bundleId, plan1CancelDate, plan1, plan1Phase3, 5));
- expectedAmount = ZERO;
+ expectedAmount = new BigDecimal("-2.40");
testInvoiceGeneration(accountId, events, invoices, plan1CancelDate, 1, expectedAmount);
// on 5/10/2011, invoice SubscriptionBase 2 (trial)
@@ -496,7 +496,7 @@ public class TestDefaultInvoiceGenerator extends InvoiceTestSuiteNoDB {
// on 7/31/2011, convert SubscriptionBase 3 to annual
events.add(createBillingEvent(subscriptionId3, bundleId, plan3UpgradeToAnnualDate, plan3, plan3Phase2, 31));
- testInvoiceGeneration(accountId, events, invoices, plan3UpgradeToAnnualDate, 2, ONE_HUNDRED);
+ testInvoiceGeneration(accountId, events, invoices, plan3UpgradeToAnnualDate, 2, new BigDecimal("93.55"));
// on 8/7/2011, invoice SubscriptionBase 4 (plan 2)
events.add(createBillingEvent(subscriptionId4, bundleId, plan4ChangeOfPlanDate, plan4b, plan4bPhase1, 7));
@@ -518,7 +518,7 @@ public class TestDefaultInvoiceGenerator extends InvoiceTestSuiteNoDB {
// on 10/7/2011, invoice SubscriptionBase 4 (plan 2), cancel SubscriptionBase 5
events.add(createBillingEvent(subscriptionId5, bundleId, plan5CancelDate, plan5, plan5Phase2, 10));
- testInvoiceGeneration(accountId, events, invoices, plan5CancelDate, 2, TWENTY_FOUR);
+ testInvoiceGeneration(accountId, events, invoices, plan5CancelDate, 2, new BigDecimal("22.00"));
// on 10/10/2011, invoice plan 2 (evergreen)
expectedAmount = FORTY;
@@ -903,10 +903,10 @@ public class TestDefaultInvoiceGenerator extends InvoiceTestSuiteNoDB {
distributeItems(invoices);
// ensure that the original invoice balance is zero
- assertEquals(invoice1.getBalance().compareTo(new BigDecimal("-10.0")), 0);
+ assertEquals(invoice1.getBalance().compareTo(BigDecimal.ZERO), 0);
// ensure that the account balance is correct
- assertEquals(invoice2.getBalance().compareTo(FIVE), 0);
+ assertEquals(invoice2.getBalance().compareTo(new BigDecimal("-5.0")), 0);
}
// Regression test for #170 (see https://github.com/killbill/killbill/pull/173)
diff --git a/invoice/src/test/java/org/killbill/billing/invoice/tree/TestSubscriptionItemTree.java b/invoice/src/test/java/org/killbill/billing/invoice/tree/TestSubscriptionItemTree.java
index 1a12fdb..47d94aa 100644
--- a/invoice/src/test/java/org/killbill/billing/invoice/tree/TestSubscriptionItemTree.java
+++ b/invoice/src/test/java/org/killbill/billing/invoice/tree/TestSubscriptionItemTree.java
@@ -75,20 +75,20 @@ public class TestSubscriptionItemTree /* extends InvoiceTestSuiteNoDB */ {
expectedResult.add(expected2);
// First test with items in order
- SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId);
+ SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId, invoiceId);
tree.addItem(initial);
tree.addItem(newItem);
tree.addItem(repair);
tree.build();
verifyResult(tree.getView(), expectedResult);
- tree = new SubscriptionItemTree(subscriptionId);
+ tree = new SubscriptionItemTree(subscriptionId, invoiceId);
tree.addItem(repair);
tree.addItem(newItem);
tree.addItem(initial);
tree.build();
verifyResult(tree.getView(), expectedResult);
- tree = new SubscriptionItemTree(subscriptionId);
+ tree = new SubscriptionItemTree(subscriptionId, invoiceId);
tree.addItem(repair);
tree.addItem(initial);
tree.addItem(newItem);
@@ -131,7 +131,7 @@ public class TestSubscriptionItemTree /* extends InvoiceTestSuiteNoDB */ {
expectedResult.add(expected3);
// First test with items in order
- SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId);
+ SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId, invoiceId);
tree.addItem(initial);
tree.addItem(newItem1);
tree.addItem(repair1);
@@ -140,7 +140,7 @@ public class TestSubscriptionItemTree /* extends InvoiceTestSuiteNoDB */ {
tree.build();
verifyResult(tree.getView(), expectedResult);
- tree = new SubscriptionItemTree(subscriptionId);
+ tree = new SubscriptionItemTree(subscriptionId, invoiceId);
tree.addItem(repair2);
tree.addItem(newItem1);
tree.addItem(newItem2);
@@ -149,7 +149,7 @@ public class TestSubscriptionItemTree /* extends InvoiceTestSuiteNoDB */ {
tree.build();
verifyResult(tree.getView(), expectedResult);
- tree = new SubscriptionItemTree(subscriptionId);
+ tree = new SubscriptionItemTree(subscriptionId, invoiceId);
tree.addItem(repair1);
tree.addItem(newItem1);
tree.addItem(initial);
@@ -187,7 +187,7 @@ public class TestSubscriptionItemTree /* extends InvoiceTestSuiteNoDB */ {
expectedResult.add(expected3);
// First test with items in order
- SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId);
+ SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId, invoiceId);
tree.addItem(initial);
tree.addItem(block1);
tree.addItem(block2);
@@ -218,7 +218,7 @@ public class TestSubscriptionItemTree /* extends InvoiceTestSuiteNoDB */ {
expectedResult.add(expected1);
expectedResult.add(expected2);
- SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId);
+ SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId, invoiceId);
tree.addItem(first);
tree.addItem(second);
tree.addItem(block1);
@@ -250,7 +250,7 @@ public class TestSubscriptionItemTree /* extends InvoiceTestSuiteNoDB */ {
expectedResult.add(monthly1);
expectedResult.add(monthly2);
- SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId);
+ SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId, invoiceId);
tree.addItem(annual);
tree.addItem(repair);
tree.addItem(monthly1);
@@ -258,7 +258,7 @@ public class TestSubscriptionItemTree /* extends InvoiceTestSuiteNoDB */ {
tree.build();
verifyResult(tree.getView(), expectedResult);
- tree = new SubscriptionItemTree(subscriptionId);
+ tree = new SubscriptionItemTree(subscriptionId, invoiceId);
tree.addItem(monthly1);
tree.addItem(repair);
tree.addItem(annual);
@@ -266,7 +266,7 @@ public class TestSubscriptionItemTree /* extends InvoiceTestSuiteNoDB */ {
tree.build();
verifyResult(tree.getView(), expectedResult);
- tree = new SubscriptionItemTree(subscriptionId);
+ tree = new SubscriptionItemTree(subscriptionId, invoiceId);
tree.addItem(monthly1);
tree.addItem(monthly2);
tree.addItem(annual);
@@ -304,7 +304,7 @@ public class TestSubscriptionItemTree /* extends InvoiceTestSuiteNoDB */ {
expectedResult.add(annual);
// First test with items in order
- SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId);
+ SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId, invoiceId);
tree.addItem(monthly1);
tree.addItem(monthly2);
tree.addItem(repair);
@@ -341,7 +341,7 @@ public class TestSubscriptionItemTree /* extends InvoiceTestSuiteNoDB */ {
expectedResult.add(annual);
// First test with items in order
- SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId);
+ SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId, invoiceId);
tree.addItem(monthly1);
tree.addItem(monthly2);
tree.addItem(repair);
@@ -378,7 +378,7 @@ public class TestSubscriptionItemTree /* extends InvoiceTestSuiteNoDB */ {
final InvoiceItem newItem2 = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, planName, phaseName, changeDate, endDate, amount1, rate1, currency);
- final SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId);
+ final SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId, invoiceId);
tree.addItem(initial);
tree.addItem(newItem1);
tree.addItem(repair1);
@@ -404,7 +404,7 @@ public class TestSubscriptionItemTree /* extends InvoiceTestSuiteNoDB */ {
final BigDecimal monthlyRate = new BigDecimal("12.00");
final BigDecimal monthlyAmount = monthlyRate;
- final SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId);
+ final SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId, invoiceId);
tree.flatten(true);
final InvoiceItem proposed1 = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, planName, phaseName, startDate, endDate, monthlyAmount, monthlyRate, currency);
@@ -425,7 +425,7 @@ public class TestSubscriptionItemTree /* extends InvoiceTestSuiteNoDB */ {
final BigDecimal monthlyRate = new BigDecimal("12.00");
final BigDecimal monthlyAmount = monthlyRate;
- final SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId);
+ final SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId, invoiceId);
final InvoiceItem monthly1 = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, planName, phaseName, startDate, endDate, monthlyAmount, monthlyRate, currency);
tree.addItem(monthly1);
tree.flatten(true);
@@ -451,7 +451,7 @@ public class TestSubscriptionItemTree /* extends InvoiceTestSuiteNoDB */ {
final BigDecimal monthlyRate2 = new BigDecimal("15.00");
final BigDecimal monthlyAmount2 = monthlyRate2;
- final SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId);
+ final SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId, invoiceId);
final InvoiceItem monthly1 = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, planName, phaseName, startDate, endDate, monthlyAmount1, monthlyRate1, currency);
tree.addItem(monthly1);
tree.flatten(true);
@@ -478,7 +478,7 @@ public class TestSubscriptionItemTree /* extends InvoiceTestSuiteNoDB */ {
final BigDecimal monthlyRate1 = new BigDecimal("12.00");
final BigDecimal monthlyAmount1 = monthlyRate1;
- final SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId);
+ final SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId, invoiceId);
final InvoiceItem monthly1 = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, planName, phaseName, startDate, endDate, monthlyAmount1, monthlyRate1, currency);
tree.addItem(monthly1);
tree.flatten(true);
@@ -504,7 +504,7 @@ public class TestSubscriptionItemTree /* extends InvoiceTestSuiteNoDB */ {
final BigDecimal monthlyRate1 = new BigDecimal("12.00");
final BigDecimal monthlyAmount1 = monthlyRate1;
- final SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId);
+ final SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId, invoiceId);
final InvoiceItem monthly1 = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, planName, phaseName, startDate, endDate, monthlyAmount1, monthlyRate1, currency);
tree.addItem(monthly1);
tree.flatten(true);
@@ -530,7 +530,7 @@ public class TestSubscriptionItemTree /* extends InvoiceTestSuiteNoDB */ {
final BigDecimal monthlyRate1 = new BigDecimal("12.00");
final BigDecimal monthlyAmount1 = monthlyRate1;
- final SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId);
+ final SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId, invoiceId);
final InvoiceItem monthly1 = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, planName, phaseName, startDate, endDate, monthlyAmount1, monthlyRate1, currency);
tree.addItem(monthly1);
tree.flatten(true);
@@ -562,7 +562,7 @@ public class TestSubscriptionItemTree /* extends InvoiceTestSuiteNoDB */ {
final BigDecimal monthlyRate = new BigDecimal("12.00");
final BigDecimal monthlyAmount = monthlyRate;
- final SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId);
+ final SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId, invoiceId);
final InvoiceItem monthly = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, planName, phaseName, startDate, endDate, monthlyAmount, monthlyRate, currency);
tree.addItem(monthly);
tree.flatten(true);
@@ -585,7 +585,7 @@ public class TestSubscriptionItemTree /* extends InvoiceTestSuiteNoDB */ {
// Dot it again but with proposed items out of order
- final SubscriptionItemTree treeAgain = new SubscriptionItemTree(subscriptionId);
+ final SubscriptionItemTree treeAgain = new SubscriptionItemTree(subscriptionId, invoiceId);
final InvoiceItem monthlyAgain = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, planName, phaseName, startDate, endDate, monthlyAmount, monthlyRate, currency);
treeAgain.addItem(monthlyAgain);
treeAgain.flatten(true);
@@ -617,7 +617,7 @@ public class TestSubscriptionItemTree /* extends InvoiceTestSuiteNoDB */ {
final BigDecimal monthlyRate2 = new BigDecimal("20.00");
final BigDecimal monthlyAmount2 = monthlyRate1;
- final SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId);
+ final SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId, invoiceId);
final InvoiceItem monthly1 = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, planName, phaseName, startDate, endDate, monthlyAmount1, monthlyRate1, currency);
tree.addItem(monthly1);
tree.flatten(true);
@@ -652,7 +652,7 @@ public class TestSubscriptionItemTree /* extends InvoiceTestSuiteNoDB */ {
final BigDecimal rate3 = new BigDecimal("29.95");
final BigDecimal proratedAmount3 = new BigDecimal("23.19");
- final SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId);
+ final SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId, invoiceId);
final InvoiceItem initial = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, planName, phaseName, startDate, endDate, amount1, rate1, currency);
final InvoiceItem newItem1 = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, "foo", "foo", change1, endDate, proratedAmount2, rate2, currency);
final InvoiceItem repair1 = new RepairAdjInvoiceItem(invoiceId, accountId, change1, endDate, new BigDecimal("-483.86"), currency, initial.getId());
@@ -688,7 +688,7 @@ public class TestSubscriptionItemTree /* extends InvoiceTestSuiteNoDB */ {
final BigDecimal monthlyAmount = monthlyRate;
final BigDecimal fixedAmount = new BigDecimal("5.00");
- final SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId);
+ final SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId, invoiceId);
final InvoiceItem monthly = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, planName, phaseName, startDate, endDate, monthlyAmount, monthlyRate, currency);
final InvoiceItem fixed = new FixedPriceInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, planName, phaseName, startDate, fixedAmount, currency);
tree.addItem(monthly);
@@ -714,7 +714,7 @@ public class TestSubscriptionItemTree /* extends InvoiceTestSuiteNoDB */ {
final BigDecimal monthlyAmount = monthlyRate;
final BigDecimal fixedAmount = new BigDecimal("5.00");
- final SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId);
+ final SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId, invoiceId);
final InvoiceItem monthly = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, planName, phaseName, startDate, endDate, monthlyAmount, monthlyRate, currency);
tree.addItem(monthly);
tree.flatten(true);
@@ -742,7 +742,7 @@ public class TestSubscriptionItemTree /* extends InvoiceTestSuiteNoDB */ {
final BigDecimal rate1 = new BigDecimal("12.00");
final BigDecimal amount1 = rate1;
- final SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId);
+ final SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId, invoiceId);
final InvoiceItem initial = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, planName, phaseName, startDate, endDate, amount1, rate1, currency);
final InvoiceItem itemAdj = new ItemAdjInvoiceItem(initial, itemAdjDate, new BigDecimal("-2.00"), currency);
tree.addItem(initial);
@@ -772,7 +772,7 @@ public class TestSubscriptionItemTree /* extends InvoiceTestSuiteNoDB */ {
final BigDecimal rate1 = new BigDecimal("12.00");
final BigDecimal amount1 = rate1;
- final SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId);
+ final SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId, invoiceId);
final InvoiceItem initial = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, planName, phaseName, startDate, endDate, amount1, rate1, currency);
final InvoiceItem itemAdj = new ItemAdjInvoiceItem(initial, itemAdjDate, new BigDecimal("-10.00"), currency);
tree.addItem(initial);
@@ -809,7 +809,7 @@ public class TestSubscriptionItemTree /* extends InvoiceTestSuiteNoDB */ {
final InvoiceItem monthly2 = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, planName, phaseName, endMonthly1, endMonthly2, monthlyAmount, monthlyRate, currency);
// First test with items in order
- SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId);
+ SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId, invoiceId);
tree.addItem(monthly1);
tree.addItem(monthly2);
tree.flatten(true);
@@ -833,7 +833,7 @@ public class TestSubscriptionItemTree /* extends InvoiceTestSuiteNoDB */ {
@Test(groups = "fast")
public void verifyJson() {
- SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId);
+ SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId, invoiceId);
final UUID id1 = UUID.fromString("e8ba6ce7-9bd4-417d-af53-70951ecaa99f");
final InvoiceItem yearly1 = new RecurringInvoiceItem(id1, new DateTime(), invoiceId, accountId, bundleId, subscriptionId, planName, phaseName, new LocalDate("2014-01-01"), new LocalDate("2015-01-01"), BigDecimal.TEN, BigDecimal.TEN, currency);
tree.addItem(yearly1);
jaxrs/pom.xml 6(+5 -1)
diff --git a/jaxrs/pom.xml b/jaxrs/pom.xml
index f40e5f3..a8641bc 100644
--- a/jaxrs/pom.xml
+++ b/jaxrs/pom.xml
@@ -19,7 +19,7 @@
<parent>
<artifactId>killbill</artifactId>
<groupId>org.kill-bill.billing</groupId>
- <version>0.11.13-SNAPSHOT</version>
+ <version>0.11.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-jaxrs</artifactId>
@@ -66,6 +66,10 @@
<artifactId>jersey-server</artifactId>
</dependency>
<dependency>
+ <groupId>com.wordnik</groupId>
+ <artifactId>swagger-annotations</artifactId>
+ </dependency>
+ <dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<scope>provided</scope>
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/AccountEmailJson.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/AccountEmailJson.java
index a0447c5..5d91029 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/AccountEmailJson.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/AccountEmailJson.java
@@ -19,15 +19,17 @@ package org.killbill.billing.jaxrs.json;
import java.util.UUID;
import org.joda.time.DateTime;
-
import org.killbill.billing.account.api.AccountEmail;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
+import com.wordnik.swagger.annotations.ApiModelProperty;
public class AccountEmailJson extends JsonBase {
+ @ApiModelProperty(dataType = "java.util.UUID")
private final String accountId;
+ @ApiModelProperty(required = true)
private final String email;
@JsonCreator
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/AccountJson.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/AccountJson.java
index 7e6ceef..3ea7daf 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/AccountJson.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/AccountJson.java
@@ -32,9 +32,12 @@ import org.killbill.billing.util.audit.AccountAuditLogs;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Objects;
+import com.google.common.base.Strings;
+import com.wordnik.swagger.annotations.ApiModelProperty;
public class AccountJson extends JsonBase {
+ @ApiModelProperty(dataType = "java.util.UUID")
private final String accountId;
private final String externalKey;
private final BigDecimal accountCBA;
@@ -44,6 +47,7 @@ public class AccountJson extends JsonBase {
private final String email;
private final Integer billCycleDayLocal;
private final String currency;
+ @ApiModelProperty(dataType = "java.util.UUID")
private final String paymentMethodId;
private final String timeZone;
private final String address1;
@@ -137,7 +141,7 @@ public class AccountJson extends JsonBase {
return new AccountData() {
@Override
public DateTimeZone getTimeZone() {
- return (timeZone != null) ? DateTimeZone.forID(timeZone) : null;
+ return (Strings.emptyToNull(timeZone) != null) ? DateTimeZone.forID(timeZone) : null;
}
@Override
@@ -203,7 +207,7 @@ public class AccountJson extends JsonBase {
@Override
public Currency getCurrency() {
- if (currency == null) {
+ if (Strings.emptyToNull(currency) == null) {
return null;
} else {
return Currency.valueOf(currency);
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/AuditLogJson.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/AuditLogJson.java
index 9db5376..951e271 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/AuditLogJson.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/AuditLogJson.java
@@ -22,10 +22,12 @@ import org.killbill.billing.util.audit.AuditLog;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
+import com.wordnik.swagger.annotations.ApiModelProperty;
public class AuditLogJson {
private final String changeType;
+ @ApiModelProperty(dataType = "org.joda.time.DateTime")
private final DateTime changeDate;
private final String changedBy;
private final String reasonCode;
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/BillingExceptionJson.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/BillingExceptionJson.java
index a009eb5..181fa6d 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/BillingExceptionJson.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/BillingExceptionJson.java
@@ -54,12 +54,13 @@ public class BillingExceptionJson {
this.stackTrace = stackTrace;
}
- public BillingExceptionJson(final Exception exception) {
+ public BillingExceptionJson(final Exception exception, final boolean withStackTrace) {
this(exception.getClass().getName(),
exception instanceof BillingExceptionBase ? ((BillingExceptionBase) exception).getCode() : null,
exception.getLocalizedMessage(),
exception.getCause() == null ? null : exception.getCause().getClass().getName(),
exception.getCause() == null ? null : exception.getCause().getLocalizedMessage(),
+ !withStackTrace ? ImmutableList.<StackTraceElementJson>of() :
Lists.<StackTraceElement, StackTraceElementJson>transform(ImmutableList.<StackTraceElement>copyOf(exception.getStackTrace()),
new Function<StackTraceElement, StackTraceElementJson>() {
@Override
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/BundleJson.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/BundleJson.java
index 249e149..9c3a1f0 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/BundleJson.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/BundleJson.java
@@ -31,10 +31,13 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableList;
+import com.wordnik.swagger.annotations.ApiModelProperty;
public class BundleJson extends JsonBase {
+ @ApiModelProperty(dataType = "java.util.UUID", required = true)
protected final String accountId;
+ @ApiModelProperty(dataType = "java.util.UUID")
protected final String bundleId;
protected final String externalKey;
private final List<SubscriptionJson> subscriptions;
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/CreditJson.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/CreditJson.java
index ab5112d..5819a22 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/CreditJson.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/CreditJson.java
@@ -21,23 +21,24 @@ import java.util.List;
import javax.annotation.Nullable;
-import org.joda.time.DateTime;
-import org.joda.time.DateTimeZone;
import org.joda.time.LocalDate;
-
import org.killbill.billing.invoice.api.Invoice;
import org.killbill.billing.invoice.api.InvoiceItem;
import org.killbill.billing.util.audit.AuditLog;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
+import com.wordnik.swagger.annotations.ApiModelProperty;
public class CreditJson extends JsonBase {
+ @ApiModelProperty(required = true)
private final BigDecimal creditAmount;
+ @ApiModelProperty(dataType = "java.util.UUID")
private final String invoiceId;
private final String invoiceNumber;
private final LocalDate effectiveDate;
+ @ApiModelProperty(dataType = "java.util.UUID", required = true)
private final String accountId;
@JsonCreator
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/CustomFieldJson.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/CustomFieldJson.java
index c0abc8a..9013d28 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/CustomFieldJson.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/CustomFieldJson.java
@@ -26,13 +26,18 @@ import org.killbill.billing.util.customfield.CustomField;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
+import com.wordnik.swagger.annotations.ApiModelProperty;
public class CustomFieldJson extends JsonBase {
+ @ApiModelProperty(dataType = "java.util.UUID")
private final String customFieldId;
+ @ApiModelProperty(dataType = "java.util.UUID")
private final String objectId;
private final ObjectType objectType;
+ @ApiModelProperty(required = true)
private final String name;
+ @ApiModelProperty(required = true)
private final String value;
@JsonCreator
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/GatewayNotificationJson.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/GatewayNotificationJson.java
index 923258c..bfc1b85 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/GatewayNotificationJson.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/GatewayNotificationJson.java
@@ -28,9 +28,11 @@ import org.killbill.billing.payment.plugin.api.GatewayNotification;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
+import com.wordnik.swagger.annotations.ApiModelProperty;
public class GatewayNotificationJson extends JsonBase {
+ @ApiModelProperty(dataType = "java.util.UUID")
private final String kbPaymentId;
private final Integer status;
private final String entity;
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/HostedPaymentPageFormDescriptorJson.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/HostedPaymentPageFormDescriptorJson.java
index 2753e70..623cdca 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/HostedPaymentPageFormDescriptorJson.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/HostedPaymentPageFormDescriptorJson.java
@@ -23,9 +23,11 @@ import org.killbill.billing.payment.plugin.api.HostedPaymentPageFormDescriptor;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
+import com.wordnik.swagger.annotations.ApiModelProperty;
public class HostedPaymentPageFormDescriptorJson extends JsonBase {
+ @ApiModelProperty(dataType = "java.util.UUID")
private final String kbAccountId;
private final String formMethod;
private final String formUrl;
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/InvoiceEmailJson.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/InvoiceEmailJson.java
index 0a4f024..a0e5d9e 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/InvoiceEmailJson.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/InvoiceEmailJson.java
@@ -19,9 +19,11 @@ package org.killbill.billing.jaxrs.json;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonProperty;
+import com.wordnik.swagger.annotations.ApiModelProperty;
public class InvoiceEmailJson extends JsonBase {
+ @ApiModelProperty(dataType = "java.util.UUID")
private final String accountId;
private final boolean isNotifiedForInvoices;
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/InvoiceItemJson.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/InvoiceItemJson.java
index 0d87f23..a476a22 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/InvoiceItemJson.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/InvoiceItemJson.java
@@ -31,14 +31,21 @@ import org.killbill.billing.util.audit.AuditLog;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
+import com.wordnik.swagger.annotations.ApiModelProperty;
public class InvoiceItemJson extends JsonBase {
+ @ApiModelProperty(dataType = "java.util.UUID", required = true)
private final String invoiceItemId;
+ @ApiModelProperty(dataType = "java.util.UUID")
private final String invoiceId;
+ @ApiModelProperty(dataType = "java.util.UUID")
private final String linkedInvoiceItemId;
+ @ApiModelProperty(dataType = "java.util.UUID", required = true)
private final String accountId;
+ @ApiModelProperty(dataType = "java.util.UUID")
private final String bundleId;
+ @ApiModelProperty(dataType = "java.util.UUID")
private final String subscriptionId;
private final String planName;
private final String phaseName;
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/InvoiceJson.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/InvoiceJson.java
index b45e4c4..639d2c9 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/InvoiceJson.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/InvoiceJson.java
@@ -31,11 +31,13 @@ import org.killbill.billing.util.audit.AuditLog;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
+import com.wordnik.swagger.annotations.ApiModelProperty;
public class InvoiceJson extends JsonBase {
private final BigDecimal amount;
private final String currency;
+ @ApiModelProperty(dataType = "java.util.UUID")
private final String invoiceId;
private final LocalDate invoiceDate;
private final LocalDate targetDate;
@@ -43,6 +45,7 @@ public class InvoiceJson extends JsonBase {
private final BigDecimal balance;
private final BigDecimal creditAdj;
private final BigDecimal refundAdj;
+ @ApiModelProperty(dataType = "java.util.UUID")
private final String accountId;
private final List<InvoiceItemJson> items;
private final String bundleKeys;
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/InvoicePaymentJson.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/InvoicePaymentJson.java
index f7c366d..f37d2e4 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/InvoicePaymentJson.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/InvoicePaymentJson.java
@@ -29,9 +29,11 @@ import org.killbill.billing.util.audit.AccountAuditLogs;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
+import com.wordnik.swagger.annotations.ApiModelProperty;
public class InvoicePaymentJson extends PaymentJson {
+ @ApiModelProperty(dataType = "java.util.UUID")
private final String targetInvoiceId;
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/NotificationJson.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/NotificationJson.java
index e8fcd14..469e2c4 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/NotificationJson.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/NotificationJson.java
@@ -20,6 +20,7 @@ import org.killbill.billing.notification.plugin.api.ExtBusEvent;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
+import com.wordnik.swagger.annotations.ApiModelProperty;
/*
* Use to communicate back with client after they registered a callback
@@ -27,8 +28,10 @@ import com.fasterxml.jackson.annotation.JsonProperty;
public class NotificationJson {
private final String eventType;
+ @ApiModelProperty(dataType = "java.util.UUID")
private final String accountId;
private final String objectType;
+ @ApiModelProperty(dataType = "java.util.UUID")
private final String objectId;
@JsonCreator
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/PaymentJson.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/PaymentJson.java
index 4bf0f5d..3a85882 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/PaymentJson.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/PaymentJson.java
@@ -31,10 +31,13 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
+import com.wordnik.swagger.annotations.ApiModelProperty;
public class PaymentJson extends JsonBase {
+ @ApiModelProperty(dataType = "java.util.UUID")
private final String accountId;
+ @ApiModelProperty(dataType = "java.util.UUID")
private final String paymentId;
private final String paymentNumber;
private final String paymentExternalKey;
@@ -44,6 +47,7 @@ public class PaymentJson extends JsonBase {
private final BigDecimal refundedAmount;
private final BigDecimal creditedAmount;
private final String currency;
+ @ApiModelProperty(dataType = "java.util.UUID")
private final String paymentMethodId;
private final List<? extends PaymentTransactionJson> transactions;
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/PaymentMethodJson.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/PaymentMethodJson.java
index 0482484..2cc6720 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/PaymentMethodJson.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/PaymentMethodJson.java
@@ -36,11 +36,14 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Function;
import com.google.common.collect.Collections2;
+import com.wordnik.swagger.annotations.ApiModelProperty;
public class PaymentMethodJson extends JsonBase {
private final String externalKey;
+ @ApiModelProperty(dataType = "java.util.UUID")
private final String paymentMethodId;
+ @ApiModelProperty(dataType = "java.util.UUID")
private final String accountId;
private final Boolean isDefault;
private final String pluginName;
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/PaymentTransactionJson.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/PaymentTransactionJson.java
index 09fb976..82a40dd 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/PaymentTransactionJson.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/PaymentTransactionJson.java
@@ -27,17 +27,27 @@ import org.killbill.billing.util.audit.AuditLog;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
+import com.wordnik.swagger.annotations.ApiModel;
+import com.wordnik.swagger.annotations.ApiModelProperty;
+@ApiModel(description = "Payment transaction")
public class PaymentTransactionJson extends JsonBase {
+ @ApiModelProperty(dataType = "java.util.UUID")
private final String transactionId;
private final String transactionExternalKey;
+ @ApiModelProperty(value = "Associated payment id, required when notifying state transitions", dataType = "java.util.UUID")
private final String paymentId;
private final String paymentExternalKey;
+ @ApiModelProperty(dataType = "org.killbill.billing.payment.api.TransactionType")
private final String transactionType;
+ @ApiModelProperty(dataType = "org.joda.time.DateTime")
private final DateTime effectiveDate;
+ @ApiModelProperty(value = "Transaction status, required for state change notifications", dataType = "org.killbill.billing.payment.api.TransactionStatus")
private final String status;
+ @ApiModelProperty(value = "Transaction amount, required except for void operations")
private final BigDecimal amount;
+ @ApiModelProperty(value = "Amount currency (account currency unless specified)", dataType = "org.killbill.billing.catalog.api.Currency")
private final String currency;
private final String gatewayErrorCode;
private final String gatewayErrorMsg;
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/RolledUpUsageJson.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/RolledUpUsageJson.java
index 0cc9bc6..c8185b2 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/RolledUpUsageJson.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/RolledUpUsageJson.java
@@ -27,9 +27,11 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
+import com.wordnik.swagger.annotations.ApiModelProperty;
public class RolledUpUsageJson {
+ @ApiModelProperty(dataType = "java.util.UUID")
private final String subscriptionId;
private final LocalDate startDate;
private final LocalDate endDate;
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/SessionJson.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/SessionJson.java
index fbd5eca..03f7395 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/SessionJson.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/SessionJson.java
@@ -22,11 +22,14 @@ import org.joda.time.DateTimeZone;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
+import com.wordnik.swagger.annotations.ApiModelProperty;
public class SessionJson {
private final String id;
+ @ApiModelProperty(dataType = "org.joda.time.DateTime")
private final DateTime startDate;
+ @ApiModelProperty(dataType = "org.joda.time.DateTime")
private final DateTime lastAccessDate;
private final Long timeout;
private final String host;
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/SubscriptionJson.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/SubscriptionJson.java
index ffecd4a..4296784 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/SubscriptionJson.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/SubscriptionJson.java
@@ -33,17 +33,25 @@ import org.killbill.billing.util.audit.AccountAuditLogs;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
+import com.wordnik.swagger.annotations.ApiModelProperty;
public class SubscriptionJson extends JsonBase {
+ @ApiModelProperty(dataType = "java.util.UUID")
private final String accountId;
+ @ApiModelProperty(dataType = "java.util.UUID")
private final String bundleId;
+ @ApiModelProperty(dataType = "java.util.UUID")
private final String subscriptionId;
private final String externalKey;
private final LocalDate startDate;
+ @ApiModelProperty(required = true)
private final String productName;
+ @ApiModelProperty(dataType = "org.killbill.billing.catalog.api.ProductCategory", required = true)
private final String productCategory;
+ @ApiModelProperty(dataType = "org.killbill.billing.catalog.api.BillingPeriod", required = true)
private final String billingPeriod;
+ @ApiModelProperty(required = true)
private final String priceList;
private final LocalDate cancelledDate;
private final LocalDate chargedThroughDate;
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/SubscriptionUsageRecordJson.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/SubscriptionUsageRecordJson.java
index 06caa2d..9e961a6 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/SubscriptionUsageRecordJson.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/SubscriptionUsageRecordJson.java
@@ -30,10 +30,13 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
+import com.wordnik.swagger.annotations.ApiModelProperty;
public class SubscriptionUsageRecordJson {
+ @ApiModelProperty(dataType = "java.util.UUID", required = true)
private final String subscriptionId;
+ @ApiModelProperty(required = true)
private final List<UnitUsageRecordJson> unitUsageRecords;
@JsonCreator
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/TagDefinitionJson.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/TagDefinitionJson.java
index fd1c5cb..fedac1c 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/TagDefinitionJson.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/TagDefinitionJson.java
@@ -29,12 +29,16 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Function;
import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableList;
+import com.wordnik.swagger.annotations.ApiModelProperty;
public class TagDefinitionJson extends JsonBase {
+ @ApiModelProperty(dataType = "java.util.UUID")
private final String id;
private final Boolean isControlTag;
+ @ApiModelProperty(required = true)
private final String name;
+ @ApiModelProperty(required = true)
private final String description;
private final List<String> applicableObjectTypes;
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/TagJson.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/TagJson.java
index 6307410..0e8233d 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/TagJson.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/TagJson.java
@@ -27,11 +27,15 @@ import org.killbill.billing.util.tag.TagDefinition;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
+import com.wordnik.swagger.annotations.ApiModelProperty;
public class TagJson extends JsonBase {
+ @ApiModelProperty(dataType = "java.util.UUID")
private final String tagId;
+ @ApiModelProperty(dataType = "org.killbill.billing.ObjectType")
private final ObjectType objectType;
+ @ApiModelProperty(dataType = "java.util.UUID")
private final String tagDefinitionId;
private final String tagDefinitionName;
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/TenantJson.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/TenantJson.java
index 6670881..76fe844 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/TenantJson.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/TenantJson.java
@@ -21,13 +21,17 @@ import org.killbill.billing.tenant.api.TenantData;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
+import com.wordnik.swagger.annotations.ApiModelProperty;
public class TenantJson extends JsonBase {
- protected final String tenantId;
- protected final String externalKey;
- protected final String apiKey;
- protected final String apiSecret;
+ @ApiModelProperty(dataType = "java.util.UUID")
+ private final String tenantId;
+ private final String externalKey;
+ @ApiModelProperty(required = true)
+ private final String apiKey;
+ @ApiModelProperty(required = true)
+ private final String apiSecret;
@JsonCreator
public TenantJson(@JsonProperty("tenantId") final String tenantId,
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/TenantKeyJson.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/TenantKeyJson.java
index 51d4bdf..f3d3b3d 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/TenantKeyJson.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/TenantKeyJson.java
@@ -26,7 +26,6 @@ public class TenantKeyJson {
private final String key;
private final List<String> values;
-
@JsonCreator
public TenantKeyJson(@JsonProperty("key") final String key,
@JsonProperty("values") final List<String> values) {
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/mappers/ExceptionMapperBase.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/mappers/ExceptionMapperBase.java
index 7e32c1d..047d76e 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/mappers/ExceptionMapperBase.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/mappers/ExceptionMapperBase.java
@@ -48,6 +48,8 @@ public abstract class ExceptionMapperBase {
private static final Logger log = LoggerFactory.getLogger(ExceptionMapperBase.class);
private static final ObjectMapper mapper = new ObjectMapper();
+ private static final String QUERY_WITH_STACK_TRACE = "withStackTrace";
+
protected Response fallback(final Exception exception, final UriInfo uriInfo) {
if (exception.getCause() == null) {
return buildBadRequestResponse(exception, uriInfo);
@@ -114,7 +116,7 @@ public abstract class ExceptionMapperBase {
log.warn("Conflicting request", e);
final Response.ResponseBuilder responseBuilder = Response.status(Status.CONFLICT);
- serializeException(e, responseBuilder);
+ serializeException(e, uriInfo, responseBuilder);
return responseBuilder.build();
}
@@ -123,7 +125,7 @@ public abstract class ExceptionMapperBase {
log.info("Not found", e);
final Response.ResponseBuilder responseBuilder = Response.status(Status.NOT_FOUND);
- serializeException(e, responseBuilder);
+ serializeException(e, uriInfo, responseBuilder);
return responseBuilder.build();
}
@@ -132,7 +134,7 @@ public abstract class ExceptionMapperBase {
log.warn("Bad request", e);
final Response.ResponseBuilder responseBuilder = Response.status(Status.BAD_REQUEST);
- serializeException(e, responseBuilder);
+ serializeException(e, uriInfo, responseBuilder);
return responseBuilder.build();
}
@@ -142,7 +144,7 @@ public abstract class ExceptionMapperBase {
// TODO Forbidden?
final Response.ResponseBuilder responseBuilder = Response.status(Status.UNAUTHORIZED);
- serializeException(e, responseBuilder);
+ serializeException(e, uriInfo, responseBuilder);
return responseBuilder.build();
}
@@ -151,23 +153,24 @@ public abstract class ExceptionMapperBase {
log.warn("Internal error", e);
final Response.ResponseBuilder responseBuilder = Response.status(Status.INTERNAL_SERVER_ERROR);
- serializeException(e, responseBuilder);
+ serializeException(e, uriInfo, responseBuilder);
return responseBuilder.build();
}
protected Response buildPluginTimeoutResponse(final Exception e, final UriInfo uriInfo) {
final Response.ResponseBuilder responseBuilder = Response.status(Status.ACCEPTED);
- serializeException(e, responseBuilder);
+ serializeException(e, uriInfo, responseBuilder);
return responseBuilder.build();
}
- private void serializeException(final Exception e, final Response.ResponseBuilder responseBuilder) {
- final BillingExceptionJson billingExceptionJson = new BillingExceptionJson(e);
+ private void serializeException(final Exception e, final UriInfo uriInfo, final Response.ResponseBuilder responseBuilder) {
+ final boolean withStackTrace = uriInfo.getQueryParameters() != null && "true".equals(uriInfo.getQueryParameters().getFirst(QUERY_WITH_STACK_TRACE));
+ final BillingExceptionJson billingExceptionJson = new BillingExceptionJson(e, withStackTrace);
try {
final String billingExceptionJsonAsString = mapper.writeValueAsString(billingExceptionJson);
responseBuilder.entity(billingExceptionJsonAsString).type(MediaType.APPLICATION_JSON);
- } catch (JsonProcessingException jsonException) {
+ } catch (final JsonProcessingException jsonException) {
log.warn("Unable to serialize exception", jsonException);
responseBuilder.entity(e.toString()).type(MediaType.TEXT_PLAIN_TYPE);
}
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/mappers/JsonMappingExceptionMapper.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/mappers/JsonMappingExceptionMapper.java
new file mode 100644
index 0000000..d13b523
--- /dev/null
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/mappers/JsonMappingExceptionMapper.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2014 Groupon, Inc
+ * Copyright 2014 The Billing Project, LLC
+ *
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
+ * (the "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.killbill.billing.jaxrs.mappers;
+
+import javax.inject.Singleton;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+import javax.ws.rs.ext.ExceptionMapper;
+import javax.ws.rs.ext.Provider;
+
+import com.fasterxml.jackson.databind.JsonMappingException;
+
+@Singleton
+@Provider
+public class JsonMappingExceptionMapper extends ExceptionMapperBase implements ExceptionMapper<JsonMappingException> {
+
+ private final UriInfo uriInfo;
+
+ public JsonMappingExceptionMapper(@Context final UriInfo uriInfo) {
+ this.uriInfo = uriInfo;
+ }
+
+ @Override
+ public Response toResponse(final JsonMappingException exception) {
+ // Likely bad arguments
+ return buildBadRequestResponse(exception, uriInfo);
+ }
+}
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/mappers/TenantApiExceptionMapper.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/mappers/TenantApiExceptionMapper.java
new file mode 100644
index 0000000..820ba2a
--- /dev/null
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/mappers/TenantApiExceptionMapper.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2014 Groupon, Inc
+ * Copyright 2014 The Billing Project, LLC
+ *
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
+ * (the "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.killbill.billing.jaxrs.mappers;
+
+import javax.inject.Singleton;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+import javax.ws.rs.ext.ExceptionMapper;
+import javax.ws.rs.ext.Provider;
+
+import org.killbill.billing.ErrorCode;
+import org.killbill.billing.tenant.api.TenantApiException;
+
+@Singleton
+@Provider
+public class TenantApiExceptionMapper extends ExceptionMapperBase implements ExceptionMapper<TenantApiException> {
+
+ private final UriInfo uriInfo;
+
+ public TenantApiExceptionMapper(@Context final UriInfo uriInfo) {
+ this.uriInfo = uriInfo;
+ }
+
+ @Override
+ public Response toResponse(final TenantApiException exception) {
+ if (exception.getCode() == ErrorCode.TENANT_ALREADY_EXISTS.getCode()) {
+ return buildConflictingRequestResponse(exception, uriInfo);
+ } else if (exception.getCode() == ErrorCode.TENANT_DOES_NOT_EXIST_FOR_ID.getCode()) {
+ return buildNotFoundResponse(exception, uriInfo);
+ } else if (exception.getCode() == ErrorCode.TENANT_DOES_NOT_EXIST_FOR_KEY.getCode()) {
+ return buildNotFoundResponse(exception, uriInfo);
+ } else if (exception.getCode() == ErrorCode.TENANT_DOES_NOT_EXIST_FOR_API_KEY.getCode()) {
+ return buildNotFoundResponse(exception, uriInfo);
+ } else if (exception.getCode() == ErrorCode.TENANT_CREATION_FAILED.getCode()) {
+ return buildInternalErrorResponse(exception, uriInfo);
+ } else if (exception.getCode() == ErrorCode.TENANT_UPDATE_FAILED.getCode()) {
+ return buildInternalErrorResponse(exception, uriInfo);
+ } else if (exception.getCode() == ErrorCode.TENANT_NO_SUCH_KEY.getCode()) {
+ return buildNotFoundResponse(exception, uriInfo);
+ } else {
+ return fallback(exception, uriInfo);
+ }
+ }
+}
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/AccountResource.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/AccountResource.java
index 95e1a82..6ffc71a 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/AccountResource.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/AccountResource.java
@@ -65,13 +65,14 @@ import org.killbill.billing.jaxrs.json.AccountJson;
import org.killbill.billing.jaxrs.json.AccountTimelineJson;
import org.killbill.billing.jaxrs.json.BundleJson;
import org.killbill.billing.jaxrs.json.CustomFieldJson;
-import org.killbill.billing.jaxrs.json.PaymentJson;
-import org.killbill.billing.jaxrs.json.PaymentTransactionJson;
import org.killbill.billing.jaxrs.json.InvoiceEmailJson;
import org.killbill.billing.jaxrs.json.InvoiceJson;
import org.killbill.billing.jaxrs.json.InvoicePaymentJson;
import org.killbill.billing.jaxrs.json.OverdueStateJson;
+import org.killbill.billing.jaxrs.json.PaymentJson;
import org.killbill.billing.jaxrs.json.PaymentMethodJson;
+import org.killbill.billing.jaxrs.json.PaymentTransactionJson;
+import org.killbill.billing.jaxrs.json.TagJson;
import org.killbill.billing.jaxrs.util.Context;
import org.killbill.billing.jaxrs.util.JaxrsUriBuilder;
import org.killbill.billing.overdue.OverdueApiException;
@@ -107,11 +108,16 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.inject.Inject;
import com.google.inject.Singleton;
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+import com.wordnik.swagger.annotations.ApiResponse;
+import com.wordnik.swagger.annotations.ApiResponses;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
@Singleton
@Path(JaxrsResource.ACCOUNTS_PATH)
+@Api(value = JaxrsResource.ACCOUNTS_PATH, description = "Operations on accounts")
public class AccountResource extends JaxRsResourceBase {
private static final String ID_PARAM_NAME = "accountId";
@@ -145,6 +151,9 @@ public class AccountResource extends JaxRsResourceBase {
@GET
@Path("/{accountId:" + UUID_PATTERN + "}")
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve an account by id", response = AccountJson.class)
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid account id supplied"),
+ @ApiResponse(code = 404, message = "Account not found")})
public Response getAccount(@PathParam("accountId") final String accountId,
@QueryParam(QUERY_ACCOUNT_WITH_BALANCE) @DefaultValue("false") final Boolean accountWithBalance,
@QueryParam(QUERY_ACCOUNT_WITH_BALANCE_AND_CBA) @DefaultValue("false") final Boolean accountWithBalanceAndCBA,
@@ -161,6 +170,8 @@ public class AccountResource extends JaxRsResourceBase {
@GET
@Path("/" + PAGINATION)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "List accounts", response = AccountJson.class, responseContainer = "List")
+ @ApiResponses(value = {})
public Response getAccounts(@QueryParam(QUERY_SEARCH_OFFSET) @DefaultValue("0") final Long offset,
@QueryParam(QUERY_SEARCH_LIMIT) @DefaultValue("100") final Long limit,
@QueryParam(QUERY_ACCOUNT_WITH_BALANCE) @DefaultValue("false") final Boolean accountWithBalance,
@@ -188,6 +199,8 @@ public class AccountResource extends JaxRsResourceBase {
@GET
@Path("/" + SEARCH + "/{searchKey:" + ANYTHING_PATTERN + "}")
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Search accounts", response = AccountJson.class, responseContainer = "List")
+ @ApiResponses(value = {})
public Response searchAccounts(@PathParam("searchKey") final String searchKey,
@QueryParam(QUERY_SEARCH_OFFSET) @DefaultValue("0") final Long offset,
@QueryParam(QUERY_SEARCH_LIMIT) @DefaultValue("100") final Long limit,
@@ -217,6 +230,9 @@ public class AccountResource extends JaxRsResourceBase {
@GET
@Path("/{accountId:" + UUID_PATTERN + "}/" + BUNDLES)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve bundles for account", response = BundleJson.class, responseContainer = "List")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid account id supplied"),
+ @ApiResponse(code = 404, message = "Account not found")})
public Response getAccountBundles(@PathParam("accountId") final String accountId,
@QueryParam(QUERY_EXTERNAL_KEY) final String externalKey,
@javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException, SubscriptionApiException {
@@ -241,6 +257,8 @@ public class AccountResource extends JaxRsResourceBase {
@Timed
@GET
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve an account by external key", response = AccountJson.class)
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Account not found")})
public Response getAccountByKey(@QueryParam(QUERY_EXTERNAL_KEY) final String externalKey,
@QueryParam(QUERY_ACCOUNT_WITH_BALANCE) @DefaultValue("false") final Boolean accountWithBalance,
@QueryParam(QUERY_ACCOUNT_WITH_BALANCE_AND_CBA) @DefaultValue("false") final Boolean accountWithBalanceAndCBA,
@@ -271,12 +289,16 @@ public class AccountResource extends JaxRsResourceBase {
@POST
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Create account")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid account data supplied")})
public Response createAccount(final AccountJson json,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
@HeaderParam(HDR_REASON) final String reason,
@HeaderParam(HDR_COMMENT) final String comment,
@javax.ws.rs.core.Context final HttpServletRequest request,
@javax.ws.rs.core.Context final UriInfo uriInfo) throws AccountApiException {
+ verifyNonNullOrEmpty(json, "AccountJson body should be specified");
+
final AccountData data = json.toAccountData();
final Account account = accountUserApi.createAccount(data, context.createContext(createdBy, reason, comment, request));
return uriBuilder.buildResponse(uriInfo, AccountResource.class, "getAccount", account.getId());
@@ -287,12 +309,16 @@ public class AccountResource extends JaxRsResourceBase {
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("/{accountId:" + UUID_PATTERN + "}")
+ @ApiOperation(value = "Update account")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid account data supplied")})
public Response updateAccount(final AccountJson json,
@PathParam("accountId") final String accountId,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
@HeaderParam(HDR_REASON) final String reason,
@HeaderParam(HDR_COMMENT) final String comment,
@javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException {
+ verifyNonNullOrEmpty(json, "AccountJson body should be specified");
+
final AccountData data = json.toAccountData();
final UUID uuid = UUID.fromString(accountId);
accountUserApi.updateAccount(uuid, data, context.createContext(createdBy, reason, comment, request));
@@ -304,6 +330,8 @@ public class AccountResource extends JaxRsResourceBase {
@DELETE
@Path("/{accountId:" + UUID_PATTERN + "}")
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Delete account", hidden = true)
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid account id supplied")})
public Response cancelAccount(@PathParam("accountId") final String accountId,
@javax.ws.rs.core.Context final HttpServletRequest request) {
/*
@@ -322,6 +350,9 @@ public class AccountResource extends JaxRsResourceBase {
@GET
@Path("/{accountId:" + UUID_PATTERN + "}/" + TIMELINE)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve account timeline", response = AccountTimelineJson.class)
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid account id supplied"),
+ @ApiResponse(code = 404, message = "Account not found")})
public Response getAccountTimeline(@PathParam("accountId") final String accountIdString,
@QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode,
@javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException, PaymentApiException, SubscriptionApiException {
@@ -356,6 +387,9 @@ public class AccountResource extends JaxRsResourceBase {
@GET
@Path("/{accountId:" + UUID_PATTERN + "}/" + EMAIL_NOTIFICATIONS)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve account email notification", response = InvoiceEmailJson.class)
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid account id supplied"),
+ @ApiResponse(code = 404, message = "Account not found")})
public Response getEmailNotificationsForAccount(@PathParam("accountId") final String accountId,
@javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException {
final Account account = accountUserApi.getAccountById(UUID.fromString(accountId), context.createContext(request));
@@ -369,12 +403,17 @@ public class AccountResource extends JaxRsResourceBase {
@Path("/{accountId:" + UUID_PATTERN + "}/" + EMAIL_NOTIFICATIONS)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
- public Response getEmailNotificationsForAccount(final InvoiceEmailJson json,
+ @ApiOperation(value = "Set account email notification")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid account id supplied"),
+ @ApiResponse(code = 404, message = "Account not found")})
+ public Response setEmailNotificationsForAccount(final InvoiceEmailJson json,
@PathParam("accountId") final String accountIdString,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
@HeaderParam(HDR_REASON) final String reason,
@HeaderParam(HDR_COMMENT) final String comment,
@javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException {
+ verifyNonNullOrEmpty(json, "InvoiceEmailJson body should be specified");
+
final CallContext callContext = context.createContext(createdBy, reason, comment, request);
final UUID accountId = UUID.fromString(accountIdString);
@@ -395,6 +434,8 @@ public class AccountResource extends JaxRsResourceBase {
@Path("/{accountId:" + UUID_PATTERN + "}/" + CBA_REBALANCING)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Rebalance account CBA")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid account id supplied")})
public Response rebalanceExistingCBAOnAccount(@PathParam("accountId") final String accountIdString,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
@HeaderParam(HDR_REASON) final String reason,
@@ -417,6 +458,9 @@ public class AccountResource extends JaxRsResourceBase {
@GET
@Path("/{accountId:" + UUID_PATTERN + "}/" + INVOICES)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve account invoices", response = InvoiceJson.class)
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid account id supplied"),
+ @ApiResponse(code = 404, message = "Account not found")})
public Response getInvoices(@PathParam("accountId") final String accountIdString,
@QueryParam(QUERY_INVOICE_WITH_ITEMS) @DefaultValue("false") final boolean withItems,
@QueryParam(QUERY_UNPAID_INVOICES_ONLY) @DefaultValue("false") final boolean unpaidInvoicesOnly,
@@ -451,6 +495,9 @@ public class AccountResource extends JaxRsResourceBase {
@GET
@Path("/{accountId:" + UUID_PATTERN + "}/" + INVOICE_PAYMENTS)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve account invoice payments", response = InvoicePaymentJson.class, responseContainer = "List")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid account id supplied"),
+ @ApiResponse(code = 404, message = "Account not found")})
public Response getInvoicePayments(@PathParam("accountId") final String accountIdStr,
@QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode,
@QueryParam(QUERY_WITH_PLUGIN_INFO) @DefaultValue("false") final Boolean withPluginInfo,
@@ -476,6 +523,9 @@ public class AccountResource extends JaxRsResourceBase {
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
@Path("/{accountId:" + UUID_PATTERN + "}/" + INVOICE_PAYMENTS)
+ @ApiOperation(value = "Trigger a payment for all unpaid invoices")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid account id supplied"),
+ @ApiResponse(code = 404, message = "Account not found")})
public Response payAllInvoices(@PathParam("accountId") final String accountId,
@QueryParam(QUERY_PAYMENT_EXTERNAL) @DefaultValue("false") final Boolean externalPayment,
@QueryParam(QUERY_PAYMENT_AMOUNT) final BigDecimal paymentAmount,
@@ -524,6 +574,9 @@ public class AccountResource extends JaxRsResourceBase {
@Path("/{accountId:" + UUID_PATTERN + "}/" + PAYMENT_METHODS)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Add a payment method")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid account id supplied"),
+ @ApiResponse(code = 404, message = "Account not found")})
public Response createPaymentMethod(final PaymentMethodJson json,
@PathParam("accountId") final String accountId,
@QueryParam(QUERY_PAYMENT_METHOD_IS_DEFAULT) @DefaultValue("false") final Boolean isDefault,
@@ -534,6 +587,9 @@ public class AccountResource extends JaxRsResourceBase {
@HeaderParam(HDR_COMMENT) final String comment,
@javax.ws.rs.core.Context final UriInfo uriInfo,
@javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException, PaymentApiException {
+ verifyNonNullOrEmpty(json, "PaymentMethodJson body should be specified");
+ verifyNonNullOrEmpty(json.getPluginName(), "PaymentMethodJson pluginName should be specified");
+
final Iterable<PluginProperty> pluginProperties = extractPluginProperties(pluginPropertiesString);
final CallContext callContext = context.createContext(createdBy, reason, comment, request);
@@ -560,6 +616,9 @@ public class AccountResource extends JaxRsResourceBase {
@GET
@Path("/{accountId:" + UUID_PATTERN + "}/" + PAYMENT_METHODS)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve account payment methods", response = PaymentMethodJson.class, responseContainer = "List")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid account id supplied"),
+ @ApiResponse(code = 404, message = "Account not found")})
public Response getPaymentMethods(@PathParam("accountId") final String accountId,
@QueryParam(QUERY_WITH_PLUGIN_INFO) @DefaultValue("false") final Boolean withPluginInfo,
@QueryParam(QUERY_PLUGIN_PROPERTY) final List<String> pluginPropertiesString,
@@ -586,6 +645,9 @@ public class AccountResource extends JaxRsResourceBase {
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("/{accountId:" + UUID_PATTERN + "}/" + PAYMENT_METHODS + "/{paymentMethodId:" + UUID_PATTERN + "}/" + PAYMENT_METHODS_DEFAULT_PATH_POSTFIX)
+ @ApiOperation(value = "Set the default payment method")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid account id or payment method id supplied"),
+ @ApiResponse(code = 404, message = "Account not found")})
public Response setDefaultPaymentMethod(@PathParam("accountId") final String accountId,
@PathParam("paymentMethodId") final String paymentMethodId,
@QueryParam(QUERY_PAY_ALL_UNPAID_INVOICES) @DefaultValue("false") final Boolean payAllUnpaidInvoices,
@@ -616,6 +678,8 @@ public class AccountResource extends JaxRsResourceBase {
@GET
@Path("/{accountId:" + UUID_PATTERN + "}/" + PAYMENTS)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve account payments", response = PaymentJson.class, responseContainer = "List")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid account id supplied")})
public Response getPayments(@PathParam("accountId") final String accountIdStr,
@QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode,
@QueryParam(QUERY_PLUGIN_PROPERTY) final List<String> pluginPropertiesString,
@@ -640,15 +704,22 @@ public class AccountResource extends JaxRsResourceBase {
@Path("/{accountId:" + UUID_PATTERN + "}/" + PAYMENTS)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Trigger a payment (authorization, purchase or credit)")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid account id supplied"),
+ @ApiResponse(code = 404, message = "Account not found")})
public Response processPayment(final PaymentTransactionJson json,
- @PathParam("accountId") final String accountIdStr,
- @QueryParam("paymentMethodId") final String paymentMethodIdStr,
- @QueryParam(QUERY_PLUGIN_PROPERTY) final List<String> pluginPropertiesString,
- @HeaderParam(HDR_CREATED_BY) final String createdBy,
- @HeaderParam(HDR_REASON) final String reason,
- @HeaderParam(HDR_COMMENT) final String comment,
- @javax.ws.rs.core.Context final UriInfo uriInfo,
- @javax.ws.rs.core.Context final HttpServletRequest request) throws PaymentApiException, AccountApiException {
+ @PathParam("accountId") final String accountIdStr,
+ @QueryParam("paymentMethodId") final String paymentMethodIdStr,
+ @QueryParam(QUERY_PLUGIN_PROPERTY) final List<String> pluginPropertiesString,
+ @HeaderParam(HDR_CREATED_BY) final String createdBy,
+ @HeaderParam(HDR_REASON) final String reason,
+ @HeaderParam(HDR_COMMENT) final String comment,
+ @javax.ws.rs.core.Context final UriInfo uriInfo,
+ @javax.ws.rs.core.Context final HttpServletRequest request) throws PaymentApiException, AccountApiException {
+ verifyNonNullOrEmpty(json, "PaymentTransactionJson body should be specified");
+ verifyNonNullOrEmpty(json.getTransactionType(), "PaymentTransactionJson transactionType needs to be set",
+ json.getAmount(), "PaymentTransactionJson amount needs to be set");
+
final Iterable<PluginProperty> pluginProperties = extractPluginProperties(pluginPropertiesString);
final CallContext callContext = context.createContext(createdBy, reason, comment, request);
final UUID accountId = UUID.fromString(accountIdStr);
@@ -688,6 +759,9 @@ public class AccountResource extends JaxRsResourceBase {
@GET
@Path("/{accountId:" + UUID_PATTERN + "}/" + OVERDUE)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve overdue state for account", response = OverdueStateJson.class)
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid account id supplied"),
+ @ApiResponse(code = 404, message = "Account not found")})
public Response getOverdueAccount(@PathParam("accountId") final String accountId,
@javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException, OverdueException, OverdueApiException {
final TenantContext tenantContext = context.createContext(request);
@@ -706,6 +780,8 @@ public class AccountResource extends JaxRsResourceBase {
@GET
@Path("/{accountId:" + UUID_PATTERN + "}/" + CUSTOM_FIELDS)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve account custom fields", response = CustomFieldJson.class, responseContainer = "List")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid account id supplied")})
public Response getCustomFields(@PathParam(ID_PARAM_NAME) final String id,
@QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode,
@javax.ws.rs.core.Context final HttpServletRequest request) {
@@ -717,6 +793,8 @@ public class AccountResource extends JaxRsResourceBase {
@Path("/{accountId:" + UUID_PATTERN + "}/" + CUSTOM_FIELDS)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Add custom fields to account")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid account id supplied")})
public Response createCustomFields(@PathParam(ID_PARAM_NAME) final String id,
final List<CustomFieldJson> customFields,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
@@ -733,6 +811,8 @@ public class AccountResource extends JaxRsResourceBase {
@Path("/{accountId:" + UUID_PATTERN + "}/" + CUSTOM_FIELDS)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Remove custom fields from account")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid account id supplied")})
public Response deleteCustomFields(@PathParam(ID_PARAM_NAME) final String id,
@QueryParam(QUERY_CUSTOM_FIELDS) final String customFieldList,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
@@ -751,6 +831,9 @@ public class AccountResource extends JaxRsResourceBase {
@GET
@Path("/{accountId:" + UUID_PATTERN + "}/" + TAGS)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve account tags", response = TagJson.class, responseContainer = "List")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid account id supplied"),
+ @ApiResponse(code = 404, message = "Account not found")})
public Response getTags(@PathParam(ID_PARAM_NAME) final String accountIdString,
@QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode,
@QueryParam(QUERY_TAGS_INCLUDED_DELETED) @DefaultValue("false") final Boolean includedDeleted,
@@ -763,6 +846,8 @@ public class AccountResource extends JaxRsResourceBase {
@POST
@Path("/{accountId:" + UUID_PATTERN + "}/" + TAGS)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Add tags to account")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid account id supplied")})
public Response createTags(@PathParam(ID_PARAM_NAME) final String id,
@QueryParam(QUERY_TAGS) final String tagList,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
@@ -779,6 +864,8 @@ public class AccountResource extends JaxRsResourceBase {
@Path("/{accountId:" + UUID_PATTERN + "}/" + TAGS)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Remove tags from account")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid account id supplied or account does not have a default payment method (AUTO_PAY_OFF tag only)")})
public Response deleteTags(@PathParam(ID_PARAM_NAME) final String id,
@QueryParam(QUERY_TAGS) final String tagList,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
@@ -816,6 +903,8 @@ public class AccountResource extends JaxRsResourceBase {
@GET
@Path("/{accountId:" + UUID_PATTERN + "}/" + EMAILS)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve an account emails", response = AccountEmailJson.class, responseContainer = "List")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid account id supplied")})
public Response getEmails(@PathParam(ID_PARAM_NAME) final String id,
@javax.ws.rs.core.Context final HttpServletRequest request) {
final UUID accountId = UUID.fromString(id);
@@ -833,6 +922,9 @@ public class AccountResource extends JaxRsResourceBase {
@Path("/{accountId:" + UUID_PATTERN + "}/" + EMAILS)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Add account email")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid account id supplied"),
+ @ApiResponse(code = 404, message = "Account not found")})
public Response addEmail(final AccountEmailJson json,
@PathParam(ID_PARAM_NAME) final String id,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
@@ -840,6 +932,9 @@ public class AccountResource extends JaxRsResourceBase {
@HeaderParam(HDR_COMMENT) final String comment,
@javax.ws.rs.core.Context final HttpServletRequest request,
@javax.ws.rs.core.Context final UriInfo uriInfo) throws AccountApiException {
+ verifyNonNullOrEmpty(json, "AccountEmailJson body should be specified");
+ verifyNonNullOrEmpty(json.getEmail(), "AccountEmailJson email needs to be set");
+
final CallContext callContext = context.createContext(createdBy, reason, comment, request);
final UUID accountId = UUID.fromString(id);
@@ -868,6 +963,8 @@ public class AccountResource extends JaxRsResourceBase {
@DELETE
@Path("/{accountId:" + UUID_PATTERN + "}/" + EMAILS + "/{email}")
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Delete email from account")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid account id supplied")})
public Response removeEmail(@PathParam(ID_PARAM_NAME) final String id,
@PathParam("email") final String email,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/BundleResource.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/BundleResource.java
index ad97126..a0481e4 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/BundleResource.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/BundleResource.java
@@ -40,13 +40,10 @@ import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.UriInfo;
import org.joda.time.LocalDate;
-
import org.killbill.billing.ObjectType;
import org.killbill.billing.account.api.AccountApiException;
import org.killbill.billing.account.api.AccountUserApi;
import org.killbill.billing.catalog.api.BillingActionPolicy;
-import org.killbill.billing.payment.api.PaymentApi;
-import org.killbill.clock.Clock;
import org.killbill.billing.entitlement.api.EntitlementApi;
import org.killbill.billing.entitlement.api.EntitlementApiException;
import org.killbill.billing.entitlement.api.SubscriptionApi;
@@ -54,8 +51,10 @@ import org.killbill.billing.entitlement.api.SubscriptionApiException;
import org.killbill.billing.entitlement.api.SubscriptionBundle;
import org.killbill.billing.jaxrs.json.BundleJson;
import org.killbill.billing.jaxrs.json.CustomFieldJson;
+import org.killbill.billing.jaxrs.json.TagJson;
import org.killbill.billing.jaxrs.util.Context;
import org.killbill.billing.jaxrs.util.JaxrsUriBuilder;
+import org.killbill.billing.payment.api.PaymentApi;
import org.killbill.billing.util.api.AuditUserApi;
import org.killbill.billing.util.api.CustomFieldApiException;
import org.killbill.billing.util.api.CustomFieldUserApi;
@@ -66,15 +65,21 @@ import org.killbill.billing.util.audit.AccountAuditLogs;
import org.killbill.billing.util.callcontext.CallContext;
import org.killbill.billing.util.callcontext.TenantContext;
import org.killbill.billing.util.entity.Pagination;
+import org.killbill.clock.Clock;
import com.codahale.metrics.annotation.Timed;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableMap;
import com.google.inject.Inject;
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+import com.wordnik.swagger.annotations.ApiResponse;
+import com.wordnik.swagger.annotations.ApiResponses;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
@Path(JaxrsResource.BUNDLES_PATH)
+@Api(value = JaxrsResource.BUNDLES_PATH, description = "Operations on bundles")
public class BundleResource extends JaxRsResourceBase {
private static final String ID_PARAM_NAME = "bundleId";
@@ -102,6 +107,9 @@ public class BundleResource extends JaxRsResourceBase {
@GET
@Path("/{bundleId:" + UUID_PATTERN + "}")
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve a bundle by id", response = BundleJson.class)
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid bundle id supplied"),
+ @ApiResponse(code = 404, message = "Bundle not found")})
public Response getBundle(@PathParam("bundleId") final String bundleId,
@javax.ws.rs.core.Context final HttpServletRequest request) throws SubscriptionApiException {
final UUID id = UUID.fromString(bundleId);
@@ -113,6 +121,8 @@ public class BundleResource extends JaxRsResourceBase {
@Timed
@GET
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve a bundle by external key", response = BundleJson.class)
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Bundle not found")})
public Response getBundleByKey(@QueryParam(QUERY_EXTERNAL_KEY) final String externalKey,
@javax.ws.rs.core.Context final HttpServletRequest request) throws SubscriptionApiException {
final SubscriptionBundle bundle = subscriptionApi.getActiveSubscriptionBundleForExternalKey(externalKey, context.createContext(request));
@@ -124,6 +134,8 @@ public class BundleResource extends JaxRsResourceBase {
@GET
@Path("/" + PAGINATION)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "List bundles", response = BundleJson.class, responseContainer = "List")
+ @ApiResponses(value = {})
public Response getBundles(@QueryParam(QUERY_SEARCH_OFFSET) @DefaultValue("0") final Long offset,
@QueryParam(QUERY_SEARCH_LIMIT) @DefaultValue("100") final Long limit,
@QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode,
@@ -150,6 +162,8 @@ public class BundleResource extends JaxRsResourceBase {
@GET
@Path("/" + SEARCH + "/{searchKey:" + ANYTHING_PATTERN + "}")
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Search bundles", response = BundleJson.class, responseContainer = "List")
+ @ApiResponses(value = {})
public Response searchBundles(@PathParam("searchKey") final String searchKey,
@QueryParam(QUERY_SEARCH_OFFSET) @DefaultValue("0") final Long offset,
@QueryParam(QUERY_SEARCH_LIMIT) @DefaultValue("100") final Long limit,
@@ -179,6 +193,9 @@ public class BundleResource extends JaxRsResourceBase {
@Path("/{bundleId:" + UUID_PATTERN + "}/" + PAUSE)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Pause a bundle")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid bundle id supplied"),
+ @ApiResponse(code = 404, message = "Bundle not found")})
public Response pauseBundle(@PathParam(ID_PARAM_NAME) final String id,
@QueryParam(QUERY_REQUESTED_DT) final String requestedDate,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
@@ -199,6 +216,9 @@ public class BundleResource extends JaxRsResourceBase {
@Path("/{bundleId:" + UUID_PATTERN + "}/" + RESUME)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Resume a bundle")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid bundle id supplied"),
+ @ApiResponse(code = 404, message = "Bundle not found")})
public Response resumeBundle(@PathParam(ID_PARAM_NAME) final String id,
@QueryParam(QUERY_REQUESTED_DT) final String requestedDate,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
@@ -218,6 +238,8 @@ public class BundleResource extends JaxRsResourceBase {
@GET
@Path("/{bundleId:" + UUID_PATTERN + "}/" + CUSTOM_FIELDS)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve bundle custom fields", response = CustomFieldJson.class, responseContainer = "List")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid bundle id supplied")})
public Response getCustomFields(@PathParam(ID_PARAM_NAME) final String id,
@QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode,
@javax.ws.rs.core.Context final HttpServletRequest request) {
@@ -229,6 +251,8 @@ public class BundleResource extends JaxRsResourceBase {
@Path("/{bundleId:" + UUID_PATTERN + "}/" + CUSTOM_FIELDS)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Add custom fields to bundle")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid bundle id supplied")})
public Response createCustomFields(@PathParam(ID_PARAM_NAME) final String id,
final List<CustomFieldJson> customFields,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
@@ -245,6 +269,8 @@ public class BundleResource extends JaxRsResourceBase {
@Path("/{bundleId:" + UUID_PATTERN + "}/" + CUSTOM_FIELDS)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Remove custom fields from bundle")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid bundle id supplied")})
public Response deleteCustomFields(@PathParam(ID_PARAM_NAME) final String id,
@QueryParam(QUERY_CUSTOM_FIELDS) final String customFieldList,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
@@ -259,6 +285,9 @@ public class BundleResource extends JaxRsResourceBase {
@GET
@Path("/{bundleId:" + UUID_PATTERN + "}/" + TAGS)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve bundle tags", response = TagJson.class, responseContainer = "List")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid bundle id supplied"),
+ @ApiResponse(code = 404, message = "Bundle not found")})
public Response getTags(@PathParam(ID_PARAM_NAME) final String bundleIdString,
@QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode,
@QueryParam(QUERY_TAGS_INCLUDED_DELETED) @DefaultValue("false") final Boolean includedDeleted,
@@ -274,6 +303,9 @@ public class BundleResource extends JaxRsResourceBase {
@Path("/{bundleId:" + UUID_PATTERN + "}")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Transfer a bundle to another account")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid bundle id, requested date or policy supplied"),
+ @ApiResponse(code = 404, message = "Bundle not found")})
public Response transferBundle(final BundleJson json,
@PathParam(ID_PARAM_NAME) final String id,
@QueryParam(QUERY_REQUESTED_DT) final String requestedDate,
@@ -283,6 +315,8 @@ public class BundleResource extends JaxRsResourceBase {
@HeaderParam(HDR_COMMENT) final String comment,
@javax.ws.rs.core.Context final UriInfo uriInfo,
@javax.ws.rs.core.Context final HttpServletRequest request) throws EntitlementApiException, SubscriptionApiException, AccountApiException {
+ verifyNonNullOrEmpty(json, "BundleJson body should be specified");
+ verifyNonNullOrEmpty(json.getAccountId(), "BundleJson accountId needs to be set");
final BillingActionPolicy policy = BillingActionPolicy.valueOf(policyString.toUpperCase());
@@ -301,6 +335,8 @@ public class BundleResource extends JaxRsResourceBase {
@Path("/{bundleId:" + UUID_PATTERN + "}/" + TAGS)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Add tags to bundle")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid bundle id supplied")})
public Response createTags(@PathParam(ID_PARAM_NAME) final String id,
@QueryParam(QUERY_TAGS) final String tagList,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
@@ -317,6 +353,8 @@ public class BundleResource extends JaxRsResourceBase {
@Path("/{bundleId:" + UUID_PATTERN + "}/" + TAGS)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Remove tags from bundle")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid bundle id supplied")})
public Response deleteTags(@PathParam(ID_PARAM_NAME) final String id,
@QueryParam(QUERY_TAGS) final String tagList,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/CatalogResource.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/CatalogResource.java
index 1de293d..d4c7311 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/CatalogResource.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/CatalogResource.java
@@ -32,26 +32,30 @@ import org.killbill.billing.catalog.api.CatalogApiException;
import org.killbill.billing.catalog.api.CatalogService;
import org.killbill.billing.catalog.api.Listing;
import org.killbill.billing.catalog.api.StaticCatalog;
-import org.killbill.billing.payment.api.PaymentApi;
-import org.killbill.clock.Clock;
import org.killbill.billing.jaxrs.json.CatalogJsonSimple;
import org.killbill.billing.jaxrs.json.PlanDetailJson;
import org.killbill.billing.jaxrs.util.Context;
import org.killbill.billing.jaxrs.util.JaxrsUriBuilder;
+import org.killbill.billing.payment.api.PaymentApi;
import org.killbill.billing.util.api.AuditUserApi;
import org.killbill.billing.util.api.CustomFieldUserApi;
import org.killbill.billing.util.api.TagUserApi;
+import org.killbill.clock.Clock;
import org.killbill.xmlloader.XMLWriter;
import com.codahale.metrics.annotation.Timed;
import com.google.inject.Inject;
import com.google.inject.Singleton;
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+import com.wordnik.swagger.annotations.ApiResponses;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static javax.ws.rs.core.MediaType.APPLICATION_XML;
@Singleton
@Path(JaxrsResource.CATALOG_PATH)
+@Api(value = JaxrsResource.CATALOG_PATH, description = "Catalog information")
public class CatalogResource extends JaxRsResourceBase {
private final CatalogService catalogService;
@@ -73,6 +77,8 @@ public class CatalogResource extends JaxRsResourceBase {
@Timed
@GET
@Produces(APPLICATION_XML)
+ @ApiOperation(value = "Retrieve the full catalog as XML", response = String.class, hidden = true)
+ @ApiResponses(value = {})
public Response getCatalogXml(@javax.ws.rs.core.Context final HttpServletRequest request) throws Exception {
return Response.status(Status.OK).entity(XMLWriter.writeXML(catalogService.getCurrentCatalog(), StaticCatalog.class)).build();
}
@@ -80,6 +86,8 @@ public class CatalogResource extends JaxRsResourceBase {
@Timed
@GET
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve the full catalog as JSON", response = StaticCatalog.class)
+ @ApiResponses(value = {})
public Response getCatalogJson(@javax.ws.rs.core.Context final HttpServletRequest request) throws Exception {
final StaticCatalog catalog = catalogService.getCurrentCatalog();
@@ -104,6 +112,8 @@ public class CatalogResource extends JaxRsResourceBase {
@GET
@Path("/availableAddons")
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve available add-ons for a given product", response = PlanDetailJson.class, responseContainer = "List")
+ @ApiResponses(value = {})
public Response getAvailableAddons(@QueryParam("baseProductName") final String baseProductName,
@javax.ws.rs.core.Context final HttpServletRequest request) throws CatalogApiException {
final StaticCatalog catalog = catalogService.getCurrentCatalog();
@@ -119,6 +129,8 @@ public class CatalogResource extends JaxRsResourceBase {
@GET
@Path("/availableBasePlans")
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve available base plans", response = PlanDetailJson.class, responseContainer = "List")
+ @ApiResponses(value = {})
public Response getAvailableBasePlans(@javax.ws.rs.core.Context final HttpServletRequest request) throws CatalogApiException {
final StaticCatalog catalog = catalogService.getCurrentCatalog();
final List<Listing> listings = catalog.getAvailableBasePlanListings();
@@ -133,6 +145,8 @@ public class CatalogResource extends JaxRsResourceBase {
@GET
@Path("/simpleCatalog")
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve a summarized version of the catalog as JSON", response = CatalogJsonSimple.class)
+ @ApiResponses(value = {})
public Response getSimpleCatalog(@javax.ws.rs.core.Context final HttpServletRequest request) throws CatalogApiException {
final StaticCatalog catalog = catalogService.getCurrentCatalog();
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/CreditResource.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/CreditResource.java
index 3af4ca5..bfad1b1 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/CreditResource.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/CreditResource.java
@@ -30,13 +30,10 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import org.joda.time.LocalDate;
-
import org.killbill.billing.ObjectType;
import org.killbill.billing.account.api.Account;
import org.killbill.billing.account.api.AccountApiException;
import org.killbill.billing.account.api.AccountUserApi;
-import org.killbill.billing.payment.api.PaymentApi;
-import org.killbill.clock.Clock;
import org.killbill.billing.invoice.api.Invoice;
import org.killbill.billing.invoice.api.InvoiceApiException;
import org.killbill.billing.invoice.api.InvoiceItem;
@@ -44,19 +41,26 @@ import org.killbill.billing.invoice.api.InvoiceUserApi;
import org.killbill.billing.jaxrs.json.CreditJson;
import org.killbill.billing.jaxrs.util.Context;
import org.killbill.billing.jaxrs.util.JaxrsUriBuilder;
+import org.killbill.billing.payment.api.PaymentApi;
import org.killbill.billing.util.api.AuditUserApi;
import org.killbill.billing.util.api.CustomFieldUserApi;
import org.killbill.billing.util.api.TagUserApi;
import org.killbill.billing.util.callcontext.CallContext;
import org.killbill.billing.util.callcontext.TenantContext;
+import org.killbill.clock.Clock;
import com.google.inject.Inject;
import com.google.inject.Singleton;
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+import com.wordnik.swagger.annotations.ApiResponse;
+import com.wordnik.swagger.annotations.ApiResponses;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
@Singleton
@Path(JaxrsResource.CREDITS_PATH)
+@Api(value = JaxrsResource.CREDITS_PATH, description = "Operations on credits")
public class CreditResource extends JaxRsResourceBase {
private final InvoiceUserApi invoiceUserApi;
@@ -80,6 +84,9 @@ public class CreditResource extends JaxRsResourceBase {
@GET
@Path("/{creditId:" + UUID_PATTERN + "}")
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve a credit by id", response = CreditJson.class)
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid credit id supplied"),
+ @ApiResponse(code = 404, message = "Credit not found")})
public Response getCredit(@PathParam("creditId") final String creditId,
@javax.ws.rs.core.Context final HttpServletRequest request) throws InvoiceApiException, AccountApiException {
final TenantContext tenantContext = context.createContext(request);
@@ -92,12 +99,19 @@ public class CreditResource extends JaxRsResourceBase {
@POST
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Create a credit")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid account id supplied"),
+ @ApiResponse(code = 404, message = "Account not found")})
public Response createCredit(final CreditJson json,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
@HeaderParam(HDR_REASON) final String reason,
@HeaderParam(HDR_COMMENT) final String comment,
@javax.ws.rs.core.Context final HttpServletRequest request,
@javax.ws.rs.core.Context final UriInfo uriInfo) throws AccountApiException, InvoiceApiException {
+ verifyNonNullOrEmpty(json, "CreditJson body should be specified");
+ verifyNonNullOrEmpty(json.getAccountId(), "CreditJson accountId needs to be set",
+ json.getCreditAmount(), "CreditJson creditAmount needs to be set");
+
final CallContext callContext = context.createContext(createdBy, reason, comment, request);
final Account account = accountUserApi.getAccountById(UUID.fromString(json.getAccountId()), callContext);
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/CustomFieldResource.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/CustomFieldResource.java
index 35556ad..58f5bf9 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/CustomFieldResource.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/CustomFieldResource.java
@@ -30,11 +30,10 @@ import javax.ws.rs.core.Response;
import org.killbill.billing.ObjectType;
import org.killbill.billing.account.api.AccountUserApi;
-import org.killbill.billing.payment.api.PaymentApi;
-import org.killbill.clock.Clock;
import org.killbill.billing.jaxrs.json.CustomFieldJson;
import org.killbill.billing.jaxrs.util.Context;
import org.killbill.billing.jaxrs.util.JaxrsUriBuilder;
+import org.killbill.billing.payment.api.PaymentApi;
import org.killbill.billing.util.api.AuditUserApi;
import org.killbill.billing.util.api.CustomFieldApiException;
import org.killbill.billing.util.api.CustomFieldUserApi;
@@ -43,17 +42,22 @@ import org.killbill.billing.util.audit.AuditLog;
import org.killbill.billing.util.callcontext.TenantContext;
import org.killbill.billing.util.customfield.CustomField;
import org.killbill.billing.util.entity.Pagination;
+import org.killbill.clock.Clock;
import com.codahale.metrics.annotation.Timed;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableMap;
import com.google.inject.Inject;
import com.google.inject.Singleton;
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+import com.wordnik.swagger.annotations.ApiResponses;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
@Singleton
@Path(JaxrsResource.CUSTOM_FIELDS_PATH)
+@Api(value = JaxrsResource.CUSTOM_FIELDS_PATH, description = "Operations on custom fields")
public class CustomFieldResource extends JaxRsResourceBase {
@Inject
@@ -72,6 +76,8 @@ public class CustomFieldResource extends JaxRsResourceBase {
@GET
@Path("/" + PAGINATION)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "List custom fields", response = CustomFieldJson.class, responseContainer = "List")
+ @ApiResponses(value = {})
public Response getCustomFields(@QueryParam(QUERY_SEARCH_OFFSET) @DefaultValue("0") final Long offset,
@QueryParam(QUERY_SEARCH_LIMIT) @DefaultValue("100") final Long limit,
@QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode,
@@ -96,6 +102,8 @@ public class CustomFieldResource extends JaxRsResourceBase {
@GET
@Path("/" + SEARCH + "/{searchKey:" + ANYTHING_PATTERN + "}")
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Search custom fields", response = CustomFieldJson.class, responseContainer = "List")
+ @ApiResponses(value = {})
public Response searchCustomFields(@PathParam("searchKey") final String searchKey,
@QueryParam(QUERY_SEARCH_OFFSET) @DefaultValue("0") final Long offset,
@QueryParam(QUERY_SEARCH_LIMIT) @DefaultValue("100") final Long limit,
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/ExportResource.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/ExportResource.java
index 672d7e2..50be28e 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/ExportResource.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/ExportResource.java
@@ -31,23 +31,28 @@ import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.StreamingOutput;
import org.killbill.billing.account.api.AccountUserApi;
-import org.killbill.billing.payment.api.PaymentApi;
-import org.killbill.clock.Clock;
import org.killbill.billing.jaxrs.util.Context;
import org.killbill.billing.jaxrs.util.JaxrsUriBuilder;
+import org.killbill.billing.payment.api.PaymentApi;
import org.killbill.billing.util.api.AuditUserApi;
import org.killbill.billing.util.api.CustomFieldUserApi;
import org.killbill.billing.util.api.ExportUserApi;
import org.killbill.billing.util.api.TagUserApi;
import org.killbill.billing.util.callcontext.CallContext;
+import org.killbill.clock.Clock;
import com.codahale.metrics.annotation.Timed;
import com.google.inject.Singleton;
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+import com.wordnik.swagger.annotations.ApiResponse;
+import com.wordnik.swagger.annotations.ApiResponses;
import static javax.ws.rs.core.MediaType.TEXT_PLAIN;
@Singleton
@Path(JaxrsResource.EXPORT_PATH)
+@Api(value = JaxrsResource.EXPORT_PATH, description = "Export endpoints")
public class ExportResource extends JaxRsResourceBase {
private final ExportUserApi exportUserApi;
@@ -70,6 +75,9 @@ public class ExportResource extends JaxRsResourceBase {
@GET
@Path("/{accountId:" + UUID_PATTERN + "}")
@Produces(TEXT_PLAIN)
+ @ApiOperation(value = "Export account data", response = String.class)
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid account id supplied"),
+ @ApiResponse(code = 404, message = "Account not found")})
public StreamingOutput exportDataForAccount(@PathParam("accountId") final String accountId,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
@HeaderParam(HDR_REASON) final String reason,
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/InvoicePaymentResource.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/InvoicePaymentResource.java
index 2995a0c..3a68362 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/InvoicePaymentResource.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/InvoicePaymentResource.java
@@ -49,6 +49,7 @@ import org.killbill.billing.jaxrs.json.CustomFieldJson;
import org.killbill.billing.jaxrs.json.InvoiceItemJson;
import org.killbill.billing.jaxrs.json.InvoicePaymentJson;
import org.killbill.billing.jaxrs.json.InvoicePaymentTransactionJson;
+import org.killbill.billing.jaxrs.json.TagJson;
import org.killbill.billing.jaxrs.util.Context;
import org.killbill.billing.jaxrs.util.JaxrsUriBuilder;
import org.killbill.billing.payment.api.Payment;
@@ -71,10 +72,15 @@ import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.inject.Inject;
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+import com.wordnik.swagger.annotations.ApiResponse;
+import com.wordnik.swagger.annotations.ApiResponses;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
@Path(JaxrsResource.INVOICE_PAYMENTS_PATH)
+@Api(value = JaxrsResource.INVOICE_PAYMENTS_PATH, description = "Operations on invoice payments")
public class InvoicePaymentResource extends JaxRsResourceBase {
private static final String ID_PARAM_NAME = "paymentId";
@@ -99,6 +105,9 @@ public class InvoicePaymentResource extends JaxRsResourceBase {
@GET
@Path("/{paymentId:" + UUID_PATTERN + "}/")
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve a payment by id", response = InvoicePaymentJson.class)
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid payment id supplied"),
+ @ApiResponse(code = 404, message = "Payment not found")})
public Response getInvoicePayment(@PathParam("paymentId") final String paymentIdStr,
@QueryParam(QUERY_WITH_PLUGIN_INFO) @DefaultValue("false") final Boolean withPluginInfo,
@QueryParam(QUERY_PLUGIN_PROPERTY) final List<String> pluginPropertiesString,
@@ -129,6 +138,9 @@ public class InvoicePaymentResource extends JaxRsResourceBase {
@Path("/{paymentId:" + UUID_PATTERN + "}/" + REFUNDS)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Refund a payment, and adjust the invoice if needed")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid payment id supplied"),
+ @ApiResponse(code = 404, message = "Account or payment not found")})
public Response createRefundWithAdjustments(final InvoicePaymentTransactionJson json,
@PathParam("paymentId") final String paymentId,
@QueryParam(QUERY_PLUGIN_PROPERTY) final List<String> pluginPropertiesString,
@@ -137,6 +149,7 @@ public class InvoicePaymentResource extends JaxRsResourceBase {
@HeaderParam(HDR_COMMENT) final String comment,
@javax.ws.rs.core.Context final UriInfo uriInfo,
@javax.ws.rs.core.Context final HttpServletRequest request) throws PaymentApiException, AccountApiException {
+ verifyNonNullOrEmpty(json, "InvoicePaymentTransactionJson body should be specified");
final CallContext callContext = context.createContext(createdBy, reason, comment, request);
final UUID paymentUuid = UUID.fromString(paymentId);
@@ -172,6 +185,9 @@ public class InvoicePaymentResource extends JaxRsResourceBase {
@Path("/{paymentId:" + UUID_PATTERN + "}/" + CHARGEBACKS)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Record a chargeback")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid payment id supplied"),
+ @ApiResponse(code = 404, message = "Account or payment not found")})
public Response createChargeback(final InvoicePaymentTransactionJson json,
@PathParam("paymentId") final String paymentId,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
@@ -179,6 +195,8 @@ public class InvoicePaymentResource extends JaxRsResourceBase {
@HeaderParam(HDR_COMMENT) final String comment,
@javax.ws.rs.core.Context final UriInfo uriInfo,
@javax.ws.rs.core.Context final HttpServletRequest request) throws PaymentApiException, AccountApiException {
+ verifyNonNullOrEmpty(json, "InvoicePaymentTransactionJson body should be specified");
+ verifyNonNullOrEmpty(json.getAmount(), "InvoicePaymentTransactionJson amount needs to be set");
final CallContext callContext = context.createContext(createdBy, reason, comment, request);
final UUID paymentUuid = UUID.fromString(paymentId);
@@ -195,6 +213,8 @@ public class InvoicePaymentResource extends JaxRsResourceBase {
@GET
@Path("/{paymentId:" + UUID_PATTERN + "}/" + CUSTOM_FIELDS)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve payment custom fields", response = CustomFieldJson.class, responseContainer = "List")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid payment id supplied")})
public Response getCustomFields(@PathParam(ID_PARAM_NAME) final String id,
@QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode,
@javax.ws.rs.core.Context final HttpServletRequest request) {
@@ -206,6 +226,8 @@ public class InvoicePaymentResource extends JaxRsResourceBase {
@Path("/{paymentId:" + UUID_PATTERN + "}/" + CUSTOM_FIELDS)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Add custom fields to payment")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid payment id supplied")})
public Response createCustomFields(@PathParam(ID_PARAM_NAME) final String id,
final List<CustomFieldJson> customFields,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
@@ -222,6 +244,8 @@ public class InvoicePaymentResource extends JaxRsResourceBase {
@Path("/{paymentId:" + UUID_PATTERN + "}/" + CUSTOM_FIELDS)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Remove custom fields from payment")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid payment id supplied")})
public Response deleteCustomFields(@PathParam(ID_PARAM_NAME) final String id,
@QueryParam(QUERY_CUSTOM_FIELDS) final String customFieldList,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
@@ -236,6 +260,9 @@ public class InvoicePaymentResource extends JaxRsResourceBase {
@GET
@Path("/{paymentId:" + UUID_PATTERN + "}/" + TAGS)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve payment tags", response = TagJson.class, responseContainer = "List")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid payment id supplied"),
+ @ApiResponse(code = 404, message = "Payment not found")})
public Response getTags(@PathParam(ID_PARAM_NAME) final String paymentIdString,
@QueryParam(QUERY_PLUGIN_PROPERTY) final List<String> pluginPropertiesString,
@QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode,
@@ -253,6 +280,8 @@ public class InvoicePaymentResource extends JaxRsResourceBase {
@Path("/{paymentId:" + UUID_PATTERN + "}/" + TAGS)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Add tags to payment")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid payment id supplied")})
public Response createTags(@PathParam(ID_PARAM_NAME) final String id,
@QueryParam(QUERY_TAGS) final String tagList,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
@@ -269,6 +298,8 @@ public class InvoicePaymentResource extends JaxRsResourceBase {
@Path("/{paymentId:" + UUID_PATTERN + "}/" + TAGS)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Remove tags from payment")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid payment id supplied")})
public Response deleteTags(@PathParam(ID_PARAM_NAME) final String id,
@QueryParam(QUERY_TAGS) final String tagList,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/InvoiceResource.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/InvoiceResource.java
index 43ab896..9399f63 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/InvoiceResource.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/InvoiceResource.java
@@ -63,6 +63,7 @@ import org.killbill.billing.jaxrs.json.CustomFieldJson;
import org.killbill.billing.jaxrs.json.InvoiceItemJson;
import org.killbill.billing.jaxrs.json.InvoiceJson;
import org.killbill.billing.jaxrs.json.InvoicePaymentJson;
+import org.killbill.billing.jaxrs.json.TagJson;
import org.killbill.billing.jaxrs.util.Context;
import org.killbill.billing.jaxrs.util.JaxrsUriBuilder;
import org.killbill.billing.payment.api.Payment;
@@ -90,11 +91,16 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.inject.Inject;
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+import com.wordnik.swagger.annotations.ApiResponse;
+import com.wordnik.swagger.annotations.ApiResponses;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static javax.ws.rs.core.MediaType.TEXT_HTML;
@Path(JaxrsResource.INVOICES_PATH)
+@Api(value = JaxrsResource.INVOICES_PATH, description = "Operations on invoices")
public class InvoiceResource extends JaxRsResourceBase {
private static final Logger log = LoggerFactory.getLogger(InvoiceResource.class);
@@ -123,6 +129,9 @@ public class InvoiceResource extends JaxRsResourceBase {
@GET
@Path("/{invoiceId:" + UUID_PATTERN + "}/")
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve an invoice by id", response = InvoiceJson.class)
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid invoice id supplied"),
+ @ApiResponse(code = 404, message = "Invoice not found")})
public Response getInvoice(@PathParam("invoiceId") final String invoiceId,
@QueryParam(QUERY_INVOICE_WITH_ITEMS) @DefaultValue("false") final boolean withItems,
@QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode,
@@ -143,6 +152,8 @@ public class InvoiceResource extends JaxRsResourceBase {
@GET
@Path("/{invoiceNumber:" + NUMBER_PATTERN + "}/")
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve an invoice by number", response = InvoiceJson.class)
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Invoice not found")})
public Response getInvoiceByNumber(@PathParam("invoiceNumber") final Integer invoiceNumber,
@QueryParam(QUERY_INVOICE_WITH_ITEMS) @DefaultValue("false") final boolean withItems,
@QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode,
@@ -163,6 +174,8 @@ public class InvoiceResource extends JaxRsResourceBase {
@GET
@Path("/{invoiceId:" + UUID_PATTERN + "}/html")
@Produces(TEXT_HTML)
+ @ApiOperation(value = "Render an invoice as HTML", response = String.class)
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Invoice not found")})
public Response getInvoiceAsHTML(@PathParam("invoiceId") final String invoiceId,
@javax.ws.rs.core.Context final HttpServletRequest request) throws InvoiceApiException, IOException, AccountApiException {
return Response.status(Status.OK).entity(invoiceApi.getInvoiceAsHTML(UUID.fromString(invoiceId), context.createContext(request))).build();
@@ -172,6 +185,8 @@ public class InvoiceResource extends JaxRsResourceBase {
@GET
@Path("/" + PAGINATION)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "List invoices", response = InvoiceJson.class, responseContainer = "List")
+ @ApiResponses(value = {})
public Response getInvoices(@QueryParam(QUERY_SEARCH_OFFSET) @DefaultValue("0") final Long offset,
@QueryParam(QUERY_SEARCH_LIMIT) @DefaultValue("100") final Long limit,
@QueryParam(QUERY_INVOICE_WITH_ITEMS) @DefaultValue("false") final Boolean withItems,
@@ -202,6 +217,8 @@ public class InvoiceResource extends JaxRsResourceBase {
@GET
@Path("/" + SEARCH + "/{searchKey:" + ANYTHING_PATTERN + "}")
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Search invoices", response = InvoiceJson.class, responseContainer = "List")
+ @ApiResponses(value = {})
public Response searchInvoices(@PathParam("searchKey") final String searchKey,
@QueryParam(QUERY_SEARCH_OFFSET) @DefaultValue("0") final Long offset,
@QueryParam(QUERY_SEARCH_LIMIT) @DefaultValue("100") final Long limit,
@@ -233,6 +250,8 @@ public class InvoiceResource extends JaxRsResourceBase {
@POST
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Trigger an invoice generation", response = InvoiceJson.class)
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid account id or target datetime supplied")})
public Response createFutureInvoice(@QueryParam(QUERY_ACCOUNT_ID) final String accountId,
@QueryParam(QUERY_TARGET_DATE) final String targetDateTime,
@QueryParam(QUERY_DRY_RUN) @DefaultValue("false") final Boolean dryRun,
@@ -258,6 +277,9 @@ public class InvoiceResource extends JaxRsResourceBase {
@Path("/{invoiceId:" + UUID_PATTERN + "}" + "/{invoiceItemId:" + UUID_PATTERN + "}/cba")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Delete a CBA item")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid account id, invoice id or invoice item id supplied"),
+ @ApiResponse(code = 404, message = "Account or invoice not found")})
public Response deleteCBA(@PathParam("invoiceId") final String invoiceId,
@PathParam("invoiceItemId") final String invoiceItemId,
@QueryParam(QUERY_ACCOUNT_ID) final String accountId,
@@ -279,6 +301,9 @@ public class InvoiceResource extends JaxRsResourceBase {
@Path("/{invoiceId:" + UUID_PATTERN + "}")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Adjust an invoice item")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid account id, invoice id or invoice item id supplied"),
+ @ApiResponse(code = 404, message = "Invoice not found")})
public Response adjustInvoiceItem(final InvoiceItemJson json,
@PathParam("invoiceId") final String invoiceId,
@QueryParam(QUERY_REQUESTED_DT) final String requestedDateTimeString,
@@ -287,6 +312,10 @@ public class InvoiceResource extends JaxRsResourceBase {
@HeaderParam(HDR_COMMENT) final String comment,
@javax.ws.rs.core.Context final HttpServletRequest request,
@javax.ws.rs.core.Context final UriInfo uriInfo) throws AccountApiException, InvoiceApiException {
+ verifyNonNullOrEmpty(json, "InvoiceItemJson body should be specified");
+ verifyNonNullOrEmpty(json.getAccountId(), "InvoiceItemJson accountId needs to be set",
+ json.getInvoiceItemId(), "InvoiceItemJson invoiceItemId needs to be set");
+
final CallContext callContext = context.createContext(createdBy, reason, comment, request);
final UUID accountId = UUID.fromString(json.getAccountId());
@@ -316,6 +345,9 @@ public class InvoiceResource extends JaxRsResourceBase {
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
@Path("/" + CHARGES + "/{accountId:" + UUID_PATTERN + "}")
+ @ApiOperation(value = "Create external charge(s)", response = InvoiceItemJson.class, responseContainer = "List")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid account id supplied"),
+ @ApiResponse(code = 404, message = "Account not found")})
public Response createExternalCharges(final Iterable<InvoiceItemJson> externalChargesJson,
@PathParam("accountId") final String accountId,
@QueryParam(QUERY_REQUESTED_DT) final String requestedDateTimeString,
@@ -384,6 +416,9 @@ public class InvoiceResource extends JaxRsResourceBase {
@GET
@Path("/{invoiceId:" + UUID_PATTERN + "}/" + PAYMENTS)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve payments associated with an invoice", response = InvoicePaymentJson.class, responseContainer = "List")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid invoice id supplied"),
+ @ApiResponse(code = 404, message = "Invoice not found")})
public Response getPayments(@PathParam("invoiceId") final String invoiceId,
@QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode,
@QueryParam(QUERY_WITH_PLUGIN_INFO) @DefaultValue("false") final Boolean withPluginInfo,
@@ -411,6 +446,9 @@ public class InvoiceResource extends JaxRsResourceBase {
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
@Path("/{invoiceId:" + UUID_PATTERN + "}/" + PAYMENTS)
+ @ApiOperation(value = "Trigger a payment for invoice")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid account id or invoice id supplied"),
+ @ApiResponse(code = 404, message = "Account not found")})
public Response createInstantPayment(final InvoicePaymentJson payment,
@QueryParam(QUERY_PAYMENT_EXTERNAL) @DefaultValue("false") final Boolean externalPayment,
@QueryParam(QUERY_PLUGIN_PROPERTY) final List<String> pluginPropertiesString,
@@ -419,6 +457,11 @@ public class InvoiceResource extends JaxRsResourceBase {
@HeaderParam(HDR_COMMENT) final String comment,
@javax.ws.rs.core.Context final HttpServletRequest request,
@javax.ws.rs.core.Context final UriInfo uriInfo) throws AccountApiException, PaymentApiException {
+ verifyNonNullOrEmpty(payment, "InvoicePaymentJson body should be specified");
+ verifyNonNullOrEmpty(payment.getAccountId(), "InvoicePaymentJson accountId needs to be set",
+ payment.getTargetInvoiceId(), "InvoicePaymentJson targetInvoiceId needs to be set",
+ payment.getPurchasedAmount(), "InvoicePaymentJson purchasedAmount needs to be set");
+
final Iterable<PluginProperty> pluginProperties = extractPluginProperties(pluginPropertiesString);
final CallContext callContext = context.createContext(createdBy, reason, comment, request);
@@ -434,6 +477,9 @@ public class InvoiceResource extends JaxRsResourceBase {
@Path("/{invoiceId:" + UUID_PATTERN + "}/" + EMAIL_NOTIFICATIONS)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Trigger an email notification for invoice")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid invoice id supplied"),
+ @ApiResponse(code = 404, message = "Account or invoice not found")})
public Response triggerEmailNotificationForInvoice(@PathParam("invoiceId") final String invoiceId,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
@HeaderParam(HDR_REASON) final String reason,
@@ -458,6 +504,8 @@ public class InvoiceResource extends JaxRsResourceBase {
@GET
@Path("/{invoiceId:" + UUID_PATTERN + "}/" + CUSTOM_FIELDS)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve invoice custom fields", response = CustomFieldJson.class, responseContainer = "List")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid invoice id supplied")})
public Response getCustomFields(@PathParam(ID_PARAM_NAME) final String id,
@QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode,
@javax.ws.rs.core.Context final HttpServletRequest request) {
@@ -469,6 +517,8 @@ public class InvoiceResource extends JaxRsResourceBase {
@Path("/{invoiceId:" + UUID_PATTERN + "}/" + CUSTOM_FIELDS)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Add custom fields to invoice")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid invoice id supplied")})
public Response createCustomFields(@PathParam(ID_PARAM_NAME) final String id,
final List<CustomFieldJson> customFields,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
@@ -485,6 +535,8 @@ public class InvoiceResource extends JaxRsResourceBase {
@Path("/{invoiceId:" + UUID_PATTERN + "}/" + CUSTOM_FIELDS)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Remove custom fields from invoice")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid invoice id supplied")})
public Response deleteCustomFields(@PathParam(ID_PARAM_NAME) final String id,
@QueryParam(QUERY_CUSTOM_FIELDS) final String customFieldList,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
@@ -499,6 +551,9 @@ public class InvoiceResource extends JaxRsResourceBase {
@GET
@Path("/{invoiceId:" + UUID_PATTERN + "}/" + TAGS)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve invoice tags", response = TagJson.class, responseContainer = "List")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid invoice id supplied"),
+ @ApiResponse(code = 404, message = "Invoice not found")})
public Response getTags(@PathParam(ID_PARAM_NAME) final String invoiceIdString,
@QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode,
@QueryParam(QUERY_TAGS_INCLUDED_DELETED) @DefaultValue("false") final Boolean includedDeleted,
@@ -514,6 +569,8 @@ public class InvoiceResource extends JaxRsResourceBase {
@Path("/{invoiceId:" + UUID_PATTERN + "}/" + TAGS)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Add tags to invoice")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid invoice id supplied")})
public Response createTags(@PathParam(ID_PARAM_NAME) final String id,
@QueryParam(QUERY_TAGS) final String tagList,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
@@ -530,6 +587,8 @@ public class InvoiceResource extends JaxRsResourceBase {
@Path("/{invoiceId:" + UUID_PATTERN + "}/" + TAGS)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Remove tags from invoice")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid invoice id supplied")})
public Response deleteTags(@PathParam(ID_PARAM_NAME) final String id,
@QueryParam(QUERY_TAGS) final String tagList,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/JaxrsResource.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/JaxrsResource.java
index aeabae3..a6d97d0 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/JaxrsResource.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/JaxrsResource.java
@@ -191,6 +191,9 @@ public interface JaxrsResource {
// No PREFIX here!
public static final String PLUGINS_PATH = "/" + PLUGINS;
+ public static final String TEST = "test";
+ public static final String TEST_PATH = PREFIX + "/" + TEST;
+
public static final String CBA_REBALANCING = "cbaRebalancing";
public static final String PAUSE = "pause";
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/JaxRsResourceBase.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/JaxRsResourceBase.java
index e3d8de4..e2ede5d 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/JaxRsResourceBase.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/JaxRsResourceBase.java
@@ -23,6 +23,7 @@ import java.io.OutputStream;
import java.math.BigDecimal;
import java.net.URI;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
@@ -85,7 +86,9 @@ import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.core.JsonGenerator;
import com.google.common.base.Function;
import com.google.common.base.Joiner;
+import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
+import com.google.common.base.Strings;
import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
@@ -197,6 +200,8 @@ public abstract class JaxRsResourceBase implements JaxrsResource {
final UriInfo uriInfo) throws CustomFieldApiException {
final LinkedList<CustomField> input = new LinkedList<CustomField>();
for (final CustomFieldJson cur : customFields) {
+ verifyNonNullOrEmpty(cur.getName(), "CustomFieldJson name needs to be set");
+ verifyNonNullOrEmpty(cur.getValue(), "CustomFieldJson value needs to be set");
input.add(new StringCustomField(cur.getName(), cur.getValue(), getObjectType(), id, context.getCreatedDate()));
}
@@ -368,9 +373,9 @@ public abstract class JaxRsResourceBase implements JaxrsResource {
}
@Override
- public String getPaymentControlPluginName() {
- /* Contract with plugin */
- return "__INVOICE_PAYMENT_CONTROL_PLUGIN__";
+ public List<String> getPaymentControlPluginNames() {
+ /* Will default to org.killbill.payment.control.plugin in payment sub-system */
+ return null;
}
};
}
@@ -399,4 +404,13 @@ public abstract class JaxRsResourceBase implements JaxrsResource {
return invoicePayment != null ? invoicePayment.getInvoiceId() : null;
}
+ protected void verifyNonNullOrEmpty(final Object... elements) {
+ Preconditions.checkArgument(elements.length % 2 == 0, "%s should have an even number of elements", Arrays.toString(elements));
+ for (int i = 0; i < elements.length; i += 2) {
+ final Object argument = elements[i];
+ final Object errorMessage = elements[i + 1];
+ final boolean expression = argument instanceof String ? Strings.emptyToNull((String) argument) != null : argument != null;
+ Preconditions.checkArgument(expression, errorMessage);
+ }
+ }
}
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/PaymentGatewayResource.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/PaymentGatewayResource.java
index 829bef6..fc8ce6a 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/PaymentGatewayResource.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/PaymentGatewayResource.java
@@ -58,11 +58,16 @@ import com.google.common.base.Function;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+import com.wordnik.swagger.annotations.ApiResponse;
+import com.wordnik.swagger.annotations.ApiResponses;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static javax.ws.rs.core.MediaType.WILDCARD;
@Path(JaxrsResource.PAYMENT_GATEWAYS_PATH)
+@Api(value = JaxrsResource.PAYMENT_GATEWAYS_PATH, description = "HPP endpoints")
public class PaymentGatewayResource extends JaxRsResourceBase {
private final PaymentGatewayApi paymentGatewayApi;
@@ -86,7 +91,9 @@ public class PaymentGatewayResource extends JaxRsResourceBase {
@Path("/" + HOSTED + "/" + FORM + "/{" + QUERY_ACCOUNT_ID + ":" + UUID_PATTERN + "}")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
- // Generate form data to redirect the customer to the gateway
+ @ApiOperation(value = "Generate form data to redirect the customer to the gateway", response = HostedPaymentPageFormDescriptorJson.class)
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid accountId supplied"),
+ @ApiResponse(code = 404, message = "Account not found")})
public Response buildFormDescriptor(final HostedPaymentPageFieldsJson json,
@PathParam(QUERY_ACCOUNT_ID) final String accountIdString,
@QueryParam(QUERY_PLUGIN_PROPERTY) final List<String> pluginPropertiesString,
@@ -124,6 +131,8 @@ public class PaymentGatewayResource extends JaxRsResourceBase {
@Path("/" + NOTIFICATION + "/{" + QUERY_PAYMENT_PLUGIN_NAME + ":" + ANYTHING_PATTERN + "}")
@Consumes(WILDCARD)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Process a gateway notification", notes = "The response is built by the appropriate plugin")
+ @ApiResponses(value = {})
public Response processNotification(final String body,
@PathParam(QUERY_PAYMENT_PLUGIN_NAME) final String pluginName,
@QueryParam(QUERY_PLUGIN_PROPERTY) final List<String> pluginPropertiesString,
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/PaymentMethodResource.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/PaymentMethodResource.java
index 183eb21..002622a 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/PaymentMethodResource.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/PaymentMethodResource.java
@@ -63,11 +63,16 @@ import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.google.inject.Inject;
import com.google.inject.Singleton;
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+import com.wordnik.swagger.annotations.ApiResponse;
+import com.wordnik.swagger.annotations.ApiResponses;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
@Singleton
@Path(JaxrsResource.PAYMENT_METHODS_PATH)
+@Api(value = JaxrsResource.PAYMENT_METHODS_PATH, description = "Operations on payment methods")
public class PaymentMethodResource extends JaxRsResourceBase {
@Inject
@@ -86,6 +91,9 @@ public class PaymentMethodResource extends JaxRsResourceBase {
@GET
@Path("/{paymentMethodId:" + UUID_PATTERN + "}")
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve a payment method by id", response = PaymentMethodJson.class)
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid paymentMethodId supplied"),
+ @ApiResponse(code = 404, message = "Account or payment method not found")})
public Response getPaymentMethod(@PathParam("paymentMethodId") final String paymentMethodId,
@QueryParam(QUERY_PLUGIN_PROPERTY) final List<String> pluginPropertiesString,
@QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode,
@@ -105,6 +113,8 @@ public class PaymentMethodResource extends JaxRsResourceBase {
@Timed
@GET
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve a payment method by external key", response = PaymentMethodJson.class)
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Account or payment method not found")})
public Response getPaymentMethodByKey(@QueryParam(QUERY_EXTERNAL_KEY) final String externalKey,
@QueryParam(QUERY_PLUGIN_PROPERTY) final List<String> pluginPropertiesString,
@QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode,
@@ -124,6 +134,8 @@ public class PaymentMethodResource extends JaxRsResourceBase {
@GET
@Path("/" + PAGINATION)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "List payment methods", response = PaymentMethodJson.class, responseContainer = "List")
+ @ApiResponses(value = {})
public Response getPaymentMethods(@QueryParam(QUERY_SEARCH_OFFSET) @DefaultValue("0") final Long offset,
@QueryParam(QUERY_SEARCH_LIMIT) @DefaultValue("100") final Long limit,
@QueryParam(QUERY_PAYMENT_METHOD_PLUGIN_NAME) final String pluginName,
@@ -178,6 +190,8 @@ public class PaymentMethodResource extends JaxRsResourceBase {
@GET
@Path("/" + SEARCH + "/{searchKey:" + ANYTHING_PATTERN + "}")
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Search payment methods", response = PaymentMethodJson.class, responseContainer = "List")
+ @ApiResponses(value = {})
public Response searchPaymentMethods(@PathParam("searchKey") final String searchKey,
@QueryParam(QUERY_SEARCH_OFFSET) @DefaultValue("0") final Long offset,
@QueryParam(QUERY_SEARCH_LIMIT) @DefaultValue("100") final Long limit,
@@ -235,6 +249,9 @@ public class PaymentMethodResource extends JaxRsResourceBase {
@DELETE
@Produces(APPLICATION_JSON)
@Path("/{paymentMethodId:" + UUID_PATTERN + "}")
+ @ApiOperation(value = "Delete a payment method")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid paymentMethodId supplied"),
+ @ApiResponse(code = 404, message = "Account or payment method not found")})
public Response deletePaymentMethod(@PathParam("paymentMethodId") final String paymentMethodId,
@QueryParam(QUERY_DELETE_DEFAULT_PM_WITH_AUTO_PAY_OFF) @DefaultValue("false") final Boolean deleteDefaultPaymentMethodWithAutoPayOff,
@QueryParam(QUERY_PLUGIN_PROPERTY) final List<String> pluginPropertiesString,
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/PaymentResource.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/PaymentResource.java
index b9496c4..43b3464 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/PaymentResource.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/PaymentResource.java
@@ -65,10 +65,15 @@ import com.codahale.metrics.annotation.Timed;
import com.google.common.base.Function;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+import com.wordnik.swagger.annotations.ApiResponse;
+import com.wordnik.swagger.annotations.ApiResponses;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
@Path(JaxrsResource.PAYMENTS_PATH)
+@Api(value = JaxrsResource.PAYMENTS_PATH, description = "Operations on payments")
public class PaymentResource extends JaxRsResourceBase {
@Inject
@@ -87,6 +92,9 @@ public class PaymentResource extends JaxRsResourceBase {
@GET
@Path("/{paymentId:" + UUID_PATTERN + "}/")
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve a payment by id", response = PaymentJson.class)
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid paymentId supplied"),
+ @ApiResponse(code = 404, message = "Payment not found")})
public Response getPayment(@PathParam("paymentId") final String paymentIdStr,
@QueryParam(QUERY_WITH_PLUGIN_INFO) @DefaultValue("false") final Boolean withPluginInfo,
@QueryParam(QUERY_PLUGIN_PROPERTY) final List<String> pluginPropertiesString,
@@ -106,6 +114,8 @@ public class PaymentResource extends JaxRsResourceBase {
@GET
@Path("/" + PAGINATION)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Get payments", response = PaymentJson.class, responseContainer = "List")
+ @ApiResponses(value = {})
public Response getPayments(@QueryParam(QUERY_SEARCH_OFFSET) @DefaultValue("0") final Long offset,
@QueryParam(QUERY_SEARCH_LIMIT) @DefaultValue("100") final Long limit,
@QueryParam(QUERY_PAYMENT_PLUGIN_NAME) final String pluginName,
@@ -147,6 +157,8 @@ public class PaymentResource extends JaxRsResourceBase {
@GET
@Path("/" + SEARCH + "/{searchKey:" + ANYTHING_PATTERN + "}")
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Search payments", response = PaymentJson.class, responseContainer = "List")
+ @ApiResponses(value = {})
public Response searchPayments(@PathParam("searchKey") final String searchKey,
@QueryParam(QUERY_SEARCH_OFFSET) @DefaultValue("0") final Long offset,
@QueryParam(QUERY_SEARCH_LIMIT) @DefaultValue("100") final Long limit,
@@ -192,6 +204,9 @@ public class PaymentResource extends JaxRsResourceBase {
@Path("/{paymentId:" + UUID_PATTERN + "}/")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Capture an existing authorization")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid paymentId supplied"),
+ @ApiResponse(code = 404, message = "Account or payment not found")})
public Response captureAuthorization(final PaymentTransactionJson json,
@PathParam("paymentId") final String paymentIdStr,
@QueryParam(QUERY_PLUGIN_PROPERTY) final List<String> pluginPropertiesString,
@@ -200,6 +215,9 @@ public class PaymentResource extends JaxRsResourceBase {
@HeaderParam(HDR_COMMENT) final String comment,
@javax.ws.rs.core.Context final UriInfo uriInfo,
@javax.ws.rs.core.Context final HttpServletRequest request) throws PaymentApiException, AccountApiException {
+ verifyNonNullOrEmpty(json, "PaymentTransactionJson body should be specified");
+ verifyNonNullOrEmpty(json.getAmount(), "PaymentTransactionJson amount needs to be set");
+
final Iterable<PluginProperty> pluginProperties = extractPluginProperties(pluginPropertiesString);
final CallContext callContext = context.createContext(createdBy, reason, comment, request);
final UUID paymentId = UUID.fromString(paymentIdStr);
@@ -218,6 +236,9 @@ public class PaymentResource extends JaxRsResourceBase {
@Path("/{paymentId:" + UUID_PATTERN + "}/" + REFUNDS)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Refund an existing payment")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid paymentId supplied"),
+ @ApiResponse(code = 404, message = "Account or payment not found")})
public Response refundPayment(final PaymentTransactionJson json,
@PathParam("paymentId") final String paymentIdStr,
@QueryParam(QUERY_PLUGIN_PROPERTY) final List<String> pluginPropertiesString,
@@ -226,6 +247,9 @@ public class PaymentResource extends JaxRsResourceBase {
@HeaderParam(HDR_COMMENT) final String comment,
@javax.ws.rs.core.Context final UriInfo uriInfo,
@javax.ws.rs.core.Context final HttpServletRequest request) throws PaymentApiException, AccountApiException {
+ verifyNonNullOrEmpty(json, "PaymentTransactionJson body should be specified");
+ verifyNonNullOrEmpty(json.getAmount(), "PaymentTransactionJson amount needs to be set");
+
final Iterable<PluginProperty> pluginProperties = extractPluginProperties(pluginPropertiesString);
final CallContext callContext = context.createContext(createdBy, reason, comment, request);
final UUID paymentId = UUID.fromString(paymentIdStr);
@@ -244,6 +268,9 @@ public class PaymentResource extends JaxRsResourceBase {
@Path("/{paymentId:" + UUID_PATTERN + "}/")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Void an existing payment")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid paymentId supplied"),
+ @ApiResponse(code = 404, message = "Account or payment not found")})
public Response voidPayment(final PaymentTransactionJson json,
@PathParam("paymentId") final String paymentIdStr,
@QueryParam(QUERY_PLUGIN_PROPERTY) final List<String> pluginPropertiesString,
@@ -269,6 +296,9 @@ public class PaymentResource extends JaxRsResourceBase {
@Path("/{paymentId:" + UUID_PATTERN + "}/" + CHARGEBACKS)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Record a chargeback")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid paymentId supplied"),
+ @ApiResponse(code = 404, message = "Account not found")})
public Response chargebackPayment(final PaymentTransactionJson json,
@PathParam("paymentId") final String paymentIdStr,
@QueryParam(QUERY_PLUGIN_PROPERTY) final List<String> pluginPropertiesString,
@@ -277,6 +307,9 @@ public class PaymentResource extends JaxRsResourceBase {
@HeaderParam(HDR_COMMENT) final String comment,
@javax.ws.rs.core.Context final UriInfo uriInfo,
@javax.ws.rs.core.Context final HttpServletRequest request) throws PaymentApiException, AccountApiException {
+ verifyNonNullOrEmpty(json, "PaymentTransactionJson body should be specified");
+ verifyNonNullOrEmpty(json.getAmount(), "PaymentTransactionJson amount needs to be set");
+
final Iterable<PluginProperty> pluginProperties = extractPluginProperties(pluginPropertiesString);
final CallContext callContext = context.createContext(createdBy, reason, comment, request);
final UUID paymentId = UUID.fromString(paymentIdStr);
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/PluginResource.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/PluginResource.java
index f581061..2526e84 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/PluginResource.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/PluginResource.java
@@ -62,9 +62,11 @@ import com.google.common.io.ByteStreams;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.google.inject.name.Named;
+import com.wordnik.swagger.annotations.Api;
@Singleton
@Path(JaxrsResource.PLUGINS_PATH + "{subResources:.*}")
+@Api(value = JaxrsResource.PLUGINS_PATH + "{subResources:.*}", description = "Plugins servlets", hidden = true)
public class PluginResource extends JaxRsResourceBase {
private static final Logger log = LoggerFactory.getLogger(PluginResource.class);
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/SecurityResource.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/SecurityResource.java
index c4348b5..a9abece 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/SecurityResource.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/SecurityResource.java
@@ -47,11 +47,15 @@ import com.google.common.base.Functions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.inject.Inject;
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+import com.wordnik.swagger.annotations.ApiResponses;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
@Singleton
@Path(JaxrsResource.SECURITY_PATH)
+@Api(value = JaxrsResource.SECURITY_PATH, description = "Information about RBAC")
public class SecurityResource extends JaxRsResourceBase {
private final SecurityApi securityApi;
@@ -74,6 +78,8 @@ public class SecurityResource extends JaxRsResourceBase {
@GET
@Path("/permissions")
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "List user permissions", response = String.class, responseContainer = "List")
+ @ApiResponses(value = {})
public Response getCurrentUserPermissions(@javax.ws.rs.core.Context final HttpServletRequest request) {
final Set<Permission> permissions = securityApi.getCurrentUserPermissions(context.createContext(request));
final List<String> json = ImmutableList.<String>copyOf(Iterables.<Permission, String>transform(permissions, Functions.toStringFunction()));
@@ -84,6 +90,8 @@ public class SecurityResource extends JaxRsResourceBase {
@GET
@Path("/subject")
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Get user information", response = SubjectJson.class)
+ @ApiResponses(value = {})
public Response getCurrentUserSubject(@javax.ws.rs.core.Context final HttpServletRequest request) {
final Subject subject = SecurityUtils.getSubject();
final SubjectJson subjectJson = new SubjectJson(subject);
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/SubscriptionResource.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/SubscriptionResource.java
index ddd2768..e83a503 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/SubscriptionResource.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/SubscriptionResource.java
@@ -38,10 +38,6 @@ import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.UriInfo;
import org.joda.time.LocalDate;
-import org.killbill.billing.payment.api.PaymentApi;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import org.killbill.billing.ObjectType;
import org.killbill.billing.account.api.AccountApiException;
import org.killbill.billing.account.api.AccountUserApi;
@@ -49,7 +45,6 @@ import org.killbill.billing.catalog.api.BillingActionPolicy;
import org.killbill.billing.catalog.api.BillingPeriod;
import org.killbill.billing.catalog.api.PlanPhaseSpecifier;
import org.killbill.billing.catalog.api.ProductCategory;
-import org.killbill.clock.Clock;
import org.killbill.billing.entitlement.api.Entitlement;
import org.killbill.billing.entitlement.api.Entitlement.EntitlementActionPolicy;
import org.killbill.billing.entitlement.api.EntitlementApi;
@@ -65,9 +60,11 @@ import org.killbill.billing.events.PaymentInfoInternalEvent;
import org.killbill.billing.events.PaymentPluginErrorInternalEvent;
import org.killbill.billing.jaxrs.json.CustomFieldJson;
import org.killbill.billing.jaxrs.json.SubscriptionJson;
+import org.killbill.billing.jaxrs.json.TagJson;
import org.killbill.billing.jaxrs.util.Context;
import org.killbill.billing.jaxrs.util.JaxrsUriBuilder;
import org.killbill.billing.jaxrs.util.KillbillEventHandler;
+import org.killbill.billing.payment.api.PaymentApi;
import org.killbill.billing.util.api.AuditUserApi;
import org.killbill.billing.util.api.CustomFieldApiException;
import org.killbill.billing.util.api.CustomFieldUserApi;
@@ -77,13 +74,21 @@ import org.killbill.billing.util.api.TagUserApi;
import org.killbill.billing.util.callcontext.CallContext;
import org.killbill.billing.util.callcontext.TenantContext;
import org.killbill.billing.util.userrequest.CompletionUserRequestBase;
+import org.killbill.clock.Clock;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.codahale.metrics.annotation.Timed;
import com.google.inject.Inject;
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+import com.wordnik.swagger.annotations.ApiResponse;
+import com.wordnik.swagger.annotations.ApiResponses;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
@Path(JaxrsResource.SUBSCRIPTIONS_PATH)
+@Api(value = JaxrsResource.SUBSCRIPTIONS_PATH, description = "Operations on subscriptions")
public class SubscriptionResource extends JaxRsResourceBase {
private static final Logger log = LoggerFactory.getLogger(SubscriptionResource.class);
@@ -115,6 +120,9 @@ public class SubscriptionResource extends JaxRsResourceBase {
@GET
@Path("/{subscriptionId:" + UUID_PATTERN + "}")
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve a subscription by id", response = SubscriptionJson.class)
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid subscription id supplied"),
+ @ApiResponse(code = 404, message = "Subscription not found")})
public Response getEntitlement(@PathParam("subscriptionId") final String subscriptionId,
@javax.ws.rs.core.Context final HttpServletRequest request) throws SubscriptionApiException {
final UUID uuid = UUID.fromString(subscriptionId);
@@ -127,6 +135,8 @@ public class SubscriptionResource extends JaxRsResourceBase {
@POST
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Create an entitlement")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid entitlement supplied")})
public Response createEntitlement(final SubscriptionJson entitlement,
@QueryParam(QUERY_REQUESTED_DT) final String requestedDate,
@QueryParam(QUERY_CALL_COMPLETION) @DefaultValue("false") final Boolean callCompletion,
@@ -136,6 +146,18 @@ public class SubscriptionResource extends JaxRsResourceBase {
@HeaderParam(HDR_COMMENT) final String comment,
@javax.ws.rs.core.Context final HttpServletRequest request,
@javax.ws.rs.core.Context final UriInfo uriInfo) throws EntitlementApiException, AccountApiException, SubscriptionApiException {
+ verifyNonNullOrEmpty(entitlement, "SubscriptionJson body should be specified");
+ verifyNonNullOrEmpty(entitlement.getProductName(), "SubscriptionJson productName needs to be set",
+ entitlement.getProductCategory(), "SubscriptionJson productCategory needs to be set",
+ entitlement.getBillingPeriod(), "SubscriptionJson billingPeriod needs to be set",
+ entitlement.getPriceList(), "SubscriptionJson priceList needs to be set");
+ final boolean createAddOnEntitlement = ProductCategory.ADD_ON.toString().equals(entitlement.getProductCategory());
+ if (createAddOnEntitlement) {
+ verifyNonNullOrEmpty(entitlement.getBundleId(), "SubscriptionJson bundleId should be specified");
+ } else {
+ verifyNonNullOrEmpty(entitlement.getAccountId(), "SubscriptionJson accountId should be specified");
+ }
+
final CallContext callContext = context.createContext(createdBy, reason, comment, request);
final EntitlementCallCompletionCallback<Entitlement> callback = new EntitlementCallCompletionCallback<Entitlement>() {
@Override
@@ -148,7 +170,7 @@ public class SubscriptionResource extends JaxRsResourceBase {
final UUID accountId = entitlement.getAccountId() != null ? UUID.fromString(entitlement.getAccountId()) : null;
final LocalDate inputLocalDate = toLocalDate(accountId, requestedDate, callContext);
final UUID bundleId = entitlement.getBundleId() != null ? UUID.fromString(entitlement.getBundleId()) : null;
- return (entitlement.getProductCategory().equals(ProductCategory.ADD_ON.toString())) ?
+ return createAddOnEntitlement ?
entitlementApi.addEntitlement(bundleId, spec, inputLocalDate, callContext) :
entitlementApi.createBaseEntitlement(accountId, spec, entitlement.getExternalKey(), inputLocalDate, callContext);
}
@@ -172,6 +194,9 @@ public class SubscriptionResource extends JaxRsResourceBase {
@PUT
@Path("/{subscriptionId:" + UUID_PATTERN + "}/uncancel")
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Un-cancel an entitlement")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid subscription id supplied"),
+ @ApiResponse(code = 404, message = "Entitlement not found")})
public Response uncancelEntitlementPlan(@PathParam("subscriptionId") final String subscriptionId,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
@HeaderParam(HDR_REASON) final String reason,
@@ -188,6 +213,9 @@ public class SubscriptionResource extends JaxRsResourceBase {
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
@Path("/{subscriptionId:" + UUID_PATTERN + "}")
+ @ApiOperation(value = "Change entitlement plan")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid subscription id supplied"),
+ @ApiResponse(code = 404, message = "Entitlement not found")})
public Response changeEntitlementPlan(final SubscriptionJson entitlement,
@PathParam("subscriptionId") final String subscriptionId,
@QueryParam(QUERY_REQUESTED_DT) final String requestedDate,
@@ -198,6 +226,11 @@ public class SubscriptionResource extends JaxRsResourceBase {
@HeaderParam(HDR_REASON) final String reason,
@HeaderParam(HDR_COMMENT) final String comment,
@javax.ws.rs.core.Context final HttpServletRequest request) throws EntitlementApiException, AccountApiException, SubscriptionApiException {
+ verifyNonNullOrEmpty(entitlement, "SubscriptionJson body should be specified");
+ verifyNonNullOrEmpty(entitlement.getProductName(), "SubscriptionJson productName needs to be set",
+ entitlement.getBillingPeriod(), "SubscriptionJson billingPeriod needs to be set",
+ entitlement.getPriceList(), "SubscriptionJson priceList needs to be set");
+
final CallContext callContext = context.createContext(createdBy, reason, comment, request);
final EntitlementCallCompletionCallback<Response> callback = new EntitlementCallCompletionCallback<Response>() {
@@ -248,6 +281,9 @@ public class SubscriptionResource extends JaxRsResourceBase {
@DELETE
@Path("/{subscriptionId:" + UUID_PATTERN + "}")
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Cancel an entitlement plan")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid subscription id supplied"),
+ @ApiResponse(code = 404, message = "Entitlement not found")})
public Response cancelEntitlementPlan(@PathParam("subscriptionId") final String subscriptionId,
@QueryParam(QUERY_REQUESTED_DT) final String requestedDate,
@QueryParam(QUERY_CALL_COMPLETION) @DefaultValue("false") final Boolean callCompletion,
@@ -400,6 +436,8 @@ public class SubscriptionResource extends JaxRsResourceBase {
@GET
@Path("/{subscriptionId:" + UUID_PATTERN + "}/" + CUSTOM_FIELDS)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve subscription custom fields", response = CustomFieldJson.class, responseContainer = "List")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid subscription id supplied")})
public Response getCustomFields(@PathParam(ID_PARAM_NAME) final String id,
@QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode,
@javax.ws.rs.core.Context final HttpServletRequest request) {
@@ -410,6 +448,8 @@ public class SubscriptionResource extends JaxRsResourceBase {
@Path("/{subscriptionId:" + UUID_PATTERN + "}/" + CUSTOM_FIELDS)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Add custom fields to subscription")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid subscription id supplied")})
public Response createCustomFields(@PathParam(ID_PARAM_NAME) final String id,
final List<CustomFieldJson> customFields,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
@@ -425,6 +465,8 @@ public class SubscriptionResource extends JaxRsResourceBase {
@Path("/{subscriptionId:" + UUID_PATTERN + "}/" + CUSTOM_FIELDS)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Remove custom fields from subscription")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid subscription id supplied")})
public Response deleteCustomFields(@PathParam(ID_PARAM_NAME) final String id,
@QueryParam(QUERY_CUSTOM_FIELDS) final String customFieldList,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
@@ -439,6 +481,9 @@ public class SubscriptionResource extends JaxRsResourceBase {
@GET
@Path("/{subscriptionId:" + UUID_PATTERN + "}/" + TAGS)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve subscription tags", response = TagJson.class, responseContainer = "List")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid subscription id supplied"),
+ @ApiResponse(code = 404, message = "Subscription not found")})
public Response getTags(@PathParam(ID_PARAM_NAME) final String subscriptionIdString,
@QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode,
@QueryParam(QUERY_TAGS_INCLUDED_DELETED) @DefaultValue("false") final Boolean includedDeleted,
@@ -453,6 +498,8 @@ public class SubscriptionResource extends JaxRsResourceBase {
@Path("/{subscriptionId:" + UUID_PATTERN + "}/" + TAGS)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Add tags to subscription")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid subscription id supplied")})
public Response createTags(@PathParam(ID_PARAM_NAME) final String id,
@QueryParam(QUERY_TAGS) final String tagList,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
@@ -468,6 +515,8 @@ public class SubscriptionResource extends JaxRsResourceBase {
@Path("/{subscriptionId:" + UUID_PATTERN + "}/" + TAGS)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Remove tags from subscription")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid subscription id supplied")})
public Response deleteTags(@PathParam(ID_PARAM_NAME) final String id,
@QueryParam(QUERY_TAGS) final String tagList,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/TagDefinitionResource.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/TagDefinitionResource.java
index 343dd43..0afb793 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/TagDefinitionResource.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/TagDefinitionResource.java
@@ -38,11 +38,10 @@ import javax.ws.rs.core.UriInfo;
import org.killbill.billing.ObjectType;
import org.killbill.billing.account.api.AccountUserApi;
-import org.killbill.billing.payment.api.PaymentApi;
-import org.killbill.clock.Clock;
import org.killbill.billing.jaxrs.json.TagDefinitionJson;
import org.killbill.billing.jaxrs.util.Context;
import org.killbill.billing.jaxrs.util.JaxrsUriBuilder;
+import org.killbill.billing.payment.api.PaymentApi;
import org.killbill.billing.util.api.AuditUserApi;
import org.killbill.billing.util.api.CustomFieldUserApi;
import org.killbill.billing.util.api.TagDefinitionApiException;
@@ -50,16 +49,21 @@ import org.killbill.billing.util.api.TagUserApi;
import org.killbill.billing.util.audit.AuditLog;
import org.killbill.billing.util.callcontext.TenantContext;
import org.killbill.billing.util.tag.TagDefinition;
+import org.killbill.clock.Clock;
import com.codahale.metrics.annotation.Timed;
-import com.google.common.base.Preconditions;
import com.google.inject.Inject;
import com.google.inject.Singleton;
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+import com.wordnik.swagger.annotations.ApiResponse;
+import com.wordnik.swagger.annotations.ApiResponses;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
@Singleton
@Path(JaxrsResource.TAG_DEFINITIONS_PATH)
+@Api(value = JaxrsResource.TAG_DEFINITIONS_PATH, description = "Operations on tag definitions")
public class TagDefinitionResource extends JaxRsResourceBase {
@Inject
@@ -77,6 +81,8 @@ public class TagDefinitionResource extends JaxRsResourceBase {
@Timed
@GET
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "List tag definitions", response = TagDefinitionJson.class, responseContainer = "List")
+ @ApiResponses(value = {})
public Response getTagDefinitions(@javax.ws.rs.core.Context final HttpServletRequest request,
@QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode) {
final TenantContext tenantContext = context.createContext(request);
@@ -95,6 +101,8 @@ public class TagDefinitionResource extends JaxRsResourceBase {
@GET
@Path("/{tagDefinitionId:" + UUID_PATTERN + "}")
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve a tag definition", response = TagDefinitionJson.class)
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid tagDefinitionId supplied")})
public Response getTagDefinition(@PathParam("tagDefinitionId") final String tagDefId,
@QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode,
@javax.ws.rs.core.Context final HttpServletRequest request) throws TagDefinitionApiException {
@@ -109,6 +117,8 @@ public class TagDefinitionResource extends JaxRsResourceBase {
@POST
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Create a tag definition")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid name or description supplied")})
public Response createTagDefinition(final TagDefinitionJson json,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
@HeaderParam(HDR_REASON) final String reason,
@@ -116,8 +126,9 @@ public class TagDefinitionResource extends JaxRsResourceBase {
@javax.ws.rs.core.Context final HttpServletRequest request,
@javax.ws.rs.core.Context final UriInfo uriInfo) throws TagDefinitionApiException {
// Checked as the database layer as well, but bail early and return 400 instead of 500
- Preconditions.checkNotNull(json.getName(), String.format("TagDefinition name needs to be set"));
- Preconditions.checkNotNull(json.getDescription(), String.format("TagDefinition description needs to be set"));
+ verifyNonNullOrEmpty(json, "TagDefinitionJson body should be specified");
+ verifyNonNullOrEmpty(json.getName(), "TagDefinition name needs to be set",
+ json.getDescription(), "TagDefinition description needs to be set");
final TagDefinition createdTagDef = tagUserApi.createTagDefinition(json.getName(), json.getDescription(), context.createContext(createdBy, reason, comment, request));
return uriBuilder.buildResponse(uriInfo, TagDefinitionResource.class, "getTagDefinition", createdTagDef.getId());
@@ -127,6 +138,8 @@ public class TagDefinitionResource extends JaxRsResourceBase {
@DELETE
@Path("/{tagDefinitionId:" + UUID_PATTERN + "}")
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Delete a tag definition")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid tagDefinitionId supplied")})
public Response deleteTagDefinition(@PathParam("tagDefinitionId") final String tagDefId,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
@HeaderParam(HDR_REASON) final String reason,
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/TagResource.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/TagResource.java
index 4871ce2..6370612 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/TagResource.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/TagResource.java
@@ -53,11 +53,16 @@ import com.google.common.base.Function;
import com.google.common.collect.ImmutableMap;
import com.google.inject.Inject;
import com.google.inject.Singleton;
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+import com.wordnik.swagger.annotations.ApiResponse;
+import com.wordnik.swagger.annotations.ApiResponses;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
@Singleton
@Path(JaxrsResource.TAGS_PATH)
+@Api(value = JaxrsResource.TAGS_PATH, description = "Operations on tags")
public class TagResource extends JaxRsResourceBase {
@Inject
@@ -76,6 +81,8 @@ public class TagResource extends JaxRsResourceBase {
@GET
@Path("/" + PAGINATION)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "List tags", response = TagJson.class, responseContainer = "List")
+ @ApiResponses(value = {})
public Response getTags(@QueryParam(QUERY_SEARCH_OFFSET) @DefaultValue("0") final Long offset,
@QueryParam(QUERY_SEARCH_LIMIT) @DefaultValue("100") final Long limit,
@QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode,
@@ -107,6 +114,8 @@ public class TagResource extends JaxRsResourceBase {
@GET
@Path("/" + SEARCH + "/{searchKey:" + ANYTHING_PATTERN + "}")
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Search tags", response = TagJson.class, responseContainer = "List")
+ @ApiResponses(value = {})
public Response searchTags(@PathParam("searchKey") final String searchKey,
@QueryParam(QUERY_SEARCH_OFFSET) @DefaultValue("0") final Long offset,
@QueryParam(QUERY_SEARCH_LIMIT) @DefaultValue("100") final Long limit,
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/TenantResource.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/TenantResource.java
index b0e6789..045eb04 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/TenantResource.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/TenantResource.java
@@ -57,11 +57,16 @@ import org.killbill.billing.util.callcontext.TenantContext;
import com.codahale.metrics.annotation.Timed;
import com.google.inject.Inject;
import com.google.inject.Singleton;
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+import com.wordnik.swagger.annotations.ApiResponse;
+import com.wordnik.swagger.annotations.ApiResponses;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
@Singleton
@Path(JaxrsResource.TENANTS_PATH)
+@Api(value = JaxrsResource.TENANTS_PATH, description = "Operations on tenants")
public class TenantResource extends JaxRsResourceBase {
private final TenantUserApi tenantApi;
@@ -84,6 +89,9 @@ public class TenantResource extends JaxRsResourceBase {
@GET
@Path("/{tenantId:" + UUID_PATTERN + "}")
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve a tenant by id", response = TenantJson.class)
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid tenantId supplied"),
+ @ApiResponse(code = 404, message = "Tenant not found")})
public Response getTenant(@PathParam("tenantId") final String tenantId) throws TenantApiException {
final Tenant tenant = tenantApi.getTenantById(UUID.fromString(tenantId));
return Response.status(Status.OK).entity(new TenantJson(tenant)).build();
@@ -92,6 +100,8 @@ public class TenantResource extends JaxRsResourceBase {
@Timed
@GET
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve a tenant by its API key", response = TenantJson.class)
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Tenant not found")})
public Response getTenantByApiKey(@QueryParam(QUERY_API_KEY) final String externalKey) throws TenantApiException {
final Tenant tenant = tenantApi.getTenantByApiKey(externalKey);
return Response.status(Status.OK).entity(new TenantJson(tenant)).build();
@@ -101,12 +111,18 @@ public class TenantResource extends JaxRsResourceBase {
@POST
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Create a tenant")
+ @ApiResponses(value = {@ApiResponse(code = 500, message = "Tenant already exists")})
public Response createTenant(final TenantJson json,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
@HeaderParam(HDR_REASON) final String reason,
@HeaderParam(HDR_COMMENT) final String comment,
@javax.ws.rs.core.Context final HttpServletRequest request,
@javax.ws.rs.core.Context final UriInfo uriInfo) throws TenantApiException {
+ verifyNonNullOrEmpty(json, "TenantJson body should be specified");
+ verifyNonNullOrEmpty(json.getApiKey(), "TenantJson apiKey needs to be set",
+ json.getApiSecret(), "TenantJson apiSecret needs to be set");
+
final TenantData data = json.toTenantData();
final Tenant tenant = tenantApi.createTenant(data, context.createContext(createdBy, reason, comment, request));
return uriBuilder.buildResponse(uriInfo, TenantResource.class, "getTenant", tenant.getId());
@@ -117,6 +133,8 @@ public class TenantResource extends JaxRsResourceBase {
@Path("/" + REGISTER_NOTIFICATION_CALLBACK)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Create a push notification")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid tenantId supplied")})
public Response registerPushNotificationCallback(@PathParam("tenantId") final String tenantId,
@QueryParam(QUERY_NOTIFICATION_CALLBACK) final String notificationCallback,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
@@ -133,6 +151,8 @@ public class TenantResource extends JaxRsResourceBase {
@GET
@Path("/" + REGISTER_NOTIFICATION_CALLBACK)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve a push notification", response = TenantKeyJson.class)
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid tenantId supplied")})
public Response getPushNotificationCallbacks(@javax.ws.rs.core.Context final HttpServletRequest request) throws TenantApiException {
final TenantContext tenatContext = context.createContext(request);
@@ -144,6 +164,8 @@ public class TenantResource extends JaxRsResourceBase {
@Timed
@DELETE
@Path("/REGISTER_NOTIFICATION_CALLBACK")
+ @ApiOperation(value = "Delete a push notification")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid tenantId supplied")})
public Response deletePushNotificationCallbacks(@PathParam("tenantId") final String tenantId,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
@HeaderParam(HDR_REASON) final String reason,
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/TestResource.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/TestResource.java
index cc11223..2801eed 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/TestResource.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/TestResource.java
@@ -55,6 +55,10 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+import com.wordnik.swagger.annotations.ApiResponse;
+import com.wordnik.swagger.annotations.ApiResponses;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
@@ -67,7 +71,8 @@ import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
// so to be used with great caution.
//
//
-@Path(JaxrsResource.PREFIX + "/test")
+@Path(JaxrsResource.TEST_PATH)
+@Api(value = JaxrsResource.TEST_PATH, description = "Operations for testing")
public class TestResource extends JaxRsResourceBase {
private static final Logger log = LoggerFactory.getLogger(TestResource.class);
@@ -118,6 +123,8 @@ public class TestResource extends JaxRsResourceBase {
@GET
@Path("/clock")
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Get the current time", response = ClockResource.class)
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid timezone supplied")})
public Response getCurrentTime(@QueryParam("timeZone") final String timeZoneStr) {
final DateTimeZone timeZone = timeZoneStr != null ? DateTimeZone.forID(timeZoneStr) : DateTimeZone.UTC;
final DateTime now = clock.getUTCNow();
@@ -128,6 +135,8 @@ public class TestResource extends JaxRsResourceBase {
@POST
@Path("/clock")
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Set the current time", response = ClockResource.class)
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid time or timezone supplied")})
public Response setTestClockTime(@QueryParam(QUERY_REQUESTED_DT) final String requestedClockDate,
@QueryParam("timeZone") final String timeZoneStr,
@QueryParam("timeoutSec") @DefaultValue("5") final Long timeoutSec,
@@ -150,6 +159,8 @@ public class TestResource extends JaxRsResourceBase {
@PUT
@Path("/clock")
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Move the current time", response = ClockResource.class)
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid timezone supplied")})
public Response updateTestClockTime(@QueryParam("days") final Integer addDays,
@QueryParam("weeks") final Integer addWeeks,
@QueryParam("months") final Integer addMonths,
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/TransactionResource.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/TransactionResource.java
index d3bca8c..68d9060 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/TransactionResource.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/TransactionResource.java
@@ -17,25 +17,16 @@
package org.killbill.billing.jaxrs.resources;
-import java.net.URI;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
import java.util.UUID;
-import java.util.concurrent.atomic.AtomicReference;
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
@@ -43,8 +34,6 @@ import org.killbill.billing.ObjectType;
import org.killbill.billing.account.api.Account;
import org.killbill.billing.account.api.AccountApiException;
import org.killbill.billing.account.api.AccountUserApi;
-import org.killbill.billing.catalog.api.Currency;
-import org.killbill.billing.jaxrs.json.PaymentJson;
import org.killbill.billing.jaxrs.json.PaymentTransactionJson;
import org.killbill.billing.jaxrs.util.Context;
import org.killbill.billing.jaxrs.util.JaxrsUriBuilder;
@@ -56,21 +45,20 @@ import org.killbill.billing.payment.api.TransactionStatus;
import org.killbill.billing.util.api.AuditUserApi;
import org.killbill.billing.util.api.CustomFieldUserApi;
import org.killbill.billing.util.api.TagUserApi;
-import org.killbill.billing.util.audit.AccountAuditLogs;
import org.killbill.billing.util.callcontext.CallContext;
-import org.killbill.billing.util.callcontext.TenantContext;
-import org.killbill.billing.util.entity.Pagination;
import org.killbill.clock.Clock;
import com.codahale.metrics.annotation.Timed;
-import com.google.common.base.Function;
-import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+import com.wordnik.swagger.annotations.ApiResponse;
+import com.wordnik.swagger.annotations.ApiResponses;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
@Path(JaxrsResource.PAYMENT_TRANSACTIONS)
+@Api(value = JaxrsResource.PAYMENT_TRANSACTIONS, description = "Operations on payment transactions")
public class TransactionResource extends JaxRsResourceBase {
@Inject
@@ -90,13 +78,19 @@ public class TransactionResource extends JaxRsResourceBase {
@Path("/{transactionId:" + UUID_PATTERN + "}/")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Mark a pending payment transaction as succeeded or failed")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid paymentId supplied"),
+ @ApiResponse(code = 404, message = "Account or Payment not found")})
public Response notifyStateChanged(final PaymentTransactionJson json,
- @PathParam("transactionId") final String transactionIdStr,
- @HeaderParam(HDR_CREATED_BY) final String createdBy,
- @HeaderParam(HDR_REASON) final String reason,
- @HeaderParam(HDR_COMMENT) final String comment,
- @javax.ws.rs.core.Context final UriInfo uriInfo,
- @javax.ws.rs.core.Context final HttpServletRequest request) throws PaymentApiException, AccountApiException {
+ @PathParam("transactionId") final String transactionIdStr,
+ @HeaderParam(HDR_CREATED_BY) final String createdBy,
+ @HeaderParam(HDR_REASON) final String reason,
+ @HeaderParam(HDR_COMMENT) final String comment,
+ @javax.ws.rs.core.Context final UriInfo uriInfo,
+ @javax.ws.rs.core.Context final HttpServletRequest request) throws PaymentApiException, AccountApiException {
+ verifyNonNullOrEmpty(json, "PaymentTransactionJson body should be specified");
+ verifyNonNullOrEmpty(json.getPaymentId(), "PaymentTransactionJson paymentId needs to be set",
+ json.getStatus(), "PaymentTransactionJson status needs to be set");
final CallContext callContext = context.createContext(createdBy, reason, comment, request);
@@ -104,13 +98,11 @@ public class TransactionResource extends JaxRsResourceBase {
final Payment payment = paymentApi.getPayment(paymentId, false, ImmutableList.<PluginProperty>of(), callContext);
final Account account = accountUserApi.getAccountById(payment.getAccountId(), callContext);
- final boolean success = json.getStatus().equals(TransactionStatus.SUCCESS.name());
+ final boolean success = TransactionStatus.SUCCESS.name().equals(json.getStatus());
final Payment result = paymentApi.notifyPendingTransactionOfStateChanged(account, UUID.fromString(transactionIdStr), success, callContext);
return uriBuilder.buildResponse(uriInfo, PaymentResource.class, "getPayment", result.getId());
}
-
-
@Override
protected ObjectType getObjectType() {
return ObjectType.TRANSACTION;
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/UsageResource.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/UsageResource.java
index 048cae1..f961ac2 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/UsageResource.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/UsageResource.java
@@ -19,7 +19,6 @@ package org.killbill.billing.jaxrs.resources;
import java.util.List;
import java.util.UUID;
-import javax.annotation.concurrent.Immutable;
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
@@ -60,10 +59,16 @@ import com.codahale.metrics.annotation.Timed;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.inject.Singleton;
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+import com.wordnik.swagger.annotations.ApiResponse;
+import com.wordnik.swagger.annotations.ApiResponses;
+
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
@Singleton
@Path(JaxrsResource.USAGES_PATH)
+@Api(value = JaxrsResource.USAGES_PATH, description = "Operations on usage")
public class UsageResource extends JaxRsResourceBase {
private final UsageUserApi usageUserApi;
@@ -89,15 +94,17 @@ public class UsageResource extends JaxRsResourceBase {
@POST
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Record usage for a subscription")
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid subscription (e.g. inactive)")})
public Response recordUsage(final SubscriptionUsageRecordJson json,
- @HeaderParam(HDR_CREATED_BY) final String createdBy,
- @HeaderParam(HDR_REASON) final String reason,
- @HeaderParam(HDR_COMMENT) final String comment,
- @javax.ws.rs.core.Context final HttpServletRequest request,
- @javax.ws.rs.core.Context final UriInfo uriInfo) throws EntitlementApiException, AccountApiException {
-
- Preconditions.checkNotNull(json.getSubscriptionId());
- Preconditions.checkNotNull(json.getUnitUsageRecords());
+ @HeaderParam(HDR_CREATED_BY) final String createdBy,
+ @HeaderParam(HDR_REASON) final String reason,
+ @HeaderParam(HDR_COMMENT) final String comment,
+ @javax.ws.rs.core.Context final HttpServletRequest request,
+ @javax.ws.rs.core.Context final UriInfo uriInfo) throws EntitlementApiException, AccountApiException {
+ verifyNonNullOrEmpty(json, "SubscriptionUsageRecordJson body should be specified");
+ verifyNonNullOrEmpty(json.getSubscriptionId(), "SubscriptionUsageRecordJson subscriptionId needs to be set",
+ json.getUnitUsageRecords(), "SubscriptionUsageRecordJson unitUsageRecords needs to be set");
Preconditions.checkArgument(!json.getUnitUsageRecords().isEmpty());
final CallContext callContext = context.createContext(createdBy, reason, comment, request);
@@ -116,11 +123,13 @@ public class UsageResource extends JaxRsResourceBase {
@GET
@Path("/{subscriptionId:" + UUID_PATTERN + "}/{unitType}")
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve usage for a subscription and unit type", response = RolledUpUsageJson.class)
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Missing start date or end date")})
public Response getUsage(@PathParam("subscriptionId") final String subscriptionId,
@PathParam("unitType") final String unitType,
@QueryParam(QUERY_START_DATE) final String startDate,
@QueryParam(QUERY_END_DATE) final String endDate,
- @javax.ws.rs.core.Context final HttpServletRequest request) {
+ @javax.ws.rs.core.Context final HttpServletRequest request) {
if (startDate == null || endDate == null) {
return Response.status(Status.BAD_REQUEST).build();
@@ -139,10 +148,12 @@ public class UsageResource extends JaxRsResourceBase {
@GET
@Path("/{subscriptionId:" + UUID_PATTERN + "}")
@Produces(APPLICATION_JSON)
+ @ApiOperation(value = "Retrieve usage for a subscription", response = RolledUpUsageJson.class)
+ @ApiResponses(value = {@ApiResponse(code = 400, message = "Missing start date or end date")})
public Response getAllUsage(@PathParam("subscriptionId") final String subscriptionId,
- @QueryParam(QUERY_START_DATE) final String startDate,
- @QueryParam(QUERY_END_DATE) final String endDate,
- @javax.ws.rs.core.Context final HttpServletRequest request) {
+ @QueryParam(QUERY_START_DATE) final String startDate,
+ @QueryParam(QUERY_END_DATE) final String endDate,
+ @javax.ws.rs.core.Context final HttpServletRequest request) {
if (startDate == null || endDate == null) {
return Response.status(Status.BAD_REQUEST).build();
diff --git a/jaxrs/src/test/java/org/killbill/billing/jaxrs/json/TestBillingExceptionJson.java b/jaxrs/src/test/java/org/killbill/billing/jaxrs/json/TestBillingExceptionJson.java
index 86b605c..626df42 100644
--- a/jaxrs/src/test/java/org/killbill/billing/jaxrs/json/TestBillingExceptionJson.java
+++ b/jaxrs/src/test/java/org/killbill/billing/jaxrs/json/TestBillingExceptionJson.java
@@ -56,7 +56,7 @@ public class TestBillingExceptionJson extends JaxrsTestSuiteNoDB {
nil.toString();
Assert.fail();
} catch (final NullPointerException e) {
- final BillingExceptionJson exceptionJson = new BillingExceptionJson(e);
+ final BillingExceptionJson exceptionJson = new BillingExceptionJson(e, true);
Assert.assertEquals(exceptionJson.getClassName(), e.getClass().getName());
Assert.assertNull(exceptionJson.getCode());
Assert.assertNull(exceptionJson.getMessage());
@@ -66,6 +66,14 @@ public class TestBillingExceptionJson extends JaxrsTestSuiteNoDB {
Assert.assertEquals(exceptionJson.getStackTrace().get(0).getClassName(), TestBillingExceptionJson.class.getName());
Assert.assertEquals(exceptionJson.getStackTrace().get(0).getMethodName(), "testFromException");
Assert.assertFalse(exceptionJson.getStackTrace().get(0).getNativeMethod());
+
+ final BillingExceptionJson exceptionJsonNoStackTrace = new BillingExceptionJson(e, false);
+ Assert.assertEquals(exceptionJsonNoStackTrace.getClassName(), e.getClass().getName());
+ Assert.assertNull(exceptionJsonNoStackTrace.getCode());
+ Assert.assertNull(exceptionJsonNoStackTrace.getMessage());
+ Assert.assertNull(exceptionJsonNoStackTrace.getCauseClassName());
+ Assert.assertNull(exceptionJsonNoStackTrace.getCauseMessage());
+ Assert.assertTrue(exceptionJsonNoStackTrace.getStackTrace().isEmpty());
}
}
}
junction/pom.xml 2(+1 -1)
diff --git a/junction/pom.xml b/junction/pom.xml
index 7b561ef..474ba84 100644
--- a/junction/pom.xml
+++ b/junction/pom.xml
@@ -19,7 +19,7 @@
<parent>
<artifactId>killbill</artifactId>
<groupId>org.kill-bill.billing</groupId>
- <version>0.11.13-SNAPSHOT</version>
+ <version>0.11.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-junction</artifactId>
NEWS 7(+7 -0)
diff --git a/NEWS b/NEWS
index 00a09e9..791f4fa 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,10 @@
+0.11.13
+ Swagger integration
+ Fixes for PaymentControlApi
+ https://github.com/killbill/killbill/issues/152
+ https://github.com/killbill/killbill/issues/227
+ https://github.com/killbill/killbill/issues/198
+
0.11.12
Fix issues around timezones
Switch to HikariCP by default
overdue/pom.xml 2(+1 -1)
diff --git a/overdue/pom.xml b/overdue/pom.xml
index da25e0d..05667cc 100644
--- a/overdue/pom.xml
+++ b/overdue/pom.xml
@@ -19,7 +19,7 @@
<parent>
<artifactId>killbill</artifactId>
<groupId>org.kill-bill.billing</groupId>
- <version>0.11.13-SNAPSHOT</version>
+ <version>0.11.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-overdue</artifactId>
payment/pom.xml 2(+1 -1)
diff --git a/payment/pom.xml b/payment/pom.xml
index a2bb3b6..fbac2a8 100644
--- a/payment/pom.xml
+++ b/payment/pom.xml
@@ -19,7 +19,7 @@
<parent>
<artifactId>killbill</artifactId>
<groupId>org.kill-bill.billing</groupId>
- <version>0.11.13-SNAPSHOT</version>
+ <version>0.11.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-payment</artifactId>
diff --git a/payment/src/main/java/org/killbill/billing/payment/api/DefaultPaymentApi.java b/payment/src/main/java/org/killbill/billing/payment/api/DefaultPaymentApi.java
index 3c0b151..15ec0cb 100644
--- a/payment/src/main/java/org/killbill/billing/payment/api/DefaultPaymentApi.java
+++ b/payment/src/main/java/org/killbill/billing/payment/api/DefaultPaymentApi.java
@@ -35,6 +35,7 @@ import org.killbill.billing.payment.core.PluginControlledPaymentProcessor;
import org.killbill.billing.util.callcontext.CallContext;
import org.killbill.billing.util.callcontext.InternalCallContextFactory;
import org.killbill.billing.util.callcontext.TenantContext;
+import org.killbill.billing.util.config.PaymentConfig;
import org.killbill.billing.util.entity.Pagination;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -47,13 +48,15 @@ public class DefaultPaymentApi implements PaymentApi {
private static final Logger log = LoggerFactory.getLogger(DefaultPaymentApi.class);
+ private final PaymentConfig paymentConfig;
private final PaymentProcessor paymentProcessor;
private final PaymentMethodProcessor paymentMethodProcessor;
private final PluginControlledPaymentProcessor pluginControlledPaymentProcessor;
private final InternalCallContextFactory internalCallContextFactory;
@Inject
- public DefaultPaymentApi(final PaymentProcessor paymentProcessor, final PaymentMethodProcessor paymentMethodProcessor, final PluginControlledPaymentProcessor pluginControlledPaymentProcessor, final InternalCallContextFactory internalCallContextFactory) {
+ public DefaultPaymentApi(final PaymentConfig paymentConfig, final PaymentProcessor paymentProcessor, final PaymentMethodProcessor paymentMethodProcessor, final PluginControlledPaymentProcessor pluginControlledPaymentProcessor, final InternalCallContextFactory internalCallContextFactory) {
+ this.paymentConfig = paymentConfig;
this.paymentProcessor = paymentProcessor;
this.paymentMethodProcessor = paymentMethodProcessor;
this.pluginControlledPaymentProcessor = pluginControlledPaymentProcessor;
@@ -137,7 +140,7 @@ public class DefaultPaymentApi implements PaymentApi {
paymentMethodId :
paymentMethodProcessor.createOrGetExternalPaymentMethod(UUID.randomUUID().toString(), account, properties, callContext, internalCallContext);
return pluginControlledPaymentProcessor.createPurchase(IS_API_PAYMENT, account, nonNulPaymentMethodId, paymentId, amount, currency, paymentExternalKey, paymentTransactionExternalKey,
- properties, paymentOptions.getPaymentControlPluginName(), callContext, internalCallContext);
+ properties, toPaymentControlPluginNames(paymentOptions), callContext, internalCallContext);
}
@@ -192,7 +195,7 @@ public class DefaultPaymentApi implements PaymentApi {
final InternalCallContext internalCallContext = internalCallContextFactory.createInternalCallContext(account.getId(), callContext);
return pluginControlledPaymentProcessor.createRefund(IS_API_PAYMENT, account, paymentId, amount, currency, paymentTransactionExternalKey,
- properties, paymentOptions.getPaymentControlPluginName(), callContext, internalCallContext);
+ properties, toPaymentControlPluginNames(paymentOptions), callContext, internalCallContext);
}
@@ -259,7 +262,7 @@ public class DefaultPaymentApi implements PaymentApi {
final InternalCallContext internalCallContext = internalCallContextFactory.createInternalCallContext(account.getId(), callContext);
return pluginControlledPaymentProcessor.createChargeback(account, paymentId, paymentTransactionExternalKey, amount, currency,
- paymentOptions.getPaymentControlPluginName(), callContext, internalCallContext);
+ toPaymentControlPluginNames(paymentOptions), callContext, internalCallContext);
}
@Override
@@ -423,6 +426,10 @@ public class DefaultPaymentApi implements PaymentApi {
}
}
+ private List<String> toPaymentControlPluginNames(final PaymentOptions paymentOptions) {
+ return paymentOptions.getPaymentControlPluginNames() != null ? paymentOptions.getPaymentControlPluginNames() : paymentConfig.getPaymentControlPluginNames();
+ }
+
private void checkNotNullParameter(final Object parameter, final String parameterName) throws PaymentApiException {
if (parameter == null) {
throw new PaymentApiException(ErrorCode.PAYMENT_INVALID_PARAMETER, parameterName, "should not be null");
diff --git a/payment/src/main/java/org/killbill/billing/payment/bus/InvoiceHandler.java b/payment/src/main/java/org/killbill/billing/payment/bus/InvoiceHandler.java
index a5fcee7..0157839 100644
--- a/payment/src/main/java/org/killbill/billing/payment/bus/InvoiceHandler.java
+++ b/payment/src/main/java/org/killbill/billing/payment/bus/InvoiceHandler.java
@@ -40,10 +40,12 @@ import org.killbill.billing.util.callcontext.CallContext;
import org.killbill.billing.util.callcontext.CallOrigin;
import org.killbill.billing.util.callcontext.InternalCallContextFactory;
import org.killbill.billing.util.callcontext.UserType;
+import org.killbill.billing.util.config.PaymentConfig;
import org.killbill.billing.util.dao.NonEntityDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.common.collect.ImmutableList;
import com.google.common.eventbus.Subscribe;
import com.google.inject.Inject;
@@ -54,15 +56,18 @@ public class InvoiceHandler {
private final PluginControlledPaymentProcessor pluginControlledPaymentProcessor;
private final NonEntityDao nonEntityDao;
private final CacheControllerDispatcher controllerDispatcher;
+ private final PaymentConfig paymentConfig;
private static final Logger log = LoggerFactory.getLogger(InvoiceHandler.class);
@Inject
- public InvoiceHandler(final AccountInternalApi accountApi,
+ public InvoiceHandler(final PaymentConfig paymentConfig,
+ final AccountInternalApi accountApi,
final PluginControlledPaymentProcessor pluginControlledPaymentProcessor,
final NonEntityDao nonEntityDao,
final InternalCallContextFactory internalCallContextFactory,
final CacheControllerDispatcher controllerDispatcher) {
+ this.paymentConfig = paymentConfig;
this.accountApi = accountApi;
this.internalCallContextFactory = internalCallContextFactory;
this.pluginControlledPaymentProcessor = pluginControlledPaymentProcessor;
@@ -88,8 +93,9 @@ public class InvoiceHandler {
final CallContext callContext = internalContext.toCallContext(nonEntityDao.retrieveIdFromObject(internalContext.getTenantRecordId(), ObjectType.TENANT, controllerDispatcher.getCacheController(CacheType.OBJECT_ID)));
final BigDecimal amountToBePaid = null; // We let the plugin compute how much should be paid
+ final List<String> paymentControlPluginNames = paymentConfig.getPaymentControlPluginNames() != null ? paymentConfig.getPaymentControlPluginNames() : ImmutableList.of(InvoicePaymentControlPluginApi.PLUGIN_NAME);
pluginControlledPaymentProcessor.createPurchase(false, account, account.getPaymentMethodId(), null, amountToBePaid, account.getCurrency(), UUID.randomUUID().toString(), UUID.randomUUID().toString(),
- properties, InvoicePaymentControlPluginApi.PLUGIN_NAME, callContext, internalContext);
+ properties, paymentControlPluginNames, callContext, internalContext);
} catch (final AccountApiException e) {
log.error("Failed to process invoice payment", e);
} catch (final PaymentApiException e) {
diff --git a/payment/src/main/java/org/killbill/billing/payment/control/InvoicePaymentControlPluginApi.java b/payment/src/main/java/org/killbill/billing/payment/control/InvoicePaymentControlPluginApi.java
index dbfe997..68483dd 100644
--- a/payment/src/main/java/org/killbill/billing/payment/control/InvoicePaymentControlPluginApi.java
+++ b/payment/src/main/java/org/killbill/billing/payment/control/InvoicePaymentControlPluginApi.java
@@ -110,7 +110,7 @@ public final class InvoicePaymentControlPluginApi implements PaymentControlPlugi
}
@Override
- public PriorPaymentControlResult priorCall(final PaymentControlContext paymentControlContext) throws PaymentControlApiException {
+ public PriorPaymentControlResult priorCall(final PaymentControlContext paymentControlContext, Iterable<PluginProperty> properties) throws PaymentControlApiException {
final TransactionType transactionType = paymentControlContext.getTransactionType();
Preconditions.checkArgument(transactionType == TransactionType.PURCHASE ||
@@ -124,14 +124,14 @@ public final class InvoicePaymentControlPluginApi implements PaymentControlPlugi
case REFUND:
return getPluginRefundResult(paymentControlContext, internalContext);
case CHARGEBACK:
- return new DefaultPriorPaymentControlResult(false, paymentControlContext.getAmount());
+ return new DefaultPriorPaymentControlResult(false, paymentControlContext.getAmount(), null, null);
default:
throw new IllegalStateException("Unexpected transactionType " + transactionType);
}
}
@Override
- public void onSuccessCall(final PaymentControlContext paymentControlContext) throws PaymentControlApiException {
+ public void onSuccessCall(final PaymentControlContext paymentControlContext, Iterable<PluginProperty> properties) throws PaymentControlApiException {
final TransactionType transactionType = paymentControlContext.getTransactionType();
Preconditions.checkArgument(transactionType == TransactionType.PURCHASE ||
@@ -188,7 +188,7 @@ public final class InvoicePaymentControlPluginApi implements PaymentControlPlugi
}
@Override
- public FailureCallResult onFailureCall(final PaymentControlContext paymentControlContext) throws
+ public FailureCallResult onFailureCall(final PaymentControlContext paymentControlContext, Iterable<PluginProperty> properties) throws
PaymentControlApiException {
final InternalCallContext internalContext = internalCallContextFactory.createInternalCallContext(paymentControlContext.getAccountId(), paymentControlContext);
@@ -209,7 +209,8 @@ public final class InvoicePaymentControlPluginApi implements PaymentControlPlugi
public void process_AUTO_PAY_OFF_removal(final Account account, final InternalCallContext internalCallContext) {
final List<PluginAutoPayOffModelDao> entries = controlDao.getAutoPayOffEntry(account.getId());
for (PluginAutoPayOffModelDao cur : entries) {
- retryServiceScheduler.scheduleRetry(ObjectType.ACCOUNT, account.getId(), cur.getAttemptId(), PLUGIN_NAME, clock.getUTCNow());
+ // TODO In theory we should pass not only PLUGIN_NAME, but also all the plugin list associated which the original call
+ retryServiceScheduler.scheduleRetry(ObjectType.ACCOUNT, account.getId(), cur.getAttemptId(), ImmutableList.<String>of(PLUGIN_NAME), clock.getUTCNow());
}
controlDao.removeAutoPayOffEntry(account.getId());
}
@@ -240,7 +241,7 @@ public final class InvoicePaymentControlPluginApi implements PaymentControlPlugi
" aborted : invoice balance is = " + invoice.getBalance() +
", requested payment amount is = " + paymentControlPluginContext.getAmount());
} else {
- return new DefaultPriorPaymentControlResult(isAborted, requestedAmount);
+ return new DefaultPriorPaymentControlResult(isAborted, requestedAmount, null, null);
}
} catch (InvoiceApiException e) {
throw new PaymentControlApiException(e);
@@ -273,7 +274,7 @@ public final class InvoicePaymentControlPluginApi implements PaymentControlPlugi
" aborted : invoice item sum amount is " + amountToBeRefunded +
", requested refund amount is = " + paymentControlPluginContext.getAmount());
} else {
- return new DefaultPriorPaymentControlResult(isAborted, amountToBeRefunded);
+ return new DefaultPriorPaymentControlResult(isAborted, amountToBeRefunded, null, null);
}
}
diff --git a/payment/src/main/java/org/killbill/billing/payment/core/janitor/AttemptCompletionTask.java b/payment/src/main/java/org/killbill/billing/payment/core/janitor/AttemptCompletionTask.java
index 5714907..717142d 100644
--- a/payment/src/main/java/org/killbill/billing/payment/core/janitor/AttemptCompletionTask.java
+++ b/payment/src/main/java/org/killbill/billing/payment/core/janitor/AttemptCompletionTask.java
@@ -96,7 +96,7 @@ final class AttemptCompletionTask extends CompletionTaskBase<PaymentAttemptModel
final Account account = accountInternalApi.getAccountById(attempt.getAccountId(), tenantContext);
final boolean isApiPayment = true; // unclear
- final RetryablePaymentStateContext paymentStateContext = new RetryablePaymentStateContext(attempt.getPluginName(),
+ final RetryablePaymentStateContext paymentStateContext = new RetryablePaymentStateContext(attempt.toPaymentControlPluginNames(),
isApiPayment,
transaction.getPaymentId(),
attempt.getPaymentExternalKey(),
diff --git a/payment/src/main/java/org/killbill/billing/payment/core/PluginControlledPaymentProcessor.java b/payment/src/main/java/org/killbill/billing/payment/core/PluginControlledPaymentProcessor.java
index 9f5fbda..c6c5979 100644
--- a/payment/src/main/java/org/killbill/billing/payment/core/PluginControlledPaymentProcessor.java
+++ b/payment/src/main/java/org/killbill/billing/payment/core/PluginControlledPaymentProcessor.java
@@ -17,11 +17,13 @@
package org.killbill.billing.payment.core;
import java.math.BigDecimal;
+import java.util.List;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
import javax.annotation.Nullable;
import javax.inject.Inject;
+import javax.sql.rowset.Joinable;
import org.killbill.automaton.MissingEntryException;
import org.killbill.automaton.State;
@@ -53,6 +55,7 @@ import org.killbill.billing.util.dao.NonEntityDao;
import org.killbill.clock.Clock;
import org.killbill.commons.locker.GlobalLocker;
+import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList;
import com.google.inject.name.Named;
@@ -60,6 +63,8 @@ import static org.killbill.billing.payment.glue.PaymentModule.PLUGIN_EXECUTOR_NA
public class PluginControlledPaymentProcessor extends ProcessorBase {
+ private static final Joiner JOINER = Joiner.on(", ");
+
private final PluginControlledPaymentAutomatonRunner pluginControlledPaymentAutomatonRunner;
private final RetryStateMachineHelper retrySMHelper;
private final CacheControllerDispatcher controllerDispatcher;
@@ -84,7 +89,7 @@ public class PluginControlledPaymentProcessor extends ProcessorBase {
}
public Payment createAuthorization(final boolean isApiPayment, final Account account, final UUID paymentMethodId, @Nullable final UUID paymentId, final BigDecimal amount, final Currency currency, final String paymentExternalKey, final String transactionExternalKey,
- final Iterable<PluginProperty> properties, final String paymentControlPluginName, final CallContext callContext, final InternalCallContext internalCallContext) throws PaymentApiException {
+ final Iterable<PluginProperty> properties, final List<String> paymentControlPluginNames, final CallContext callContext, final InternalCallContext internalCallContext) throws PaymentApiException {
return pluginControlledPaymentAutomatonRunner.run(isApiPayment,
TransactionType.AUTHORIZE,
account,
@@ -95,13 +100,13 @@ public class PluginControlledPaymentProcessor extends ProcessorBase {
amount,
currency,
properties,
- paymentControlPluginName,
+ paymentControlPluginNames,
callContext, internalCallContext);
}
public Payment createCapture(final boolean isApiPayment, final Account account, final UUID paymentId, final BigDecimal amount, final Currency currency,
final String transactionExternalKey,
- final Iterable<PluginProperty> properties, final String paymentControlPluginName,
+ final Iterable<PluginProperty> properties, final List<String> paymentControlPluginNames,
final CallContext callContext, final InternalCallContext internalCallContext) throws PaymentApiException {
return pluginControlledPaymentAutomatonRunner.run(isApiPayment,
TransactionType.CAPTURE,
@@ -113,13 +118,13 @@ public class PluginControlledPaymentProcessor extends ProcessorBase {
amount,
currency,
properties,
- paymentControlPluginName,
+ paymentControlPluginNames,
callContext, internalCallContext);
}
public Payment createPurchase(final boolean isApiPayment, final Account account, final UUID paymentMethodId, final UUID paymentId, final BigDecimal amount, final Currency currency,
final String paymentExternalKey, final String transactionExternalKey, final Iterable<PluginProperty> properties,
- final String paymentControlPluginName, final CallContext callContext, final InternalCallContext internalCallContext) throws PaymentApiException {
+ final List<String> paymentControlPluginNames, final CallContext callContext, final InternalCallContext internalCallContext) throws PaymentApiException {
return pluginControlledPaymentAutomatonRunner.run(isApiPayment,
TransactionType.PURCHASE,
account,
@@ -130,7 +135,7 @@ public class PluginControlledPaymentProcessor extends ProcessorBase {
amount,
currency,
properties,
- paymentControlPluginName,
+ paymentControlPluginNames,
callContext, internalCallContext);
}
@@ -151,7 +156,7 @@ public class PluginControlledPaymentProcessor extends ProcessorBase {
}
public Payment createRefund(final boolean isApiPayment, final Account account, final UUID paymentId, final BigDecimal amount, final Currency currency, final String transactionExternalKey,
- final Iterable<PluginProperty> properties, final String paymentControlPluginName, final CallContext callContext, final InternalCallContext internalCallContext) throws PaymentApiException {
+ final Iterable<PluginProperty> properties, final List<String> paymentControlPluginNames, final CallContext callContext, final InternalCallContext internalCallContext) throws PaymentApiException {
return pluginControlledPaymentAutomatonRunner.run(isApiPayment,
TransactionType.REFUND,
account,
@@ -162,12 +167,12 @@ public class PluginControlledPaymentProcessor extends ProcessorBase {
amount,
currency,
properties,
- paymentControlPluginName,
+ paymentControlPluginNames,
callContext, internalCallContext);
}
public Payment createCredit(final boolean isApiPayment, final Account account, final UUID paymentMethodId, final UUID paymentId, final BigDecimal amount, final Currency currency, final String paymentExternalKey,
- final String transactionExternalKey, final Iterable<PluginProperty> properties, final String paymentControlPluginName, final CallContext callContext, final InternalCallContext internalCallContext) throws PaymentApiException {
+ final String transactionExternalKey, final Iterable<PluginProperty> properties, final List<String> paymentControlPluginNames, final CallContext callContext, final InternalCallContext internalCallContext) throws PaymentApiException {
return pluginControlledPaymentAutomatonRunner.run(isApiPayment,
TransactionType.CREDIT,
@@ -179,12 +184,12 @@ public class PluginControlledPaymentProcessor extends ProcessorBase {
amount,
currency,
properties,
- paymentControlPluginName,
+ paymentControlPluginNames,
callContext, internalCallContext);
}
public Payment createChargeback(final Account account, final UUID paymentId, final String transactionExternalKey, final BigDecimal amount, final Currency currency,
- final String paymentControlPluginName, final CallContext callContext, final InternalCallContext internalCallContext) throws PaymentApiException {
+ final List<String> paymentControlPluginNames, final CallContext callContext, final InternalCallContext internalCallContext) throws PaymentApiException {
return pluginControlledPaymentAutomatonRunner.run(true,
TransactionType.CHARGEBACK,
account,
@@ -195,11 +200,11 @@ public class PluginControlledPaymentProcessor extends ProcessorBase {
amount,
currency,
ImmutableList.<PluginProperty>of(),
- paymentControlPluginName,
+ paymentControlPluginNames,
callContext, internalCallContext);
}
- public void retryPaymentTransaction(final UUID attemptId, final String pluginName, final InternalCallContext internalCallContext) {
+ public void retryPaymentTransaction(final UUID attemptId, final List<String> paymentControlPluginNames, final InternalCallContext internalCallContext) {
try {
final PaymentAttemptModelDao attempt = paymentDao.getPaymentAttempt(attemptId, internalCallContext);
@@ -223,18 +228,29 @@ public class PluginControlledPaymentProcessor extends ProcessorBase {
attempt.getAmount(),
attempt.getCurrency(),
pluginProperties,
- pluginName,
+ paymentControlPluginNames,
callContext,
internalCallContext);
} catch (AccountApiException e) {
- log.warn("Failed to retry attempt " + attemptId + " for plugin " + pluginName, e);
+ log.warn("Failed to retry attempt " + attemptId + toPluginNamesOnError(" for plugins ", paymentControlPluginNames), e);
} catch (PaymentApiException e) {
- log.warn("Failed to retry attempt " + attemptId + " for plugin " + pluginName, e);
+ log.warn("Failed to retry attempt " + attemptId + toPluginNamesOnError(" for plugins ", paymentControlPluginNames), e);
} catch (PluginPropertySerializerException e) {
- log.warn("Failed to retry attempt " + attemptId + " for plugin " + pluginName, e);
+ log.warn("Failed to retry attempt " + attemptId + toPluginNamesOnError(" for plugins ", paymentControlPluginNames), e);
} catch (MissingEntryException e) {
- log.warn("Failed to retry attempt " + attemptId + " for plugin " + pluginName, e);
+ log.warn("Failed to retry attempt " + attemptId + toPluginNamesOnError(" for plugins ", paymentControlPluginNames), e);
+ }
+ }
+
+ private String toPluginNamesOnError(final String prefixMessage, final List<String> paymentControlPluginNames) {
+ if (paymentControlPluginNames == null || paymentControlPluginNames.size() == 0) {
+ return "";
}
+ final StringBuilder tmp = new StringBuilder(prefixMessage)
+ .append("(")
+ .append(JOINER.join(paymentControlPluginNames))
+ .append(")");
+ return tmp.toString();
}
}
diff --git a/payment/src/main/java/org/killbill/billing/payment/core/sm/PaymentStateContext.java b/payment/src/main/java/org/killbill/billing/payment/core/sm/PaymentStateContext.java
index 32b18a2..3aafe01 100644
--- a/payment/src/main/java/org/killbill/billing/payment/core/sm/PaymentStateContext.java
+++ b/payment/src/main/java/org/killbill/billing/payment/core/sm/PaymentStateContext.java
@@ -47,13 +47,13 @@ public class PaymentStateContext {
protected PaymentTransactionInfoPlugin paymentInfoPlugin;
protected BigDecimal amount;
protected String paymentExternalKey;
+ protected Currency currency;
// Can be updated later via paymentTransactionModelDao (e.g. for auth or purchase)
protected final UUID paymentId;
protected final UUID transactionId;
protected final String paymentTransactionExternalKey;
protected final Account account;
- protected final Currency currency;
protected final TransactionType transactionType;
protected final boolean shouldLockAccountAndDispatch;
protected final Iterable<PluginProperty> properties;
diff --git a/payment/src/main/java/org/killbill/billing/payment/core/sm/PluginControlledPaymentAutomatonRunner.java b/payment/src/main/java/org/killbill/billing/payment/core/sm/PluginControlledPaymentAutomatonRunner.java
index ec4280c..0df1324 100644
--- a/payment/src/main/java/org/killbill/billing/payment/core/sm/PluginControlledPaymentAutomatonRunner.java
+++ b/payment/src/main/java/org/killbill/billing/payment/core/sm/PluginControlledPaymentAutomatonRunner.java
@@ -17,6 +17,7 @@
package org.killbill.billing.payment.core.sm;
import java.math.BigDecimal;
+import java.util.List;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
@@ -81,23 +82,23 @@ public class PluginControlledPaymentAutomatonRunner extends PaymentAutomatonRunn
public Payment run(final boolean isApiPayment, final TransactionType transactionType, final Account account, @Nullable final UUID paymentMethodId,
@Nullable final UUID paymentId, @Nullable final String paymentExternalKey, final String paymentTransactionExternalKey,
@Nullable final BigDecimal amount, @Nullable final Currency currency,
- final Iterable<PluginProperty> properties, @Nullable final String pluginName,
+ final Iterable<PluginProperty> properties, @Nullable final List<String> paymentControlPluginNames,
final CallContext callContext, final InternalCallContext internalCallContext) throws PaymentApiException {
return run(retrySMHelper.getInitialState(), isApiPayment, transactionType, account, paymentMethodId, paymentId, paymentExternalKey, paymentTransactionExternalKey,
- amount, currency, properties, pluginName, callContext, internalCallContext);
+ amount, currency, properties, paymentControlPluginNames, callContext, internalCallContext);
}
public Payment run(final State state, final boolean isApiPayment, final TransactionType transactionType, final Account account, @Nullable final UUID paymentMethodId,
@Nullable final UUID paymentId, @Nullable final String paymentExternalKey, final String paymentTransactionExternalKey,
@Nullable final BigDecimal amount, @Nullable final Currency currency,
- final Iterable<PluginProperty> properties, @Nullable final String pluginName,
+ final Iterable<PluginProperty> properties, @Nullable final List<String> paymentControlPluginNames,
final CallContext callContext, final InternalCallContext internalCallContext) throws PaymentApiException {
final RetryablePaymentStateContext paymentStateContext = createContext(isApiPayment, transactionType, account, paymentMethodId,
paymentId, paymentExternalKey,
paymentTransactionExternalKey,
amount, currency,
- properties, pluginName, callContext, internalCallContext);
+ properties, paymentControlPluginNames, callContext, internalCallContext);
try {
final OperationCallback callback = createOperationCallback(transactionType, paymentStateContext);
@@ -149,8 +150,8 @@ public class PluginControlledPaymentAutomatonRunner extends PaymentAutomatonRunn
RetryablePaymentStateContext createContext(final boolean isApiPayment, final TransactionType transactionType, final Account account, @Nullable final UUID paymentMethodId,
@Nullable final UUID paymentId, @Nullable final String paymentExternalKey, final String paymentTransactionExternalKey,
@Nullable final BigDecimal amount, @Nullable final Currency currency, final Iterable<PluginProperty> properties,
- final String pluginName, final CallContext callContext, final InternalCallContext internalCallContext) throws PaymentApiException {
- return new RetryablePaymentStateContext(pluginName, isApiPayment, paymentId, paymentExternalKey, paymentTransactionExternalKey, transactionType, account,
+ final List<String> paymentControlPluginNames, final CallContext callContext, final InternalCallContext internalCallContext) throws PaymentApiException {
+ return new RetryablePaymentStateContext(paymentControlPluginNames, isApiPayment, paymentId, paymentExternalKey, paymentTransactionExternalKey, transactionType, account,
paymentMethodId, amount, currency, properties, internalCallContext, callContext);
}
diff --git a/payment/src/main/java/org/killbill/billing/payment/core/sm/RetryablePaymentStateContext.java b/payment/src/main/java/org/killbill/billing/payment/core/sm/RetryablePaymentStateContext.java
index 678d987..7461aca 100644
--- a/payment/src/main/java/org/killbill/billing/payment/core/sm/RetryablePaymentStateContext.java
+++ b/payment/src/main/java/org/killbill/billing/payment/core/sm/RetryablePaymentStateContext.java
@@ -17,6 +17,7 @@
package org.killbill.billing.payment.core.sm;
import java.math.BigDecimal;
+import java.util.List;
import java.util.UUID;
import javax.annotation.Nullable;
@@ -38,15 +39,15 @@ import com.google.common.collect.Iterables;
public class RetryablePaymentStateContext extends PaymentStateContext {
private DateTime retryDate;
- private String pluginName;
+ private List<String> paymentControlPluginNames;
private Payment result;
- public RetryablePaymentStateContext(@Nullable final String pluginName, final boolean isApiPayment, @Nullable final UUID paymentId, final String paymentExternalKey,
+ public RetryablePaymentStateContext(@Nullable final List<String> paymentControlPluginNames, final boolean isApiPayment, @Nullable final UUID paymentId, final String paymentExternalKey,
@Nullable final String paymentTransactionExternalKey, final TransactionType transactionType,
final Account account, @Nullable final UUID paymentMethodId, final BigDecimal amount, final Currency currency,
final Iterable<PluginProperty> properties, final InternalCallContext internalCallContext, final CallContext callContext) {
super(isApiPayment, paymentId, null, null, paymentExternalKey, paymentTransactionExternalKey, transactionType, account, paymentMethodId, amount, currency, true, null, properties, internalCallContext, callContext);
- this.pluginName = pluginName;
+ this.paymentControlPluginNames = paymentControlPluginNames;
}
public DateTime getRetryDate() {
@@ -57,12 +58,8 @@ public class RetryablePaymentStateContext extends PaymentStateContext {
this.retryDate = retryDate;
}
- public String getPluginName() {
- return pluginName;
- }
-
- public void setPluginName(final String pluginName) {
- this.pluginName = pluginName;
+ public List<String> getPaymentControlPluginNames() {
+ return paymentControlPluginNames;
}
public Payment getResult() {
@@ -77,6 +74,10 @@ public class RetryablePaymentStateContext extends PaymentStateContext {
this.amount = adjustedAmount;
}
+ public void setCurrency(final Currency currency) {
+ this.currency = currency;
+ }
+
public PaymentTransaction getCurrentTransaction() {
if (result == null || result.getTransactions() == null) {
return null;
diff --git a/payment/src/main/java/org/killbill/billing/payment/core/sm/RetryCompletionOperationCallback.java b/payment/src/main/java/org/killbill/billing/payment/core/sm/RetryCompletionOperationCallback.java
index 91e1f92..4dab872 100644
--- a/payment/src/main/java/org/killbill/billing/payment/core/sm/RetryCompletionOperationCallback.java
+++ b/payment/src/main/java/org/killbill/billing/payment/core/sm/RetryCompletionOperationCallback.java
@@ -60,7 +60,7 @@ public class RetryCompletionOperationCallback extends RetryOperationCallback {
retryablePaymentStateContext.isApiPayment(),
paymentStateContext.callContext);
- onCompletion(retryablePaymentStateContext.getPluginName(), updatedPaymentControlContext);
+ onCompletion(retryablePaymentStateContext.getPaymentControlPluginNames(), updatedPaymentControlContext);
return PluginDispatcher.createPluginDispatcherReturnType(OperationResult.SUCCESS);
}
});
diff --git a/payment/src/main/java/org/killbill/billing/payment/core/sm/RetryEnteringStateCallback.java b/payment/src/main/java/org/killbill/billing/payment/core/sm/RetryEnteringStateCallback.java
index 0b7889f..1b9554d 100644
--- a/payment/src/main/java/org/killbill/billing/payment/core/sm/RetryEnteringStateCallback.java
+++ b/payment/src/main/java/org/killbill/billing/payment/core/sm/RetryEnteringStateCallback.java
@@ -51,7 +51,7 @@ public class RetryEnteringStateCallback implements EnteringStateCallback {
if ("RETRIED".equals(state.getName())) {
retryServiceScheduler.scheduleRetry(ObjectType.PAYMENT_ATTEMPT, attempt.getId(), attempt.getId(),
- paymentStateContext.getPluginName(), paymentStateContext.getRetryDate());
+ paymentStateContext.getPaymentControlPluginNames(), paymentStateContext.getRetryDate());
}
}
}
diff --git a/payment/src/main/java/org/killbill/billing/payment/core/sm/RetryLeavingStateCallback.java b/payment/src/main/java/org/killbill/billing/payment/core/sm/RetryLeavingStateCallback.java
index 4a4b2ed..cd9f2c3 100644
--- a/payment/src/main/java/org/killbill/billing/payment/core/sm/RetryLeavingStateCallback.java
+++ b/payment/src/main/java/org/killbill/billing/payment/core/sm/RetryLeavingStateCallback.java
@@ -73,7 +73,7 @@ public class RetryLeavingStateCallback implements LeavingStateCallback {
utcNow, utcNow, stateContext.getPaymentExternalKey(), null,
stateContext.paymentTransactionExternalKey, transactionType, initialState.getName(),
stateContext.getAmount(), stateContext.getCurrency(),
- stateContext.getPluginName(), serializedProperties);
+ stateContext.getPaymentControlPluginNames(), serializedProperties);
retryablePaymentAutomatonRunner.paymentDao.insertPaymentAttemptWithProperties(attempt, stateContext.internalCallContext);
stateContext.setAttemptId(attempt.getId());
diff --git a/payment/src/main/java/org/killbill/billing/payment/core/sm/RetryOperationCallback.java b/payment/src/main/java/org/killbill/billing/payment/core/sm/RetryOperationCallback.java
index 580e180..64cf0ba 100644
--- a/payment/src/main/java/org/killbill/billing/payment/core/sm/RetryOperationCallback.java
+++ b/payment/src/main/java/org/killbill/billing/payment/core/sm/RetryOperationCallback.java
@@ -17,6 +17,7 @@
package org.killbill.billing.payment.core.sm;
import java.math.BigDecimal;
+import java.util.List;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
@@ -94,7 +95,7 @@ public abstract class RetryOperationCallback extends OperationCallbackBase<Payme
final PriorPaymentControlResult pluginResult;
try {
- pluginResult = getPluginResult(retryablePaymentStateContext.getPluginName(), paymentControlContext);
+ pluginResult = getPluginResult(retryablePaymentStateContext.getPaymentControlPluginNames(), paymentControlContext);
if (pluginResult.isAborted()) {
// Transition to ABORTED
return PluginDispatcher.createPluginDispatcherReturnType(OperationResult.EXCEPTION);
@@ -107,10 +108,7 @@ public abstract class RetryOperationCallback extends OperationCallbackBase<Payme
final boolean success;
try {
// Adjust amount with value returned by plugin if necessary
- if (paymentStateContext.getAmount() == null ||
- (pluginResult.getAdjustedAmount() != null && pluginResult.getAdjustedAmount().compareTo(paymentStateContext.getAmount()) != 0)) {
- ((RetryablePaymentStateContext) paymentStateContext).setAmount(pluginResult.getAdjustedAmount());
- }
+ adjustStateContextValues(paymentStateContext, pluginResult);
final Payment result = doCallSpecificOperationCallback();
((RetryablePaymentStateContext) paymentStateContext).setResult(result);
@@ -134,7 +132,7 @@ public abstract class RetryOperationCallback extends OperationCallbackBase<Payme
retryablePaymentStateContext.isApiPayment(),
paymentStateContext.callContext);
- onCompletion(retryablePaymentStateContext.getPluginName(), updatedPaymentControlContext);
+ onCompletion(retryablePaymentStateContext.getPaymentControlPluginNames(), updatedPaymentControlContext);
return PluginDispatcher.createPluginDispatcherReturnType(OperationResult.SUCCESS);
} else {
throw new OperationException(null, getOperationResultAndSetContext(retryablePaymentStateContext, paymentControlContext));
@@ -177,12 +175,30 @@ public abstract class RetryOperationCallback extends OperationCallbackBase<Payme
return new OperationException(e, getOperationResultOnException(paymentStateContext));
}
- protected void onCompletion(final String pluginName, final PaymentControlContext paymentControlContext) {
- final PaymentControlPluginApi plugin = paymentControlPluginRegistry.getServiceForName(pluginName);
- try {
- plugin.onSuccessCall(paymentControlContext);
- } catch (final PaymentControlApiException e) {
- logger.warn("Plugin " + pluginName + " failed to complete onCompletion call for " + paymentControlContext.getPaymentExternalKey(), e);
+ protected void onCompletion(final List<String> paymentControlPluginNames, final PaymentControlContext paymentControlContext) {
+ for (String pluginName : paymentControlPluginNames) {
+ final PaymentControlPluginApi plugin = paymentControlPluginRegistry.getServiceForName(pluginName);
+ if (plugin != null) {
+ try {
+ plugin.onSuccessCall(paymentControlContext, paymentStateContext.getProperties());
+ } catch (final PaymentControlApiException e) {
+ logger.warn("Plugin " + pluginName + " failed to complete onCompletion call for " + paymentControlContext.getPaymentExternalKey(), e);
+ }
+ }
+ }
+ }
+
+ private final void adjustStateContextValues(final PaymentStateContext inputContext, final PriorPaymentControlResult pluginResult) {
+
+ final RetryablePaymentStateContext input = (RetryablePaymentStateContext) inputContext;
+ if (pluginResult.getAdjustedAmount() != null) {
+ input.setAmount(pluginResult.getAdjustedAmount());
+ }
+ if (pluginResult.getAdjustedCurrency() != null) {
+ input.setCurrency(pluginResult.getAdjustedCurrency());
+ }
+ if (pluginResult.getAdjustedPaymentMethodId() != null) {
+ input.setPaymentMethodId(pluginResult.getAdjustedPaymentMethodId());
}
}
@@ -192,14 +208,43 @@ public abstract class RetryOperationCallback extends OperationCallbackBase<Payme
return operationResult;
}
- private PriorPaymentControlResult getPluginResult(final String pluginName, final PaymentControlContext paymentControlContext) throws PaymentControlApiException {
- final PaymentControlPluginApi plugin = paymentControlPluginRegistry.getServiceForName(pluginName);
- final PriorPaymentControlResult result = plugin.priorCall(paymentControlContext);
- return result;
+ private PriorPaymentControlResult getPluginResult(final List<String> paymentControlPluginNames, final PaymentControlContext paymentControlContextArg) throws PaymentControlApiException {
+
+ // Return as soon as the first plugin aborts, or the last result for the last plugin
+ PriorPaymentControlResult prevResult = null;
+
+ PaymentControlContext inputPaymentControlContext = paymentControlContextArg;
+
+ for (String pluginName : paymentControlPluginNames) {
+ final PaymentControlPluginApi plugin = paymentControlPluginRegistry.getServiceForName(pluginName);
+ if (plugin == null) {
+ // First call to plugin, we log warn, if plugin is not registered
+ logger.warn("Skipping payment plugin control {} when fetching results", pluginName);
+ continue;
+ }
+ prevResult = plugin.priorCall(inputPaymentControlContext, paymentStateContext.getProperties());
+ if (prevResult.isAborted()) {
+ break;
+ }
+ inputPaymentControlContext = new DefaultPaymentControlContext(paymentStateContext.getAccount(),
+ prevResult.getAdjustedPaymentMethodId() != null ? prevResult.getAdjustedPaymentMethodId() : inputPaymentControlContext.getPaymentMethodId(),
+ retryablePaymentStateContext.getAttemptId(),
+ paymentStateContext.getPaymentId(),
+ paymentStateContext.getPaymentExternalKey(),
+ paymentStateContext.getPaymentTransactionExternalKey(),
+ paymentStateContext.getTransactionType(),
+ prevResult.getAdjustedAmount() != null ? prevResult.getAdjustedAmount() : inputPaymentControlContext.getAmount(),
+ prevResult.getAdjustedCurrency() != null ? prevResult.getAdjustedCurrency() : inputPaymentControlContext.getCurrency(),
+ paymentStateContext.getProperties(),
+ retryablePaymentStateContext.isApiPayment(),
+ paymentStateContext.callContext);
+
+ }
+ return prevResult;
}
private OperationResult getOperationResultAndSetContext(final RetryablePaymentStateContext retryablePaymentStateContext, final PaymentControlContext paymentControlContext) {
- final DateTime retryDate = getNextRetryDate(retryablePaymentStateContext.getPluginName(), paymentControlContext);
+ final DateTime retryDate = getNextRetryDate(retryablePaymentStateContext.getPaymentControlPluginNames(), paymentControlContext);
if (retryDate != null) {
((RetryablePaymentStateContext) paymentStateContext).setRetryDate(retryDate);
return OperationResult.FAILURE;
@@ -208,15 +253,25 @@ public abstract class RetryOperationCallback extends OperationCallbackBase<Payme
}
}
- private DateTime getNextRetryDate(final String pluginName, final PaymentControlContext paymentControlContext) {
- try {
+ private DateTime getNextRetryDate(final List<String> paymentControlPluginNames, final PaymentControlContext paymentControlContext) {
+ DateTime candidate = null;
+ for (String pluginName : paymentControlPluginNames) {
final PaymentControlPluginApi plugin = paymentControlPluginRegistry.getServiceForName(pluginName);
- final FailureCallResult result = plugin.onFailureCall(paymentControlContext);
- return result.getNextRetryDate();
- } catch (final PaymentControlApiException e) {
- logger.warn("Plugin " + pluginName + " failed to return next retryDate for payment " + paymentControlContext.getPaymentExternalKey(), e);
- return null;
+ if (plugin != null) {
+ try {
+ final FailureCallResult result = plugin.onFailureCall(paymentControlContext, paymentStateContext.getProperties());
+ if (candidate == null) {
+ candidate = result.getNextRetryDate();
+ } else if (result.getNextRetryDate() != null) {
+ candidate = candidate.compareTo(result.getNextRetryDate()) > 0 ? result.getNextRetryDate() : candidate;
+ }
+ } catch (final PaymentControlApiException e) {
+ logger.warn("Plugin " + pluginName + " failed to return next retryDate for payment " + paymentControlContext.getPaymentExternalKey(), e);
+ return candidate;
+ }
+ }
}
+ return candidate;
}
public static class DefaultPaymentControlContext extends DefaultCallContext implements PaymentControlContext {
@@ -328,5 +383,25 @@ public abstract class RetryOperationCallback extends OperationCallbackBase<Payme
public Iterable<PluginProperty> getPluginProperties() {
return properties;
}
+
+ @Override
+ public String toString() {
+ return "DefaultPaymentControlContext{" +
+ "account=" + account +
+ ", paymentMethodId=" + paymentMethodId +
+ ", attemptId=" + attemptId +
+ ", paymentId=" + paymentId +
+ ", paymentExternalKey='" + paymentExternalKey + '\'' +
+ ", transactionId=" + transactionId +
+ ", transactionExternalKey='" + transactionExternalKey + '\'' +
+ ", transactionType=" + transactionType +
+ ", amount=" + amount +
+ ", currency=" + currency +
+ ", processedAmount=" + processedAmount +
+ ", processedCurrency=" + processedCurrency +
+ ", isApiPayment=" + isApiPayment +
+ ", properties=" + properties +
+ '}';
+ }
}
}
diff --git a/payment/src/main/java/org/killbill/billing/payment/dao/PaymentAttemptModelDao.java b/payment/src/main/java/org/killbill/billing/payment/dao/PaymentAttemptModelDao.java
index fdc1354..85d218a 100644
--- a/payment/src/main/java/org/killbill/billing/payment/dao/PaymentAttemptModelDao.java
+++ b/payment/src/main/java/org/killbill/billing/payment/dao/PaymentAttemptModelDao.java
@@ -31,8 +31,13 @@ import org.killbill.billing.util.entity.Entity;
import org.killbill.billing.util.entity.dao.EntityModelDao;
import org.killbill.billing.util.entity.dao.EntityModelDaoBase;
+import com.google.common.base.Joiner;
+import com.google.common.collect.ImmutableList;
+
public class PaymentAttemptModelDao extends EntityModelDaoBase implements EntityModelDao<Entity> {
+ private static final Joiner JOINER = Joiner.on(",");
+
private UUID accountId;
private UUID paymentMethodId;
private String paymentExternalKey;
@@ -66,9 +71,9 @@ public class PaymentAttemptModelDao extends EntityModelDaoBase implements Entity
public PaymentAttemptModelDao(final UUID accountId, final UUID paymentMethodId, @Nullable final DateTime createdDate, @Nullable final DateTime updatedDate,
final String paymentExternalKey, final UUID transactionId, final String transactionExternalKey, final TransactionType transactionType, final String stateName,
- final BigDecimal amount, final Currency currency, final String pluginName, final byte [] pluginProperties) {
+ final BigDecimal amount, final Currency currency, final List<String> paymentControlPluginNames, final byte [] pluginProperties) {
this(accountId, paymentMethodId, UUID.randomUUID(), createdDate, updatedDate, paymentExternalKey, transactionId, transactionExternalKey, transactionType, stateName,
- amount, currency, pluginName, pluginProperties);
+ amount, currency, toPluginNames(paymentControlPluginNames), pluginProperties);
}
public String getPaymentExternalKey() {
@@ -159,6 +164,14 @@ public class PaymentAttemptModelDao extends EntityModelDaoBase implements Entity
this.currency = currency;
}
+ public final List<String> toPaymentControlPluginNames() {
+ if (pluginName == null) {
+ return ImmutableList.<String>of();
+ }
+ final String [] parts = pluginName.split(",");
+ return ImmutableList.<String>copyOf(parts);
+ }
+
@Override
public boolean equals(final Object o) {
if (this == o) {
@@ -233,4 +246,7 @@ public class PaymentAttemptModelDao extends EntityModelDaoBase implements Entity
return TableName.PAYMENT_ATTEMPT_HISTORY;
}
+ private static final String toPluginNames(final List<String> paymentControlPluginNames) {
+ return paymentControlPluginNames == null || paymentControlPluginNames.size() == 0 ? null : JOINER.join(paymentControlPluginNames);
+ }
}
diff --git a/payment/src/main/java/org/killbill/billing/payment/provider/DefaultNoOpPaymentControlProviderPlugin.java b/payment/src/main/java/org/killbill/billing/payment/provider/DefaultNoOpPaymentControlProviderPlugin.java
index 33ddf53..6a398d6 100644
--- a/payment/src/main/java/org/killbill/billing/payment/provider/DefaultNoOpPaymentControlProviderPlugin.java
+++ b/payment/src/main/java/org/killbill/billing/payment/provider/DefaultNoOpPaymentControlProviderPlugin.java
@@ -17,6 +17,7 @@
package org.killbill.billing.payment.provider;
import org.joda.time.DateTime;
+import org.killbill.billing.payment.api.PluginProperty;
import org.killbill.billing.payment.retry.DefaultFailureCallResult;
import org.killbill.billing.payment.retry.DefaultPriorPaymentControlResult;
import org.killbill.billing.retry.plugin.api.FailureCallResult;
@@ -32,16 +33,16 @@ public class DefaultNoOpPaymentControlProviderPlugin implements PaymentControlPl
private DateTime nextRetryDate;
@Override
- public PriorPaymentControlResult priorCall(final PaymentControlContext retryPluginContext) throws PaymentControlApiException {
- return new DefaultPriorPaymentControlResult(isRetryAborted, null);
+ public PriorPaymentControlResult priorCall(final PaymentControlContext retryPluginContext, Iterable<PluginProperty> properties) throws PaymentControlApiException {
+ return new DefaultPriorPaymentControlResult(isRetryAborted, null, null, null);
}
@Override
- public void onSuccessCall(final PaymentControlContext paymentControlContext) throws PaymentControlApiException {
+ public void onSuccessCall(final PaymentControlContext paymentControlContext, Iterable<PluginProperty> properties) throws PaymentControlApiException {
}
@Override
- public FailureCallResult onFailureCall(final PaymentControlContext paymentControlContext) throws PaymentControlApiException {
+ public FailureCallResult onFailureCall(final PaymentControlContext paymentControlContext, Iterable<PluginProperty> properties) throws PaymentControlApiException {
return new DefaultFailureCallResult(nextRetryDate);
}
diff --git a/payment/src/main/java/org/killbill/billing/payment/provider/DefaultPaymentControlProviderPlugin.java b/payment/src/main/java/org/killbill/billing/payment/provider/DefaultPaymentControlProviderPlugin.java
index 575c1e5..7a49679 100644
--- a/payment/src/main/java/org/killbill/billing/payment/provider/DefaultPaymentControlProviderPlugin.java
+++ b/payment/src/main/java/org/killbill/billing/payment/provider/DefaultPaymentControlProviderPlugin.java
@@ -16,6 +16,7 @@
package org.killbill.billing.payment.provider;
+import org.killbill.billing.payment.api.PluginProperty;
import org.killbill.billing.payment.retry.DefaultFailureCallResult;
import org.killbill.billing.payment.retry.DefaultPriorPaymentControlResult;
import org.killbill.billing.retry.plugin.api.FailureCallResult;
@@ -29,17 +30,17 @@ public class DefaultPaymentControlProviderPlugin implements PaymentControlPlugin
public static final String PLUGIN_NAME = "__DEFAULT_PAYMENT_CONTROL__";
@Override
- public PriorPaymentControlResult priorCall(final PaymentControlContext paymentControlContext) throws PaymentControlApiException {
- return new DefaultPriorPaymentControlResult(false, null);
+ public PriorPaymentControlResult priorCall(final PaymentControlContext paymentControlContext, Iterable<PluginProperty> properties) throws PaymentControlApiException {
+ return new DefaultPriorPaymentControlResult(false, null, null, null);
}
@Override
- public void onSuccessCall(final PaymentControlContext paymentControlContext) {
+ public void onSuccessCall(final PaymentControlContext paymentControlContext, Iterable<PluginProperty> properties) {
}
@Override
- public FailureCallResult onFailureCall(final PaymentControlContext paymentControlContext) {
+ public FailureCallResult onFailureCall(final PaymentControlContext paymentControlContext, Iterable<PluginProperty> properties) {
return new DefaultFailureCallResult(null);
}
}
diff --git a/payment/src/main/java/org/killbill/billing/payment/retry/BaseRetryService.java b/payment/src/main/java/org/killbill/billing/payment/retry/BaseRetryService.java
index b72d4c7..659d344 100644
--- a/payment/src/main/java/org/killbill/billing/payment/retry/BaseRetryService.java
+++ b/payment/src/main/java/org/killbill/billing/payment/retry/BaseRetryService.java
@@ -19,6 +19,7 @@
package org.killbill.billing.payment.retry;
import java.io.IOException;
+import java.util.List;
import java.util.UUID;
import org.joda.time.DateTime;
@@ -70,7 +71,7 @@ public abstract class BaseRetryService implements RetryService {
}
final PaymentRetryNotificationKey key = (PaymentRetryNotificationKey) notificationKey;
final InternalCallContext callContext = internalCallContextFactory.createInternalCallContext(tenantRecordId, accountRecordId, PAYMENT_RETRY_SERVICE, CallOrigin.INTERNAL, UserType.SYSTEM, userToken);
- retryPaymentTransaction(key.getAttemptId(), key.getPluginName(), callContext);
+ retryPaymentTransaction(key.getAttemptId(), key.getPaymentControlPluginNames(), callContext);
}
}
);
@@ -104,17 +105,17 @@ public abstract class BaseRetryService implements RetryService {
this.internalCallContextFactory = internalCallContextFactory;
}
- public boolean scheduleRetry(final ObjectType objectType, final UUID objectId, final UUID attemptId, final String pluginName, final DateTime timeOfRetry) {
- return scheduleRetryInternal(objectType, objectId, attemptId, pluginName, timeOfRetry, null);
+ public boolean scheduleRetry(final ObjectType objectType, final UUID objectId, final UUID attemptId, final List<String> paymentControlPluginNames, final DateTime timeOfRetry) {
+ return scheduleRetryInternal(objectType, objectId, attemptId, paymentControlPluginNames, timeOfRetry, null);
}
- private boolean scheduleRetryInternal(final ObjectType objectType, final UUID objectId, final UUID attemptId, final String pluginName, final DateTime timeOfRetry, final EntitySqlDaoWrapperFactory<EntitySqlDao> transactionalDao) {
+ private boolean scheduleRetryInternal(final ObjectType objectType, final UUID objectId, final UUID attemptId, final List<String> paymentControlPluginNames, final DateTime timeOfRetry, final EntitySqlDaoWrapperFactory<EntitySqlDao> transactionalDao) {
final InternalCallContext context = createCallContextFromPaymentId(objectType, objectId);
try {
final NotificationQueue retryQueue = notificationQueueService.getNotificationQueue(DefaultPaymentService.SERVICE_NAME, getQueueName());
- final NotificationEvent key = new PaymentRetryNotificationKey(attemptId, pluginName);
+ final NotificationEvent key = new PaymentRetryNotificationKey(attemptId, paymentControlPluginNames);
if (retryQueue != null) {
if (transactionalDao == null) {
retryQueue.recordFutureNotification(timeOfRetry, key, context.getUserToken(), context.getAccountRecordId(), context.getTenantRecordId());
diff --git a/payment/src/main/java/org/killbill/billing/payment/retry/DefaultPriorPaymentControlResult.java b/payment/src/main/java/org/killbill/billing/payment/retry/DefaultPriorPaymentControlResult.java
index dc2e457..07574be 100644
--- a/payment/src/main/java/org/killbill/billing/payment/retry/DefaultPriorPaymentControlResult.java
+++ b/payment/src/main/java/org/killbill/billing/payment/retry/DefaultPriorPaymentControlResult.java
@@ -17,21 +17,30 @@
package org.killbill.billing.payment.retry;
import java.math.BigDecimal;
+import java.util.UUID;
+import org.killbill.billing.catalog.api.Currency;
import org.killbill.billing.retry.plugin.api.PriorPaymentControlResult;
public class DefaultPriorPaymentControlResult implements PriorPaymentControlResult {
private final boolean isAborted;
private final BigDecimal adjustedRetryAmount;
+ private final Currency adjustedCurrency;
+ private final UUID adjustedPaymentMethodId;
- public DefaultPriorPaymentControlResult(final boolean isAborted, final BigDecimal adjustedRetryAmount) {
+ public DefaultPriorPaymentControlResult(final boolean isAborted,
+ final BigDecimal adjustedRetryAmount,
+ final Currency adjustedCurrency,
+ final UUID adjustedPaymentMethodId) {
this.isAborted = isAborted;
this.adjustedRetryAmount = adjustedRetryAmount;
+ this.adjustedCurrency = adjustedCurrency;
+ this.adjustedPaymentMethodId = adjustedPaymentMethodId;
}
public DefaultPriorPaymentControlResult(final boolean isAborted) {
- this(isAborted, null);
+ this(isAborted, null, null, null);
}
@Override
@@ -43,4 +52,13 @@ public class DefaultPriorPaymentControlResult implements PriorPaymentControlResu
public BigDecimal getAdjustedAmount() {
return adjustedRetryAmount;
}
+
+ @Override
+ public Currency getAdjustedCurrency() {
+ return adjustedCurrency;
+ }
+ @Override
+ public UUID getAdjustedPaymentMethodId() {
+ return adjustedPaymentMethodId;
+ }
}
diff --git a/payment/src/main/java/org/killbill/billing/payment/retry/DefaultRetryService.java b/payment/src/main/java/org/killbill/billing/payment/retry/DefaultRetryService.java
index f08f43a..b7e94a5 100644
--- a/payment/src/main/java/org/killbill/billing/payment/retry/DefaultRetryService.java
+++ b/payment/src/main/java/org/killbill/billing/payment/retry/DefaultRetryService.java
@@ -16,6 +16,7 @@
package org.killbill.billing.payment.retry;
+import java.util.List;
import java.util.UUID;
import org.killbill.billing.callcontext.InternalCallContext;
@@ -45,8 +46,8 @@ public class DefaultRetryService extends BaseRetryService implements RetryServic
@Override
- public void retryPaymentTransaction(final UUID attemptId, final String pluginName, final InternalCallContext context) {
- processor.retryPaymentTransaction(attemptId, pluginName, context);
+ public void retryPaymentTransaction(final UUID attemptId, final List<String> paymentControlPluginNames, final InternalCallContext context) {
+ processor.retryPaymentTransaction(attemptId, paymentControlPluginNames, context);
}
public static class DefaultRetryServiceScheduler extends RetryServiceScheduler {
diff --git a/payment/src/main/java/org/killbill/billing/payment/retry/PaymentRetryNotificationKey.java b/payment/src/main/java/org/killbill/billing/payment/retry/PaymentRetryNotificationKey.java
index 50a3155..d2569fd 100644
--- a/payment/src/main/java/org/killbill/billing/payment/retry/PaymentRetryNotificationKey.java
+++ b/payment/src/main/java/org/killbill/billing/payment/retry/PaymentRetryNotificationKey.java
@@ -16,6 +16,7 @@
package org.killbill.billing.payment.retry;
+import java.util.List;
import java.util.UUID;
import org.killbill.notificationq.api.NotificationEvent;
@@ -26,20 +27,20 @@ import com.fasterxml.jackson.annotation.JsonProperty;
public class PaymentRetryNotificationKey implements NotificationEvent {
private final UUID attemptId;
- private final String pluginName;
+ private final List<String> paymentControlPluginNames;
@JsonCreator
public PaymentRetryNotificationKey(@JsonProperty("attemptId") UUID attemptId,
- @JsonProperty("pluginName") String pluginName) {
+ @JsonProperty("paymentControlPluginNames") List<String> paymentControlPluginNames) {
this.attemptId = attemptId;
- this.pluginName = pluginName;
+ this.paymentControlPluginNames = paymentControlPluginNames;
}
public UUID getAttemptId() {
return attemptId;
}
- public String getPluginName() {
- return pluginName;
+ public List<String> getPaymentControlPluginNames() {
+ return paymentControlPluginNames;
}
}
diff --git a/payment/src/main/java/org/killbill/billing/payment/retry/RetryService.java b/payment/src/main/java/org/killbill/billing/payment/retry/RetryService.java
index 9864e0a..ea320f1 100644
--- a/payment/src/main/java/org/killbill/billing/payment/retry/RetryService.java
+++ b/payment/src/main/java/org/killbill/billing/payment/retry/RetryService.java
@@ -18,6 +18,7 @@
package org.killbill.billing.payment.retry;
+import java.util.List;
import java.util.UUID;
import org.killbill.billing.callcontext.InternalCallContext;
@@ -35,5 +36,5 @@ public interface RetryService {
public String getQueueName();
- public void retryPaymentTransaction(final UUID attemptId, String pluginName, final InternalCallContext context);
+ public void retryPaymentTransaction(final UUID attemptId, List<String> paymentControlPluginNames, final InternalCallContext context);
}
diff --git a/payment/src/main/resources/org/killbill/billing/payment/ddl.sql b/payment/src/main/resources/org/killbill/billing/payment/ddl.sql
index 5689d8f..b184656 100644
--- a/payment/src/main/resources/org/killbill/billing/payment/ddl.sql
+++ b/payment/src/main/resources/org/killbill/billing/payment/ddl.sql
@@ -14,7 +14,7 @@ CREATE TABLE payment_attempts (
state_name varchar(32) NOT NULL,
amount numeric(15,9),
currency char(3),
- plugin_name varchar(50) NOT NULL,
+ plugin_name varchar(1024) NOT NULL,
plugin_properties blob(8194),
created_by varchar(50) NOT NULL,
created_date datetime NOT NULL,
@@ -45,7 +45,7 @@ CREATE TABLE payment_attempt_history (
state_name varchar(32) NOT NULL,
amount numeric(15,9),
currency char(3),
- plugin_name varchar(50) NOT NULL,
+ plugin_name varchar(1024) NOT NULL,
plugin_properties blob(8194),
change_type char(6) NOT NULL,
created_by varchar(50) NOT NULL,
diff --git a/payment/src/test/java/org/killbill/billing/payment/api/TestPaymentApi.java b/payment/src/test/java/org/killbill/billing/payment/api/TestPaymentApi.java
index ce075e3..38eb6ad 100644
--- a/payment/src/test/java/org/killbill/billing/payment/api/TestPaymentApi.java
+++ b/payment/src/test/java/org/killbill/billing/payment/api/TestPaymentApi.java
@@ -57,8 +57,8 @@ public class TestPaymentApi extends PaymentTestSuiteWithEmbeddedDB {
}
@Override
- public String getPaymentControlPluginName() {
- return InvoicePaymentControlPluginApi.PLUGIN_NAME;
+ public List<String> getPaymentControlPluginNames() {
+ return ImmutableList.<String>of(InvoicePaymentControlPluginApi.PLUGIN_NAME);
}
};
diff --git a/payment/src/test/java/org/killbill/billing/payment/api/TestPaymentApiNoDB.java b/payment/src/test/java/org/killbill/billing/payment/api/TestPaymentApiNoDB.java
index 22454ae..fd55a2c 100644
--- a/payment/src/test/java/org/killbill/billing/payment/api/TestPaymentApiNoDB.java
+++ b/payment/src/test/java/org/killbill/billing/payment/api/TestPaymentApiNoDB.java
@@ -57,8 +57,8 @@ public class TestPaymentApiNoDB extends PaymentTestSuiteNoDB {
return false;
}
@Override
- public String getPaymentControlPluginName() {
- return InvoicePaymentControlPluginApi.PLUGIN_NAME;
+ public List<String> getPaymentControlPluginNames() {
+ return ImmutableList.<String>of(InvoicePaymentControlPluginApi.PLUGIN_NAME);
}
};
diff --git a/payment/src/test/java/org/killbill/billing/payment/core/sm/MockRetryablePaymentAutomatonRunner.java b/payment/src/test/java/org/killbill/billing/payment/core/sm/MockRetryablePaymentAutomatonRunner.java
index 992e210..918c9b1 100644
--- a/payment/src/test/java/org/killbill/billing/payment/core/sm/MockRetryablePaymentAutomatonRunner.java
+++ b/payment/src/test/java/org/killbill/billing/payment/core/sm/MockRetryablePaymentAutomatonRunner.java
@@ -17,6 +17,7 @@
package org.killbill.billing.payment.core.sm;
import java.math.BigDecimal;
+import java.util.List;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
@@ -48,6 +49,8 @@ import org.killbill.bus.api.PersistentBus;
import org.killbill.clock.Clock;
import org.killbill.commons.locker.GlobalLocker;
+import com.google.common.collect.ImmutableList;
+
import static org.killbill.billing.payment.glue.PaymentModule.PLUGIN_EXECUTOR_NAMED;
import static org.killbill.billing.payment.glue.PaymentModule.RETRYABLE_NAMED;
@@ -77,10 +80,10 @@ public class MockRetryablePaymentAutomatonRunner extends PluginControlledPayment
@Nullable final UUID paymentId, @Nullable final String paymentExternalKey, final String paymentTransactionExternalKey,
@Nullable final BigDecimal amount, @Nullable final Currency currency,
final Iterable<PluginProperty> properties,
- final String pluginName, final CallContext callContext, final InternalCallContext internalCallContext) throws PaymentApiException {
+ final List<String> pluginNames, final CallContext callContext, final InternalCallContext internalCallContext) throws PaymentApiException {
if (context == null) {
return super.createContext(isApiPayment, transactionType, account, paymentMethodId, paymentId, paymentExternalKey, paymentTransactionExternalKey,
- amount, currency, properties, pluginName, callContext, internalCallContext);
+ amount, currency, properties, pluginNames, callContext, internalCallContext);
} else {
return context;
}
diff --git a/payment/src/test/java/org/killbill/billing/payment/core/sm/TestRetryablePayment.java b/payment/src/test/java/org/killbill/billing/payment/core/sm/TestRetryablePayment.java
index 5acf9df..71cb99e 100644
--- a/payment/src/test/java/org/killbill/billing/payment/core/sm/TestRetryablePayment.java
+++ b/payment/src/test/java/org/killbill/billing/payment/core/sm/TestRetryablePayment.java
@@ -167,7 +167,7 @@ public class TestRetryablePayment extends PaymentTestSuiteNoDB {
eventBus);
paymentStateContext =
- new RetryablePaymentStateContext(MockPaymentControlProviderPlugin.PLUGIN_NAME,
+ new RetryablePaymentStateContext(ImmutableList.<String>of(MockPaymentControlProviderPlugin.PLUGIN_NAME),
true,
null,
paymentExternalKey,
@@ -632,7 +632,7 @@ public class TestRetryablePayment extends PaymentTestSuiteNoDB {
new PaymentTransactionModelDao(transactionId, attempt.getId(), paymentTransactionExternalKey, utcNow, utcNow, paymentId, TransactionType.AUTHORIZE, utcNow, TransactionStatus.PAYMENT_FAILURE, amount, currency, "bla", "foo"),
internalCallContext);
- processor.retryPaymentTransaction(attempt.getId(), MockPaymentControlProviderPlugin.PLUGIN_NAME, internalCallContext);
+ processor.retryPaymentTransaction(attempt.getId(), ImmutableList.<String>of(MockPaymentControlProviderPlugin.PLUGIN_NAME), internalCallContext);
final List<PaymentAttemptModelDao> pas = paymentDao.getPaymentAttemptByTransactionExternalKey(paymentTransactionExternalKey, internalCallContext);
assertEquals(pas.size(), 2);
@@ -676,7 +676,7 @@ public class TestRetryablePayment extends PaymentTestSuiteNoDB {
internalCallContext
);
- processor.retryPaymentTransaction(attempt.getId(), MockPaymentControlProviderPlugin.PLUGIN_NAME, internalCallContext);
+ processor.retryPaymentTransaction(attempt.getId(), ImmutableList.<String>of(MockPaymentControlProviderPlugin.PLUGIN_NAME), internalCallContext);
final List<PaymentAttemptModelDao> pas = paymentDao.getPaymentAttemptByTransactionExternalKey(paymentTransactionExternalKey, internalCallContext);
assertEquals(pas.size(), 2);
@@ -724,7 +724,7 @@ public class TestRetryablePayment extends PaymentTestSuiteNoDB {
internalCallContext
);
- processor.retryPaymentTransaction(attempt.getId(), MockPaymentControlProviderPlugin.PLUGIN_NAME, internalCallContext);
+ processor.retryPaymentTransaction(attempt.getId(), ImmutableList.<String>of(MockPaymentControlProviderPlugin.PLUGIN_NAME), internalCallContext);
final List<PaymentAttemptModelDao> pas = paymentDao.getPaymentAttemptByTransactionExternalKey(paymentTransactionExternalKey, internalCallContext);
assertEquals(pas.size(), 2);
diff --git a/payment/src/test/java/org/killbill/billing/payment/dao/TestPaymentDao.java b/payment/src/test/java/org/killbill/billing/payment/dao/TestPaymentDao.java
index 69045eb..67679de 100644
--- a/payment/src/test/java/org/killbill/billing/payment/dao/TestPaymentDao.java
+++ b/payment/src/test/java/org/killbill/billing/payment/dao/TestPaymentDao.java
@@ -64,7 +64,7 @@ public class TestPaymentDao extends PaymentTestSuiteWithEmbeddedDB {
final byte[] serialized = PluginPropertySerializer.serialize(properties);
final PaymentAttemptModelDao attempt = new PaymentAttemptModelDao(UUID.randomUUID(), UUID.randomUUID(), clock.getUTCNow(), clock.getUTCNow(),
paymentExternalKey, transactionId, transactionExternalKey, transactionType, stateName,
- BigDecimal.ZERO, Currency.ALL, pluginName, serialized);
+ BigDecimal.ZERO, Currency.ALL, ImmutableList.<String>of(pluginName), serialized);
PaymentAttemptModelDao savedAttempt = paymentDao.insertPaymentAttemptWithProperties(attempt, internalCallContext);
assertEquals(savedAttempt.getTransactionExternalKey(), transactionExternalKey);
diff --git a/payment/src/test/java/org/killbill/billing/payment/provider/MockPaymentControlProviderPlugin.java b/payment/src/test/java/org/killbill/billing/payment/provider/MockPaymentControlProviderPlugin.java
index fc0b8a3..f3dd18f 100644
--- a/payment/src/test/java/org/killbill/billing/payment/provider/MockPaymentControlProviderPlugin.java
+++ b/payment/src/test/java/org/killbill/billing/payment/provider/MockPaymentControlProviderPlugin.java
@@ -17,6 +17,7 @@
package org.killbill.billing.payment.provider;
import org.joda.time.DateTime;
+import org.killbill.billing.payment.api.PluginProperty;
import org.killbill.billing.payment.retry.DefaultFailureCallResult;
import org.killbill.billing.payment.retry.DefaultPriorPaymentControlResult;
import org.killbill.billing.retry.plugin.api.FailureCallResult;
@@ -43,17 +44,17 @@ public class MockPaymentControlProviderPlugin implements PaymentControlPluginApi
}
@Override
- public PriorPaymentControlResult priorCall(final PaymentControlContext paymentControlContext) throws PaymentControlApiException{
- return new DefaultPriorPaymentControlResult(isAborted, null);
+ public PriorPaymentControlResult priorCall(final PaymentControlContext paymentControlContext, Iterable<PluginProperty> properties) throws PaymentControlApiException{
+ return new DefaultPriorPaymentControlResult(isAborted, null, null, null);
}
@Override
- public void onSuccessCall(final PaymentControlContext paymentControlContext) throws PaymentControlApiException {
+ public void onSuccessCall(final PaymentControlContext paymentControlContext, Iterable<PluginProperty> properties) throws PaymentControlApiException {
}
@Override
- public FailureCallResult onFailureCall(final PaymentControlContext paymentControlContext) throws PaymentControlApiException {
+ public FailureCallResult onFailureCall(final PaymentControlContext paymentControlContext, Iterable<PluginProperty> properties) throws PaymentControlApiException {
return new DefaultFailureCallResult(nextRetryDate);
}
}
diff --git a/payment/src/test/java/org/killbill/billing/payment/TestJanitor.java b/payment/src/test/java/org/killbill/billing/payment/TestJanitor.java
index 3281965..485e449 100644
--- a/payment/src/test/java/org/killbill/billing/payment/TestJanitor.java
+++ b/payment/src/test/java/org/killbill/billing/payment/TestJanitor.java
@@ -48,6 +48,7 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.inject.Inject;
@@ -62,8 +63,8 @@ public class TestJanitor extends PaymentTestSuiteWithEmbeddedDB {
}
@Override
- public String getPaymentControlPluginName() {
- return InvoicePaymentControlPluginApi.PLUGIN_NAME;
+ public List<String> getPaymentControlPluginNames() {
+ return ImmutableList.of(InvoicePaymentControlPluginApi.PLUGIN_NAME);
}
};
diff --git a/payment/src/test/java/org/killbill/billing/payment/TestRetryService.java b/payment/src/test/java/org/killbill/billing/payment/TestRetryService.java
index 9b9537e..54744ef 100644
--- a/payment/src/test/java/org/killbill/billing/payment/TestRetryService.java
+++ b/payment/src/test/java/org/killbill/billing/payment/TestRetryService.java
@@ -144,7 +144,7 @@ public class TestRetryService extends PaymentTestSuiteNoDB {
final String transactionExternalKey = UUID.randomUUID().toString();
try {
pluginControlledPaymentProcessor.createPurchase(false, account, account.getPaymentMethodId(), null, amount, Currency.USD, paymentExternalKey, transactionExternalKey,
- createPropertiesForInvoice(invoice), InvoicePaymentControlPluginApi.PLUGIN_NAME, callContext, internalCallContext);
+ createPropertiesForInvoice(invoice), ImmutableList.<String>of(InvoicePaymentControlPluginApi.PLUGIN_NAME), callContext, internalCallContext);
} catch (final PaymentApiException e) {
failed = true;
}
pom.xml 4(+2 -2)
diff --git a/pom.xml b/pom.xml
index 49396f1..f2d71f1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -20,10 +20,10 @@
<parent>
<artifactId>killbill-oss-parent</artifactId>
<groupId>org.kill-bill.billing</groupId>
- <version>0.7.30</version>
+ <version>0.8.4</version>
</parent>
<artifactId>killbill</artifactId>
- <version>0.11.13-SNAPSHOT</version>
+ <version>0.11.14-SNAPSHOT</version>
<packaging>pom</packaging>
<name>killbill</name>
<description>Library for managing recurring subscriptions and the associated billing</description>
profiles/killbill/pom.xml 10(+9 -1)
diff --git a/profiles/killbill/pom.xml b/profiles/killbill/pom.xml
index a2714f6..2535c3c 100644
--- a/profiles/killbill/pom.xml
+++ b/profiles/killbill/pom.xml
@@ -21,7 +21,7 @@
<parent>
<artifactId>killbill-profiles</artifactId>
<groupId>org.kill-bill.billing</groupId>
- <version>0.11.13-SNAPSHOT</version>
+ <version>0.11.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-profiles-killbill</artifactId>
@@ -64,6 +64,10 @@
<artifactId>jersey-guice</artifactId>
</dependency>
<dependency>
+ <groupId>com.wordnik</groupId>
+ <artifactId>swagger-jersey-jaxrs_2.10</artifactId>
+ </dependency>
+ <dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP-java6</artifactId>
</dependency>
@@ -207,6 +211,10 @@
</dependency>
<dependency>
<groupId>org.kill-bill.billing</groupId>
+ <artifactId>killbill-platform-osgi-bundles-lib-killbill</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.kill-bill.billing</groupId>
<artifactId>killbill-platform-server</artifactId>
<classifier>classes</classifier>
</dependency>
diff --git a/profiles/killbill/src/main/java/org/killbill/billing/server/filters/ResponseCorsFilter.java b/profiles/killbill/src/main/java/org/killbill/billing/server/filters/ResponseCorsFilter.java
new file mode 100644
index 0000000..4a2ad53
--- /dev/null
+++ b/profiles/killbill/src/main/java/org/killbill/billing/server/filters/ResponseCorsFilter.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2014 Groupon, Inc
+ * Copyright 2014 The Billing Project, LLC
+ *
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
+ * (the "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.killbill.billing.server.filters;
+
+import java.io.IOException;
+
+import javax.inject.Singleton;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletResponse;
+
+@Singleton
+public class ResponseCorsFilter implements Filter {
+
+ @Override
+ public void init(final FilterConfig filterConfig) throws ServletException {
+ }
+
+ @Override
+ public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException {
+ final HttpServletResponse res = (HttpServletResponse) response;
+ res.addHeader("Access-Control-Allow-Origin", "*");
+ res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT, OPTIONS");
+ res.addHeader("Access-Control-Allow-Headers", "Authorization, Content-Type, X-Killbill-ApiKey, X-Killbill-ApiSecret");
+ chain.doFilter(request, response);
+ }
+
+ @Override
+ public void destroy() {
+ }
+}
diff --git a/profiles/killbill/src/main/java/org/killbill/billing/server/listeners/KillbillGuiceListener.java b/profiles/killbill/src/main/java/org/killbill/billing/server/listeners/KillbillGuiceListener.java
index 21dfe24..1069083 100644
--- a/profiles/killbill/src/main/java/org/killbill/billing/server/listeners/KillbillGuiceListener.java
+++ b/profiles/killbill/src/main/java/org/killbill/billing/server/listeners/KillbillGuiceListener.java
@@ -24,10 +24,11 @@ import java.net.URISyntaxException;
import javax.servlet.ServletContext;
import org.killbill.billing.jaxrs.resources.JaxRsResourceBase;
-import org.killbill.billing.server.filters.ProfilingContainerResponseFilter;
import org.killbill.billing.jaxrs.util.KillbillEventHandler;
import org.killbill.billing.platform.api.KillbillConfigSource;
import org.killbill.billing.platform.config.DefaultKillbillConfigSource;
+import org.killbill.billing.server.filters.ProfilingContainerResponseFilter;
+import org.killbill.billing.server.filters.ResponseCorsFilter;
import org.killbill.billing.server.modules.KillbillServerModule;
import org.killbill.billing.server.security.TenantFilter;
import org.killbill.bus.api.PersistentBus;
@@ -38,30 +39,43 @@ import org.slf4j.LoggerFactory;
import com.google.common.collect.ImmutableMap;
import com.google.inject.Module;
import com.google.inject.servlet.ServletModule;
+import com.wordnik.swagger.jaxrs.config.BeanConfig;
public class KillbillGuiceListener extends KillbillPlatformGuiceListener {
private static final Logger logger = LoggerFactory.getLogger(KillbillGuiceListener.class);
+ private static final String SWAGGER_PATH = "api-docs";
+
private KillbillEventHandler killbilleventHandler;
@Override
protected ServletModule getServletModule() {
// Don't filter all requests through Jersey, only the JAX-RS APIs (otherwise,
// things like static resources, favicon, etc. are 404'ed)
- final BaseServerModuleBuilder builder = new BaseServerModuleBuilder().setJaxrsUriPattern("(" + JaxRsResourceBase.PREFIX + "|" + JaxRsResourceBase.PLUGINS_PATH + ")" + "/.*")
+ final BaseServerModuleBuilder builder = new BaseServerModuleBuilder().setJaxrsUriPattern("/" + SWAGGER_PATH + "|((/" + SWAGGER_PATH + "|" + JaxRsResourceBase.PREFIX + "|" + JaxRsResourceBase.PLUGINS_PATH + ")" + "/.*)")
.addJaxrsResource("org.killbill.billing.jaxrs.mappers")
- .addJaxrsResource("org.killbill.billing.jaxrs.resources");
+ .addJaxrsResource("org.killbill.billing.jaxrs.resources")
+ // Swagger integration
+ .addJaxrsResource("com.wordnik.swagger.jersey.listing");
//
// Add jersey filters which are executed prior jersey write the output stream
//
builder.addJerseyFilter("com.sun.jersey.api.container.filter.LoggingFilter");
+ // Disable WADL - it generates noisy log messages, such as:
+ // c.s.j.s.w.g.AbstractWadlGeneratorGrammarGenerator - Couldn't find grammar element for class javax.ws.rs.core.Response
+ builder.addJerseyParam("com.sun.jersey.config.feature.DisableWADL", "true");
+
// The logging filter is still incompatible with the GZIP filter
//builder.addJerseyFilter(GZIPContentEncodingFilter.class.getName());
builder.addJerseyFilter(ProfilingContainerResponseFilter.class.getName());
+ // Broader, to support the "Try it out!" feature
+ //builder.addFilter("/" + SWAGGER_PATH + "*", ResponseCorsFilter.class);
+ builder.addFilter("/*", ResponseCorsFilter.class);
+
// Add TenantFilter right after is multi-tenancy has been configured.
if (config.isMultiTenancyEnabled()) {
builder.addFilter("/*", TenantFilter.class);
@@ -69,7 +83,6 @@ public class KillbillGuiceListener extends KillbillPlatformGuiceListener {
return builder.build();
}
-
@Override
protected Module getModule(final ServletContext servletContext) {
return new KillbillServerModule(servletContext, config, configSource);
@@ -103,4 +116,19 @@ public class KillbillGuiceListener extends KillbillPlatformGuiceListener {
logger.warn("Failed to unregister for event notifications", e);
}
}
+
+ @Override
+ protected void startLifecycleStage3() {
+ super.startLifecycleStage3();
+
+ final BeanConfig beanConfig = new BeanConfig();
+ beanConfig.setResourcePackage("org.killbill.billing.jaxrs.resources");
+ beanConfig.setTitle("Kill Bill");
+ beanConfig.setDescription("Kill Bill is an open-source billing and payments platform");
+ beanConfig.setContact("killbilling-users@googlegroups.com");
+ beanConfig.setLicense("Apache License, Version 2.0");
+ beanConfig.setLicenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html");
+ beanConfig.setBasePath(config.getBaseUrl());
+ beanConfig.setScan(true);
+ }
}
diff --git a/profiles/killbill/src/main/java/org/killbill/billing/server/modules/KillbillServerModule.java b/profiles/killbill/src/main/java/org/killbill/billing/server/modules/KillbillServerModule.java
index 42c7487..c853dad 100644
--- a/profiles/killbill/src/main/java/org/killbill/billing/server/modules/KillbillServerModule.java
+++ b/profiles/killbill/src/main/java/org/killbill/billing/server/modules/KillbillServerModule.java
@@ -51,6 +51,7 @@ import org.killbill.billing.platform.api.KillbillConfigSource;
import org.killbill.billing.server.DefaultServerService;
import org.killbill.billing.server.ServerService;
import org.killbill.billing.server.config.KillbillServerConfig;
+import org.killbill.billing.server.filters.ResponseCorsFilter;
import org.killbill.billing.server.notifications.PushNotificationListener;
import org.killbill.billing.subscription.glue.DefaultSubscriptionModule;
import org.killbill.billing.tenant.glue.TenantModule;
@@ -89,6 +90,7 @@ public class KillbillServerModule extends KillbillPlatformModule {
installKillbillModules();
configureResources();
+ configureFilters();
configurePushNotification();
}
@@ -169,6 +171,10 @@ public class KillbillServerModule extends KillbillPlatformModule {
bind(TenantResource.class).asEagerSingleton();
}
+ protected void configureFilters() {
+ bind(ResponseCorsFilter.class).asEagerSingleton();
+ }
+
protected void configurePushNotification() {
bind(ServerService.class).to(DefaultServerService.class).asEagerSingleton();
bind(PushNotificationListener.class).asEagerSingleton();
diff --git a/profiles/killbill/src/main/java/org/killbill/billing/server/modules/KillBillShiroWebModule.java b/profiles/killbill/src/main/java/org/killbill/billing/server/modules/KillBillShiroWebModule.java
index ae27622..113ed01 100644
--- a/profiles/killbill/src/main/java/org/killbill/billing/server/modules/KillBillShiroWebModule.java
+++ b/profiles/killbill/src/main/java/org/killbill/billing/server/modules/KillBillShiroWebModule.java
@@ -19,11 +19,16 @@
package org.killbill.billing.server.modules;
import javax.servlet.ServletContext;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
import org.apache.shiro.cache.CacheManager;
import org.apache.shiro.guice.web.ShiroWebModule;
import org.apache.shiro.session.mgt.SessionManager;
+import org.apache.shiro.web.filter.authc.BasicHttpAuthenticationFilter;
import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;
+import org.apache.shiro.web.util.WebUtils;
import org.killbill.billing.jaxrs.resources.JaxrsResource;
import org.killbill.billing.util.config.RbacConfig;
import org.killbill.billing.util.glue.EhCacheManagerProvider;
@@ -35,6 +40,7 @@ import org.killbill.billing.util.security.shiro.realm.KillBillJndiLdapRealm;
import org.skife.config.ConfigSource;
import org.skife.config.ConfigurationObjectFactory;
+import com.google.inject.Key;
import com.google.inject.binder.AnnotatedBindingBuilder;
// For Kill Bill server only.
@@ -63,7 +69,7 @@ public class KillBillShiroWebModule extends ShiroWebModule {
bind(CacheManager.class).toProvider(EhCacheManagerProvider.class).asEagerSingleton();
if (KillBillShiroModule.isRBACEnabled()) {
- addFilterChain(JaxrsResource.PREFIX + "/**", AUTHC_BASIC);
+ addFilterChain(JaxrsResource.PREFIX + "/**", Key.get(CorsBasicHttpAuthenticationFilter.class));
}
}
@@ -76,4 +82,16 @@ public class KillBillShiroWebModule extends ShiroWebModule {
// Magic provider to configure the session DAO
bind(JDBCSessionDao.class).toProvider(JDBCSessionDaoProvider.class).asEagerSingleton();
}
+
+ public static final class CorsBasicHttpAuthenticationFilter extends BasicHttpAuthenticationFilter {
+
+ @Override
+ protected boolean isAccessAllowed(final ServletRequest request, final ServletResponse response, final Object mappedValue) {
+ final HttpServletRequest httpRequest = WebUtils.toHttp(request);
+ final String httpMethod = httpRequest.getMethod();
+ // Don't require any authorization or authentication header for OPTIONS requests
+ // See https://bugzilla.mozilla.org/show_bug.cgi?id=778548 and http://www.kinvey.com/blog/60/kinvey-adds-cross-origin-resource-sharing-cors
+ return "OPTIONS".equalsIgnoreCase(httpMethod) || super.isAccessAllowed(request, response, mappedValue);
+ }
+ }
}
diff --git a/profiles/killbill/src/main/java/org/killbill/billing/server/security/TenantFilter.java b/profiles/killbill/src/main/java/org/killbill/billing/server/security/TenantFilter.java
index 1a65fd0..6e1165e 100644
--- a/profiles/killbill/src/main/java/org/killbill/billing/server/security/TenantFilter.java
+++ b/profiles/killbill/src/main/java/org/killbill/billing/server/security/TenantFilter.java
@@ -130,6 +130,8 @@ public class TenantFilter implements Filter {
("/1.0/kb/tenants".equals(path) && "POST".equals(httpServletRequest.getMethod())) ||
// Metrics servlets
(KillbillGuiceListener.METRICS_SERVLETS_PATHS.contains(path) && "GET".equals(httpServletRequest.getMethod())) ||
+ // See KillBillShiroWebModule#CorsBasicHttpAuthenticationFilter
+ "OPTIONS".equals(httpServletRequest.getMethod()) ||
// Welcome screen, static resources, etc.
(!path.startsWith("/1.0") && "GET".equals(httpServletRequest.getMethod()))
) {
profiles/killbill/src/main/webapp/api.html 147(+147 -0)
diff --git a/profiles/killbill/src/main/webapp/api.html b/profiles/killbill/src/main/webapp/api.html
new file mode 100644
index 0000000..0ce3e81
--- /dev/null
+++ b/profiles/killbill/src/main/webapp/api.html
@@ -0,0 +1,147 @@
+<!--
+ ~ Copyright 2010-2013 Ning, Inc.
+ ~
+ ~ Ning licenses this file to you under the Apache License, version 2.0
+ ~ (the "License"); you may not use this file except in compliance with the
+ ~ License. You may obtain a copy of the License at:
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ ~ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ ~ License for the specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Kill Bill APIs</title>
+ <link href='//fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'/>
+ <link href='//fonts.googleapis.com/css?family=Roboto:400,700' rel='stylesheet' type='text/css'/>
+ <link href='css/reset.css' media='screen' rel='stylesheet' type='text/css'/>
+ <link href='css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
+ <link href='css/reset.css' media='print' rel='stylesheet' type='text/css'/>
+ <link href='css/screen.css' media='print' rel='stylesheet' type='text/css'/>
+ <link href='css/killbill-swagger.css' media='screen' rel='stylesheet' type='text/css'/>
+ <link href='css/killbill-swagger.css' media='print' rel='stylesheet' type='text/css'/>
+ <script type="text/javascript" src="lib/shred.bundle.js"></script>
+ <script src='lib/jquery-1.8.0.min.js' type='text/javascript'></script>
+ <script src='lib/jquery.slideto.min.js' type='text/javascript'></script>
+ <script src='lib/jquery.wiggle.min.js' type='text/javascript'></script>
+ <script src='lib/jquery.ba-bbq.min.js' type='text/javascript'></script>
+ <script src='lib/handlebars-1.0.0.js' type='text/javascript'></script>
+ <script src='lib/underscore-min.js' type='text/javascript'></script>
+ <script src='lib/backbone-min.js' type='text/javascript'></script>
+ <script src='lib/swagger.js' type='text/javascript'></script>
+ <script src='lib/swagger-client.js' type='text/javascript'></script>
+ <script src='lib/swagger-ui.min.js' type='text/javascript'></script>
+ <script src='lib/highlight.7.3.pack.js' type='text/javascript'></script>
+
+ <!-- enabling this will enable oauth2 implicit scope support -->
+ <script src='lib/swagger-oauth.js' type='text/javascript'></script>
+ <script type="text/javascript">
+ $(function () {
+ var url = window.location.search.match(/url=([^&]+)/);
+ if (url && url.length > 1) {
+ url = url[1];
+ } else {
+ url = "http://127.0.0.1:8080/api-docs";
+ }
+ window.swaggerUi = new SwaggerUi({
+ url: url,
+ dom_id: "swagger-ui-container",
+ supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
+ onComplete: function(swaggerApi, swaggerUi){
+ log("Loaded SwaggerUI");
+ if(typeof initOAuth == "function") {
+ /*
+ initOAuth({
+ clientId: "your-client-id",
+ realm: "your-realms",
+ appName: "your-app-name"
+ });
+ */
+ }
+ $('pre code').each(function(i, e) {
+ hljs.highlightBlock(e)
+ });
+ },
+ onFailure: function(data) {
+ log("Unable to Load SwaggerUI");
+ },
+ docExpansion: "none",
+ sorter : "alpha"
+ });
+
+ function addApiKeyAuthorization() {
+ var key = $('#input_apiKey')[0].value;
+ log("key: " + key);
+ if(key && key.trim() != "") {
+ log("added key " + key);
+ window.authorizations.add("api_key", new ApiKeyAuthorization("api_key", key, "query"));
+ }
+ }
+
+ $('#input_apiKey').change(function() {
+ addApiKeyAuthorization();
+ });
+
+ // if you have an apiKey you would like to pre-populate on the page for demonstration purposes...
+ /*
+ var apiKey = "myApiKeyXXXX123456789";
+ $('#input_apiKey').val(apiKey);
+ addApiKeyAuthorization();
+ */
+
+ $.each(["#input_kb_apiKey", "#input_kb_apiSecret", "#input_kb_username", "#input_kb_password"], function(idx, selector_id) {
+ $(selector_id).change(function() {
+ setHeaders();
+ });
+ });
+
+ function setHeader(header, value) {
+ if (value && value.trim() != "") {
+ log("Setting header " + header + " to " + value);
+ window.authorizations.remove(header);
+ window.authorizations.add(header, new ApiKeyAuthorization(header, value, "header"));
+ }
+ }
+
+ function setHeaders() {
+ setHeader("X-Killbill-ApiKey", $("#input_kb_apiKey")[0].value || "bob");
+ setHeader("X-Killbill-ApiSecret", $("#input_kb_apiSecret")[0].value || "lazar");
+ setHeader("Authorization", "Basic " + btoa(($("#input_kb_username")[0].value || "admin") + ":" + ($("#input_kb_password")[0].value || "password")));
+ }
+
+ setHeaders();
+
+ window.swaggerUi.load();
+ });
+ </script>
+</head>
+
+<body class="swagger-section">
+<div id='header'>
+ <div class="swagger-ui-wrap">
+ <div id="kb-logo-container">
+ <a href="http://kill-bill.org">
+ <img id="kb-logo" title="Kill Bill" border="0" alt="Kill Bill" src="../images/killbill_logo.png">
+ </a>
+ </div>
+ <form id='api_selector'>
+ <div class='input'><input placeholder="http://127.0.0.1:8080/api-docs" id="input_baseUrl" name="baseUrl" type="text" size="38"/></div>
+ <div class='input'><input placeholder="api_key" id="input_kb_apiKey" name="apiKey" type="text" size="8"/></div>
+ <div class='input'><input placeholder="api_secret" id="input_kb_apiSecret" name="apiSecret" type="text" size="8"/></div>
+ <div class='input'><input placeholder="username" id="input_kb_username" name="username" type="text" size="8"/></div>
+ <div class='input'><input placeholder="password" id="input_kb_password" name="password" type="text" size="8"/></div>
+ <div class='input'><a id="explore" href="#">Explore</a></div>
+ </form>
+ </div>
+</div>
+
+<div id="message-bar" class="swagger-ui-wrap"> </div>
+<div id="swagger-ui-container" class="swagger-ui-wrap"></div>
+</body>
+</html>
diff --git a/profiles/killbill/src/main/webapp/css/killbill-swagger.css b/profiles/killbill/src/main/webapp/css/killbill-swagger.css
new file mode 100644
index 0000000..ded906d
--- /dev/null
+++ b/profiles/killbill/src/main/webapp/css/killbill-swagger.css
@@ -0,0 +1,50 @@
+#api_info {
+ display: none;
+}
+
+/*
+#header {
+ display: none;
+}
+
+.footer {
+ display: none;
+}
+*/
+
+#kb-logo-container {
+ max-width: 175px;
+ margin-left: -220px;
+ margin-top: -10px;
+ float: left;
+}
+
+img#kb-logo {
+ max-width: 100%;
+ height: auto;
+ width: auto\9; /* ie8 */
+}
+
+.swagger-section .swagger-ui-wrap {
+ height: 24px;
+}
+
+.swagger-section .swagger-ui-wrap {
+ font-family: "Roboto Light";
+}
+
+.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 {
+ font-family: "Roboto Light";
+}
+
+.swagger-section #header {
+ background-color: transparent;
+}
+
+.swagger-section #header form#api_selector {
+ float: left;
+}
+
+.swagger-section #header form#api_selector .input a#explore {
+ background-color: #e44c3a;
+}
\ No newline at end of file
profiles/killbill/src/main/webapp/css/reset.css 125(+125 -0)
diff --git a/profiles/killbill/src/main/webapp/css/reset.css b/profiles/killbill/src/main/webapp/css/reset.css
new file mode 100644
index 0000000..b2b0789
--- /dev/null
+++ b/profiles/killbill/src/main/webapp/css/reset.css
@@ -0,0 +1,125 @@
+/* http://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 */
+html,
+body,
+div,
+span,
+applet,
+object,
+iframe,
+h1,
+h2,
+h3,
+h4,
+h5,
+h6,
+p,
+blockquote,
+pre,
+a,
+abbr,
+acronym,
+address,
+big,
+cite,
+code,
+del,
+dfn,
+em,
+img,
+ins,
+kbd,
+q,
+s,
+samp,
+small,
+strike,
+strong,
+sub,
+sup,
+tt,
+var,
+b,
+u,
+i,
+center,
+dl,
+dt,
+dd,
+ol,
+ul,
+li,
+fieldset,
+form,
+label,
+legend,
+table,
+caption,
+tbody,
+tfoot,
+thead,
+tr,
+th,
+td,
+article,
+aside,
+canvas,
+details,
+embed,
+figure,
+figcaption,
+footer,
+header,
+hgroup,
+menu,
+nav,
+output,
+ruby,
+section,
+summary,
+time,
+mark,
+audio,
+video {
+ margin: 0;
+ padding: 0;
+ border: 0;
+ font-size: 100%;
+ font: inherit;
+ vertical-align: baseline;
+}
+/* HTML5 display-role reset for older browsers */
+article,
+aside,
+details,
+figcaption,
+figure,
+footer,
+header,
+hgroup,
+menu,
+nav,
+section {
+ display: block;
+}
+body {
+ line-height: 1;
+}
+ol,
+ul {
+ list-style: none;
+}
+blockquote,
+q {
+ quotes: none;
+}
+blockquote:before,
+blockquote:after,
+q:before,
+q:after {
+ content: '';
+ content: none;
+}
+table {
+ border-collapse: collapse;
+ border-spacing: 0;
+}
profiles/killbill/src/main/webapp/css/screen.css 1224(+1224 -0)
diff --git a/profiles/killbill/src/main/webapp/css/screen.css b/profiles/killbill/src/main/webapp/css/screen.css
new file mode 100644
index 0000000..478b998
--- /dev/null
+++ b/profiles/killbill/src/main/webapp/css/screen.css
@@ -0,0 +1,1224 @@
+/* Original style from softwaremaniacs.org (c) Ivan Sagalaev <Maniac@SoftwareManiacs.Org> */
+.swagger-section pre code {
+ display: block;
+ padding: 0.5em;
+ background: #F0F0F0;
+}
+.swagger-section pre code,
+.swagger-section pre .subst,
+.swagger-section pre .tag .title,
+.swagger-section pre .lisp .title,
+.swagger-section pre .clojure .built_in,
+.swagger-section pre .nginx .title {
+ color: black;
+}
+.swagger-section pre .string,
+.swagger-section pre .title,
+.swagger-section pre .constant,
+.swagger-section pre .parent,
+.swagger-section pre .tag .value,
+.swagger-section pre .rules .value,
+.swagger-section pre .rules .value .number,
+.swagger-section pre .preprocessor,
+.swagger-section pre .ruby .symbol,
+.swagger-section pre .ruby .symbol .string,
+.swagger-section pre .aggregate,
+.swagger-section pre .template_tag,
+.swagger-section pre .django .variable,
+.swagger-section pre .smalltalk .class,
+.swagger-section pre .addition,
+.swagger-section pre .flow,
+.swagger-section pre .stream,
+.swagger-section pre .bash .variable,
+.swagger-section pre .apache .tag,
+.swagger-section pre .apache .cbracket,
+.swagger-section pre .tex .command,
+.swagger-section pre .tex .special,
+.swagger-section pre .erlang_repl .function_or_atom,
+.swagger-section pre .markdown .header {
+ color: #800;
+}
+.swagger-section pre .comment,
+.swagger-section pre .annotation,
+.swagger-section pre .template_comment,
+.swagger-section pre .diff .header,
+.swagger-section pre .chunk,
+.swagger-section pre .markdown .blockquote {
+ color: #888;
+}
+.swagger-section pre .number,
+.swagger-section pre .date,
+.swagger-section pre .regexp,
+.swagger-section pre .literal,
+.swagger-section pre .smalltalk .symbol,
+.swagger-section pre .smalltalk .char,
+.swagger-section pre .go .constant,
+.swagger-section pre .change,
+.swagger-section pre .markdown .bullet,
+.swagger-section pre .markdown .link_url {
+ color: #080;
+}
+.swagger-section pre .label,
+.swagger-section pre .javadoc,
+.swagger-section pre .ruby .string,
+.swagger-section pre .decorator,
+.swagger-section pre .filter .argument,
+.swagger-section pre .localvars,
+.swagger-section pre .array,
+.swagger-section pre .attr_selector,
+.swagger-section pre .important,
+.swagger-section pre .pseudo,
+.swagger-section pre .pi,
+.swagger-section pre .doctype,
+.swagger-section pre .deletion,
+.swagger-section pre .envvar,
+.swagger-section pre .shebang,
+.swagger-section pre .apache .sqbracket,
+.swagger-section pre .nginx .built_in,
+.swagger-section pre .tex .formula,
+.swagger-section pre .erlang_repl .reserved,
+.swagger-section pre .prompt,
+.swagger-section pre .markdown .link_label,
+.swagger-section pre .vhdl .attribute,
+.swagger-section pre .clojure .attribute,
+.swagger-section pre .coffeescript .property {
+ color: #8888ff;
+}
+.swagger-section pre .keyword,
+.swagger-section pre .id,
+.swagger-section pre .phpdoc,
+.swagger-section pre .title,
+.swagger-section pre .built_in,
+.swagger-section pre .aggregate,
+.swagger-section pre .css .tag,
+.swagger-section pre .javadoctag,
+.swagger-section pre .phpdoc,
+.swagger-section pre .yardoctag,
+.swagger-section pre .smalltalk .class,
+.swagger-section pre .winutils,
+.swagger-section pre .bash .variable,
+.swagger-section pre .apache .tag,
+.swagger-section pre .go .typename,
+.swagger-section pre .tex .command,
+.swagger-section pre .markdown .strong,
+.swagger-section pre .request,
+.swagger-section pre .status {
+ font-weight: bold;
+}
+.swagger-section pre .markdown .emphasis {
+ font-style: italic;
+}
+.swagger-section pre .nginx .built_in {
+ font-weight: normal;
+}
+.swagger-section pre .coffeescript .javascript,
+.swagger-section pre .javascript .xml,
+.swagger-section pre .tex .formula,
+.swagger-section pre .xml .javascript,
+.swagger-section pre .xml .vbscript,
+.swagger-section pre .xml .css,
+.swagger-section pre .xml .cdata {
+ opacity: 0.5;
+}
+.swagger-section .swagger-ui-wrap {
+ line-height: 1;
+ font-family: "Droid Sans", sans-serif;
+ max-width: 960px;
+ margin-left: auto;
+ margin-right: auto;
+}
+.swagger-section .swagger-ui-wrap b,
+.swagger-section .swagger-ui-wrap strong {
+ font-family: "Droid Sans", sans-serif;
+ font-weight: bold;
+}
+.swagger-section .swagger-ui-wrap q,
+.swagger-section .swagger-ui-wrap blockquote {
+ quotes: none;
+}
+.swagger-section .swagger-ui-wrap p {
+ line-height: 1.4em;
+ padding: 0 0 10px;
+ color: #333333;
+}
+.swagger-section .swagger-ui-wrap q:before,
+.swagger-section .swagger-ui-wrap q:after,
+.swagger-section .swagger-ui-wrap blockquote:before,
+.swagger-section .swagger-ui-wrap blockquote:after {
+ content: none;
+}
+.swagger-section .swagger-ui-wrap .heading_with_menu h1,
+.swagger-section .swagger-ui-wrap .heading_with_menu h2,
+.swagger-section .swagger-ui-wrap .heading_with_menu h3,
+.swagger-section .swagger-ui-wrap .heading_with_menu h4,
+.swagger-section .swagger-ui-wrap .heading_with_menu h5,
+.swagger-section .swagger-ui-wrap .heading_with_menu h6 {
+ display: block;
+ clear: none;
+ float: left;
+ -moz-box-sizing: border-box;
+ -webkit-box-sizing: border-box;
+ -ms-box-sizing: border-box;
+ box-sizing: border-box;
+ width: 60%;
+}
+.swagger-section .swagger-ui-wrap table {
+ border-collapse: collapse;
+ border-spacing: 0;
+}
+.swagger-section .swagger-ui-wrap table thead tr th {
+ padding: 5px;
+ font-size: 0.9em;
+ color: #666666;
+ border-bottom: 1px solid #999999;
+}
+.swagger-section .swagger-ui-wrap table tbody tr:last-child td {
+ border-bottom: none;
+}
+.swagger-section .swagger-ui-wrap table tbody tr.offset {
+ background-color: #f0f0f0;
+}
+.swagger-section .swagger-ui-wrap table tbody tr td {
+ padding: 6px;
+ font-size: 0.9em;
+ border-bottom: 1px solid #cccccc;
+ vertical-align: top;
+ line-height: 1.3em;
+}
+.swagger-section .swagger-ui-wrap ol {
+ margin: 0px 0 10px;
+ padding: 0 0 0 18px;
+ list-style-type: decimal;
+}
+.swagger-section .swagger-ui-wrap ol li {
+ padding: 5px 0px;
+ font-size: 0.9em;
+ color: #333333;
+}
+.swagger-section .swagger-ui-wrap ol,
+.swagger-section .swagger-ui-wrap ul {
+ list-style: none;
+}
+.swagger-section .swagger-ui-wrap h1 a,
+.swagger-section .swagger-ui-wrap h2 a,
+.swagger-section .swagger-ui-wrap h3 a,
+.swagger-section .swagger-ui-wrap h4 a,
+.swagger-section .swagger-ui-wrap h5 a,
+.swagger-section .swagger-ui-wrap h6 a {
+ text-decoration: none;
+}
+.swagger-section .swagger-ui-wrap h1 a:hover,
+.swagger-section .swagger-ui-wrap h2 a:hover,
+.swagger-section .swagger-ui-wrap h3 a:hover,
+.swagger-section .swagger-ui-wrap h4 a:hover,
+.swagger-section .swagger-ui-wrap h5 a:hover,
+.swagger-section .swagger-ui-wrap h6 a:hover {
+ text-decoration: underline;
+}
+.swagger-section .swagger-ui-wrap h1 span.divider,
+.swagger-section .swagger-ui-wrap h2 span.divider,
+.swagger-section .swagger-ui-wrap h3 span.divider,
+.swagger-section .swagger-ui-wrap h4 span.divider,
+.swagger-section .swagger-ui-wrap h5 span.divider,
+.swagger-section .swagger-ui-wrap h6 span.divider {
+ color: #aaaaaa;
+}
+.swagger-section .swagger-ui-wrap a {
+ color: #547f00;
+}
+.swagger-section .swagger-ui-wrap a img {
+ border: none;
+}
+.swagger-section .swagger-ui-wrap article,
+.swagger-section .swagger-ui-wrap aside,
+.swagger-section .swagger-ui-wrap details,
+.swagger-section .swagger-ui-wrap figcaption,
+.swagger-section .swagger-ui-wrap figure,
+.swagger-section .swagger-ui-wrap footer,
+.swagger-section .swagger-ui-wrap header,
+.swagger-section .swagger-ui-wrap hgroup,
+.swagger-section .swagger-ui-wrap menu,
+.swagger-section .swagger-ui-wrap nav,
+.swagger-section .swagger-ui-wrap section,
+.swagger-section .swagger-ui-wrap summary {
+ display: block;
+}
+.swagger-section .swagger-ui-wrap pre {
+ font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
+ background-color: #fcf6db;
+ border: 1px solid #e5e0c6;
+ padding: 10px;
+}
+.swagger-section .swagger-ui-wrap pre code {
+ line-height: 1.6em;
+ background: none;
+}
+.swagger-section .swagger-ui-wrap .content > .content-type > div > label {
+ clear: both;
+ display: block;
+ color: #0F6AB4;
+ font-size: 1.1em;
+ margin: 0;
+ padding: 15px 0 5px;
+}
+.swagger-section .swagger-ui-wrap .content pre {
+ font-size: 12px;
+ margin-top: 5px;
+ padding: 5px;
+}
+.swagger-section .swagger-ui-wrap .icon-btn {
+ cursor: pointer;
+}
+.swagger-section .swagger-ui-wrap .info_title {
+ padding-bottom: 10px;
+ font-weight: bold;
+ font-size: 25px;
+}
+.swagger-section .swagger-ui-wrap p.big,
+.swagger-section .swagger-ui-wrap div.big p {
+ font-size: 1em;
+ margin-bottom: 10px;
+}
+.swagger-section .swagger-ui-wrap form.fullwidth ol li.string input,
+.swagger-section .swagger-ui-wrap form.fullwidth ol li.url input,
+.swagger-section .swagger-ui-wrap form.fullwidth ol li.text textarea,
+.swagger-section .swagger-ui-wrap form.fullwidth ol li.numeric input {
+ width: 500px !important;
+}
+.swagger-section .swagger-ui-wrap .info_license {
+ padding-bottom: 5px;
+}
+.swagger-section .swagger-ui-wrap .info_tos {
+ padding-bottom: 5px;
+}
+.swagger-section .swagger-ui-wrap .message-fail {
+ color: #cc0000;
+}
+.swagger-section .swagger-ui-wrap .info_contact {
+ padding-bottom: 5px;
+}
+.swagger-section .swagger-ui-wrap .info_description {
+ padding-bottom: 10px;
+ font-size: 15px;
+}
+.swagger-section .swagger-ui-wrap .markdown ol li,
+.swagger-section .swagger-ui-wrap .markdown ul li {
+ padding: 3px 0px;
+ line-height: 1.4em;
+ color: #333333;
+}
+.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.string input,
+.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.url input,
+.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.numeric input {
+ display: block;
+ padding: 4px;
+ width: auto;
+ clear: both;
+}
+.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.string input.title,
+.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.url input.title,
+.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.numeric input.title {
+ font-size: 1.3em;
+}
+.swagger-section .swagger-ui-wrap table.fullwidth {
+ width: 100%;
+}
+.swagger-section .swagger-ui-wrap .model-signature {
+ font-family: "Droid Sans", sans-serif;
+ font-size: 1em;
+ line-height: 1.5em;
+}
+.swagger-section .swagger-ui-wrap .model-signature .signature-nav a {
+ text-decoration: none;
+ color: #AAA;
+}
+.swagger-section .swagger-ui-wrap .model-signature .signature-nav a:hover {
+ text-decoration: underline;
+ color: black;
+}
+.swagger-section .swagger-ui-wrap .model-signature .signature-nav .selected {
+ color: black;
+ text-decoration: none;
+}
+.swagger-section .swagger-ui-wrap .model-signature .propType {
+ color: #5555aa;
+}
+.swagger-section .swagger-ui-wrap .model-signature pre:hover {
+ background-color: #ffffdd;
+}
+.swagger-section .swagger-ui-wrap .model-signature pre {
+ font-size: .85em;
+ line-height: 1.2em;
+ overflow: auto;
+ max-height: 200px;
+ cursor: pointer;
+}
+.swagger-section .swagger-ui-wrap .model-signature ul.signature-nav {
+ display: block;
+ margin: 0;
+ padding: 0;
+}
+.swagger-section .swagger-ui-wrap .model-signature ul.signature-nav li:last-child {
+ padding-right: 0;
+ border-right: none;
+}
+.swagger-section .swagger-ui-wrap .model-signature ul.signature-nav li {
+ float: left;
+ margin: 0 5px 5px 0;
+ padding: 2px 5px 2px 0;
+ border-right: 1px solid #ddd;
+}
+.swagger-section .swagger-ui-wrap .model-signature .propOpt {
+ color: #555;
+}
+.swagger-section .swagger-ui-wrap .model-signature .snippet small {
+ font-size: 0.75em;
+}
+.swagger-section .swagger-ui-wrap .model-signature .propOptKey {
+ font-style: italic;
+}
+.swagger-section .swagger-ui-wrap .model-signature .description .strong {
+ font-weight: bold;
+ color: #000;
+ font-size: .9em;
+}
+.swagger-section .swagger-ui-wrap .model-signature .description div {
+ font-size: 0.9em;
+ line-height: 1.5em;
+ margin-left: 1em;
+}
+.swagger-section .swagger-ui-wrap .model-signature .description .stronger {
+ font-weight: bold;
+ color: #000;
+}
+.swagger-section .swagger-ui-wrap .model-signature .propName {
+ font-weight: bold;
+}
+.swagger-section .swagger-ui-wrap .model-signature .signature-container {
+ clear: both;
+}
+.swagger-section .swagger-ui-wrap .body-textarea {
+ width: 300px;
+ height: 100px;
+ border: 1px solid #aaa;
+}
+.swagger-section .swagger-ui-wrap .markdown p code,
+.swagger-section .swagger-ui-wrap .markdown li code {
+ font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
+ background-color: #f0f0f0;
+ color: black;
+ padding: 1px 3px;
+}
+.swagger-section .swagger-ui-wrap .required {
+ font-weight: bold;
+}
+.swagger-section .swagger-ui-wrap input.parameter {
+ width: 300px;
+ border: 1px solid #aaa;
+}
+.swagger-section .swagger-ui-wrap h1 {
+ color: black;
+ font-size: 1.5em;
+ line-height: 1.3em;
+ padding: 10px 0 10px 0;
+ font-family: "Droid Sans", sans-serif;
+ font-weight: bold;
+}
+.swagger-section .swagger-ui-wrap .heading_with_menu {
+ float: none;
+ clear: both;
+ overflow: hidden;
+ display: block;
+}
+.swagger-section .swagger-ui-wrap .heading_with_menu ul {
+ display: block;
+ clear: none;
+ float: right;
+ -moz-box-sizing: border-box;
+ -webkit-box-sizing: border-box;
+ -ms-box-sizing: border-box;
+ box-sizing: border-box;
+ margin-top: 10px;
+}
+.swagger-section .swagger-ui-wrap h2 {
+ color: black;
+ font-size: 1.3em;
+ padding: 10px 0 10px 0;
+}
+.swagger-section .swagger-ui-wrap h2 a {
+ color: black;
+}
+.swagger-section .swagger-ui-wrap h2 span.sub {
+ font-size: 0.7em;
+ color: #999999;
+ font-style: italic;
+}
+.swagger-section .swagger-ui-wrap h2 span.sub a {
+ color: #777777;
+}
+.swagger-section .swagger-ui-wrap span.weak {
+ color: #666666;
+}
+.swagger-section .swagger-ui-wrap .message-success {
+ color: #89BF04;
+}
+.swagger-section .swagger-ui-wrap caption,
+.swagger-section .swagger-ui-wrap th,
+.swagger-section .swagger-ui-wrap td {
+ text-align: left;
+ font-weight: normal;
+ vertical-align: middle;
+}
+.swagger-section .swagger-ui-wrap .code {
+ font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
+}
+.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.text textarea {
+ font-family: "Droid Sans", sans-serif;
+ height: 250px;
+ padding: 4px;
+ display: block;
+ clear: both;
+}
+.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.select select {
+ display: block;
+ clear: both;
+}
+.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.boolean {
+ float: none;
+ clear: both;
+ overflow: hidden;
+ display: block;
+}
+.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.boolean label {
+ display: block;
+ float: left;
+ clear: none;
+ margin: 0;
+ padding: 0;
+}
+.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.boolean input {
+ display: block;
+ float: left;
+ clear: none;
+ margin: 0 5px 0 0;
+}
+.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.required label {
+ color: black;
+}
+.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li label {
+ display: block;
+ clear: both;
+ width: auto;
+ padding: 0 0 3px;
+ color: #666666;
+}
+.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li label abbr {
+ padding-left: 3px;
+ color: #888888;
+}
+.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li p.inline-hints {
+ margin-left: 0;
+ font-style: italic;
+ font-size: 0.9em;
+ margin: 0;
+}
+.swagger-section .swagger-ui-wrap form.formtastic fieldset.buttons {
+ margin: 0;
+ padding: 0;
+}
+.swagger-section .swagger-ui-wrap span.blank,
+.swagger-section .swagger-ui-wrap span.empty {
+ color: #888888;
+ font-style: italic;
+}
+.swagger-section .swagger-ui-wrap .markdown h3 {
+ color: #547f00;
+}
+.swagger-section .swagger-ui-wrap .markdown h4 {
+ color: #666666;
+}
+.swagger-section .swagger-ui-wrap .markdown pre {
+ font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
+ background-color: #fcf6db;
+ border: 1px solid #e5e0c6;
+ padding: 10px;
+ margin: 0 0 10px 0;
+}
+.swagger-section .swagger-ui-wrap .markdown pre code {
+ line-height: 1.6em;
+}
+.swagger-section .swagger-ui-wrap div.gist {
+ margin: 20px 0 25px 0 !important;
+}
+.swagger-section .swagger-ui-wrap ul#resources {
+ font-family: "Droid Sans", sans-serif;
+ font-size: 0.9em;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource {
+ border-bottom: 1px solid #dddddd;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource:hover div.heading h2 a,
+.swagger-section .swagger-ui-wrap ul#resources li.resource.active div.heading h2 a {
+ color: black;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource:hover div.heading ul.options li a,
+.swagger-section .swagger-ui-wrap ul#resources li.resource.active div.heading ul.options li a {
+ color: #555555;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource:last-child {
+ border-bottom: none;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading {
+ border: 1px solid transparent;
+ float: none;
+ clear: both;
+ overflow: hidden;
+ display: block;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options {
+ overflow: hidden;
+ padding: 0;
+ display: block;
+ clear: none;
+ float: right;
+ margin: 14px 10px 0 0;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li {
+ float: left;
+ clear: none;
+ margin: 0;
+ padding: 2px 10px;
+ border-right: 1px solid #dddddd;
+ color: #666666;
+ font-size: 0.9em;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li a {
+ color: #aaaaaa;
+ text-decoration: none;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li a:hover {
+ text-decoration: underline;
+ color: black;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li a:hover,
+.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li a:active,
+.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li a.active {
+ text-decoration: underline;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li:first-child,
+.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li.first {
+ padding-left: 0;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li:last-child,
+.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li.last {
+ padding-right: 0;
+ border-right: none;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options:first-child,
+.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options.first {
+ padding-left: 0;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 {
+ color: #999999;
+ padding-left: 0;
+ display: block;
+ clear: none;
+ float: left;
+ font-family: "Droid Sans", sans-serif;
+ font-weight: bold;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 a {
+ color: #999999;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 a:hover {
+ color: black;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation {
+ float: none;
+ clear: both;
+ overflow: hidden;
+ display: block;
+ margin: 0 0 10px;
+ padding: 0;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading {
+ float: none;
+ clear: both;
+ overflow: hidden;
+ display: block;
+ margin: 0;
+ padding: 0;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 {
+ display: block;
+ clear: none;
+ float: left;
+ width: auto;
+ margin: 0;
+ padding: 0;
+ line-height: 1.1em;
+ color: black;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 span.path {
+ padding-left: 10px;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 span.path a {
+ color: black;
+ text-decoration: none;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 span.path a:hover {
+ text-decoration: underline;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 span.http_method a {
+ text-transform: uppercase;
+ text-decoration: none;
+ color: white;
+ display: inline-block;
+ width: 50px;
+ font-size: 0.7em;
+ text-align: center;
+ padding: 7px 0 4px;
+ -moz-border-radius: 2px;
+ -webkit-border-radius: 2px;
+ -o-border-radius: 2px;
+ -ms-border-radius: 2px;
+ -khtml-border-radius: 2px;
+ border-radius: 2px;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 span {
+ margin: 0;
+ padding: 0;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading ul.options {
+ overflow: hidden;
+ padding: 0;
+ display: block;
+ clear: none;
+ float: right;
+ margin: 6px 10px 0 0;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading ul.options li {
+ float: left;
+ clear: none;
+ margin: 0;
+ padding: 2px 10px;
+ font-size: 0.9em;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading ul.options li a {
+ text-decoration: none;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading ul.options li.access {
+ color: black;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content {
+ border-top: none;
+ padding: 10px;
+ -moz-border-radius-bottomleft: 6px;
+ -webkit-border-bottom-left-radius: 6px;
+ -o-border-bottom-left-radius: 6px;
+ -ms-border-bottom-left-radius: 6px;
+ -khtml-border-bottom-left-radius: 6px;
+ border-bottom-left-radius: 6px;
+ -moz-border-radius-bottomright: 6px;
+ -webkit-border-bottom-right-radius: 6px;
+ -o-border-bottom-right-radius: 6px;
+ -ms-border-bottom-right-radius: 6px;
+ -khtml-border-bottom-right-radius: 6px;
+ border-bottom-right-radius: 6px;
+ margin: 0 0 20px;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content h4 {
+ font-size: 1.1em;
+ margin: 0;
+ padding: 15px 0 5px;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header {
+ float: none;
+ clear: both;
+ overflow: hidden;
+ display: block;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header a {
+ padding: 4px 0 0 10px;
+ display: inline-block;
+ font-size: 0.9em;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header input.submit {
+ display: block;
+ clear: none;
+ float: left;
+ padding: 6px 8px;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header span.response_throbber {
+ background-image: url('../images/throbber.gif');
+ width: 128px;
+ height: 16px;
+ display: block;
+ clear: none;
+ float: right;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content form input[type='text'].error {
+ outline: 2px solid black;
+ outline-color: #cc0000;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.response div.block pre {
+ font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
+ padding: 10px;
+ font-size: 0.9em;
+ max-height: 400px;
+ overflow-y: auto;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading {
+ background-color: #f9f2e9;
+ border: 1px solid #f0e0ca;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading h3 span.http_method a {
+ background-color: #c5862b;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li {
+ border-right: 1px solid #dddddd;
+ border-right-color: #f0e0ca;
+ color: #c5862b;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li a {
+ color: #c5862b;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content {
+ background-color: #faf5ee;
+ border: 1px solid #f0e0ca;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content h4 {
+ color: #c5862b;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content div.sandbox_header a {
+ color: #dcb67f;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.heading {
+ background-color: #fcffcd;
+ border: 1px solid black;
+ border-color: #ffd20f;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.heading h3 span.http_method a {
+ text-transform: uppercase;
+ background-color: #ffd20f;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.heading ul.options li {
+ border-right: 1px solid #dddddd;
+ border-right-color: #ffd20f;
+ color: #ffd20f;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.heading ul.options li a {
+ color: #ffd20f;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.content {
+ background-color: #fcffcd;
+ border: 1px solid black;
+ border-color: #ffd20f;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.content h4 {
+ color: #ffd20f;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.content div.sandbox_header a {
+ color: #6fc992;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading {
+ background-color: #f5e8e8;
+ border: 1px solid #e8c6c7;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading h3 span.http_method a {
+ text-transform: uppercase;
+ background-color: #a41e22;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li {
+ border-right: 1px solid #dddddd;
+ border-right-color: #e8c6c7;
+ color: #a41e22;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li a {
+ color: #a41e22;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content {
+ background-color: #f7eded;
+ border: 1px solid #e8c6c7;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content h4 {
+ color: #a41e22;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content div.sandbox_header a {
+ color: #c8787a;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading {
+ background-color: #e7f6ec;
+ border: 1px solid #c3e8d1;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading h3 span.http_method a {
+ background-color: #10a54a;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li {
+ border-right: 1px solid #dddddd;
+ border-right-color: #c3e8d1;
+ color: #10a54a;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li a {
+ color: #10a54a;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content {
+ background-color: #ebf7f0;
+ border: 1px solid #c3e8d1;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content h4 {
+ color: #10a54a;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content div.sandbox_header a {
+ color: #6fc992;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading {
+ background-color: #FCE9E3;
+ border: 1px solid #F5D5C3;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading h3 span.http_method a {
+ background-color: #D38042;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading ul.options li {
+ border-right: 1px solid #dddddd;
+ border-right-color: #f0cecb;
+ color: #D38042;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading ul.options li a {
+ color: #D38042;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.content {
+ background-color: #faf0ef;
+ border: 1px solid #f0cecb;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.content h4 {
+ color: #D38042;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.content div.sandbox_header a {
+ color: #dcb67f;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading {
+ background-color: #e7f0f7;
+ border: 1px solid #c3d9ec;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading h3 span.http_method a {
+ background-color: #0f6ab4;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li {
+ border-right: 1px solid #dddddd;
+ border-right-color: #c3d9ec;
+ color: #0f6ab4;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li a {
+ color: #0f6ab4;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content {
+ background-color: #ebf3f9;
+ border: 1px solid #c3d9ec;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content h4 {
+ color: #0f6ab4;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content div.sandbox_header a {
+ color: #6fa5d2;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.options div.heading {
+ background-color: #e7f0f7;
+ border: 1px solid #c3d9ec;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.options div.heading h3 span.http_method a {
+ background-color: #0f6ab4;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.options div.heading ul.options li {
+ border-right: 1px solid #dddddd;
+ border-right-color: #c3d9ec;
+ color: #0f6ab4;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.options div.heading ul.options li a {
+ color: #0f6ab4;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.options div.content {
+ background-color: #ebf3f9;
+ border: 1px solid #c3d9ec;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.options div.content h4 {
+ color: #0f6ab4;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.options div.content div.sandbox_header a {
+ color: #6fa5d2;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.content,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.content,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content {
+ border-top: none;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li:last-child,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li:last-child,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.heading ul.options li:last-child,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li:last-child,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading ul.options li:last-child,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li:last-child,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li.last,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li.last,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.heading ul.options li.last,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li.last,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading ul.options li.last,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li.last {
+ padding-right: 0;
+ border-right: none;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations ul.options li a:hover,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations ul.options li a:active,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations ul.options li a.active {
+ text-decoration: underline;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations ul.options li:first-child,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations ul.options li.first {
+ padding-left: 0;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations:first-child,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations.first {
+ padding-left: 0;
+}
+.swagger-section .swagger-ui-wrap p#colophon {
+ margin: 0 15px 40px 15px;
+ padding: 10px 0;
+ font-size: 0.8em;
+ border-top: 1px solid #dddddd;
+ font-family: "Droid Sans", sans-serif;
+ color: #999999;
+ font-style: italic;
+}
+.swagger-section .swagger-ui-wrap p#colophon a {
+ text-decoration: none;
+ color: #547f00;
+}
+.swagger-section .swagger-ui-wrap h3 {
+ color: black;
+ font-size: 1.1em;
+ padding: 10px 0 10px 0;
+}
+.swagger-section .swagger-ui-wrap .markdown ol,
+.swagger-section .swagger-ui-wrap .markdown ul {
+ font-family: "Droid Sans", sans-serif;
+ margin: 5px 0 10px;
+ padding: 0 0 0 18px;
+ list-style-type: disc;
+}
+.swagger-section .swagger-ui-wrap form.form_box {
+ background-color: #ebf3f9;
+ border: 1px solid #c3d9ec;
+ padding: 10px;
+}
+.swagger-section .swagger-ui-wrap form.form_box label {
+ color: #0f6ab4 !important;
+}
+.swagger-section .swagger-ui-wrap form.form_box input[type=submit] {
+ display: block;
+ padding: 10px;
+}
+.swagger-section .swagger-ui-wrap form.form_box p.weak {
+ font-size: 0.8em;
+}
+.swagger-section .swagger-ui-wrap form.form_box p {
+ font-size: 0.9em;
+ padding: 0 0 15px;
+ color: #7e7b6d;
+}
+.swagger-section .swagger-ui-wrap form.form_box p a {
+ color: #646257;
+}
+.swagger-section .swagger-ui-wrap form.form_box p strong {
+ color: black;
+}
+.swagger-section .title {
+ font-style: bold;
+}
+.swagger-section .secondary_form {
+ display: none;
+}
+.swagger-section .main_image {
+ display: block;
+ margin-left: auto;
+ margin-right: auto;
+}
+.swagger-section .oauth_body {
+ margin-left: 100px;
+ margin-right: 100px;
+}
+.swagger-section .oauth_submit {
+ text-align: center;
+}
+.swagger-section .api-popup-dialog {
+ z-index: 10000;
+ position: absolute;
+ width: 500px;
+ background: #FFF;
+ padding: 20px;
+ border: 1px solid #ccc;
+ border-radius: 5px;
+ display: none;
+ font-size: 13px;
+ color: #777;
+}
+.swagger-section .api-popup-dialog .api-popup-title {
+ font-size: 24px;
+ padding: 10px 0;
+}
+.swagger-section .api-popup-dialog .api-popup-title {
+ font-size: 24px;
+ padding: 10px 0;
+}
+.swagger-section .api-popup-dialog p.error-msg {
+ padding-left: 5px;
+ padding-bottom: 5px;
+}
+.swagger-section .api-popup-dialog button.api-popup-authbtn {
+ height: 30px;
+}
+.swagger-section .api-popup-dialog button.api-popup-cancel {
+ height: 30px;
+}
+.swagger-section .api-popup-scopes {
+ padding: 10px 20px;
+}
+.swagger-section .api-popup-scopes li {
+ padding: 5px 0;
+ line-height: 20px;
+}
+.swagger-section .api-popup-scopes .api-scope-desc {
+ padding-left: 20px;
+ font-style: italic;
+}
+.swagger-section .api-popup-scopes li input {
+ position: relative;
+ top: 2px;
+}
+.swagger-section .api-popup-actions {
+ padding-top: 10px;
+}
+.swagger-section .access {
+ float: right;
+}
+.swagger-section .auth {
+ float: right;
+}
+.swagger-section #api_information_panel {
+ position: absolute;
+ background: #FFF;
+ border: 1px solid #ccc;
+ border-radius: 5px;
+ display: none;
+ font-size: 13px;
+ max-width: 300px;
+ line-height: 30px;
+ color: black;
+ padding: 5px;
+}
+.swagger-section #api_information_panel p .api-msg-enabled {
+ color: green;
+}
+.swagger-section #api_information_panel p .api-msg-disabled {
+ color: red;
+}
+.swagger-section .api-ic {
+ height: 18px;
+ vertical-align: middle;
+ display: inline-block;
+ background: url(../images/explorer_icons.png) no-repeat;
+}
+.swagger-section .ic-info {
+ background-position: 0 0;
+ width: 18px;
+ margin-top: -7px;
+ margin-left: 4px;
+}
+.swagger-section .ic-warning {
+ background-position: -60px 0;
+ width: 18px;
+ margin-top: -7px;
+ margin-left: 4px;
+}
+.swagger-section .ic-error {
+ background-position: -30px 0;
+ width: 18px;
+ margin-top: -7px;
+ margin-left: 4px;
+}
+.swagger-section .ic-off {
+ background-position: -90px 0;
+ width: 58px;
+ margin-top: -4px;
+ cursor: pointer;
+}
+.swagger-section .ic-on {
+ background-position: -160px 0;
+ width: 58px;
+ margin-top: -4px;
+ cursor: pointer;
+}
+.swagger-section #header {
+ background-color: #89bf04;
+ padding: 14px;
+}
+.swagger-section #header a#logo {
+ font-size: 1.5em;
+ font-weight: bold;
+ text-decoration: none;
+ background: transparent url(../images/logo_small.png) no-repeat left center;
+ padding: 20px 0 20px 40px;
+ color: white;
+}
+.swagger-section #header form#api_selector {
+ display: block;
+ clear: none;
+ float: right;
+}
+.swagger-section #header form#api_selector .input {
+ display: block;
+ clear: none;
+ float: left;
+ margin: 0 10px 0 0;
+}
+.swagger-section #header form#api_selector .input input#input_apiKey {
+ width: 200px;
+}
+.swagger-section #header form#api_selector .input input#input_baseUrl {
+ width: 400px;
+}
+.swagger-section #header form#api_selector .input a#explore {
+ display: block;
+ text-decoration: none;
+ font-weight: bold;
+ padding: 6px 8px;
+ font-size: 0.9em;
+ color: white;
+ background-color: #547f00;
+ -moz-border-radius: 4px;
+ -webkit-border-radius: 4px;
+ -o-border-radius: 4px;
+ -ms-border-radius: 4px;
+ -khtml-border-radius: 4px;
+ border-radius: 4px;
+}
+.swagger-section #header form#api_selector .input a#explore:hover {
+ background-color: #547f00;
+}
+.swagger-section #header form#api_selector .input input {
+ font-size: 0.9em;
+ padding: 3px;
+ margin: 0;
+}
+.swagger-section #content_message {
+ margin: 10px 15px;
+ font-style: italic;
+ color: #999999;
+}
+.swagger-section #message-bar {
+ min-height: 30px;
+ text-align: center;
+ padding-top: 10px;
+}
diff --git a/profiles/killbill/src/main/webapp/images/killbill_logo.png b/profiles/killbill/src/main/webapp/images/killbill_logo.png
new file mode 100644
index 0000000..feb37eb
Binary files /dev/null and b/profiles/killbill/src/main/webapp/images/killbill_logo.png differ
diff --git a/profiles/killbill/src/main/webapp/index.html b/profiles/killbill/src/main/webapp/index.html
index bc17c34..3a9c985 100644
--- a/profiles/killbill/src/main/webapp/index.html
+++ b/profiles/killbill/src/main/webapp/index.html
@@ -23,11 +23,9 @@
<!--[if lt IE 9]>
<script src=javascripts/html5.js" type="text/javascript"></script>
<![endif]-->
- <script src="javascripts/jquery.min.js"></script>
- <script src="javascripts/bootstrap.min.js"></script>
- <link rel=stylesheet type="text/css" href="stylesheets/bootstrap.min.css">
- <link rel=stylesheet type="text/css" href="stylesheets/killbill.css">
+ <link rel=stylesheet type="text/css" href="css/bootstrap.min.css">
+ <link rel=stylesheet type="text/css" href="css/killbill-bootstrap.css">
</head>
<body data-spy="scroll" data-target=".bs-docs-sidebar">
@@ -47,13 +45,14 @@
<div class="jumbotron">
<h1>Kill Bill</h1>
<h2>The Open-Source Billing Platform</h2>
- <img src="img/KillBillLogo400x400.png" style="height: 200px; margin-bottom: 20px;" />
+ <img src="images/KillBillLogo400x400.png" style="height: 200px; margin-bottom: 20px;" />
</div>
<div class="marketing">
<h1>Congratulations!</h1>
<p class="lead">Kill Bill is up and running.</p>
<ul class="inline">
+ <li><a class="btn btn-primary btn-large" href="/api.html">APIs</a></li>
<li><a class="btn btn-primary btn-large" href="/1.0/metrics?pretty=true">Metrics</a></li>
<li><a class="btn btn-primary btn-large" href="/1.0/threads">Threads</a></li>
</ul>
diff --git a/profiles/killbill/src/main/webapp/lib/backbone-min.js b/profiles/killbill/src/main/webapp/lib/backbone-min.js
new file mode 100644
index 0000000..c1c0d4f
--- /dev/null
+++ b/profiles/killbill/src/main/webapp/lib/backbone-min.js
@@ -0,0 +1,38 @@
+// Backbone.js 0.9.2
+
+// (c) 2010-2012 Jeremy Ashkenas, DocumentCloud Inc.
+// Backbone may be freely distributed under the MIT license.
+// For all details and documentation:
+// http://backbonejs.org
+(function(){var l=this,y=l.Backbone,z=Array.prototype.slice,A=Array.prototype.splice,g;g="undefined"!==typeof exports?exports:l.Backbone={};g.VERSION="0.9.2";var f=l._;!f&&"undefined"!==typeof require&&(f=require("underscore"));var i=l.jQuery||l.Zepto||l.ender;g.setDomLibrary=function(a){i=a};g.noConflict=function(){l.Backbone=y;return this};g.emulateHTTP=!1;g.emulateJSON=!1;var p=/\s+/,k=g.Events={on:function(a,b,c){var d,e,f,g,j;if(!b)return this;a=a.split(p);for(d=this._callbacks||(this._callbacks=
+{});e=a.shift();)f=(j=d[e])?j.tail:{},f.next=g={},f.context=c,f.callback=b,d[e]={tail:g,next:j?j.next:f};return this},off:function(a,b,c){var d,e,h,g,j,q;if(e=this._callbacks){if(!a&&!b&&!c)return delete this._callbacks,this;for(a=a?a.split(p):f.keys(e);d=a.shift();)if(h=e[d],delete e[d],h&&(b||c))for(g=h.tail;(h=h.next)!==g;)if(j=h.callback,q=h.context,b&&j!==b||c&&q!==c)this.on(d,j,q);return this}},trigger:function(a){var b,c,d,e,f,g;if(!(d=this._callbacks))return this;f=d.all;a=a.split(p);for(g=
+z.call(arguments,1);b=a.shift();){if(c=d[b])for(e=c.tail;(c=c.next)!==e;)c.callback.apply(c.context||this,g);if(c=f){e=c.tail;for(b=[b].concat(g);(c=c.next)!==e;)c.callback.apply(c.context||this,b)}}return this}};k.bind=k.on;k.unbind=k.off;var o=g.Model=function(a,b){var c;a||(a={});b&&b.parse&&(a=this.parse(a));if(c=n(this,"defaults"))a=f.extend({},c,a);b&&b.collection&&(this.collection=b.collection);this.attributes={};this._escapedAttributes={};this.cid=f.uniqueId("c");this.changed={};this._silent=
+{};this._pending={};this.set(a,{silent:!0});this.changed={};this._silent={};this._pending={};this._previousAttributes=f.clone(this.attributes);this.initialize.apply(this,arguments)};f.extend(o.prototype,k,{changed:null,_silent:null,_pending:null,idAttribute:"id",initialize:function(){},toJSON:function(){return f.clone(this.attributes)},get:function(a){return this.attributes[a]},escape:function(a){var b;if(b=this._escapedAttributes[a])return b;b=this.get(a);return this._escapedAttributes[a]=f.escape(null==
+b?"":""+b)},has:function(a){return null!=this.get(a)},set:function(a,b,c){var d,e;f.isObject(a)||null==a?(d=a,c=b):(d={},d[a]=b);c||(c={});if(!d)return this;d instanceof o&&(d=d.attributes);if(c.unset)for(e in d)d[e]=void 0;if(!this._validate(d,c))return!1;this.idAttribute in d&&(this.id=d[this.idAttribute]);var b=c.changes={},h=this.attributes,g=this._escapedAttributes,j=this._previousAttributes||{};for(e in d){a=d[e];if(!f.isEqual(h[e],a)||c.unset&&f.has(h,e))delete g[e],(c.silent?this._silent:
+b)[e]=!0;c.unset?delete h[e]:h[e]=a;!f.isEqual(j[e],a)||f.has(h,e)!=f.has(j,e)?(this.changed[e]=a,c.silent||(this._pending[e]=!0)):(delete this.changed[e],delete this._pending[e])}c.silent||this.change(c);return this},unset:function(a,b){(b||(b={})).unset=!0;return this.set(a,null,b)},clear:function(a){(a||(a={})).unset=!0;return this.set(f.clone(this.attributes),a)},fetch:function(a){var a=a?f.clone(a):{},b=this,c=a.success;a.success=function(d,e,f){if(!b.set(b.parse(d,f),a))return!1;c&&c(b,d)};
+a.error=g.wrapError(a.error,b,a);return(this.sync||g.sync).call(this,"read",this,a)},save:function(a,b,c){var d,e;f.isObject(a)||null==a?(d=a,c=b):(d={},d[a]=b);c=c?f.clone(c):{};if(c.wait){if(!this._validate(d,c))return!1;e=f.clone(this.attributes)}a=f.extend({},c,{silent:!0});if(d&&!this.set(d,c.wait?a:c))return!1;var h=this,i=c.success;c.success=function(a,b,e){b=h.parse(a,e);if(c.wait){delete c.wait;b=f.extend(d||{},b)}if(!h.set(b,c))return false;i?i(h,a):h.trigger("sync",h,a,c)};c.error=g.wrapError(c.error,
+h,c);b=this.isNew()?"create":"update";b=(this.sync||g.sync).call(this,b,this,c);c.wait&&this.set(e,a);return b},destroy:function(a){var a=a?f.clone(a):{},b=this,c=a.success,d=function(){b.trigger("destroy",b,b.collection,a)};if(this.isNew())return d(),!1;a.success=function(e){a.wait&&d();c?c(b,e):b.trigger("sync",b,e,a)};a.error=g.wrapError(a.error,b,a);var e=(this.sync||g.sync).call(this,"delete",this,a);a.wait||d();return e},url:function(){var a=n(this,"urlRoot")||n(this.collection,"url")||t();
+return this.isNew()?a:a+("/"==a.charAt(a.length-1)?"":"/")+encodeURIComponent(this.id)},parse:function(a){return a},clone:function(){return new this.constructor(this.attributes)},isNew:function(){return null==this.id},change:function(a){a||(a={});var b=this._changing;this._changing=!0;for(var c in this._silent)this._pending[c]=!0;var d=f.extend({},a.changes,this._silent);this._silent={};for(c in d)this.trigger("change:"+c,this,this.get(c),a);if(b)return this;for(;!f.isEmpty(this._pending);){this._pending=
+{};this.trigger("change",this,a);for(c in this.changed)!this._pending[c]&&!this._silent[c]&&delete this.changed[c];this._previousAttributes=f.clone(this.attributes)}this._changing=!1;return this},hasChanged:function(a){return!arguments.length?!f.isEmpty(this.changed):f.has(this.changed,a)},changedAttributes:function(a){if(!a)return this.hasChanged()?f.clone(this.changed):!1;var b,c=!1,d=this._previousAttributes,e;for(e in a)if(!f.isEqual(d[e],b=a[e]))(c||(c={}))[e]=b;return c},previous:function(a){return!arguments.length||
+!this._previousAttributes?null:this._previousAttributes[a]},previousAttributes:function(){return f.clone(this._previousAttributes)},isValid:function(){return!this.validate(this.attributes)},_validate:function(a,b){if(b.silent||!this.validate)return!0;var a=f.extend({},this.attributes,a),c=this.validate(a,b);if(!c)return!0;b&&b.error?b.error(this,c,b):this.trigger("error",this,c,b);return!1}});var r=g.Collection=function(a,b){b||(b={});b.model&&(this.model=b.model);b.comparator&&(this.comparator=b.comparator);
+this._reset();this.initialize.apply(this,arguments);a&&this.reset(a,{silent:!0,parse:b.parse})};f.extend(r.prototype,k,{model:o,initialize:function(){},toJSON:function(a){return this.map(function(b){return b.toJSON(a)})},add:function(a,b){var c,d,e,g,i,j={},k={},l=[];b||(b={});a=f.isArray(a)?a.slice():[a];c=0;for(d=a.length;c<d;c++){if(!(e=a[c]=this._prepareModel(a[c],b)))throw Error("Can't add an invalid model to a collection");g=e.cid;i=e.id;j[g]||this._byCid[g]||null!=i&&(k[i]||this._byId[i])?
+l.push(c):j[g]=k[i]=e}for(c=l.length;c--;)a.splice(l[c],1);c=0;for(d=a.length;c<d;c++)(e=a[c]).on("all",this._onModelEvent,this),this._byCid[e.cid]=e,null!=e.id&&(this._byId[e.id]=e);this.length+=d;A.apply(this.models,[null!=b.at?b.at:this.models.length,0].concat(a));this.comparator&&this.sort({silent:!0});if(b.silent)return this;c=0;for(d=this.models.length;c<d;c++)if(j[(e=this.models[c]).cid])b.index=c,e.trigger("add",e,this,b);return this},remove:function(a,b){var c,d,e,g;b||(b={});a=f.isArray(a)?
+a.slice():[a];c=0;for(d=a.length;c<d;c++)if(g=this.getByCid(a[c])||this.get(a[c]))delete this._byId[g.id],delete this._byCid[g.cid],e=this.indexOf(g),this.models.splice(e,1),this.length--,b.silent||(b.index=e,g.trigger("remove",g,this,b)),this._removeReference(g);return this},push:function(a,b){a=this._prepareModel(a,b);this.add(a,b);return a},pop:function(a){var b=this.at(this.length-1);this.remove(b,a);return b},unshift:function(a,b){a=this._prepareModel(a,b);this.add(a,f.extend({at:0},b));return a},
+shift:function(a){var b=this.at(0);this.remove(b,a);return b},get:function(a){return null==a?void 0:this._byId[null!=a.id?a.id:a]},getByCid:function(a){return a&&this._byCid[a.cid||a]},at:function(a){return this.models[a]},where:function(a){return f.isEmpty(a)?[]:this.filter(function(b){for(var c in a)if(a[c]!==b.get(c))return!1;return!0})},sort:function(a){a||(a={});if(!this.comparator)throw Error("Cannot sort a set without a comparator");var b=f.bind(this.comparator,this);1==this.comparator.length?
+this.models=this.sortBy(b):this.models.sort(b);a.silent||this.trigger("reset",this,a);return this},pluck:function(a){return f.map(this.models,function(b){return b.get(a)})},reset:function(a,b){a||(a=[]);b||(b={});for(var c=0,d=this.models.length;c<d;c++)this._removeReference(this.models[c]);this._reset();this.add(a,f.extend({silent:!0},b));b.silent||this.trigger("reset",this,b);return this},fetch:function(a){a=a?f.clone(a):{};void 0===a.parse&&(a.parse=!0);var b=this,c=a.success;a.success=function(d,
+e,f){b[a.add?"add":"reset"](b.parse(d,f),a);c&&c(b,d)};a.error=g.wrapError(a.error,b,a);return(this.sync||g.sync).call(this,"read",this,a)},create:function(a,b){var c=this,b=b?f.clone(b):{},a=this._prepareModel(a,b);if(!a)return!1;b.wait||c.add(a,b);var d=b.success;b.success=function(e,f){b.wait&&c.add(e,b);d?d(e,f):e.trigger("sync",a,f,b)};a.save(null,b);return a},parse:function(a){return a},chain:function(){return f(this.models).chain()},_reset:function(){this.length=0;this.models=[];this._byId=
+{};this._byCid={}},_prepareModel:function(a,b){b||(b={});a instanceof o?a.collection||(a.collection=this):(b.collection=this,a=new this.model(a,b),a._validate(a.attributes,b)||(a=!1));return a},_removeReference:function(a){this==a.collection&&delete a.collection;a.off("all",this._onModelEvent,this)},_onModelEvent:function(a,b,c,d){("add"==a||"remove"==a)&&c!=this||("destroy"==a&&this.remove(b,d),b&&a==="change:"+b.idAttribute&&(delete this._byId[b.previous(b.idAttribute)],this._byId[b.id]=b),this.trigger.apply(this,
+arguments))}});f.each("forEach,each,map,reduce,reduceRight,find,detect,filter,select,reject,every,all,some,any,include,contains,invoke,max,min,sortBy,sortedIndex,toArray,size,first,initial,rest,last,without,indexOf,shuffle,lastIndexOf,isEmpty,groupBy".split(","),function(a){r.prototype[a]=function(){return f[a].apply(f,[this.models].concat(f.toArray(arguments)))}});var u=g.Router=function(a){a||(a={});a.routes&&(this.routes=a.routes);this._bindRoutes();this.initialize.apply(this,arguments)},B=/:\w+/g,
+C=/\*\w+/g,D=/[-[\]{}()+?.,\\^$|#\s]/g;f.extend(u.prototype,k,{initialize:function(){},route:function(a,b,c){g.history||(g.history=new m);f.isRegExp(a)||(a=this._routeToRegExp(a));c||(c=this[b]);g.history.route(a,f.bind(function(d){d=this._extractParameters(a,d);c&&c.apply(this,d);this.trigger.apply(this,["route:"+b].concat(d));g.history.trigger("route",this,b,d)},this));return this},navigate:function(a,b){g.history.navigate(a,b)},_bindRoutes:function(){if(this.routes){var a=[],b;for(b in this.routes)a.unshift([b,
+this.routes[b]]);b=0;for(var c=a.length;b<c;b++)this.route(a[b][0],a[b][1],this[a[b][1]])}},_routeToRegExp:function(a){a=a.replace(D,"\\$&").replace(B,"([^/]+)").replace(C,"(.*?)");return RegExp("^"+a+"$")},_extractParameters:function(a,b){return a.exec(b).slice(1)}});var m=g.History=function(){this.handlers=[];f.bindAll(this,"checkUrl")},s=/^[#\/]/,E=/msie [\w.]+/;m.started=!1;f.extend(m.prototype,k,{interval:50,getHash:function(a){return(a=(a?a.location:window.location).href.match(/#(.*)$/))?a[1]:
+""},getFragment:function(a,b){if(null==a)if(this._hasPushState||b){var a=window.location.pathname,c=window.location.search;c&&(a+=c)}else a=this.getHash();a.indexOf(this.options.root)||(a=a.substr(this.options.root.length));return a.replace(s,"")},start:function(a){if(m.started)throw Error("Backbone.history has already been started");m.started=!0;this.options=f.extend({},{root:"/"},this.options,a);this._wantsHashChange=!1!==this.options.hashChange;this._wantsPushState=!!this.options.pushState;this._hasPushState=
+!(!this.options.pushState||!window.history||!window.history.pushState);var a=this.getFragment(),b=document.documentMode;if(b=E.exec(navigator.userAgent.toLowerCase())&&(!b||7>=b))this.iframe=i('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo("body")[0].contentWindow,this.navigate(a);this._hasPushState?i(window).bind("popstate",this.checkUrl):this._wantsHashChange&&"onhashchange"in window&&!b?i(window).bind("hashchange",this.checkUrl):this._wantsHashChange&&(this._checkUrlInterval=setInterval(this.checkUrl,
+this.interval));this.fragment=a;a=window.location;b=a.pathname==this.options.root;if(this._wantsHashChange&&this._wantsPushState&&!this._hasPushState&&!b)return this.fragment=this.getFragment(null,!0),window.location.replace(this.options.root+"#"+this.fragment),!0;this._wantsPushState&&this._hasPushState&&b&&a.hash&&(this.fragment=this.getHash().replace(s,""),window.history.replaceState({},document.title,a.protocol+"//"+a.host+this.options.root+this.fragment));if(!this.options.silent)return this.loadUrl()},
+stop:function(){i(window).unbind("popstate",this.checkUrl).unbind("hashchange",this.checkUrl);clearInterval(this._checkUrlInterval);m.started=!1},route:function(a,b){this.handlers.unshift({route:a,callback:b})},checkUrl:function(){var a=this.getFragment();a==this.fragment&&this.iframe&&(a=this.getFragment(this.getHash(this.iframe)));if(a==this.fragment)return!1;this.iframe&&this.navigate(a);this.loadUrl()||this.loadUrl(this.getHash())},loadUrl:function(a){var b=this.fragment=this.getFragment(a);return f.any(this.handlers,
+function(a){if(a.route.test(b))return a.callback(b),!0})},navigate:function(a,b){if(!m.started)return!1;if(!b||!0===b)b={trigger:b};var c=(a||"").replace(s,"");this.fragment!=c&&(this._hasPushState?(0!=c.indexOf(this.options.root)&&(c=this.options.root+c),this.fragment=c,window.history[b.replace?"replaceState":"pushState"]({},document.title,c)):this._wantsHashChange?(this.fragment=c,this._updateHash(window.location,c,b.replace),this.iframe&&c!=this.getFragment(this.getHash(this.iframe))&&(b.replace||
+this.iframe.document.open().close(),this._updateHash(this.iframe.location,c,b.replace))):window.location.assign(this.options.root+a),b.trigger&&this.loadUrl(a))},_updateHash:function(a,b,c){c?a.replace(a.toString().replace(/(javascript:|#).*$/,"")+"#"+b):a.hash=b}});var v=g.View=function(a){this.cid=f.uniqueId("view");this._configure(a||{});this._ensureElement();this.initialize.apply(this,arguments);this.delegateEvents()},F=/^(\S+)\s*(.*)$/,w="model,collection,el,id,attributes,className,tagName".split(",");
+f.extend(v.prototype,k,{tagName:"div",$:function(a){return this.$el.find(a)},initialize:function(){},render:function(){return this},remove:function(){this.$el.remove();return this},make:function(a,b,c){a=document.createElement(a);b&&i(a).attr(b);c&&i(a).html(c);return a},setElement:function(a,b){this.$el&&this.undelegateEvents();this.$el=a instanceof i?a:i(a);this.el=this.$el[0];!1!==b&&this.delegateEvents();return this},delegateEvents:function(a){if(a||(a=n(this,"events"))){this.undelegateEvents();
+for(var b in a){var c=a[b];f.isFunction(c)||(c=this[a[b]]);if(!c)throw Error('Method "'+a[b]+'" does not exist');var d=b.match(F),e=d[1],d=d[2],c=f.bind(c,this),e=e+(".delegateEvents"+this.cid);""===d?this.$el.bind(e,c):this.$el.delegate(d,e,c)}}},undelegateEvents:function(){this.$el.unbind(".delegateEvents"+this.cid)},_configure:function(a){this.options&&(a=f.extend({},this.options,a));for(var b=0,c=w.length;b<c;b++){var d=w[b];a[d]&&(this[d]=a[d])}this.options=a},_ensureElement:function(){if(this.el)this.setElement(this.el,
+!1);else{var a=n(this,"attributes")||{};this.id&&(a.id=this.id);this.className&&(a["class"]=this.className);this.setElement(this.make(this.tagName,a),!1)}}});o.extend=r.extend=u.extend=v.extend=function(a,b){var c=G(this,a,b);c.extend=this.extend;return c};var H={create:"POST",update:"PUT","delete":"DELETE",read:"GET"};g.sync=function(a,b,c){var d=H[a];c||(c={});var e={type:d,dataType:"json"};c.url||(e.url=n(b,"url")||t());if(!c.data&&b&&("create"==a||"update"==a))e.contentType="application/json",
+e.data=JSON.stringify(b.toJSON());g.emulateJSON&&(e.contentType="application/x-www-form-urlencoded",e.data=e.data?{model:e.data}:{});if(g.emulateHTTP&&("PUT"===d||"DELETE"===d))g.emulateJSON&&(e.data._method=d),e.type="POST",e.beforeSend=function(a){a.setRequestHeader("X-HTTP-Method-Override",d)};"GET"!==e.type&&!g.emulateJSON&&(e.processData=!1);return i.ajax(f.extend(e,c))};g.wrapError=function(a,b,c){return function(d,e){e=d===b?e:d;a?a(b,e,c):b.trigger("error",b,e,c)}};var x=function(){},G=function(a,
+b,c){var d;d=b&&b.hasOwnProperty("constructor")?b.constructor:function(){a.apply(this,arguments)};f.extend(d,a);x.prototype=a.prototype;d.prototype=new x;b&&f.extend(d.prototype,b);c&&f.extend(d,c);d.prototype.constructor=d;d.__super__=a.prototype;return d},n=function(a,b){return!a||!a[b]?null:f.isFunction(a[b])?a[b]():a[b]},t=function(){throw Error('A "url" property or function must be specified');}}).call(this);
profiles/killbill/src/main/webapp/lib/handlebars-1.0.0.js 2278(+2278 -0)
diff --git a/profiles/killbill/src/main/webapp/lib/handlebars-1.0.0.js b/profiles/killbill/src/main/webapp/lib/handlebars-1.0.0.js
new file mode 100644
index 0000000..c70f09d
--- /dev/null
+++ b/profiles/killbill/src/main/webapp/lib/handlebars-1.0.0.js
@@ -0,0 +1,2278 @@
+/*
+
+Copyright (C) 2011 by Yehuda Katz
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+*/
+
+// lib/handlebars/browser-prefix.js
+var Handlebars = {};
+
+(function(Handlebars, undefined) {
+;
+// lib/handlebars/base.js
+
+Handlebars.VERSION = "1.0.0";
+Handlebars.COMPILER_REVISION = 4;
+
+Handlebars.REVISION_CHANGES = {
+ 1: '<= 1.0.rc.2', // 1.0.rc.2 is actually rev2 but doesn't report it
+ 2: '== 1.0.0-rc.3',
+ 3: '== 1.0.0-rc.4',
+ 4: '>= 1.0.0'
+};
+
+Handlebars.helpers = {};
+Handlebars.partials = {};
+
+var toString = Object.prototype.toString,
+ functionType = '[object Function]',
+ objectType = '[object Object]';
+
+Handlebars.registerHelper = function(name, fn, inverse) {
+ if (toString.call(name) === objectType) {
+ if (inverse || fn) { throw new Handlebars.Exception('Arg not supported with multiple helpers'); }
+ Handlebars.Utils.extend(this.helpers, name);
+ } else {
+ if (inverse) { fn.not = inverse; }
+ this.helpers[name] = fn;
+ }
+};
+
+Handlebars.registerPartial = function(name, str) {
+ if (toString.call(name) === objectType) {
+ Handlebars.Utils.extend(this.partials, name);
+ } else {
+ this.partials[name] = str;
+ }
+};
+
+Handlebars.registerHelper('helperMissing', function(arg) {
+ if(arguments.length === 2) {
+ return undefined;
+ } else {
+ throw new Error("Missing helper: '" + arg + "'");
+ }
+});
+
+Handlebars.registerHelper('blockHelperMissing', function(context, options) {
+ var inverse = options.inverse || function() {}, fn = options.fn;
+
+ var type = toString.call(context);
+
+ if(type === functionType) { context = context.call(this); }
+
+ if(context === true) {
+ return fn(this);
+ } else if(context === false || context == null) {
+ return inverse(this);
+ } else if(type === "[object Array]") {
+ if(context.length > 0) {
+ return Handlebars.helpers.each(context, options);
+ } else {
+ return inverse(this);
+ }
+ } else {
+ return fn(context);
+ }
+});
+
+Handlebars.K = function() {};
+
+Handlebars.createFrame = Object.create || function(object) {
+ Handlebars.K.prototype = object;
+ var obj = new Handlebars.K();
+ Handlebars.K.prototype = null;
+ return obj;
+};
+
+Handlebars.logger = {
+ DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3, level: 3,
+
+ methodMap: {0: 'debug', 1: 'info', 2: 'warn', 3: 'error'},
+
+ // can be overridden in the host environment
+ log: function(level, obj) {
+ if (Handlebars.logger.level <= level) {
+ var method = Handlebars.logger.methodMap[level];
+ if (typeof console !== 'undefined' && console[method]) {
+ console[method].call(console, obj);
+ }
+ }
+ }
+};
+
+Handlebars.log = function(level, obj) { Handlebars.logger.log(level, obj); };
+
+Handlebars.registerHelper('each', function(context, options) {
+ var fn = options.fn, inverse = options.inverse;
+ var i = 0, ret = "", data;
+
+ var type = toString.call(context);
+ if(type === functionType) { context = context.call(this); }
+
+ if (options.data) {
+ data = Handlebars.createFrame(options.data);
+ }
+
+ if(context && typeof context === 'object') {
+ if(context instanceof Array){
+ for(var j = context.length; i<j; i++) {
+ if (data) { data.index = i; }
+ ret = ret + fn(context[i], { data: data });
+ }
+ } else {
+ for(var key in context) {
+ if(context.hasOwnProperty(key)) {
+ if(data) { data.key = key; }
+ ret = ret + fn(context[key], {data: data});
+ i++;
+ }
+ }
+ }
+ }
+
+ if(i === 0){
+ ret = inverse(this);
+ }
+
+ return ret;
+});
+
+Handlebars.registerHelper('if', function(conditional, options) {
+ var type = toString.call(conditional);
+ if(type === functionType) { conditional = conditional.call(this); }
+
+ if(!conditional || Handlebars.Utils.isEmpty(conditional)) {
+ return options.inverse(this);
+ } else {
+ return options.fn(this);
+ }
+});
+
+Handlebars.registerHelper('unless', function(conditional, options) {
+ return Handlebars.helpers['if'].call(this, conditional, {fn: options.inverse, inverse: options.fn});
+});
+
+Handlebars.registerHelper('with', function(context, options) {
+ var type = toString.call(context);
+ if(type === functionType) { context = context.call(this); }
+
+ if (!Handlebars.Utils.isEmpty(context)) return options.fn(context);
+});
+
+Handlebars.registerHelper('log', function(context, options) {
+ var level = options.data && options.data.level != null ? parseInt(options.data.level, 10) : 1;
+ Handlebars.log(level, context);
+});
+;
+// lib/handlebars/compiler/parser.js
+/* Jison generated parser */
+var handlebars = (function(){
+var parser = {trace: function trace() { },
+yy: {},
+symbols_: {"error":2,"root":3,"program":4,"EOF":5,"simpleInverse":6,"statements":7,"statement":8,"openInverse":9,"closeBlock":10,"openBlock":11,"mustache":12,"partial":13,"CONTENT":14,"COMMENT":15,"OPEN_BLOCK":16,"inMustache":17,"CLOSE":18,"OPEN_INVERSE":19,"OPEN_ENDBLOCK":20,"path":21,"OPEN":22,"OPEN_UNESCAPED":23,"CLOSE_UNESCAPED":24,"OPEN_PARTIAL":25,"partialName":26,"params":27,"hash":28,"dataName":29,"param":30,"STRING":31,"INTEGER":32,"BOOLEAN":33,"hashSegments":34,"hashSegment":35,"ID":36,"EQUALS":37,"DATA":38,"pathSegments":39,"SEP":40,"$accept":0,"$end":1},
+terminals_: {2:"error",5:"EOF",14:"CONTENT",15:"COMMENT",16:"OPEN_BLOCK",18:"CLOSE",19:"OPEN_INVERSE",20:"OPEN_ENDBLOCK",22:"OPEN",23:"OPEN_UNESCAPED",24:"CLOSE_UNESCAPED",25:"OPEN_PARTIAL",31:"STRING",32:"INTEGER",33:"BOOLEAN",36:"ID",37:"EQUALS",38:"DATA",40:"SEP"},
+productions_: [0,[3,2],[4,2],[4,3],[4,2],[4,1],[4,1],[4,0],[7,1],[7,2],[8,3],[8,3],[8,1],[8,1],[8,1],[8,1],[11,3],[9,3],[10,3],[12,3],[12,3],[13,3],[13,4],[6,2],[17,3],[17,2],[17,2],[17,1],[17,1],[27,2],[27,1],[30,1],[30,1],[30,1],[30,1],[30,1],[28,1],[34,2],[34,1],[35,3],[35,3],[35,3],[35,3],[35,3],[26,1],[26,1],[26,1],[29,2],[21,1],[39,3],[39,1]],
+performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$) {
+
+var $0 = $$.length - 1;
+switch (yystate) {
+case 1: return $$[$0-1];
+break;
+case 2: this.$ = new yy.ProgramNode([], $$[$0]);
+break;
+case 3: this.$ = new yy.ProgramNode($$[$0-2], $$[$0]);
+break;
+case 4: this.$ = new yy.ProgramNode($$[$0-1], []);
+break;
+case 5: this.$ = new yy.ProgramNode($$[$0]);
+break;
+case 6: this.$ = new yy.ProgramNode([], []);
+break;
+case 7: this.$ = new yy.ProgramNode([]);
+break;
+case 8: this.$ = [$$[$0]];
+break;
+case 9: $$[$0-1].push($$[$0]); this.$ = $$[$0-1];
+break;
+case 10: this.$ = new yy.BlockNode($$[$0-2], $$[$0-1].inverse, $$[$0-1], $$[$0]);
+break;
+case 11: this.$ = new yy.BlockNode($$[$0-2], $$[$0-1], $$[$0-1].inverse, $$[$0]);
+break;
+case 12: this.$ = $$[$0];
+break;
+case 13: this.$ = $$[$0];
+break;
+case 14: this.$ = new yy.ContentNode($$[$0]);
+break;
+case 15: this.$ = new yy.CommentNode($$[$0]);
+break;
+case 16: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]);
+break;
+case 17: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]);
+break;
+case 18: this.$ = $$[$0-1];
+break;
+case 19:
+ // Parsing out the '&' escape token at this level saves ~500 bytes after min due to the removal of one parser node.
+ this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1], $$[$0-2][2] === '&');
+
+break;
+case 20: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1], true);
+break;
+case 21: this.$ = new yy.PartialNode($$[$0-1]);
+break;
+case 22: this.$ = new yy.PartialNode($$[$0-2], $$[$0-1]);
+break;
+case 23:
+break;
+case 24: this.$ = [[$$[$0-2]].concat($$[$0-1]), $$[$0]];
+break;
+case 25: this.$ = [[$$[$0-1]].concat($$[$0]), null];
+break;
+case 26: this.$ = [[$$[$0-1]], $$[$0]];
+break;
+case 27: this.$ = [[$$[$0]], null];
+break;
+case 28: this.$ = [[$$[$0]], null];
+break;
+case 29: $$[$0-1].push($$[$0]); this.$ = $$[$0-1];
+break;
+case 30: this.$ = [$$[$0]];
+break;
+case 31: this.$ = $$[$0];
+break;
+case 32: this.$ = new yy.StringNode($$[$0]);
+break;
+case 33: this.$ = new yy.IntegerNode($$[$0]);
+break;
+case 34: this.$ = new yy.BooleanNode($$[$0]);
+break;
+case 35: this.$ = $$[$0];
+break;
+case 36: this.$ = new yy.HashNode($$[$0]);
+break;
+case 37: $$[$0-1].push($$[$0]); this.$ = $$[$0-1];
+break;
+case 38: this.$ = [$$[$0]];
+break;
+case 39: this.$ = [$$[$0-2], $$[$0]];
+break;
+case 40: this.$ = [$$[$0-2], new yy.StringNode($$[$0])];
+break;
+case 41: this.$ = [$$[$0-2], new yy.IntegerNode($$[$0])];
+break;
+case 42: this.$ = [$$[$0-2], new yy.BooleanNode($$[$0])];
+break;
+case 43: this.$ = [$$[$0-2], $$[$0]];
+break;
+case 44: this.$ = new yy.PartialNameNode($$[$0]);
+break;
+case 45: this.$ = new yy.PartialNameNode(new yy.StringNode($$[$0]));
+break;
+case 46: this.$ = new yy.PartialNameNode(new yy.IntegerNode($$[$0]));
+break;
+case 47: this.$ = new yy.DataNode($$[$0]);
+break;
+case 48: this.$ = new yy.IdNode($$[$0]);
+break;
+case 49: $$[$0-2].push({part: $$[$0], separator: $$[$0-1]}); this.$ = $$[$0-2];
+break;
+case 50: this.$ = [{part: $$[$0]}];
+break;
+}
+},
+table: [{3:1,4:2,5:[2,7],6:3,7:4,8:6,9:7,11:8,12:9,13:10,14:[1,11],15:[1,12],16:[1,13],19:[1,5],22:[1,14],23:[1,15],25:[1,16]},{1:[3]},{5:[1,17]},{5:[2,6],7:18,8:6,9:7,11:8,12:9,13:10,14:[1,11],15:[1,12],16:[1,13],19:[1,19],20:[2,6],22:[1,14],23:[1,15],25:[1,16]},{5:[2,5],6:20,8:21,9:7,11:8,12:9,13:10,14:[1,11],15:[1,12],16:[1,13],19:[1,5],20:[2,5],22:[1,14],23:[1,15],25:[1,16]},{17:23,18:[1,22],21:24,29:25,36:[1,28],38:[1,27],39:26},{5:[2,8],14:[2,8],15:[2,8],16:[2,8],19:[2,8],20:[2,8],22:[2,8],23:[2,8],25:[2,8]},{4:29,6:3,7:4,8:6,9:7,11:8,12:9,13:10,14:[1,11],15:[1,12],16:[1,13],19:[1,5],20:[2,7],22:[1,14],23:[1,15],25:[1,16]},{4:30,6:3,7:4,8:6,9:7,11:8,12:9,13:10,14:[1,11],15:[1,12],16:[1,13],19:[1,5],20:[2,7],22:[1,14],23:[1,15],25:[1,16]},{5:[2,12],14:[2,12],15:[2,12],16:[2,12],19:[2,12],20:[2,12],22:[2,12],23:[2,12],25:[2,12]},{5:[2,13],14:[2,13],15:[2,13],16:[2,13],19:[2,13],20:[2,13],22:[2,13],23:[2,13],25:[2,13]},{5:[2,14],14:[2,14],15:[2,14],16:[2,14],19:[2,14],20:[2,14],22:[2,14],23:[2,14],25:[2,14]},{5:[2,15],14:[2,15],15:[2,15],16:[2,15],19:[2,15],20:[2,15],22:[2,15],23:[2,15],25:[2,15]},{17:31,21:24,29:25,36:[1,28],38:[1,27],39:26},{17:32,21:24,29:25,36:[1,28],38:[1,27],39:26},{17:33,21:24,29:25,36:[1,28],38:[1,27],39:26},{21:35,26:34,31:[1,36],32:[1,37],36:[1,28],39:26},{1:[2,1]},{5:[2,2],8:21,9:7,11:8,12:9,13:10,14:[1,11],15:[1,12],16:[1,13],19:[1,19],20:[2,2],22:[1,14],23:[1,15],25:[1,16]},{17:23,21:24,29:25,36:[1,28],38:[1,27],39:26},{5:[2,4],7:38,8:6,9:7,11:8,12:9,13:10,14:[1,11],15:[1,12],16:[1,13],19:[1,19],20:[2,4],22:[1,14],23:[1,15],25:[1,16]},{5:[2,9],14:[2,9],15:[2,9],16:[2,9],19:[2,9],20:[2,9],22:[2,9],23:[2,9],25:[2,9]},{5:[2,23],14:[2,23],15:[2,23],16:[2,23],19:[2,23],20:[2,23],22:[2,23],23:[2,23],25:[2,23]},{18:[1,39]},{18:[2,27],21:44,24:[2,27],27:40,28:41,29:48,30:42,31:[1,45],32:[1,46],33:[1,47],34:43,35:49,36:[1,50],38:[1,27],39:26},{18:[2,28],24:[2,28]},{18:[2,48],24:[2,48],31:[2,48],32:[2,48],33:[2,48],36:[2,48],38:[2,48],40:[1,51]},{21:52,36:[1,28],39:26},{18:[2,50],24:[2,50],31:[2,50],32:[2,50],33:[2,50],36:[2,50],38:[2,50],40:[2,50]},{10:53,20:[1,54]},{10:55,20:[1,54]},{18:[1,56]},{18:[1,57]},{24:[1,58]},{18:[1,59],21:60,36:[1,28],39:26},{18:[2,44],36:[2,44]},{18:[2,45],36:[2,45]},{18:[2,46],36:[2,46]},{5:[2,3],8:21,9:7,11:8,12:9,13:10,14:[1,11],15:[1,12],16:[1,13],19:[1,19],20:[2,3],22:[1,14],23:[1,15],25:[1,16]},{14:[2,17],15:[2,17],16:[2,17],19:[2,17],20:[2,17],22:[2,17],23:[2,17],25:[2,17]},{18:[2,25],21:44,24:[2,25],28:61,29:48,30:62,31:[1,45],32:[1,46],33:[1,47],34:43,35:49,36:[1,50],38:[1,27],39:26},{18:[2,26],24:[2,26]},{18:[2,30],24:[2,30],31:[2,30],32:[2,30],33:[2,30],36:[2,30],38:[2,30]},{18:[2,36],24:[2,36],35:63,36:[1,64]},{18:[2,31],24:[2,31],31:[2,31],32:[2,31],33:[2,31],36:[2,31],38:[2,31]},{18:[2,32],24:[2,32],31:[2,32],32:[2,32],33:[2,32],36:[2,32],38:[2,32]},{18:[2,33],24:[2,33],31:[2,33],32:[2,33],33:[2,33],36:[2,33],38:[2,33]},{18:[2,34],24:[2,34],31:[2,34],32:[2,34],33:[2,34],36:[2,34],38:[2,34]},{18:[2,35],24:[2,35],31:[2,35],32:[2,35],33:[2,35],36:[2,35],38:[2,35]},{18:[2,38],24:[2,38],36:[2,38]},{18:[2,50],24:[2,50],31:[2,50],32:[2,50],33:[2,50],36:[2,50],37:[1,65],38:[2,50],40:[2,50]},{36:[1,66]},{18:[2,47],24:[2,47],31:[2,47],32:[2,47],33:[2,47],36:[2,47],38:[2,47]},{5:[2,10],14:[2,10],15:[2,10],16:[2,10],19:[2,10],20:[2,10],22:[2,10],23:[2,10],25:[2,10]},{21:67,36:[1,28],39:26},{5:[2,11],14:[2,11],15:[2,11],16:[2,11],19:[2,11],20:[2,11],22:[2,11],23:[2,11],25:[2,11]},{14:[2,16],15:[2,16],16:[2,16],19:[2,16],20:[2,16],22:[2,16],23:[2,16],25:[2,16]},{5:[2,19],14:[2,19],15:[2,19],16:[2,19],19:[2,19],20:[2,19],22:[2,19],23:[2,19],25:[2,19]},{5:[2,20],14:[2,20],15:[2,20],16:[2,20],19:[2,20],20:[2,20],22:[2,20],23:[2,20],25:[2,20]},{5:[2,21],14:[2,21],15:[2,21],16:[2,21],19:[2,21],20:[2,21],22:[2,21],23:[2,21],25:[2,21]},{18:[1,68]},{18:[2,24],24:[2,24]},{18:[2,29],24:[2,29],31:[2,29],32:[2,29],33:[2,29],36:[2,29],38:[2,29]},{18:[2,37],24:[2,37],36:[2,37]},{37:[1,65]},{21:69,29:73,31:[1,70],32:[1,71],33:[1,72],36:[1,28],38:[1,27],39:26},{18:[2,49],24:[2,49],31:[2,49],32:[2,49],33:[2,49],36:[2,49],38:[2,49],40:[2,49]},{18:[1,74]},{5:[2,22],14:[2,22],15:[2,22],16:[2,22],19:[2,22],20:[2,22],22:[2,22],23:[2,22],25:[2,22]},{18:[2,39],24:[2,39],36:[2,39]},{18:[2,40],24:[2,40],36:[2,40]},{18:[2,41],24:[2,41],36:[2,41]},{18:[2,42],24:[2,42],36:[2,42]},{18:[2,43],24:[2,43],36:[2,43]},{5:[2,18],14:[2,18],15:[2,18],16:[2,18],19:[2,18],20:[2,18],22:[2,18],23:[2,18],25:[2,18]}],
+defaultActions: {17:[2,1]},
+parseError: function parseError(str, hash) {
+ throw new Error(str);
+},
+parse: function parse(input) {
+ var self = this, stack = [0], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1;
+ this.lexer.setInput(input);
+ this.lexer.yy = this.yy;
+ this.yy.lexer = this.lexer;
+ this.yy.parser = this;
+ if (typeof this.lexer.yylloc == "undefined")
+ this.lexer.yylloc = {};
+ var yyloc = this.lexer.yylloc;
+ lstack.push(yyloc);
+ var ranges = this.lexer.options && this.lexer.options.ranges;
+ if (typeof this.yy.parseError === "function")
+ this.parseError = this.yy.parseError;
+ function popStack(n) {
+ stack.length = stack.length - 2 * n;
+ vstack.length = vstack.length - n;
+ lstack.length = lstack.length - n;
+ }
+ function lex() {
+ var token;
+ token = self.lexer.lex() || 1;
+ if (typeof token !== "number") {
+ token = self.symbols_[token] || token;
+ }
+ return token;
+ }
+ var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
+ while (true) {
+ state = stack[stack.length - 1];
+ if (this.defaultActions[state]) {
+ action = this.defaultActions[state];
+ } else {
+ if (symbol === null || typeof symbol == "undefined") {
+ symbol = lex();
+ }
+ action = table[state] && table[state][symbol];
+ }
+ if (typeof action === "undefined" || !action.length || !action[0]) {
+ var errStr = "";
+ if (!recovering) {
+ expected = [];
+ for (p in table[state])
+ if (this.terminals_[p] && p > 2) {
+ expected.push("'" + this.terminals_[p] + "'");
+ }
+ if (this.lexer.showPosition) {
+ errStr = "Parse error on line " + (yylineno + 1) + ":\n" + this.lexer.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
+ } else {
+ errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == 1?"end of input":"'" + (this.terminals_[symbol] || symbol) + "'");
+ }
+ this.parseError(errStr, {text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected});
+ }
+ }
+ if (action[0] instanceof Array && action.length > 1) {
+ throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
+ }
+ switch (action[0]) {
+ case 1:
+ stack.push(symbol);
+ vstack.push(this.lexer.yytext);
+ lstack.push(this.lexer.yylloc);
+ stack.push(action[1]);
+ symbol = null;
+ if (!preErrorSymbol) {
+ yyleng = this.lexer.yyleng;
+ yytext = this.lexer.yytext;
+ yylineno = this.lexer.yylineno;
+ yyloc = this.lexer.yylloc;
+ if (recovering > 0)
+ recovering--;
+ } else {
+ symbol = preErrorSymbol;
+ preErrorSymbol = null;
+ }
+ break;
+ case 2:
+ len = this.productions_[action[1]][1];
+ yyval.$ = vstack[vstack.length - len];
+ yyval._$ = {first_line: lstack[lstack.length - (len || 1)].first_line, last_line: lstack[lstack.length - 1].last_line, first_column: lstack[lstack.length - (len || 1)].first_column, last_column: lstack[lstack.length - 1].last_column};
+ if (ranges) {
+ yyval._$.range = [lstack[lstack.length - (len || 1)].range[0], lstack[lstack.length - 1].range[1]];
+ }
+ r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack);
+ if (typeof r !== "undefined") {
+ return r;
+ }
+ if (len) {
+ stack = stack.slice(0, -1 * len * 2);
+ vstack = vstack.slice(0, -1 * len);
+ lstack = lstack.slice(0, -1 * len);
+ }
+ stack.push(this.productions_[action[1]][0]);
+ vstack.push(yyval.$);
+ lstack.push(yyval._$);
+ newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
+ stack.push(newState);
+ break;
+ case 3:
+ return true;
+ }
+ }
+ return true;
+}
+};
+/* Jison generated lexer */
+var lexer = (function(){
+var lexer = ({EOF:1,
+parseError:function parseError(str, hash) {
+ if (this.yy.parser) {
+ this.yy.parser.parseError(str, hash);
+ } else {
+ throw new Error(str);
+ }
+ },
+setInput:function (input) {
+ this._input = input;
+ this._more = this._less = this.done = false;
+ this.yylineno = this.yyleng = 0;
+ this.yytext = this.matched = this.match = '';
+ this.conditionStack = ['INITIAL'];
+ this.yylloc = {first_line:1,first_column:0,last_line:1,last_column:0};
+ if (this.options.ranges) this.yylloc.range = [0,0];
+ this.offset = 0;
+ return this;
+ },
+input:function () {
+ var ch = this._input[0];
+ this.yytext += ch;
+ this.yyleng++;
+ this.offset++;
+ this.match += ch;
+ this.matched += ch;
+ var lines = ch.match(/(?:\r\n?|\n).*/g);
+ if (lines) {
+ this.yylineno++;
+ this.yylloc.last_line++;
+ } else {
+ this.yylloc.last_column++;
+ }
+ if (this.options.ranges) this.yylloc.range[1]++;
+
+ this._input = this._input.slice(1);
+ return ch;
+ },
+unput:function (ch) {
+ var len = ch.length;
+ var lines = ch.split(/(?:\r\n?|\n)/g);
+
+ this._input = ch + this._input;
+ this.yytext = this.yytext.substr(0, this.yytext.length-len-1);
+ //this.yyleng -= len;
+ this.offset -= len;
+ var oldLines = this.match.split(/(?:\r\n?|\n)/g);
+ this.match = this.match.substr(0, this.match.length-1);
+ this.matched = this.matched.substr(0, this.matched.length-1);
+
+ if (lines.length-1) this.yylineno -= lines.length-1;
+ var r = this.yylloc.range;
+
+ this.yylloc = {first_line: this.yylloc.first_line,
+ last_line: this.yylineno+1,
+ first_column: this.yylloc.first_column,
+ last_column: lines ?
+ (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length:
+ this.yylloc.first_column - len
+ };
+
+ if (this.options.ranges) {
+ this.yylloc.range = [r[0], r[0] + this.yyleng - len];
+ }
+ return this;
+ },
+more:function () {
+ this._more = true;
+ return this;
+ },
+less:function (n) {
+ this.unput(this.match.slice(n));
+ },
+pastInput:function () {
+ var past = this.matched.substr(0, this.matched.length - this.match.length);
+ return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, "");
+ },
+upcomingInput:function () {
+ var next = this.match;
+ if (next.length < 20) {
+ next += this._input.substr(0, 20-next.length);
+ }
+ return (next.substr(0,20)+(next.length > 20 ? '...':'')).replace(/\n/g, "");
+ },
+showPosition:function () {
+ var pre = this.pastInput();
+ var c = new Array(pre.length + 1).join("-");
+ return pre + this.upcomingInput() + "\n" + c+"^";
+ },
+next:function () {
+ if (this.done) {
+ return this.EOF;
+ }
+ if (!this._input) this.done = true;
+
+ var token,
+ match,
+ tempMatch,
+ index,
+ col,
+ lines;
+ if (!this._more) {
+ this.yytext = '';
+ this.match = '';
+ }
+ var rules = this._currentRules();
+ for (var i=0;i < rules.length; i++) {
+ tempMatch = this._input.match(this.rules[rules[i]]);
+ if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
+ match = tempMatch;
+ index = i;
+ if (!this.options.flex) break;
+ }
+ }
+ if (match) {
+ lines = match[0].match(/(?:\r\n?|\n).*/g);
+ if (lines) this.yylineno += lines.length;
+ this.yylloc = {first_line: this.yylloc.last_line,
+ last_line: this.yylineno+1,
+ first_column: this.yylloc.last_column,
+ last_column: lines ? lines[lines.length-1].length-lines[lines.length-1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length};
+ this.yytext += match[0];
+ this.match += match[0];
+ this.matches = match;
+ this.yyleng = this.yytext.length;
+ if (this.options.ranges) {
+ this.yylloc.range = [this.offset, this.offset += this.yyleng];
+ }
+ this._more = false;
+ this._input = this._input.slice(match[0].length);
+ this.matched += match[0];
+ token = this.performAction.call(this, this.yy, this, rules[index],this.conditionStack[this.conditionStack.length-1]);
+ if (this.done && this._input) this.done = false;
+ if (token) return token;
+ else return;
+ }
+ if (this._input === "") {
+ return this.EOF;
+ } else {
+ return this.parseError('Lexical error on line '+(this.yylineno+1)+'. Unrecognized text.\n'+this.showPosition(),
+ {text: "", token: null, line: this.yylineno});
+ }
+ },
+lex:function lex() {
+ var r = this.next();
+ if (typeof r !== 'undefined') {
+ return r;
+ } else {
+ return this.lex();
+ }
+ },
+begin:function begin(condition) {
+ this.conditionStack.push(condition);
+ },
+popState:function popState() {
+ return this.conditionStack.pop();
+ },
+_currentRules:function _currentRules() {
+ return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules;
+ },
+topState:function () {
+ return this.conditionStack[this.conditionStack.length-2];
+ },
+pushState:function begin(condition) {
+ this.begin(condition);
+ }});
+lexer.options = {};
+lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) {
+
+var YYSTATE=YY_START
+switch($avoiding_name_collisions) {
+case 0: yy_.yytext = "\\"; return 14;
+break;
+case 1:
+ if(yy_.yytext.slice(-1) !== "\\") this.begin("mu");
+ if(yy_.yytext.slice(-1) === "\\") yy_.yytext = yy_.yytext.substr(0,yy_.yyleng-1), this.begin("emu");
+ if(yy_.yytext) return 14;
+
+break;
+case 2: return 14;
+break;
+case 3:
+ if(yy_.yytext.slice(-1) !== "\\") this.popState();
+ if(yy_.yytext.slice(-1) === "\\") yy_.yytext = yy_.yytext.substr(0,yy_.yyleng-1);
+ return 14;
+
+break;
+case 4: yy_.yytext = yy_.yytext.substr(0, yy_.yyleng-4); this.popState(); return 15;
+break;
+case 5: return 25;
+break;
+case 6: return 16;
+break;
+case 7: return 20;
+break;
+case 8: return 19;
+break;
+case 9: return 19;
+break;
+case 10: return 23;
+break;
+case 11: return 22;
+break;
+case 12: this.popState(); this.begin('com');
+break;
+case 13: yy_.yytext = yy_.yytext.substr(3,yy_.yyleng-5); this.popState(); return 15;
+break;
+case 14: return 22;
+break;
+case 15: return 37;
+break;
+case 16: return 36;
+break;
+case 17: return 36;
+break;
+case 18: return 40;
+break;
+case 19: /*ignore whitespace*/
+break;
+case 20: this.popState(); return 24;
+break;
+case 21: this.popState(); return 18;
+break;
+case 22: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\"/g,'"'); return 31;
+break;
+case 23: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\'/g,"'"); return 31;
+break;
+case 24: return 38;
+break;
+case 25: return 33;
+break;
+case 26: return 33;
+break;
+case 27: return 32;
+break;
+case 28: return 36;
+break;
+case 29: yy_.yytext = yy_.yytext.substr(1, yy_.yyleng-2); return 36;
+break;
+case 30: return 'INVALID';
+break;
+case 31: return 5;
+break;
+}
+};
+lexer.rules = [/^(?:\\\\(?=(\{\{)))/,/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|$)))/,/^(?:[\s\S]*?--\}\})/,/^(?:\{\{>)/,/^(?:\{\{#)/,/^(?:\{\{\/)/,/^(?:\{\{\^)/,/^(?:\{\{\s*else\b)/,/^(?:\{\{\{)/,/^(?:\{\{&)/,/^(?:\{\{!--)/,/^(?:\{\{![\s\S]*?\}\})/,/^(?:\{\{)/,/^(?:=)/,/^(?:\.(?=[}\/ ]))/,/^(?:\.\.)/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}\}\})/,/^(?:\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@)/,/^(?:true(?=[}\s]))/,/^(?:false(?=[}\s]))/,/^(?:-?[0-9]+(?=[}\s]))/,/^(?:[^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=[=}\s\/.]))/,/^(?:\[[^\]]*\])/,/^(?:.)/,/^(?:$)/];
+lexer.conditions = {"mu":{"rules":[5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31],"inclusive":false},"emu":{"rules":[3],"inclusive":false},"com":{"rules":[4],"inclusive":false},"INITIAL":{"rules":[0,1,2,31],"inclusive":true}};
+return lexer;})()
+parser.lexer = lexer;
+function Parser () { this.yy = {}; }Parser.prototype = parser;parser.Parser = Parser;
+return new Parser;
+})();;
+// lib/handlebars/compiler/base.js
+
+Handlebars.Parser = handlebars;
+
+Handlebars.parse = function(input) {
+
+ // Just return if an already-compile AST was passed in.
+ if(input.constructor === Handlebars.AST.ProgramNode) { return input; }
+
+ Handlebars.Parser.yy = Handlebars.AST;
+ return Handlebars.Parser.parse(input);
+};
+;
+// lib/handlebars/compiler/ast.js
+Handlebars.AST = {};
+
+Handlebars.AST.ProgramNode = function(statements, inverse) {
+ this.type = "program";
+ this.statements = statements;
+ if(inverse) { this.inverse = new Handlebars.AST.ProgramNode(inverse); }
+};
+
+Handlebars.AST.MustacheNode = function(rawParams, hash, unescaped) {
+ this.type = "mustache";
+ this.escaped = !unescaped;
+ this.hash = hash;
+
+ var id = this.id = rawParams[0];
+ var params = this.params = rawParams.slice(1);
+
+ // a mustache is an eligible helper if:
+ // * its id is simple (a single part, not `this` or `..`)
+ var eligibleHelper = this.eligibleHelper = id.isSimple;
+
+ // a mustache is definitely a helper if:
+ // * it is an eligible helper, and
+ // * it has at least one parameter or hash segment
+ this.isHelper = eligibleHelper && (params.length || hash);
+
+ // if a mustache is an eligible helper but not a definite
+ // helper, it is ambiguous, and will be resolved in a later
+ // pass or at runtime.
+};
+
+Handlebars.AST.PartialNode = function(partialName, context) {
+ this.type = "partial";
+ this.partialName = partialName;
+ this.context = context;
+};
+
+Handlebars.AST.BlockNode = function(mustache, program, inverse, close) {
+ var verifyMatch = function(open, close) {
+ if(open.original !== close.original) {
+ throw new Handlebars.Exception(open.original + " doesn't match " + close.original);
+ }
+ };
+
+ verifyMatch(mustache.id, close);
+ this.type = "block";
+ this.mustache = mustache;
+ this.program = program;
+ this.inverse = inverse;
+
+ if (this.inverse && !this.program) {
+ this.isInverse = true;
+ }
+};
+
+Handlebars.AST.ContentNode = function(string) {
+ this.type = "content";
+ this.string = string;
+};
+
+Handlebars.AST.HashNode = function(pairs) {
+ this.type = "hash";
+ this.pairs = pairs;
+};
+
+Handlebars.AST.IdNode = function(parts) {
+ this.type = "ID";
+
+ var original = "",
+ dig = [],
+ depth = 0;
+
+ for(var i=0,l=parts.length; i<l; i++) {
+ var part = parts[i].part;
+ original += (parts[i].separator || '') + part;
+
+ if (part === ".." || part === "." || part === "this") {
+ if (dig.length > 0) { throw new Handlebars.Exception("Invalid path: " + original); }
+ else if (part === "..") { depth++; }
+ else { this.isScoped = true; }
+ }
+ else { dig.push(part); }
+ }
+
+ this.original = original;
+ this.parts = dig;
+ this.string = dig.join('.');
+ this.depth = depth;
+
+ // an ID is simple if it only has one part, and that part is not
+ // `..` or `this`.
+ this.isSimple = parts.length === 1 && !this.isScoped && depth === 0;
+
+ this.stringModeValue = this.string;
+};
+
+Handlebars.AST.PartialNameNode = function(name) {
+ this.type = "PARTIAL_NAME";
+ this.name = name.original;
+};
+
+Handlebars.AST.DataNode = function(id) {
+ this.type = "DATA";
+ this.id = id;
+};
+
+Handlebars.AST.StringNode = function(string) {
+ this.type = "STRING";
+ this.original =
+ this.string =
+ this.stringModeValue = string;
+};
+
+Handlebars.AST.IntegerNode = function(integer) {
+ this.type = "INTEGER";
+ this.original =
+ this.integer = integer;
+ this.stringModeValue = Number(integer);
+};
+
+Handlebars.AST.BooleanNode = function(bool) {
+ this.type = "BOOLEAN";
+ this.bool = bool;
+ this.stringModeValue = bool === "true";
+};
+
+Handlebars.AST.CommentNode = function(comment) {
+ this.type = "comment";
+ this.comment = comment;
+};
+;
+// lib/handlebars/utils.js
+
+var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack'];
+
+Handlebars.Exception = function(message) {
+ var tmp = Error.prototype.constructor.apply(this, arguments);
+
+ // Unfortunately errors are not enumerable in Chrome (at least), so `for prop in tmp` doesn't work.
+ for (var idx = 0; idx < errorProps.length; idx++) {
+ this[errorProps[idx]] = tmp[errorProps[idx]];
+ }
+};
+Handlebars.Exception.prototype = new Error();
+
+// Build out our basic SafeString type
+Handlebars.SafeString = function(string) {
+ this.string = string;
+};
+Handlebars.SafeString.prototype.toString = function() {
+ return this.string.toString();
+};
+
+var escape = {
+ "&": "&",
+ "<": "<",
+ ">": ">",
+ '"': """,
+ "'": "'",
+ "`": "`"
+};
+
+var badChars = /[&<>"'`]/g;
+var possible = /[&<>"'`]/;
+
+var escapeChar = function(chr) {
+ return escape[chr] || "&";
+};
+
+Handlebars.Utils = {
+ extend: function(obj, value) {
+ for(var key in value) {
+ if(value.hasOwnProperty(key)) {
+ obj[key] = value[key];
+ }
+ }
+ },
+
+ escapeExpression: function(string) {
+ // don't escape SafeStrings, since they're already safe
+ if (string instanceof Handlebars.SafeString) {
+ return string.toString();
+ } else if (string == null || string === false) {
+ return "";
+ }
+
+ // Force a string conversion as this will be done by the append regardless and
+ // the regex test will do this transparently behind the scenes, causing issues if
+ // an object's to string has escaped characters in it.
+ string = string.toString();
+
+ if(!possible.test(string)) { return string; }
+ return string.replace(badChars, escapeChar);
+ },
+
+ isEmpty: function(value) {
+ if (!value && value !== 0) {
+ return true;
+ } else if(toString.call(value) === "[object Array]" && value.length === 0) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+};
+;
+// lib/handlebars/compiler/compiler.js
+
+/*jshint eqnull:true*/
+var Compiler = Handlebars.Compiler = function() {};
+var JavaScriptCompiler = Handlebars.JavaScriptCompiler = function() {};
+
+// the foundHelper register will disambiguate helper lookup from finding a
+// function in a context. This is necessary for mustache compatibility, which
+// requires that context functions in blocks are evaluated by blockHelperMissing,
+// and then proceed as if the resulting value was provided to blockHelperMissing.
+
+Compiler.prototype = {
+ compiler: Compiler,
+
+ disassemble: function() {
+ var opcodes = this.opcodes, opcode, out = [], params, param;
+
+ for (var i=0, l=opcodes.length; i<l; i++) {
+ opcode = opcodes[i];
+
+ if (opcode.opcode === 'DECLARE') {
+ out.push("DECLARE " + opcode.name + "=" + opcode.value);
+ } else {
+ params = [];
+ for (var j=0; j<opcode.args.length; j++) {
+ param = opcode.args[j];
+ if (typeof param === "string") {
+ param = "\"" + param.replace("\n", "\\n") + "\"";
+ }
+ params.push(param);
+ }
+ out.push(opcode.opcode + " " + params.join(" "));
+ }
+ }
+
+ return out.join("\n");
+ },
+ equals: function(other) {
+ var len = this.opcodes.length;
+ if (other.opcodes.length !== len) {
+ return false;
+ }
+
+ for (var i = 0; i < len; i++) {
+ var opcode = this.opcodes[i],
+ otherOpcode = other.opcodes[i];
+ if (opcode.opcode !== otherOpcode.opcode || opcode.args.length !== otherOpcode.args.length) {
+ return false;
+ }
+ for (var j = 0; j < opcode.args.length; j++) {
+ if (opcode.args[j] !== otherOpcode.args[j]) {
+ return false;
+ }
+ }
+ }
+
+ len = this.children.length;
+ if (other.children.length !== len) {
+ return false;
+ }
+ for (i = 0; i < len; i++) {
+ if (!this.children[i].equals(other.children[i])) {
+ return false;
+ }
+ }
+
+ return true;
+ },
+
+ guid: 0,
+
+ compile: function(program, options) {
+ this.children = [];
+ this.depths = {list: []};
+ this.options = options;
+
+ // These changes will propagate to the other compiler components
+ var knownHelpers = this.options.knownHelpers;
+ this.options.knownHelpers = {
+ 'helperMissing': true,
+ 'blockHelperMissing': true,
+ 'each': true,
+ 'if': true,
+ 'unless': true,
+ 'with': true,
+ 'log': true
+ };
+ if (knownHelpers) {
+ for (var name in knownHelpers) {
+ this.options.knownHelpers[name] = knownHelpers[name];
+ }
+ }
+
+ return this.program(program);
+ },
+
+ accept: function(node) {
+ return this[node.type](node);
+ },
+
+ program: function(program) {
+ var statements = program.statements, statement;
+ this.opcodes = [];
+
+ for(var i=0, l=statements.length; i<l; i++) {
+ statement = statements[i];
+ this[statement.type](statement);
+ }
+ this.isSimple = l === 1;
+
+ this.depths.list = this.depths.list.sort(function(a, b) {
+ return a - b;
+ });
+
+ return this;
+ },
+
+ compileProgram: function(program) {
+ var result = new this.compiler().compile(program, this.options);
+ var guid = this.guid++, depth;
+
+ this.usePartial = this.usePartial || result.usePartial;
+
+ this.children[guid] = result;
+
+ for(var i=0, l=result.depths.list.length; i<l; i++) {
+ depth = result.depths.list[i];
+
+ if(depth < 2) { continue; }
+ else { this.addDepth(depth - 1); }
+ }
+
+ return guid;
+ },
+
+ block: function(block) {
+ var mustache = block.mustache,
+ program = block.program,
+ inverse = block.inverse;
+
+ if (program) {
+ program = this.compileProgram(program);
+ }
+
+ if (inverse) {
+ inverse = this.compileProgram(inverse);
+ }
+
+ var type = this.classifyMustache(mustache);
+
+ if (type === "helper") {
+ this.helperMustache(mustache, program, inverse);
+ } else if (type === "simple") {
+ this.simpleMustache(mustache);
+
+ // now that the simple mustache is resolved, we need to
+ // evaluate it by executing `blockHelperMissing`
+ this.opcode('pushProgram', program);
+ this.opcode('pushProgram', inverse);
+ this.opcode('emptyHash');
+ this.opcode('blockValue');
+ } else {
+ this.ambiguousMustache(mustache, program, inverse);
+
+ // now that the simple mustache is resolved, we need to
+ // evaluate it by executing `blockHelperMissing`
+ this.opcode('pushProgram', program);
+ this.opcode('pushProgram', inverse);
+ this.opcode('emptyHash');
+ this.opcode('ambiguousBlockValue');
+ }
+
+ this.opcode('append');
+ },
+
+ hash: function(hash) {
+ var pairs = hash.pairs, pair, val;
+
+ this.opcode('pushHash');
+
+ for(var i=0, l=pairs.length; i<l; i++) {
+ pair = pairs[i];
+ val = pair[1];
+
+ if (this.options.stringParams) {
+ if(val.depth) {
+ this.addDepth(val.depth);
+ }
+ this.opcode('getContext', val.depth || 0);
+ this.opcode('pushStringParam', val.stringModeValue, val.type);
+ } else {
+ this.accept(val);
+ }
+
+ this.opcode('assignToHash', pair[0]);
+ }
+ this.opcode('popHash');
+ },
+
+ partial: function(partial) {
+ var partialName = partial.partialName;
+ this.usePartial = true;
+
+ if(partial.context) {
+ this.ID(partial.context);
+ } else {
+ this.opcode('push', 'depth0');
+ }
+
+ this.opcode('invokePartial', partialName.name);
+ this.opcode('append');
+ },
+
+ content: function(content) {
+ this.opcode('appendContent', content.string);
+ },
+
+ mustache: function(mustache) {
+ var options = this.options;
+ var type = this.classifyMustache(mustache);
+
+ if (type === "simple") {
+ this.simpleMustache(mustache);
+ } else if (type === "helper") {
+ this.helperMustache(mustache);
+ } else {
+ this.ambiguousMustache(mustache);
+ }
+
+ if(mustache.escaped && !options.noEscape) {
+ this.opcode('appendEscaped');
+ } else {
+ this.opcode('append');
+ }
+ },
+
+ ambiguousMustache: function(mustache, program, inverse) {
+ var id = mustache.id,
+ name = id.parts[0],
+ isBlock = program != null || inverse != null;
+
+ this.opcode('getContext', id.depth);
+
+ this.opcode('pushProgram', program);
+ this.opcode('pushProgram', inverse);
+
+ this.opcode('invokeAmbiguous', name, isBlock);
+ },
+
+ simpleMustache: function(mustache) {
+ var id = mustache.id;
+
+ if (id.type === 'DATA') {
+ this.DATA(id);
+ } else if (id.parts.length) {
+ this.ID(id);
+ } else {
+ // Simplified ID for `this`
+ this.addDepth(id.depth);
+ this.opcode('getContext', id.depth);
+ this.opcode('pushContext');
+ }
+
+ this.opcode('resolvePossibleLambda');
+ },
+
+ helperMustache: function(mustache, program, inverse) {
+ var params = this.setupFullMustacheParams(mustache, program, inverse),
+ name = mustache.id.parts[0];
+
+ if (this.options.knownHelpers[name]) {
+ this.opcode('invokeKnownHelper', params.length, name);
+ } else if (this.options.knownHelpersOnly) {
+ throw new Error("You specified knownHelpersOnly, but used the unknown helper " + name);
+ } else {
+ this.opcode('invokeHelper', params.length, name);
+ }
+ },
+
+ ID: function(id) {
+ this.addDepth(id.depth);
+ this.opcode('getContext', id.depth);
+
+ var name = id.parts[0];
+ if (!name) {
+ this.opcode('pushContext');
+ } else {
+ this.opcode('lookupOnContext', id.parts[0]);
+ }
+
+ for(var i=1, l=id.parts.length; i<l; i++) {
+ this.opcode('lookup', id.parts[i]);
+ }
+ },
+
+ DATA: function(data) {
+ this.options.data = true;
+ if (data.id.isScoped || data.id.depth) {
+ throw new Handlebars.Exception('Scoped data references are not supported: ' + data.original);
+ }
+
+ this.opcode('lookupData');
+ var parts = data.id.parts;
+ for(var i=0, l=parts.length; i<l; i++) {
+ this.opcode('lookup', parts[i]);
+ }
+ },
+
+ STRING: function(string) {
+ this.opcode('pushString', string.string);
+ },
+
+ INTEGER: function(integer) {
+ this.opcode('pushLiteral', integer.integer);
+ },
+
+ BOOLEAN: function(bool) {
+ this.opcode('pushLiteral', bool.bool);
+ },
+
+ comment: function() {},
+
+ // HELPERS
+ opcode: function(name) {
+ this.opcodes.push({ opcode: name, args: [].slice.call(arguments, 1) });
+ },
+
+ declare: function(name, value) {
+ this.opcodes.push({ opcode: 'DECLARE', name: name, value: value });
+ },
+
+ addDepth: function(depth) {
+ if(isNaN(depth)) { throw new Error("EWOT"); }
+ if(depth === 0) { return; }
+
+ if(!this.depths[depth]) {
+ this.depths[depth] = true;
+ this.depths.list.push(depth);
+ }
+ },
+
+ classifyMustache: function(mustache) {
+ var isHelper = mustache.isHelper;
+ var isEligible = mustache.eligibleHelper;
+ var options = this.options;
+
+ // if ambiguous, we can possibly resolve the ambiguity now
+ if (isEligible && !isHelper) {
+ var name = mustache.id.parts[0];
+
+ if (options.knownHelpers[name]) {
+ isHelper = true;
+ } else if (options.knownHelpersOnly) {
+ isEligible = false;
+ }
+ }
+
+ if (isHelper) { return "helper"; }
+ else if (isEligible) { return "ambiguous"; }
+ else { return "simple"; }
+ },
+
+ pushParams: function(params) {
+ var i = params.length, param;
+
+ while(i--) {
+ param = params[i];
+
+ if(this.options.stringParams) {
+ if(param.depth) {
+ this.addDepth(param.depth);
+ }
+
+ this.opcode('getContext', param.depth || 0);
+ this.opcode('pushStringParam', param.stringModeValue, param.type);
+ } else {
+ this[param.type](param);
+ }
+ }
+ },
+
+ setupMustacheParams: function(mustache) {
+ var params = mustache.params;
+ this.pushParams(params);
+
+ if(mustache.hash) {
+ this.hash(mustache.hash);
+ } else {
+ this.opcode('emptyHash');
+ }
+
+ return params;
+ },
+
+ // this will replace setupMustacheParams when we're done
+ setupFullMustacheParams: function(mustache, program, inverse) {
+ var params = mustache.params;
+ this.pushParams(params);
+
+ this.opcode('pushProgram', program);
+ this.opcode('pushProgram', inverse);
+
+ if(mustache.hash) {
+ this.hash(mustache.hash);
+ } else {
+ this.opcode('emptyHash');
+ }
+
+ return params;
+ }
+};
+
+var Literal = function(value) {
+ this.value = value;
+};
+
+JavaScriptCompiler.prototype = {
+ // PUBLIC API: You can override these methods in a subclass to provide
+ // alternative compiled forms for name lookup and buffering semantics
+ nameLookup: function(parent, name /* , type*/) {
+ if (/^[0-9]+$/.test(name)) {
+ return parent + "[" + name + "]";
+ } else if (JavaScriptCompiler.isValidJavaScriptVariableName(name)) {
+ return parent + "." + name;
+ }
+ else {
+ return parent + "['" + name + "']";
+ }
+ },
+
+ appendToBuffer: function(string) {
+ if (this.environment.isSimple) {
+ return "return " + string + ";";
+ } else {
+ return {
+ appendToBuffer: true,
+ content: string,
+ toString: function() { return "buffer += " + string + ";"; }
+ };
+ }
+ },
+
+ initializeBuffer: function() {
+ return this.quotedString("");
+ },
+
+ namespace: "Handlebars",
+ // END PUBLIC API
+
+ compile: function(environment, options, context, asObject) {
+ this.environment = environment;
+ this.options = options || {};
+
+ Handlebars.log(Handlebars.logger.DEBUG, this.environment.disassemble() + "\n\n");
+
+ this.name = this.environment.name;
+ this.isChild = !!context;
+ this.context = context || {
+ programs: [],
+ environments: [],
+ aliases: { }
+ };
+
+ this.preamble();
+
+ this.stackSlot = 0;
+ this.stackVars = [];
+ this.registers = { list: [] };
+ this.compileStack = [];
+ this.inlineStack = [];
+
+ this.compileChildren(environment, options);
+
+ var opcodes = environment.opcodes, opcode;
+
+ this.i = 0;
+
+ for(l=opcodes.length; this.i<l; this.i++) {
+ opcode = opcodes[this.i];
+
+ if(opcode.opcode === 'DECLARE') {
+ this[opcode.name] = opcode.value;
+ } else {
+ this[opcode.opcode].apply(this, opcode.args);
+ }
+ }
+
+ return this.createFunctionContext(asObject);
+ },
+
+ nextOpcode: function() {
+ var opcodes = this.environment.opcodes;
+ return opcodes[this.i + 1];
+ },
+
+ eat: function() {
+ this.i = this.i + 1;
+ },
+
+ preamble: function() {
+ var out = [];
+
+ if (!this.isChild) {
+ var namespace = this.namespace;
+
+ var copies = "helpers = this.merge(helpers, " + namespace + ".helpers);";
+ if (this.environment.usePartial) { copies = copies + " partials = this.merge(partials, " + namespace + ".partials);"; }
+ if (this.options.data) { copies = copies + " data = data || {};"; }
+ out.push(copies);
+ } else {
+ out.push('');
+ }
+
+ if (!this.environment.isSimple) {
+ out.push(", buffer = " + this.initializeBuffer());
+ } else {
+ out.push("");
+ }
+
+ // track the last context pushed into place to allow skipping the
+ // getContext opcode when it would be a noop
+ this.lastContext = 0;
+ this.source = out;
+ },
+
+ createFunctionContext: function(asObject) {
+ var locals = this.stackVars.concat(this.registers.list);
+
+ if(locals.length > 0) {
+ this.source[1] = this.source[1] + ", " + locals.join(", ");
+ }
+
+ // Generate minimizer alias mappings
+ if (!this.isChild) {
+ for (var alias in this.context.aliases) {
+ if (this.context.aliases.hasOwnProperty(alias)) {
+ this.source[1] = this.source[1] + ', ' + alias + '=' + this.context.aliases[alias];
+ }
+ }
+ }
+
+ if (this.source[1]) {
+ this.source[1] = "var " + this.source[1].substring(2) + ";";
+ }
+
+ // Merge children
+ if (!this.isChild) {
+ this.source[1] += '\n' + this.context.programs.join('\n') + '\n';
+ }
+
+ if (!this.environment.isSimple) {
+ this.source.push("return buffer;");
+ }
+
+ var params = this.isChild ? ["depth0", "data"] : ["Handlebars", "depth0", "helpers", "partials", "data"];
+
+ for(var i=0, l=this.environment.depths.list.length; i<l; i++) {
+ params.push("depth" + this.environment.depths.list[i]);
+ }
+
+ // Perform a second pass over the output to merge content when possible
+ var source = this.mergeSource();
+
+ if (!this.isChild) {
+ var revision = Handlebars.COMPILER_REVISION,
+ versions = Handlebars.REVISION_CHANGES[revision];
+ source = "this.compilerInfo = ["+revision+",'"+versions+"'];\n"+source;
+ }
+
+ if (asObject) {
+ params.push(source);
+
+ return Function.apply(this, params);
+ } else {
+ var functionSource = 'function ' + (this.name || '') + '(' + params.join(',') + ') {\n ' + source + '}';
+ Handlebars.log(Handlebars.logger.DEBUG, functionSource + "\n\n");
+ return functionSource;
+ }
+ },
+ mergeSource: function() {
+ // WARN: We are not handling the case where buffer is still populated as the source should
+ // not have buffer append operations as their final action.
+ var source = '',
+ buffer;
+ for (var i = 0, len = this.source.length; i < len; i++) {
+ var line = this.source[i];
+ if (line.appendToBuffer) {
+ if (buffer) {
+ buffer = buffer + '\n + ' + line.content;
+ } else {
+ buffer = line.content;
+ }
+ } else {
+ if (buffer) {
+ source += 'buffer += ' + buffer + ';\n ';
+ buffer = undefined;
+ }
+ source += line + '\n ';
+ }
+ }
+ return source;
+ },
+
+ // [blockValue]
+ //
+ // On stack, before: hash, inverse, program, value
+ // On stack, after: return value of blockHelperMissing
+ //
+ // The purpose of this opcode is to take a block of the form
+ // `{{#foo}}...{{/foo}}`, resolve the value of `foo`, and
+ // replace it on the stack with the result of properly
+ // invoking blockHelperMissing.
+ blockValue: function() {
+ this.context.aliases.blockHelperMissing = 'helpers.blockHelperMissing';
+
+ var params = ["depth0"];
+ this.setupParams(0, params);
+
+ this.replaceStack(function(current) {
+ params.splice(1, 0, current);
+ return "blockHelperMissing.call(" + params.join(", ") + ")";
+ });
+ },
+
+ // [ambiguousBlockValue]
+ //
+ // On stack, before: hash, inverse, program, value
+ // Compiler value, before: lastHelper=value of last found helper, if any
+ // On stack, after, if no lastHelper: same as [blockValue]
+ // On stack, after, if lastHelper: value
+ ambiguousBlockValue: function() {
+ this.context.aliases.blockHelperMissing = 'helpers.blockHelperMissing';
+
+ var params = ["depth0"];
+ this.setupParams(0, params);
+
+ var current = this.topStack();
+ params.splice(1, 0, current);
+
+ // Use the options value generated from the invocation
+ params[params.length-1] = 'options';
+
+ this.source.push("if (!" + this.lastHelper + ") { " + current + " = blockHelperMissing.call(" + params.join(", ") + "); }");
+ },
+
+ // [appendContent]
+ //
+ // On stack, before: ...
+ // On stack, after: ...
+ //
+ // Appends the string value of `content` to the current buffer
+ appendContent: function(content) {
+ this.source.push(this.appendToBuffer(this.quotedString(content)));
+ },
+
+ // [append]
+ //
+ // On stack, before: value, ...
+ // On stack, after: ...
+ //
+ // Coerces `value` to a String and appends it to the current buffer.
+ //
+ // If `value` is truthy, or 0, it is coerced into a string and appended
+ // Otherwise, the empty string is appended
+ append: function() {
+ // Force anything that is inlined onto the stack so we don't have duplication
+ // when we examine local
+ this.flushInline();
+ var local = this.popStack();
+ this.source.push("if(" + local + " || " + local + " === 0) { " + this.appendToBuffer(local) + " }");
+ if (this.environment.isSimple) {
+ this.source.push("else { " + this.appendToBuffer("''") + " }");
+ }
+ },
+
+ // [appendEscaped]
+ //
+ // On stack, before: value, ...
+ // On stack, after: ...
+ //
+ // Escape `value` and append it to the buffer
+ appendEscaped: function() {
+ this.context.aliases.escapeExpression = 'this.escapeExpression';
+
+ this.source.push(this.appendToBuffer("escapeExpression(" + this.popStack() + ")"));
+ },
+
+ // [getContext]
+ //
+ // On stack, before: ...
+ // On stack, after: ...
+ // Compiler value, after: lastContext=depth
+ //
+ // Set the value of the `lastContext` compiler value to the depth
+ getContext: function(depth) {
+ if(this.lastContext !== depth) {
+ this.lastContext = depth;
+ }
+ },
+
+ // [lookupOnContext]
+ //
+ // On stack, before: ...
+ // On stack, after: currentContext[name], ...
+ //
+ // Looks up the value of `name` on the current context and pushes
+ // it onto the stack.
+ lookupOnContext: function(name) {
+ this.push(this.nameLookup('depth' + this.lastContext, name, 'context'));
+ },
+
+ // [pushContext]
+ //
+ // On stack, before: ...
+ // On stack, after: currentContext, ...
+ //
+ // Pushes the value of the current context onto the stack.
+ pushContext: function() {
+ this.pushStackLiteral('depth' + this.lastContext);
+ },
+
+ // [resolvePossibleLambda]
+ //
+ // On stack, before: value, ...
+ // On stack, after: resolved value, ...
+ //
+ // If the `value` is a lambda, replace it on the stack by
+ // the return value of the lambda
+ resolvePossibleLambda: function() {
+ this.context.aliases.functionType = '"function"';
+
+ this.replaceStack(function(current) {
+ return "typeof " + current + " === functionType ? " + current + ".apply(depth0) : " + current;
+ });
+ },
+
+ // [lookup]
+ //
+ // On stack, before: value, ...
+ // On stack, after: value[name], ...
+ //
+ // Replace the value on the stack with the result of looking
+ // up `name` on `value`
+ lookup: function(name) {
+ this.replaceStack(function(current) {
+ return current + " == null || " + current + " === false ? " + current + " : " + this.nameLookup(current, name, 'context');
+ });
+ },
+
+ // [lookupData]
+ //
+ // On stack, before: ...
+ // On stack, after: data[id], ...
+ //
+ // Push the result of looking up `id` on the current data
+ lookupData: function(id) {
+ this.push('data');
+ },
+
+ // [pushStringParam]
+ //
+ // On stack, before: ...
+ // On stack, after: string, currentContext, ...
+ //
+ // This opcode is designed for use in string mode, which
+ // provides the string value of a parameter along with its
+ // depth rather than resolving it immediately.
+ pushStringParam: function(string, type) {
+ this.pushStackLiteral('depth' + this.lastContext);
+
+ this.pushString(type);
+
+ if (typeof string === 'string') {
+ this.pushString(string);
+ } else {
+ this.pushStackLiteral(string);
+ }
+ },
+
+ emptyHash: function() {
+ this.pushStackLiteral('{}');
+
+ if (this.options.stringParams) {
+ this.register('hashTypes', '{}');
+ this.register('hashContexts', '{}');
+ }
+ },
+ pushHash: function() {
+ this.hash = {values: [], types: [], contexts: []};
+ },
+ popHash: function() {
+ var hash = this.hash;
+ this.hash = undefined;
+
+ if (this.options.stringParams) {
+ this.register('hashContexts', '{' + hash.contexts.join(',') + '}');
+ this.register('hashTypes', '{' + hash.types.join(',') + '}');
+ }
+ this.push('{\n ' + hash.values.join(',\n ') + '\n }');
+ },
+
+ // [pushString]
+ //
+ // On stack, before: ...
+ // On stack, after: quotedString(string), ...
+ //
+ // Push a quoted version of `string` onto the stack
+ pushString: function(string) {
+ this.pushStackLiteral(this.quotedString(string));
+ },
+
+ // [push]
+ //
+ // On stack, before: ...
+ // On stack, after: expr, ...
+ //
+ // Push an expression onto the stack
+ push: function(expr) {
+ this.inlineStack.push(expr);
+ return expr;
+ },
+
+ // [pushLiteral]
+ //
+ // On stack, before: ...
+ // On stack, after: value, ...
+ //
+ // Pushes a value onto the stack. This operation prevents
+ // the compiler from creating a temporary variable to hold
+ // it.
+ pushLiteral: function(value) {
+ this.pushStackLiteral(value);
+ },
+
+ // [pushProgram]
+ //
+ // On stack, before: ...
+ // On stack, after: program(guid), ...
+ //
+ // Push a program expression onto the stack. This takes
+ // a compile-time guid and converts it into a runtime-accessible
+ // expression.
+ pushProgram: function(guid) {
+ if (guid != null) {
+ this.pushStackLiteral(this.programExpression(guid));
+ } else {
+ this.pushStackLiteral(null);
+ }
+ },
+
+ // [invokeHelper]
+ //
+ // On stack, before: hash, inverse, program, params..., ...
+ // On stack, after: result of helper invocation
+ //
+ // Pops off the helper's parameters, invokes the helper,
+ // and pushes the helper's return value onto the stack.
+ //
+ // If the helper is not found, `helperMissing` is called.
+ invokeHelper: function(paramSize, name) {
+ this.context.aliases.helperMissing = 'helpers.helperMissing';
+
+ var helper = this.lastHelper = this.setupHelper(paramSize, name, true);
+ var nonHelper = this.nameLookup('depth' + this.lastContext, name, 'context');
+
+ this.push(helper.name + ' || ' + nonHelper);
+ this.replaceStack(function(name) {
+ return name + ' ? ' + name + '.call(' +
+ helper.callParams + ") " + ": helperMissing.call(" +
+ helper.helperMissingParams + ")";
+ });
+ },
+
+ // [invokeKnownHelper]
+ //
+ // On stack, before: hash, inverse, program, params..., ...
+ // On stack, after: result of helper invocation
+ //
+ // This operation is used when the helper is known to exist,
+ // so a `helperMissing` fallback is not required.
+ invokeKnownHelper: function(paramSize, name) {
+ var helper = this.setupHelper(paramSize, name);
+ this.push(helper.name + ".call(" + helper.callParams + ")");
+ },
+
+ // [invokeAmbiguous]
+ //
+ // On stack, before: hash, inverse, program, params..., ...
+ // On stack, after: result of disambiguation
+ //
+ // This operation is used when an expression like `{{foo}}`
+ // is provided, but we don't know at compile-time whether it
+ // is a helper or a path.
+ //
+ // This operation emits more code than the other options,
+ // and can be avoided by passing the `knownHelpers` and
+ // `knownHelpersOnly` flags at compile-time.
+ invokeAmbiguous: function(name, helperCall) {
+ this.context.aliases.functionType = '"function"';
+
+ this.pushStackLiteral('{}'); // Hash value
+ var helper = this.setupHelper(0, name, helperCall);
+
+ var helperName = this.lastHelper = this.nameLookup('helpers', name, 'helper');
+
+ var nonHelper = this.nameLookup('depth' + this.lastContext, name, 'context');
+ var nextStack = this.nextStack();
+
+ this.source.push('if (' + nextStack + ' = ' + helperName + ') { ' + nextStack + ' = ' + nextStack + '.call(' + helper.callParams + '); }');
+ this.source.push('else { ' + nextStack + ' = ' + nonHelper + '; ' + nextStack + ' = typeof ' + nextStack + ' === functionType ? ' + nextStack + '.apply(depth0) : ' + nextStack + '; }');
+ },
+
+ // [invokePartial]
+ //
+ // On stack, before: context, ...
+ // On stack after: result of partial invocation
+ //
+ // This operation pops off a context, invokes a partial with that context,
+ // and pushes the result of the invocation back.
+ invokePartial: function(name) {
+ var params = [this.nameLookup('partials', name, 'partial'), "'" + name + "'", this.popStack(), "helpers", "partials"];
+
+ if (this.options.data) {
+ params.push("data");
+ }
+
+ this.context.aliases.self = "this";
+ this.push("self.invokePartial(" + params.join(", ") + ")");
+ },
+
+ // [assignToHash]
+ //
+ // On stack, before: value, hash, ...
+ // On stack, after: hash, ...
+ //
+ // Pops a value and hash off the stack, assigns `hash[key] = value`
+ // and pushes the hash back onto the stack.
+ assignToHash: function(key) {
+ var value = this.popStack(),
+ context,
+ type;
+
+ if (this.options.stringParams) {
+ type = this.popStack();
+ context = this.popStack();
+ }
+
+ var hash = this.hash;
+ if (context) {
+ hash.contexts.push("'" + key + "': " + context);
+ }
+ if (type) {
+ hash.types.push("'" + key + "': " + type);
+ }
+ hash.values.push("'" + key + "': (" + value + ")");
+ },
+
+ // HELPERS
+
+ compiler: JavaScriptCompiler,
+
+ compileChildren: function(environment, options) {
+ var children = environment.children, child, compiler;
+
+ for(var i=0, l=children.length; i<l; i++) {
+ child = children[i];
+ compiler = new this.compiler();
+
+ var index = this.matchExistingProgram(child);
+
+ if (index == null) {
+ this.context.programs.push(''); // Placeholder to prevent name conflicts for nested children
+ index = this.context.programs.length;
+ child.index = index;
+ child.name = 'program' + index;
+ this.context.programs[index] = compiler.compile(child, options, this.context);
+ this.context.environments[index] = child;
+ } else {
+ child.index = index;
+ child.name = 'program' + index;
+ }
+ }
+ },
+ matchExistingProgram: function(child) {
+ for (var i = 0, len = this.context.environments.length; i < len; i++) {
+ var environment = this.context.environments[i];
+ if (environment && environment.equals(child)) {
+ return i;
+ }
+ }
+ },
+
+ programExpression: function(guid) {
+ this.context.aliases.self = "this";
+
+ if(guid == null) {
+ return "self.noop";
+ }
+
+ var child = this.environment.children[guid],
+ depths = child.depths.list, depth;
+
+ var programParams = [child.index, child.name, "data"];
+
+ for(var i=0, l = depths.length; i<l; i++) {
+ depth = depths[i];
+
+ if(depth === 1) { programParams.push("depth0"); }
+ else { programParams.push("depth" + (depth - 1)); }
+ }
+
+ return (depths.length === 0 ? "self.program(" : "self.programWithDepth(") + programParams.join(", ") + ")";
+ },
+
+ register: function(name, val) {
+ this.useRegister(name);
+ this.source.push(name + " = " + val + ";");
+ },
+
+ useRegister: function(name) {
+ if(!this.registers[name]) {
+ this.registers[name] = true;
+ this.registers.list.push(name);
+ }
+ },
+
+ pushStackLiteral: function(item) {
+ return this.push(new Literal(item));
+ },
+
+ pushStack: function(item) {
+ this.flushInline();
+
+ var stack = this.incrStack();
+ if (item) {
+ this.source.push(stack + " = " + item + ";");
+ }
+ this.compileStack.push(stack);
+ return stack;
+ },
+
+ replaceStack: function(callback) {
+ var prefix = '',
+ inline = this.isInline(),
+ stack;
+
+ // If we are currently inline then we want to merge the inline statement into the
+ // replacement statement via ','
+ if (inline) {
+ var top = this.popStack(true);
+
+ if (top instanceof Literal) {
+ // Literals do not need to be inlined
+ stack = top.value;
+ } else {
+ // Get or create the current stack name for use by the inline
+ var name = this.stackSlot ? this.topStackName() : this.incrStack();
+
+ prefix = '(' + this.push(name) + ' = ' + top + '),';
+ stack = this.topStack();
+ }
+ } else {
+ stack = this.topStack();
+ }
+
+ var item = callback.call(this, stack);
+
+ if (inline) {
+ if (this.inlineStack.length || this.compileStack.length) {
+ this.popStack();
+ }
+ this.push('(' + prefix + item + ')');
+ } else {
+ // Prevent modification of the context depth variable. Through replaceStack
+ if (!/^stack/.test(stack)) {
+ stack = this.nextStack();
+ }
+
+ this.source.push(stack + " = (" + prefix + item + ");");
+ }
+ return stack;
+ },
+
+ nextStack: function() {
+ return this.pushStack();
+ },
+
+ incrStack: function() {
+ this.stackSlot++;
+ if(this.stackSlot > this.stackVars.length) { this.stackVars.push("stack" + this.stackSlot); }
+ return this.topStackName();
+ },
+ topStackName: function() {
+ return "stack" + this.stackSlot;
+ },
+ flushInline: function() {
+ var inlineStack = this.inlineStack;
+ if (inlineStack.length) {
+ this.inlineStack = [];
+ for (var i = 0, len = inlineStack.length; i < len; i++) {
+ var entry = inlineStack[i];
+ if (entry instanceof Literal) {
+ this.compileStack.push(entry);
+ } else {
+ this.pushStack(entry);
+ }
+ }
+ }
+ },
+ isInline: function() {
+ return this.inlineStack.length;
+ },
+
+ popStack: function(wrapped) {
+ var inline = this.isInline(),
+ item = (inline ? this.inlineStack : this.compileStack).pop();
+
+ if (!wrapped && (item instanceof Literal)) {
+ return item.value;
+ } else {
+ if (!inline) {
+ this.stackSlot--;
+ }
+ return item;
+ }
+ },
+
+ topStack: function(wrapped) {
+ var stack = (this.isInline() ? this.inlineStack : this.compileStack),
+ item = stack[stack.length - 1];
+
+ if (!wrapped && (item instanceof Literal)) {
+ return item.value;
+ } else {
+ return item;
+ }
+ },
+
+ quotedString: function(str) {
+ return '"' + str
+ .replace(/\\/g, '\\\\')
+ .replace(/"/g, '\\"')
+ .replace(/\n/g, '\\n')
+ .replace(/\r/g, '\\r')
+ .replace(/\u2028/g, '\\u2028') // Per Ecma-262 7.3 + 7.8.4
+ .replace(/\u2029/g, '\\u2029') + '"';
+ },
+
+ setupHelper: function(paramSize, name, missingParams) {
+ var params = [];
+ this.setupParams(paramSize, params, missingParams);
+ var foundHelper = this.nameLookup('helpers', name, 'helper');
+
+ return {
+ params: params,
+ name: foundHelper,
+ callParams: ["depth0"].concat(params).join(", "),
+ helperMissingParams: missingParams && ["depth0", this.quotedString(name)].concat(params).join(", ")
+ };
+ },
+
+ // the params and contexts arguments are passed in arrays
+ // to fill in
+ setupParams: function(paramSize, params, useRegister) {
+ var options = [], contexts = [], types = [], param, inverse, program;
+
+ options.push("hash:" + this.popStack());
+
+ inverse = this.popStack();
+ program = this.popStack();
+
+ // Avoid setting fn and inverse if neither are set. This allows
+ // helpers to do a check for `if (options.fn)`
+ if (program || inverse) {
+ if (!program) {
+ this.context.aliases.self = "this";
+ program = "self.noop";
+ }
+
+ if (!inverse) {
+ this.context.aliases.self = "this";
+ inverse = "self.noop";
+ }
+
+ options.push("inverse:" + inverse);
+ options.push("fn:" + program);
+ }
+
+ for(var i=0; i<paramSize; i++) {
+ param = this.popStack();
+ params.push(param);
+
+ if(this.options.stringParams) {
+ types.push(this.popStack());
+ contexts.push(this.popStack());
+ }
+ }
+
+ if (this.options.stringParams) {
+ options.push("contexts:[" + contexts.join(",") + "]");
+ options.push("types:[" + types.join(",") + "]");
+ options.push("hashContexts:hashContexts");
+ options.push("hashTypes:hashTypes");
+ }
+
+ if(this.options.data) {
+ options.push("data:data");
+ }
+
+ options = "{" + options.join(",") + "}";
+ if (useRegister) {
+ this.register('options', options);
+ params.push('options');
+ } else {
+ params.push(options);
+ }
+ return params.join(", ");
+ }
+};
+
+var reservedWords = (
+ "break else new var" +
+ " case finally return void" +
+ " catch for switch while" +
+ " continue function this with" +
+ " default if throw" +
+ " delete in try" +
+ " do instanceof typeof" +
+ " abstract enum int short" +
+ " boolean export interface static" +
+ " byte extends long super" +
+ " char final native synchronized" +
+ " class float package throws" +
+ " const goto private transient" +
+ " debugger implements protected volatile" +
+ " double import public let yield"
+).split(" ");
+
+var compilerWords = JavaScriptCompiler.RESERVED_WORDS = {};
+
+for(var i=0, l=reservedWords.length; i<l; i++) {
+ compilerWords[reservedWords[i]] = true;
+}
+
+JavaScriptCompiler.isValidJavaScriptVariableName = function(name) {
+ if(!JavaScriptCompiler.RESERVED_WORDS[name] && /^[a-zA-Z_$][0-9a-zA-Z_$]+$/.test(name)) {
+ return true;
+ }
+ return false;
+};
+
+Handlebars.precompile = function(input, options) {
+ if (input == null || (typeof input !== 'string' && input.constructor !== Handlebars.AST.ProgramNode)) {
+ throw new Handlebars.Exception("You must pass a string or Handlebars AST to Handlebars.precompile. You passed " + input);
+ }
+
+ options = options || {};
+ if (!('data' in options)) {
+ options.data = true;
+ }
+ var ast = Handlebars.parse(input);
+ var environment = new Compiler().compile(ast, options);
+ return new JavaScriptCompiler().compile(environment, options);
+};
+
+Handlebars.compile = function(input, options) {
+ if (input == null || (typeof input !== 'string' && input.constructor !== Handlebars.AST.ProgramNode)) {
+ throw new Handlebars.Exception("You must pass a string or Handlebars AST to Handlebars.compile. You passed " + input);
+ }
+
+ options = options || {};
+ if (!('data' in options)) {
+ options.data = true;
+ }
+ var compiled;
+ function compile() {
+ var ast = Handlebars.parse(input);
+ var environment = new Compiler().compile(ast, options);
+ var templateSpec = new JavaScriptCompiler().compile(environment, options, undefined, true);
+ return Handlebars.template(templateSpec);
+ }
+
+ // Template is only compiled on first use and cached after that point.
+ return function(context, options) {
+ if (!compiled) {
+ compiled = compile();
+ }
+ return compiled.call(this, context, options);
+ };
+};
+
+;
+// lib/handlebars/runtime.js
+
+Handlebars.VM = {
+ template: function(templateSpec) {
+ // Just add water
+ var container = {
+ escapeExpression: Handlebars.Utils.escapeExpression,
+ invokePartial: Handlebars.VM.invokePartial,
+ programs: [],
+ program: function(i, fn, data) {
+ var programWrapper = this.programs[i];
+ if(data) {
+ programWrapper = Handlebars.VM.program(i, fn, data);
+ } else if (!programWrapper) {
+ programWrapper = this.programs[i] = Handlebars.VM.program(i, fn);
+ }
+ return programWrapper;
+ },
+ merge: function(param, common) {
+ var ret = param || common;
+
+ if (param && common) {
+ ret = {};
+ Handlebars.Utils.extend(ret, common);
+ Handlebars.Utils.extend(ret, param);
+ }
+ return ret;
+ },
+ programWithDepth: Handlebars.VM.programWithDepth,
+ noop: Handlebars.VM.noop,
+ compilerInfo: null
+ };
+
+ return function(context, options) {
+ options = options || {};
+ var result = templateSpec.call(container, Handlebars, context, options.helpers, options.partials, options.data);
+
+ var compilerInfo = container.compilerInfo || [],
+ compilerRevision = compilerInfo[0] || 1,
+ currentRevision = Handlebars.COMPILER_REVISION;
+
+ if (compilerRevision !== currentRevision) {
+ if (compilerRevision < currentRevision) {
+ var runtimeVersions = Handlebars.REVISION_CHANGES[currentRevision],
+ compilerVersions = Handlebars.REVISION_CHANGES[compilerRevision];
+ throw "Template was precompiled with an older version of Handlebars than the current runtime. "+
+ "Please update your precompiler to a newer version ("+runtimeVersions+") or downgrade your runtime to an older version ("+compilerVersions+").";
+ } else {
+ // Use the embedded version info since the runtime doesn't know about this revision yet
+ throw "Template was precompiled with a newer version of Handlebars than the current runtime. "+
+ "Please update your runtime to a newer version ("+compilerInfo[1]+").";
+ }
+ }
+
+ return result;
+ };
+ },
+
+ programWithDepth: function(i, fn, data /*, $depth */) {
+ var args = Array.prototype.slice.call(arguments, 3);
+
+ var program = function(context, options) {
+ options = options || {};
+
+ return fn.apply(this, [context, options.data || data].concat(args));
+ };
+ program.program = i;
+ program.depth = args.length;
+ return program;
+ },
+ program: function(i, fn, data) {
+ var program = function(context, options) {
+ options = options || {};
+
+ return fn(context, options.data || data);
+ };
+ program.program = i;
+ program.depth = 0;
+ return program;
+ },
+ noop: function() { return ""; },
+ invokePartial: function(partial, name, context, helpers, partials, data) {
+ var options = { helpers: helpers, partials: partials, data: data };
+
+ if(partial === undefined) {
+ throw new Handlebars.Exception("The partial " + name + " could not be found");
+ } else if(partial instanceof Function) {
+ return partial(context, options);
+ } else if (!Handlebars.compile) {
+ throw new Handlebars.Exception("The partial " + name + " could not be compiled when running in runtime-only mode");
+ } else {
+ partials[name] = Handlebars.compile(partial, {data: data !== undefined});
+ return partials[name](context, options);
+ }
+ }
+};
+
+Handlebars.template = Handlebars.VM.template;
+;
+// lib/handlebars/browser-suffix.js
+})(Handlebars);
+;
diff --git a/profiles/killbill/src/main/webapp/lib/highlight.7.3.pack.js b/profiles/killbill/src/main/webapp/lib/highlight.7.3.pack.js
new file mode 100644
index 0000000..9a95a75
--- /dev/null
+++ b/profiles/killbill/src/main/webapp/lib/highlight.7.3.pack.js
@@ -0,0 +1 @@
+var hljs=new function(){function l(o){return o.replace(/&/gm,"&").replace(/</gm,"<").replace(/>/gm,">")}function b(p){for(var o=p.firstChild;o;o=o.nextSibling){if(o.nodeName=="CODE"){return o}if(!(o.nodeType==3&&o.nodeValue.match(/\s+/))){break}}}function h(p,o){return Array.prototype.map.call(p.childNodes,function(q){if(q.nodeType==3){return o?q.nodeValue.replace(/\n/g,""):q.nodeValue}if(q.nodeName=="BR"){return"\n"}return h(q,o)}).join("")}function a(q){var p=(q.className+" "+q.parentNode.className).split(/\s+/);p=p.map(function(r){return r.replace(/^language-/,"")});for(var o=0;o<p.length;o++){if(e[p[o]]||p[o]=="no-highlight"){return p[o]}}}function c(q){var o=[];(function p(r,s){for(var t=r.firstChild;t;t=t.nextSibling){if(t.nodeType==3){s+=t.nodeValue.length}else{if(t.nodeName=="BR"){s+=1}else{if(t.nodeType==1){o.push({event:"start",offset:s,node:t});s=p(t,s);o.push({event:"stop",offset:s,node:t})}}}}return s})(q,0);return o}function j(x,v,w){var p=0;var y="";var r=[];function t(){if(x.length&&v.length){if(x[0].offset!=v[0].offset){return(x[0].offset<v[0].offset)?x:v}else{return v[0].event=="start"?x:v}}else{return x.length?x:v}}function s(A){function z(B){return" "+B.nodeName+'="'+l(B.value)+'"'}return"<"+A.nodeName+Array.prototype.map.call(A.attributes,z).join("")+">"}while(x.length||v.length){var u=t().splice(0,1)[0];y+=l(w.substr(p,u.offset-p));p=u.offset;if(u.event=="start"){y+=s(u.node);r.push(u.node)}else{if(u.event=="stop"){var o,q=r.length;do{q--;o=r[q];y+=("</"+o.nodeName.toLowerCase()+">")}while(o!=u.node);r.splice(q,1);while(q<r.length){y+=s(r[q]);q++}}}}return y+l(w.substr(p))}function f(q){function o(s,r){return RegExp(s,"m"+(q.cI?"i":"")+(r?"g":""))}function p(y,w){if(y.compiled){return}y.compiled=true;var s=[];if(y.k){var r={};function z(A,t){t.split(" ").forEach(function(B){var C=B.split("|");r[C[0]]=[A,C[1]?Number(C[1]):1];s.push(C[0])})}y.lR=o(y.l||hljs.IR,true);if(typeof y.k=="string"){z("keyword",y.k)}else{for(var x in y.k){if(!y.k.hasOwnProperty(x)){continue}z(x,y.k[x])}}y.k=r}if(w){if(y.bWK){y.b="\\b("+s.join("|")+")\\s"}y.bR=o(y.b?y.b:"\\B|\\b");if(!y.e&&!y.eW){y.e="\\B|\\b"}if(y.e){y.eR=o(y.e)}y.tE=y.e||"";if(y.eW&&w.tE){y.tE+=(y.e?"|":"")+w.tE}}if(y.i){y.iR=o(y.i)}if(y.r===undefined){y.r=1}if(!y.c){y.c=[]}for(var v=0;v<y.c.length;v++){if(y.c[v]=="self"){y.c[v]=y}p(y.c[v],y)}if(y.starts){p(y.starts,w)}var u=[];for(var v=0;v<y.c.length;v++){u.push(y.c[v].b)}if(y.tE){u.push(y.tE)}if(y.i){u.push(y.i)}y.t=u.length?o(u.join("|"),true):{exec:function(t){return null}}}p(q)}function d(D,E){function o(r,M){for(var L=0;L<M.c.length;L++){var K=M.c[L].bR.exec(r);if(K&&K.index==0){return M.c[L]}}}function s(K,r){if(K.e&&K.eR.test(r)){return K}if(K.eW){return s(K.parent,r)}}function t(r,K){return K.i&&K.iR.test(r)}function y(L,r){var K=F.cI?r[0].toLowerCase():r[0];return L.k.hasOwnProperty(K)&&L.k[K]}function G(){var K=l(w);if(!A.k){return K}var r="";var N=0;A.lR.lastIndex=0;var L=A.lR.exec(K);while(L){r+=K.substr(N,L.index-N);var M=y(A,L);if(M){v+=M[1];r+='<span class="'+M[0]+'">'+L[0]+"</span>"}else{r+=L[0]}N=A.lR.lastIndex;L=A.lR.exec(K)}return r+K.substr(N)}function z(){if(A.sL&&!e[A.sL]){return l(w)}var r=A.sL?d(A.sL,w):g(w);if(A.r>0){v+=r.keyword_count;B+=r.r}return'<span class="'+r.language+'">'+r.value+"</span>"}function J(){return A.sL!==undefined?z():G()}function I(L,r){var K=L.cN?'<span class="'+L.cN+'">':"";if(L.rB){x+=K;w=""}else{if(L.eB){x+=l(r)+K;w=""}else{x+=K;w=r}}A=Object.create(L,{parent:{value:A}});B+=L.r}function C(K,r){w+=K;if(r===undefined){x+=J();return 0}var L=o(r,A);if(L){x+=J();I(L,r);return L.rB?0:r.length}var M=s(A,r);if(M){if(!(M.rE||M.eE)){w+=r}x+=J();do{if(A.cN){x+="</span>"}A=A.parent}while(A!=M.parent);if(M.eE){x+=l(r)}w="";if(M.starts){I(M.starts,"")}return M.rE?0:r.length}if(t(r,A)){throw"Illegal"}w+=r;return r.length||1}var F=e[D];f(F);var A=F;var w="";var B=0;var v=0;var x="";try{var u,q,p=0;while(true){A.t.lastIndex=p;u=A.t.exec(E);if(!u){break}q=C(E.substr(p,u.index-p),u[0]);p=u.index+q}C(E.substr(p));return{r:B,keyword_count:v,value:x,language:D}}catch(H){if(H=="Illegal"){return{r:0,keyword_count:0,value:l(E)}}else{throw H}}}function g(s){var o={keyword_count:0,r:0,value:l(s)};var q=o;for(var p in e){if(!e.hasOwnProperty(p)){continue}var r=d(p,s);r.language=p;if(r.keyword_count+r.r>q.keyword_count+q.r){q=r}if(r.keyword_count+r.r>o.keyword_count+o.r){q=o;o=r}}if(q.language){o.second_best=q}return o}function i(q,p,o){if(p){q=q.replace(/^((<[^>]+>|\t)+)/gm,function(r,v,u,t){return v.replace(/\t/g,p)})}if(o){q=q.replace(/\n/g,"<br>")}return q}function m(r,u,p){var v=h(r,p);var t=a(r);if(t=="no-highlight"){return}var w=t?d(t,v):g(v);t=w.language;var o=c(r);if(o.length){var q=document.createElement("pre");q.innerHTML=w.value;w.value=j(o,c(q),v)}w.value=i(w.value,u,p);var s=r.className;if(!s.match("(\\s|^)(language-)?"+t+"(\\s|$)")){s=s?(s+" "+t):t}r.innerHTML=w.value;r.className=s;r.result={language:t,kw:w.keyword_count,re:w.r};if(w.second_best){r.second_best={language:w.second_best.language,kw:w.second_best.keyword_count,re:w.second_best.r}}}function n(){if(n.called){return}n.called=true;Array.prototype.map.call(document.getElementsByTagName("pre"),b).filter(Boolean).forEach(function(o){m(o,hljs.tabReplace)})}function k(){window.addEventListener("DOMContentLoaded",n,false);window.addEventListener("load",n,false)}var e={};this.LANGUAGES=e;this.highlight=d;this.highlightAuto=g;this.fixMarkup=i;this.highlightBlock=m;this.initHighlighting=n;this.initHighlightingOnLoad=k;this.IR="[a-zA-Z][a-zA-Z0-9_]*";this.UIR="[a-zA-Z_][a-zA-Z0-9_]*";this.NR="\\b\\d+(\\.\\d+)?";this.CNR="(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)";this.BNR="\\b(0b[01]+)";this.RSR="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|\\.|-|-=|/|/=|:|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~";this.BE={b:"\\\\[\\s\\S]",r:0};this.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[this.BE],r:0};this.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[this.BE],r:0};this.CLCM={cN:"comment",b:"//",e:"$"};this.CBLCLM={cN:"comment",b:"/\\*",e:"\\*/"};this.HCM={cN:"comment",b:"#",e:"$"};this.NM={cN:"number",b:this.NR,r:0};this.CNM={cN:"number",b:this.CNR,r:0};this.BNM={cN:"number",b:this.BNR,r:0};this.inherit=function(q,r){var o={};for(var p in q){o[p]=q[p]}if(r){for(var p in r){o[p]=r[p]}}return o}}();hljs.LANGUAGES.xml=function(a){var c="[A-Za-z0-9\\._:-]+";var b={eW:true,c:[{cN:"attribute",b:c,r:0},{b:'="',rB:true,e:'"',c:[{cN:"value",b:'"',eW:true}]},{b:"='",rB:true,e:"'",c:[{cN:"value",b:"'",eW:true}]},{b:"=",c:[{cN:"value",b:"[^\\s/>]+"}]}]};return{cI:true,c:[{cN:"pi",b:"<\\?",e:"\\?>",r:10},{cN:"doctype",b:"<!DOCTYPE",e:">",r:10,c:[{b:"\\[",e:"\\]"}]},{cN:"comment",b:"<!--",e:"-->",r:10},{cN:"cdata",b:"<\\!\\[CDATA\\[",e:"\\]\\]>",r:10},{cN:"tag",b:"<style(?=\\s|>|$)",e:">",k:{title:"style"},c:[b],starts:{e:"</style>",rE:true,sL:"css"}},{cN:"tag",b:"<script(?=\\s|>|$)",e:">",k:{title:"script"},c:[b],starts:{e:"<\/script>",rE:true,sL:"javascript"}},{b:"<%",e:"%>",sL:"vbscript"},{cN:"tag",b:"</?",e:"/?>",c:[{cN:"title",b:"[^ />]+"},b]}]}}(hljs);hljs.LANGUAGES.json=function(a){var e={literal:"true false null"};var d=[a.QSM,a.CNM];var c={cN:"value",e:",",eW:true,eE:true,c:d,k:e};var b={b:"{",e:"}",c:[{cN:"attribute",b:'\\s*"',e:'"\\s*:\\s*',eB:true,eE:true,c:[a.BE],i:"\\n",starts:c}],i:"\\S"};var f={b:"\\[",e:"\\]",c:[a.inherit(c,{cN:null})],i:"\\S"};d.splice(d.length,0,b,f);return{c:d,k:e,i:"\\S"}}(hljs);
\ No newline at end of file
diff --git a/profiles/killbill/src/main/webapp/lib/jquery.ba-bbq.min.js b/profiles/killbill/src/main/webapp/lib/jquery.ba-bbq.min.js
new file mode 100644
index 0000000..bcbf248
--- /dev/null
+++ b/profiles/killbill/src/main/webapp/lib/jquery.ba-bbq.min.js
@@ -0,0 +1,18 @@
+/*
+ * jQuery BBQ: Back Button & Query Library - v1.2.1 - 2/17/2010
+ * http://benalman.com/projects/jquery-bbq-plugin/
+ *
+ * Copyright (c) 2010 "Cowboy" Ben Alman
+ * Dual licensed under the MIT and GPL licenses.
+ * http://benalman.com/about/license/
+ */
+(function($,p){var i,m=Array.prototype.slice,r=decodeURIComponent,a=$.param,c,l,v,b=$.bbq=$.bbq||{},q,u,j,e=$.event.special,d="hashchange",A="querystring",D="fragment",y="elemUrlAttr",g="location",k="href",t="src",x=/^.*\?|#.*$/g,w=/^.*\#/,h,C={};function E(F){return typeof F==="string"}function B(G){var F=m.call(arguments,1);return function(){return G.apply(this,F.concat(m.call(arguments)))}}function n(F){return F.replace(/^[^#]*#?(.*)$/,"$1")}function o(F){return F.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")}function f(H,M,F,I,G){var O,L,K,N,J;if(I!==i){K=F.match(H?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);J=K[3]||"";if(G===2&&E(I)){L=I.replace(H?w:x,"")}else{N=l(K[2]);I=E(I)?l[H?D:A](I):I;L=G===2?I:G===1?$.extend({},I,N):$.extend({},N,I);L=a(L);if(H){L=L.replace(h,r)}}O=K[1]+(H?"#":L||!K[1]?"?":"")+L+J}else{O=M(F!==i?F:p[g][k])}return O}a[A]=B(f,0,o);a[D]=c=B(f,1,n);c.noEscape=function(G){G=G||"";var F=$.map(G.split(""),encodeURIComponent);h=new RegExp(F.join("|"),"g")};c.noEscape(",/");$.deparam=l=function(I,F){var H={},G={"true":!0,"false":!1,"null":null};$.each(I.replace(/\+/g," ").split("&"),function(L,Q){var K=Q.split("="),P=r(K[0]),J,O=H,M=0,R=P.split("]["),N=R.length-1;if(/\[/.test(R[0])&&/\]$/.test(R[N])){R[N]=R[N].replace(/\]$/,"");R=R.shift().split("[").concat(R);N=R.length-1}else{N=0}if(K.length===2){J=r(K[1]);if(F){J=J&&!isNaN(J)?+J:J==="undefined"?i:G[J]!==i?G[J]:J}if(N){for(;M<=N;M++){P=R[M]===""?O.length:R[M];O=O[P]=M<N?O[P]||(R[M+1]&&isNaN(R[M+1])?{}:[]):J}}else{if($.isArray(H[P])){H[P].push(J)}else{if(H[P]!==i){H[P]=[H[P],J]}else{H[P]=J}}}}else{if(P){H[P]=F?i:""}}});return H};function z(H,F,G){if(F===i||typeof F==="boolean"){G=F;F=a[H?D:A]()}else{F=E(F)?F.replace(H?w:x,""):F}return l(F,G)}l[A]=B(z,0);l[D]=v=B(z,1);$[y]||($[y]=function(F){return $.extend(C,F)})({a:k,base:k,iframe:t,img:t,input:t,form:"action",link:k,script:t});j=$[y];function s(I,G,H,F){if(!E(H)&&typeof H!=="object"){F=H;H=G;G=i}return this.each(function(){var L=$(this),J=G||j()[(this.nodeName||"").toLowerCase()]||"",K=J&&L.attr(J)||"";L.attr(J,a[I](K,H,F))})}$.fn[A]=B(s,A);$.fn[D]=B(s,D);b.pushState=q=function(I,F){if(E(I)&&/^#/.test(I)&&F===i){F=2}var H=I!==i,G=c(p[g][k],H?I:{},H?F:2);p[g][k]=G+(/#/.test(G)?"":"#")};b.getState=u=function(F,G){return F===i||typeof F==="boolean"?v(F):v(G)[F]};b.removeState=function(F){var G={};if(F!==i){G=u();$.each($.isArray(F)?F:arguments,function(I,H){delete G[H]})}q(G,2)};e[d]=$.extend(e[d],{add:function(F){var H;function G(J){var I=J[D]=c();J.getState=function(K,L){return K===i||typeof K==="boolean"?l(I,K):l(I,L)[K]};H.apply(this,arguments)}if($.isFunction(F)){H=F;return G}else{H=F.handler;F.handler=G}}})})(jQuery,this);
+/*
+ * jQuery hashchange event - v1.2 - 2/11/2010
+ * http://benalman.com/projects/jquery-hashchange-plugin/
+ *
+ * Copyright (c) 2010 "Cowboy" Ben Alman
+ * Dual licensed under the MIT and GPL licenses.
+ * http://benalman.com/about/license/
+ */
+(function($,i,b){var j,k=$.event.special,c="location",d="hashchange",l="href",f=$.browser,g=document.documentMode,h=f.msie&&(g===b||g<8),e="on"+d in i&&!h;function a(m){m=m||i[c][l];return m.replace(/^[^#]*#?(.*)$/,"$1")}$[d+"Delay"]=100;k[d]=$.extend(k[d],{setup:function(){if(e){return false}$(j.start)},teardown:function(){if(e){return false}$(j.stop)}});j=(function(){var m={},r,n,o,q;function p(){o=q=function(s){return s};if(h){n=$('<iframe src="javascript:0"/>').hide().insertAfter("body")[0].contentWindow;q=function(){return a(n.document[c][l])};o=function(u,s){if(u!==s){var t=n.document;t.open().close();t[c].hash="#"+u}};o(a())}}m.start=function(){if(r){return}var t=a();o||p();(function s(){var v=a(),u=q(t);if(v!==t){o(t=v,u);$(i).trigger(d)}else{if(u!==t){i[c][l]=i[c][l].replace(/#.*/,"")+"#"+u}}r=setTimeout(s,$[d+"Delay"])})()};m.stop=function(){if(!n){r&&clearTimeout(r);r=0}};return m})()})(jQuery,this);
\ No newline at end of file
diff --git a/profiles/killbill/src/main/webapp/lib/jquery.slideto.min.js b/profiles/killbill/src/main/webapp/lib/jquery.slideto.min.js
new file mode 100644
index 0000000..ba32cff
--- /dev/null
+++ b/profiles/killbill/src/main/webapp/lib/jquery.slideto.min.js
@@ -0,0 +1 @@
+(function(b){b.fn.slideto=function(a){a=b.extend({slide_duration:"slow",highlight_duration:3E3,highlight:true,highlight_color:"#FFFF99"},a);return this.each(function(){obj=b(this);b("body").animate({scrollTop:obj.offset().top},a.slide_duration,function(){a.highlight&&b.ui.version&&obj.effect("highlight",{color:a.highlight_color},a.highlight_duration)})})}})(jQuery);
diff --git a/profiles/killbill/src/main/webapp/lib/jquery.wiggle.min.js b/profiles/killbill/src/main/webapp/lib/jquery.wiggle.min.js
new file mode 100644
index 0000000..2adb0d6
--- /dev/null
+++ b/profiles/killbill/src/main/webapp/lib/jquery.wiggle.min.js
@@ -0,0 +1,8 @@
+/*
+jQuery Wiggle
+Author: WonderGroup, Jordan Thomas
+URL: http://labs.wondergroup.com/demos/mini-ui/index.html
+License: MIT (http://en.wikipedia.org/wiki/MIT_License)
+*/
+jQuery.fn.wiggle=function(o){var d={speed:50,wiggles:3,travel:5,callback:null};var o=jQuery.extend(d,o);return this.each(function(){var cache=this;var wrap=jQuery(this).wrap('<div class="wiggle-wrap"></div>').css("position","relative");var calls=0;for(i=1;i<=o.wiggles;i++){jQuery(this).animate({left:"-="+o.travel},o.speed).animate({left:"+="+o.travel*2},o.speed*2).animate({left:"-="+o.travel},o.speed,function(){calls++;if(jQuery(cache).parent().hasClass('wiggle-wrap')){jQuery(cache).parent().replaceWith(cache);}
+if(calls==o.wiggles&&jQuery.isFunction(o.callback)){o.callback();}});}});};
\ No newline at end of file
diff --git a/profiles/killbill/src/main/webapp/lib/jquery-1.8.0.min.js b/profiles/killbill/src/main/webapp/lib/jquery-1.8.0.min.js
new file mode 100644
index 0000000..f121291
--- /dev/null
+++ b/profiles/killbill/src/main/webapp/lib/jquery-1.8.0.min.js
@@ -0,0 +1,2 @@
+/*! jQuery v@1.8.0 jquery.com | jquery.org/license */
+(function(a,b){function G(a){var b=F[a]={};return p.each(a.split(s),function(a,c){b[c]=!0}),b}function J(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(I,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:+d+""===d?+d:H.test(d)?p.parseJSON(d):d}catch(f){}p.data(a,c,d)}else d=b}return d}function K(a){var b;for(b in a){if(b==="data"&&p.isEmptyObject(a[b]))continue;if(b!=="toJSON")return!1}return!0}function ba(){return!1}function bb(){return!0}function bh(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function bi(a,b){do a=a[b];while(a&&a.nodeType!==1);return a}function bj(a,b,c){b=b||0;if(p.isFunction(b))return p.grep(a,function(a,d){var e=!!b.call(a,d,a);return e===c});if(b.nodeType)return p.grep(a,function(a,d){return a===b===c});if(typeof b=="string"){var d=p.grep(a,function(a){return a.nodeType===1});if(be.test(b))return p.filter(b,d,!c);b=p.filter(b,d)}return p.grep(a,function(a,d){return p.inArray(a,b)>=0===c})}function bk(a){var b=bl.split("|"),c=a.createDocumentFragment();if(c.createElement)while(b.length)c.createElement(b.pop());return c}function bC(a,b){return a.getElementsByTagName(b)[0]||a.appendChild(a.ownerDocument.createElement(b))}function bD(a,b){if(b.nodeType!==1||!p.hasData(a))return;var c,d,e,f=p._data(a),g=p._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;d<e;d++)p.event.add(b,c,h[c][d])}g.data&&(g.data=p.extend({},g.data))}function bE(a,b){var c;if(b.nodeType!==1)return;b.clearAttributes&&b.clearAttributes(),b.mergeAttributes&&b.mergeAttributes(a),c=b.nodeName.toLowerCase(),c==="object"?(b.parentNode&&(b.outerHTML=a.outerHTML),p.support.html5Clone&&a.innerHTML&&!p.trim(b.innerHTML)&&(b.innerHTML=a.innerHTML)):c==="input"&&bv.test(a.type)?(b.defaultChecked=b.checked=a.checked,b.value!==a.value&&(b.value=a.value)):c==="option"?b.selected=a.defaultSelected:c==="input"||c==="textarea"?b.defaultValue=a.defaultValue:c==="script"&&b.text!==a.text&&(b.text=a.text),b.removeAttribute(p.expando)}function bF(a){return typeof a.getElementsByTagName!="undefined"?a.getElementsByTagName("*"):typeof a.querySelectorAll!="undefined"?a.querySelectorAll("*"):[]}function bG(a){bv.test(a.type)&&(a.defaultChecked=a.checked)}function bX(a,b){if(b in a)return b;var c=b.charAt(0).toUpperCase()+b.slice(1),d=b,e=bV.length;while(e--){b=bV[e]+c;if(b in a)return b}return d}function bY(a,b){return a=b||a,p.css(a,"display")==="none"||!p.contains(a.ownerDocument,a)}function bZ(a,b){var c,d,e=[],f=0,g=a.length;for(;f<g;f++){c=a[f];if(!c.style)continue;e[f]=p._data(c,"olddisplay"),b?(!e[f]&&c.style.display==="none"&&(c.style.display=""),c.style.display===""&&bY(c)&&(e[f]=p._data(c,"olddisplay",cb(c.nodeName)))):(d=bH(c,"display"),!e[f]&&d!=="none"&&p._data(c,"olddisplay",d))}for(f=0;f<g;f++){c=a[f];if(!c.style)continue;if(!b||c.style.display==="none"||c.style.display==="")c.style.display=b?e[f]||"":"none"}return a}function b$(a,b,c){var d=bO.exec(b);return d?Math.max(0,d[1]-(c||0))+(d[2]||"px"):b}function b_(a,b,c,d){var e=c===(d?"border":"content")?4:b==="width"?1:0,f=0;for(;e<4;e+=2)c==="margin"&&(f+=p.css(a,c+bU[e],!0)),d?(c==="content"&&(f-=parseFloat(bH(a,"padding"+bU[e]))||0),c!=="margin"&&(f-=parseFloat(bH(a,"border"+bU[e]+"Width"))||0)):(f+=parseFloat(bH(a,"padding"+bU[e]))||0,c!=="padding"&&(f+=parseFloat(bH(a,"border"+bU[e]+"Width"))||0));return f}function ca(a,b,c){var d=b==="width"?a.offsetWidth:a.offsetHeight,e=!0,f=p.support.boxSizing&&p.css(a,"boxSizing")==="border-box";if(d<=0){d=bH(a,b);if(d<0||d==null)d=a.style[b];if(bP.test(d))return d;e=f&&(p.support.boxSizingReliable||d===a.style[b]),d=parseFloat(d)||0}return d+b_(a,b,c||(f?"border":"content"),e)+"px"}function cb(a){if(bR[a])return bR[a];var b=p("<"+a+">").appendTo(e.body),c=b.css("display");b.remove();if(c==="none"||c===""){bI=e.body.appendChild(bI||p.extend(e.createElement("iframe"),{frameBorder:0,width:0,height:0}));if(!bJ||!bI.createElement)bJ=(bI.contentWindow||bI.contentDocument).document,bJ.write("<!doctype html><html><body>"),bJ.close();b=bJ.body.appendChild(bJ.createElement(a)),c=bH(b,"display"),e.body.removeChild(bI)}return bR[a]=c,c}function ch(a,b,c,d){var e;if(p.isArray(b))p.each(b,function(b,e){c||cd.test(a)?d(a,e):ch(a+"["+(typeof e=="object"?b:"")+"]",e,c,d)});else if(!c&&p.type(b)==="object")for(e in b)ch(a+"["+e+"]",b[e],c,d);else d(a,b)}function cy(a){return function(b,c){typeof b!="string"&&(c=b,b="*");var d,e,f,g=b.toLowerCase().split(s),h=0,i=g.length;if(p.isFunction(c))for(;h<i;h++)d=g[h],f=/^\+/.test(d),f&&(d=d.substr(1)||"*"),e=a[d]=a[d]||[],e[f?"unshift":"push"](c)}}function cz(a,c,d,e,f,g){f=f||c.dataTypes[0],g=g||{},g[f]=!0;var h,i=a[f],j=0,k=i?i.length:0,l=a===cu;for(;j<k&&(l||!h);j++)h=i[j](c,d,e),typeof h=="string"&&(!l||g[h]?h=b:(c.dataTypes.unshift(h),h=cz(a,c,d,e,h,g)));return(l||!h)&&!g["*"]&&(h=cz(a,c,d,e,"*",g)),h}function cA(a,c){var d,e,f=p.ajaxSettings.flatOptions||{};for(d in c)c[d]!==b&&((f[d]?a:e||(e={}))[d]=c[d]);e&&p.extend(!0,a,e)}function cB(a,c,d){var e,f,g,h,i=a.contents,j=a.dataTypes,k=a.responseFields;for(f in k)f in d&&(c[k[f]]=d[f]);while(j[0]==="*")j.shift(),e===b&&(e=a.mimeType||c.getResponseHeader("content-type"));if(e)for(f in i)if(i[f]&&i[f].test(e)){j.unshift(f);break}if(j[0]in d)g=j[0];else{for(f in d){if(!j[0]||a.converters[f+" "+j[0]]){g=f;break}h||(h=f)}g=g||h}if(g)return g!==j[0]&&j.unshift(g),d[g]}function cC(a,b){var c,d,e,f,g=a.dataTypes.slice(),h=g[0],i={},j=0;a.dataFilter&&(b=a.dataFilter(b,a.dataType));if(g[1])for(c in a.converters)i[c.toLowerCase()]=a.converters[c];for(;e=g[++j];)if(e!=="*"){if(h!=="*"&&h!==e){c=i[h+" "+e]||i["* "+e];if(!c)for(d in i){f=d.split(" ");if(f[1]===e){c=i[h+" "+f[0]]||i["* "+f[0]];if(c){c===!0?c=i[d]:i[d]!==!0&&(e=f[0],g.splice(j--,0,e));break}}}if(c!==!0)if(c&&a["throws"])b=c(b);else try{b=c(b)}catch(k){return{state:"parsererror",error:c?k:"No conversion from "+h+" to "+e}}}h=e}return{state:"success",data:b}}function cK(){try{return new a.XMLHttpRequest}catch(b){}}function cL(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function cT(){return setTimeout(function(){cM=b},0),cM=p.now()}function cU(a,b){p.each(b,function(b,c){var d=(cS[b]||[]).concat(cS["*"]),e=0,f=d.length;for(;e<f;e++)if(d[e].call(a,b,c))return})}function cV(a,b,c){var d,e=0,f=0,g=cR.length,h=p.Deferred().always(function(){delete i.elem}),i=function(){var b=cM||cT(),c=Math.max(0,j.startTime+j.duration-b),d=1-(c/j.duration||0),e=0,f=j.tweens.length;for(;e<f;e++)j.tweens[e].run(d);return h.notifyWith(a,[j,d,c]),d<1&&f?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:p.extend({},b),opts:p.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:cM||cT(),duration:c.duration,tweens:[],createTween:function(b,c,d){var e=p.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(e),e},stop:function(b){var c=0,d=b?j.tweens.length:0;for(;c<d;c++)j.tweens[c].run(1);return b?h.resolveWith(a,[j,b]):h.rejectWith(a,[j,b]),this}}),k=j.props;cW(k,j.opts.specialEasing);for(;e<g;e++){d=cR[e].call(j,a,k,j.opts);if(d)return d}return cU(j,k),p.isFunction(j.opts.start)&&j.opts.start.call(a,j),p.fx.timer(p.extend(i,{anim:j,queue:j.opts.queue,elem:a})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}function cW(a,b){var c,d,e,f,g;for(c in a){d=p.camelCase(c),e=b[d],f=a[c],p.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=p.cssHooks[d];if(g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}}function cX(a,b,c){var d,e,f,g,h,i,j,k,l=this,m=a.style,n={},o=[],q=a.nodeType&&bY(a);c.queue||(j=p._queueHooks(a,"fx"),j.unqueued==null&&(j.unqueued=0,k=j.empty.fire,j.empty.fire=function(){j.unqueued||k()}),j.unqueued++,l.always(function(){l.always(function(){j.unqueued--,p.queue(a,"fx").length||j.empty.fire()})})),a.nodeType===1&&("height"in b||"width"in b)&&(c.overflow=[m.overflow,m.overflowX,m.overflowY],p.css(a,"display")==="inline"&&p.css(a,"float")==="none"&&(!p.support.inlineBlockNeedsLayout||cb(a.nodeName)==="inline"?m.display="inline-block":m.zoom=1)),c.overflow&&(m.overflow="hidden",p.support.shrinkWrapBlocks||l.done(function(){m.overflow=c.overflow[0],m.overflowX=c.overflow[1],m.overflowY=c.overflow[2]}));for(d in b){f=b[d];if(cO.exec(f)){delete b[d];if(f===(q?"hide":"show"))continue;o.push(d)}}g=o.length;if(g){h=p._data(a,"fxshow")||p._data(a,"fxshow",{}),q?p(a).show():l.done(function(){p(a).hide()}),l.done(function(){var b;p.removeData(a,"fxshow",!0);for(b in n)p.style(a,b,n[b])});for(d=0;d<g;d++)e=o[d],i=l.createTween(e,q?h[e]:0),n[e]=h[e]||p.style(a,e),e in h||(h[e]=i.start,q&&(i.end=i.start,i.start=e==="width"||e==="height"?1:0))}}function cY(a,b,c,d,e){return new cY.prototype.init(a,b,c,d,e)}function cZ(a,b){var c,d={height:a},e=0;for(;e<4;e+=2-b)c=bU[e],d["margin"+c]=d["padding"+c]=a;return b&&(d.opacity=d.width=a),d}function c_(a){return p.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}var c,d,e=a.document,f=a.location,g=a.navigator,h=a.jQuery,i=a.$,j=Array.prototype.push,k=Array.prototype.slice,l=Array.prototype.indexOf,m=Object.prototype.toString,n=Object.prototype.hasOwnProperty,o=String.prototype.trim,p=function(a,b){return new p.fn.init(a,b,c)},q=/[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source,r=/\S/,s=/\s+/,t=r.test(" ")?/^[\s\xA0]+|[\s\xA0]+$/g:/^\s+|\s+$/g,u=/^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,v=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,w=/^[\],:{}\s]*$/,x=/(?:^|:|,)(?:\s*\[)+/g,y=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,z=/"[^"\\\r\n]*"|true|false|null|-?(?:\d\d*\.|)\d+(?:[eE][\-+]?\d+|)/g,A=/^-ms-/,B=/-([\da-z])/gi,C=function(a,b){return(b+"").toUpperCase()},D=function(){e.addEventListener?(e.removeEventListener("DOMContentLoaded",D,!1),p.ready()):e.readyState==="complete"&&(e.detachEvent("onreadystatechange",D),p.ready())},E={};p.fn=p.prototype={constructor:p,init:function(a,c,d){var f,g,h,i;if(!a)return this;if(a.nodeType)return this.context=this[0]=a,this.length=1,this;if(typeof a=="string"){a.charAt(0)==="<"&&a.charAt(a.length-1)===">"&&a.length>=3?f=[null,a,null]:f=u.exec(a);if(f&&(f[1]||!c)){if(f[1])return c=c instanceof p?c[0]:c,i=c&&c.nodeType?c.ownerDocument||c:e,a=p.parseHTML(f[1],i,!0),v.test(f[1])&&p.isPlainObject(c)&&this.attr.call(a,c,!0),p.merge(this,a);g=e.getElementById(f[2]);if(g&&g.parentNode){if(g.id!==f[2])return d.find(a);this.length=1,this[0]=g}return this.context=e,this.selector=a,this}return!c||c.jquery?(c||d).find(a):this.constructor(c).find(a)}return p.isFunction(a)?d.ready(a):(a.selector!==b&&(this.selector=a.selector,this.context=a.context),p.makeArray(a,this))},selector:"",jquery:"1.8.0",length:0,size:function(){return this.length},toArray:function(){return k.call(this)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=p.merge(this.constructor(),a);return d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")"),d},each:function(a,b){return p.each(this,a,b)},ready:function(a){return p.ready.promise().done(a),this},eq:function(a){return a=+a,a===-1?this.slice(a):this.slice(a,a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(k.apply(this,arguments),"slice",k.call(arguments).join(","))},map:function(a){return this.pushStack(p.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:j,sort:[].sort,splice:[].splice},p.fn.init.prototype=p.fn,p.extend=p.fn.extend=function(){var a,c,d,e,f,g,h=arguments[0]||{},i=1,j=arguments.length,k=!1;typeof h=="boolean"&&(k=h,h=arguments[1]||{},i=2),typeof h!="object"&&!p.isFunction(h)&&(h={}),j===i&&(h=this,--i);for(;i<j;i++)if((a=arguments[i])!=null)for(c in a){d=h[c],e=a[c];if(h===e)continue;k&&e&&(p.isPlainObject(e)||(f=p.isArray(e)))?(f?(f=!1,g=d&&p.isArray(d)?d:[]):g=d&&p.isPlainObject(d)?d:{},h[c]=p.extend(k,g,e)):e!==b&&(h[c]=e)}return h},p.extend({noConflict:function(b){return a.$===p&&(a.$=i),b&&a.jQuery===p&&(a.jQuery=h),p},isReady:!1,readyWait:1,holdReady:function(a){a?p.readyWait++:p.ready(!0)},ready:function(a){if(a===!0?--p.readyWait:p.isReady)return;if(!e.body)return setTimeout(p.ready,1);p.isReady=!0;if(a!==!0&&--p.readyWait>0)return;d.resolveWith(e,[p]),p.fn.trigger&&p(e).trigger("ready").off("ready")},isFunction:function(a){return p.type(a)==="function"},isArray:Array.isArray||function(a){return p.type(a)==="array"},isWindow:function(a){return a!=null&&a==a.window},isNumeric:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},type:function(a){return a==null?String(a):E[m.call(a)]||"object"},isPlainObject:function(a){if(!a||p.type(a)!=="object"||a.nodeType||p.isWindow(a))return!1;try{if(a.constructor&&!n.call(a,"constructor")&&!n.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||n.call(a,d)},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},error:function(a){throw new Error(a)},parseHTML:function(a,b,c){var d;return!a||typeof a!="string"?null:(typeof b=="boolean"&&(c=b,b=0),b=b||e,(d=v.exec(a))?[b.createElement(d[1])]:(d=p.buildFragment([a],b,c?null:[]),p.merge([],(d.cacheable?p.clone(d.fragment):d.fragment).childNodes)))},parseJSON:function(b){if(!b||typeof b!="string")return null;b=p.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(w.test(b.replace(y,"@").replace(z,"]").replace(x,"")))return(new Function("return "+b))();p.error("Invalid JSON: "+b)},parseXML:function(c){var d,e;if(!c||typeof c!="string")return null;try{a.DOMParser?(e=new DOMParser,d=e.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(f){d=b}return(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&p.error("Invalid XML: "+c),d},noop:function(){},globalEval:function(b){b&&r.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(A,"ms-").replace(B,C)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var e,f=0,g=a.length,h=g===b||p.isFunction(a);if(d){if(h){for(e in a)if(c.apply(a[e],d)===!1)break}else for(;f<g;)if(c.apply(a[f++],d)===!1)break}else if(h){for(e in a)if(c.call(a[e],e,a[e])===!1)break}else for(;f<g;)if(c.call(a[f],f,a[f++])===!1)break;return a},trim:o?function(a){return a==null?"":o.call(a)}:function(a){return a==null?"":a.toString().replace(t,"")},makeArray:function(a,b){var c,d=b||[];return a!=null&&(c=p.type(a),a.length==null||c==="string"||c==="function"||c==="regexp"||p.isWindow(a)?j.call(d,a):p.merge(d,a)),d},inArray:function(a,b,c){var d;if(b){if(l)return l.call(b,a,c);d=b.length,c=c?c<0?Math.max(0,d+c):c:0;for(;c<d;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,c){var d=c.length,e=a.length,f=0;if(typeof d=="number")for(;f<d;f++)a[e++]=c[f];else while(c[f]!==b)a[e++]=c[f++];return a.length=e,a},grep:function(a,b,c){var d,e=[],f=0,g=a.length;c=!!c;for(;f<g;f++)d=!!b(a[f],f),c!==d&&e.push(a[f]);return e},map:function(a,c,d){var e,f,g=[],h=0,i=a.length,j=a instanceof p||i!==b&&typeof i=="number"&&(i>0&&a[0]&&a[i-1]||i===0||p.isArray(a));if(j)for(;h<i;h++)e=c(a[h],h,d),e!=null&&(g[g.length]=e);else for(f in a)e=c(a[f],f,d),e!=null&&(g[g.length]=e);return g.concat.apply([],g)},guid:1,proxy:function(a,c){var d,e,f;return typeof c=="string"&&(d=a[c],c=a,a=d),p.isFunction(a)?(e=k.call(arguments,2),f=function(){return a.apply(c,e.concat(k.call(arguments)))},f.guid=a.guid=a.guid||f.guid||p.guid++,f):b},access:function(a,c,d,e,f,g,h){var i,j=d==null,k=0,l=a.length;if(d&&typeof d=="object"){for(k in d)p.access(a,c,k,d[k],1,g,e);f=1}else if(e!==b){i=h===b&&p.isFunction(e),j&&(i?(i=c,c=function(a,b,c){return i.call(p(a),c)}):(c.call(a,e),c=null));if(c)for(;k<l;k++)c(a[k],d,i?e.call(a[k],k,c(a[k],d)):e,h);f=1}return f?a:j?c.call(a):l?c(a[0],d):g},now:function(){return(new Date).getTime()}}),p.ready.promise=function(b){if(!d){d=p.Deferred();if(e.readyState==="complete"||e.readyState!=="loading"&&e.addEventListener)setTimeout(p.ready,1);else if(e.addEventListener)e.addEventListener("DOMContentLoaded",D,!1),a.addEventListener("load",p.ready,!1);else{e.attachEvent("onreadystatechange",D),a.attachEvent("onload",p.ready);var c=!1;try{c=a.frameElement==null&&e.documentElement}catch(f){}c&&c.doScroll&&function g(){if(!p.isReady){try{c.doScroll("left")}catch(a){return setTimeout(g,50)}p.ready()}}()}}return d.promise(b)},p.each("Boolean Number String Function Array Date RegExp Object".split(" "),function(a,b){E["[object "+b+"]"]=b.toLowerCase()}),c=p(e);var F={};p.Callbacks=function(a){a=typeof a=="string"?F[a]||G(a):p.extend({},a);var c,d,e,f,g,h,i=[],j=!a.once&&[],k=function(b){c=a.memory&&b,d=!0,h=f||0,f=0,g=i.length,e=!0;for(;i&&h<g;h++)if(i[h].apply(b[0],b[1])===!1&&a.stopOnFalse){c=!1;break}e=!1,i&&(j?j.length&&k(j.shift()):c?i=[]:l.disable())},l={add:function(){if(i){var b=i.length;(function d(b){p.each(b,function(b,c){p.isFunction(c)&&(!a.unique||!l.has(c))?i.push(c):c&&c.length&&d(c)})})(arguments),e?g=i.length:c&&(f=b,k(c))}return this},remove:function(){return i&&p.each(arguments,function(a,b){var c;while((c=p.inArray(b,i,c))>-1)i.splice(c,1),e&&(c<=g&&g--,c<=h&&h--)}),this},has:function(a){return p.inArray(a,i)>-1},empty:function(){return i=[],this},disable:function(){return i=j=c=b,this},disabled:function(){return!i},lock:function(){return j=b,c||l.disable(),this},locked:function(){return!j},fireWith:function(a,b){return b=b||[],b=[a,b.slice?b.slice():b],i&&(!d||j)&&(e?j.push(b):k(b)),this},fire:function(){return l.fireWith(this,arguments),this},fired:function(){return!!d}};return l},p.extend({Deferred:function(a){var b=[["resolve","done",p.Callbacks("once memory"),"resolved"],["reject","fail",p.Callbacks("once memory"),"rejected"],["notify","progress",p.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return p.Deferred(function(c){p.each(b,function(b,d){var f=d[0],g=a[b];e[d[1]](p.isFunction(g)?function(){var a=g.apply(this,arguments);a&&p.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f+"With"](this===e?c:this,[a])}:c[f])}),a=null}).promise()},promise:function(a){return typeof a=="object"?p.extend(a,d):d}},e={};return d.pipe=d.then,p.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[a^1][2].disable,b[2][2].lock),e[f[0]]=g.fire,e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=k.call(arguments),d=c.length,e=d!==1||a&&p.isFunction(a.promise)?d:0,f=e===1?a:p.Deferred(),g=function(a,b,c){return function(d){b[a]=this,c[a]=arguments.length>1?k.call(arguments):d,c===h?f.notifyWith(b,c):--e||f.resolveWith(b,c)}},h,i,j;if(d>1){h=new Array(d),i=new Array(d),j=new Array(d);for(;b<d;b++)c[b]&&p.isFunction(c[b].promise)?c[b].promise().done(g(b,j,c)).fail(f.reject).progress(g(b,i,h)):--e}return e||f.resolveWith(j,c),f.promise()}}),p.support=function(){var b,c,d,f,g,h,i,j,k,l,m,n=e.createElement("div");n.setAttribute("className","t"),n.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",c=n.getElementsByTagName("*"),d=n.getElementsByTagName("a")[0],d.style.cssText="top:1px;float:left;opacity:.5";if(!c||!c.length||!d)return{};f=e.createElement("select"),g=f.appendChild(e.createElement("option")),h=n.getElementsByTagName("input")[0],b={leadingWhitespace:n.firstChild.nodeType===3,tbody:!n.getElementsByTagName("tbody").length,htmlSerialize:!!n.getElementsByTagName("link").length,style:/top/.test(d.getAttribute("style")),hrefNormalized:d.getAttribute("href")==="/a",opacity:/^0.5/.test(d.style.opacity),cssFloat:!!d.style.cssFloat,checkOn:h.value==="on",optSelected:g.selected,getSetAttribute:n.className!=="t",enctype:!!e.createElement("form").enctype,html5Clone:e.createElement("nav").cloneNode(!0).outerHTML!=="<:nav></:nav>",boxModel:e.compatMode==="CSS1Compat",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,boxSizingReliable:!0,pixelPosition:!1},h.checked=!0,b.noCloneChecked=h.cloneNode(!0).checked,f.disabled=!0,b.optDisabled=!g.disabled;try{delete n.test}catch(o){b.deleteExpando=!1}!n.addEventListener&&n.attachEvent&&n.fireEvent&&(n.attachEvent("onclick",m=function(){b.noCloneEvent=!1}),n.cloneNode(!0).fireEvent("onclick"),n.detachEvent("onclick",m)),h=e.createElement("input"),h.value="t",h.setAttribute("type","radio"),b.radioValue=h.value==="t",h.setAttribute("checked","checked"),h.setAttribute("name","t"),n.appendChild(h),i=e.createDocumentFragment(),i.appendChild(n.lastChild),b.checkClone=i.cloneNode(!0).cloneNode(!0).lastChild.checked,b.appendChecked=h.checked,i.removeChild(h),i.appendChild(n);if(n.attachEvent)for(k in{submit:!0,change:!0,focusin:!0})j="on"+k,l=j in n,l||(n.setAttribute(j,"return;"),l=typeof n[j]=="function"),b[k+"Bubbles"]=l;return p(function(){var c,d,f,g,h="padding:0;margin:0;border:0;display:block;overflow:hidden;",i=e.getElementsByTagName("body")[0];if(!i)return;c=e.createElement("div"),c.style.cssText="visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:1px",i.insertBefore(c,i.firstChild),d=e.createElement("div"),c.appendChild(d),d.innerHTML="<table><tr><td></td><td>t</td></tr></table>",f=d.getElementsByTagName("td"),f[0].style.cssText="padding:0;margin:0;border:0;display:none",l=f[0].offsetHeight===0,f[0].style.display="",f[1].style.display="none",b.reliableHiddenOffsets=l&&f[0].offsetHeight===0,d.innerHTML="",d.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",b.boxSizing=d.offsetWidth===4,b.doesNotIncludeMarginInBodyOffset=i.offsetTop!==1,a.getComputedStyle&&(b.pixelPosition=(a.getComputedStyle(d,null)||{}).top!=="1%",b.boxSizingReliable=(a.getComputedStyle(d,null)||{width:"4px"}).width==="4px",g=e.createElement("div"),g.style.cssText=d.style.cssText=h,g.style.marginRight=g.style.width="0",d.style.width="1px",d.appendChild(g),b.reliableMarginRight=!parseFloat((a.getComputedStyle(g,null)||{}).marginRight)),typeof d.style.zoom!="undefined"&&(d.innerHTML="",d.style.cssText=h+"width:1px;padding:1px;display:inline;zoom:1",b.inlineBlockNeedsLayout=d.offsetWidth===3,d.style.display="block",d.style.overflow="visible",d.innerHTML="<div></div>",d.firstChild.style.width="5px",b.shrinkWrapBlocks=d.offsetWidth!==3,c.style.zoom=1),i.removeChild(c),c=d=f=g=null}),i.removeChild(n),c=d=f=g=h=i=n=null,b}();var H=/^(?:\{.*\}|\[.*\])$/,I=/([A-Z])/g;p.extend({cache:{},deletedIds:[],uuid:0,expando:"jQuery"+(p.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){return a=a.nodeType?p.cache[a[p.expando]]:a[p.expando],!!a&&!K(a)},data:function(a,c,d,e){if(!p.acceptData(a))return;var f,g,h=p.expando,i=typeof c=="string",j=a.nodeType,k=j?p.cache:a,l=j?a[h]:a[h]&&h;if((!l||!k[l]||!e&&!k[l].data)&&i&&d===b)return;l||(j?a[h]=l=p.deletedIds.pop()||++p.uuid:l=h),k[l]||(k[l]={},j||(k[l].toJSON=p.noop));if(typeof c=="object"||typeof c=="function")e?k[l]=p.extend(k[l],c):k[l].data=p.extend(k[l].data,c);return f=k[l],e||(f.data||(f.data={}),f=f.data),d!==b&&(f[p.camelCase(c)]=d),i?(g=f[c],g==null&&(g=f[p.camelCase(c)])):g=f,g},removeData:function(a,b,c){if(!p.acceptData(a))return;var d,e,f,g=a.nodeType,h=g?p.cache:a,i=g?a[p.expando]:p.expando;if(!h[i])return;if(b){d=c?h[i]:h[i].data;if(d){p.isArray(b)||(b in d?b=[b]:(b=p.camelCase(b),b in d?b=[b]:b=b.split(" ")));for(e=0,f=b.length;e<f;e++)delete d[b[e]];if(!(c?K:p.isEmptyObject)(d))return}}if(!c){delete h[i].data;if(!K(h[i]))return}g?p.cleanData([a],!0):p.support.deleteExpando||h!=h.window?delete h[i]:h[i]=null},_data:function(a,b,c){return p.data(a,b,c,!0)},acceptData:function(a){var b=a.nodeName&&p.noData[a.nodeName.toLowerCase()];return!b||b!==!0&&a.getAttribute("classid")===b}}),p.fn.extend({data:function(a,c){var d,e,f,g,h,i=this[0],j=0,k=null;if(a===b){if(this.length){k=p.data(i);if(i.nodeType===1&&!p._data(i,"parsedAttrs")){f=i.attributes;for(h=f.length;j<h;j++)g=f[j].name,g.indexOf("data-")===0&&(g=p.camelCase(g.substring(5)),J(i,g,k[g]));p._data(i,"parsedAttrs",!0)}}return k}return typeof a=="object"?this.each(function(){p.data(this,a)}):(d=a.split(".",2),d[1]=d[1]?"."+d[1]:"",e=d[1]+"!",p.access(this,function(c){if(c===b)return k=this.triggerHandler("getData"+e,[d[0]]),k===b&&i&&(k=p.data(i,a),k=J(i,a,k)),k===b&&d[1]?this.data(d[0]):k;d[1]=c,this.each(function(){var b=p(this);b.triggerHandler("setData"+e,d),p.data(this,a,c),b.triggerHandler("changeData"+e,d)})},null,c,arguments.length>1,null,!1))},removeData:function(a){return this.each(function(){p.removeData(this,a)})}}),p.extend({queue:function(a,b,c){var d;if(a)return b=(b||"fx")+"queue",d=p._data(a,b),c&&(!d||p.isArray(c)?d=p._data(a,b,p.makeArray(c)):d.push(c)),d||[]},dequeue:function(a,b){b=b||"fx";var c=p.queue(a,b),d=c.shift(),e=p._queueHooks(a,b),f=function(){p.dequeue(a,b)};d==="inprogress"&&(d=c.shift()),d&&(b==="fx"&&c.unshift("inprogress"),delete e.stop,d.call(a,f,e)),!c.length&&e&&e.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return p._data(a,c)||p._data(a,c,{empty:p.Callbacks("once memory").add(function(){p.removeData(a,b+"queue",!0),p.removeData(a,c,!0)})})}}),p.fn.extend({queue:function(a,c){var d=2;return typeof a!="string"&&(c=a,a="fx",d--),arguments.length<d?p.queue(this[0],a):c===b?this:this.each(function(){var b=p.queue(this,a,c);p._queueHooks(this,a),a==="fx"&&b[0]!=="inprogress"&&p.dequeue(this,a)})},dequeue:function(a){return this.each(function(){p.dequeue(this,a)})},delay:function(a,b){return a=p.fx?p.fx.speeds[a]||a:a,b=b||"fx",this.queue(b,function(b,c){var d=setTimeout(b,a);c.stop=function(){clearTimeout(d)}})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,c){var d,e=1,f=p.Deferred(),g=this,h=this.length,i=function(){--e||f.resolveWith(g,[g])};typeof a!="string"&&(c=a,a=b),a=a||"fx";while(h--)(d=p._data(g[h],a+"queueHooks"))&&d.empty&&(e++,d.empty.add(i));return i(),f.promise(c)}});var L,M,N,O=/[\t\r\n]/g,P=/\r/g,Q=/^(?:button|input)$/i,R=/^(?:button|input|object|select|textarea)$/i,S=/^a(?:rea|)$/i,T=/^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,U=p.support.getSetAttribute;p.fn.extend({attr:function(a,b){return p.access(this,p.attr,a,b,arguments.length>1)},removeAttr:function(a){return this.each(function(){p.removeAttr(this,a)})},prop:function(a,b){return p.access(this,p.prop,a,b,arguments.length>1)},removeProp:function(a){return a=p.propFix[a]||a,this.each(function(){try{this[a]=b,delete this[a]}catch(c){}})},addClass:function(a){var b,c,d,e,f,g,h;if(p.isFunction(a))return this.each(function(b){p(this).addClass(a.call(this,b,this.className))});if(a&&typeof a=="string"){b=a.split(s);for(c=0,d=this.length;c<d;c++){e=this[c];if(e.nodeType===1)if(!e.className&&b.length===1)e.className=a;else{f=" "+e.className+" ";for(g=0,h=b.length;g<h;g++)~f.indexOf(" "+b[g]+" ")||(f+=b[g]+" ");e.className=p.trim(f)}}}return this},removeClass:function(a){var c,d,e,f,g,h,i;if(p.isFunction(a))return this.each(function(b){p(this).removeClass(a.call(this,b,this.className))});if(a&&typeof a=="string"||a===b){c=(a||"").split(s);for(h=0,i=this.length;h<i;h++){e=this[h];if(e.nodeType===1&&e.className){d=(" "+e.className+" ").replace(O," ");for(f=0,g=c.length;f<g;f++)while(d.indexOf(" "+c[f]+" ")>-1)d=d.replace(" "+c[f]+" "," ");e.className=a?p.trim(d):""}}}return this},toggleClass:function(a,b){var c=typeof a,d=typeof b=="boolean";return p.isFunction(a)?this.each(function(c){p(this).toggleClass(a.call(this,c,this.className,b),b)}):this.each(function(){if(c==="string"){var e,f=0,g=p(this),h=b,i=a.split(s);while(e=i[f++])h=d?h:!g.hasClass(e),g[h?"addClass":"removeClass"](e)}else if(c==="undefined"||c==="boolean")this.className&&p._data(this,"__className__",this.className),this.className=this.className||a===!1?"":p._data(this,"__className__")||""})},hasClass:function(a){var b=" "+a+" ",c=0,d=this.length;for(;c<d;c++)if(this[c].nodeType===1&&(" "+this[c].className+" ").replace(O," ").indexOf(b)>-1)return!0;return!1},val:function(a){var c,d,e,f=this[0];if(!arguments.length){if(f)return c=p.valHooks[f.type]||p.valHooks[f.nodeName.toLowerCase()],c&&"get"in c&&(d=c.get(f,"value"))!==b?d:(d=f.value,typeof d=="string"?d.replace(P,""):d==null?"":d);return}return e=p.isFunction(a),this.each(function(d){var f,g=p(this);if(this.nodeType!==1)return;e?f=a.call(this,d,g.val()):f=a,f==null?f="":typeof f=="number"?f+="":p.isArray(f)&&(f=p.map(f,function(a){return a==null?"":a+""})),c=p.valHooks[this.type]||p.valHooks[this.nodeName.toLowerCase()];if(!c||!("set"in c)||c.set(this,f,"value")===b)this.value=f})}}),p.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c,d,e,f=a.selectedIndex,g=[],h=a.options,i=a.type==="select-one";if(f<0)return null;c=i?f:0,d=i?f+1:h.length;for(;c<d;c++){e=h[c];if(e.selected&&(p.support.optDisabled?!e.disabled:e.getAttribute("disabled")===null)&&(!e.parentNode.disabled||!p.nodeName(e.parentNode,"optgroup"))){b=p(e).val();if(i)return b;g.push(b)}}return i&&!g.length&&h.length?p(h[f]).val():g},set:function(a,b){var c=p.makeArray(b);return p(a).find("option").each(function(){this.selected=p.inArray(p(this).val(),c)>=0}),c.length||(a.selectedIndex=-1),c}}},attrFn:{},attr:function(a,c,d,e){var f,g,h,i=a.nodeType;if(!a||i===3||i===8||i===2)return;if(e&&p.isFunction(p.fn[c]))return p(a)[c](d);if(typeof a.getAttribute=="undefined")return p.prop(a,c,d);h=i!==1||!p.isXMLDoc(a),h&&(c=c.toLowerCase(),g=p.attrHooks[c]||(T.test(c)?M:L));if(d!==b){if(d===null){p.removeAttr(a,c);return}return g&&"set"in g&&h&&(f=g.set(a,d,c))!==b?f:(a.setAttribute(c,""+d),d)}return g&&"get"in g&&h&&(f=g.get(a,c))!==null?f:(f=a.getAttribute(c),f===null?b:f)},removeAttr:function(a,b){var c,d,e,f,g=0;if(b&&a.nodeType===1){d=b.split(s);for(;g<d.length;g++)e=d[g],e&&(c=p.propFix[e]||e,f=T.test(e),f||p.attr(a,e,""),a.removeAttribute(U?e:c),f&&c in a&&(a[c]=!1))}},attrHooks:{type:{set:function(a,b){if(Q.test(a.nodeName)&&a.parentNode)p.error("type property can't be changed");else if(!p.support.radioValue&&b==="radio"&&p.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}},value:{get:function(a,b){return L&&p.nodeName(a,"button")?L.get(a,b):b in a?a.value:null},set:function(a,b,c){if(L&&p.nodeName(a,"button"))return L.set(a,b,c);a.value=b}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(a,c,d){var e,f,g,h=a.nodeType;if(!a||h===3||h===8||h===2)return;return g=h!==1||!p.isXMLDoc(a),g&&(c=p.propFix[c]||c,f=p.propHooks[c]),d!==b?f&&"set"in f&&(e=f.set(a,d,c))!==b?e:a[c]=d:f&&"get"in f&&(e=f.get(a,c))!==null?e:a[c]},propHooks:{tabIndex:{get:function(a){var c=a.getAttributeNode("tabindex");return c&&c.specified?parseInt(c.value,10):R.test(a.nodeName)||S.test(a.nodeName)&&a.href?0:b}}}}),M={get:function(a,c){var d,e=p.prop(a,c);return e===!0||typeof e!="boolean"&&(d=a.getAttributeNode(c))&&d.nodeValue!==!1?c.toLowerCase():b},set:function(a,b,c){var d;return b===!1?p.removeAttr(a,c):(d=p.propFix[c]||c,d in a&&(a[d]=!0),a.setAttribute(c,c.toLowerCase())),c}},U||(N={name:!0,id:!0,coords:!0},L=p.valHooks.button={get:function(a,c){var d;return d=a.getAttributeNode(c),d&&(N[c]?d.value!=="":d.specified)?d.value:b},set:function(a,b,c){var d=a.getAttributeNode(c);return d||(d=e.createAttribute(c),a.setAttributeNode(d)),d.value=b+""}},p.each(["width","height"],function(a,b){p.attrHooks[b]=p.extend(p.attrHooks[b],{set:function(a,c){if(c==="")return a.setAttribute(b,"auto"),c}})}),p.attrHooks.contenteditable={get:L.get,set:function(a,b,c){b===""&&(b="false"),L.set(a,b,c)}}),p.support.hrefNormalized||p.each(["href","src","width","height"],function(a,c){p.attrHooks[c]=p.extend(p.attrHooks[c],{get:function(a){var d=a.getAttribute(c,2);return d===null?b:d}})}),p.support.style||(p.attrHooks.style={get:function(a){return a.style.cssText.toLowerCase()||b},set:function(a,b){return a.style.cssText=""+b}}),p.support.optSelected||(p.propHooks.selected=p.extend(p.propHooks.selected,{get:function(a){var b=a.parentNode;return b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex),null}})),p.support.enctype||(p.propFix.enctype="encoding"),p.support.checkOn||p.each(["radio","checkbox"],function(){p.valHooks[this]={get:function(a){return a.getAttribute("value")===null?"on":a.value}}}),p.each(["radio","checkbox"],function(){p.valHooks[this]=p.extend(p.valHooks[this],{set:function(a,b){if(p.isArray(b))return a.checked=p.inArray(p(a).val(),b)>=0}})});var V=/^(?:textarea|input|select)$/i,W=/^([^\.]*|)(?:\.(.+)|)$/,X=/(?:^|\s)hover(\.\S+|)\b/,Y=/^key/,Z=/^(?:mouse|contextmenu)|click/,$=/^(?:focusinfocus|focusoutblur)$/,_=function(a){return p.event.special.hover?a:a.replace(X,"mouseenter$1 mouseleave$1")};p.event={add:function(a,c,d,e,f){var g,h,i,j,k,l,m,n,o,q,r;if(a.nodeType===3||a.nodeType===8||!c||!d||!(g=p._data(a)))return;d.handler&&(o=d,d=o.handler,f=o.selector),d.guid||(d.guid=p.guid++),i=g.events,i||(g.events=i={}),h=g.handle,h||(g.handle=h=function(a){return typeof p!="undefined"&&(!a||p.event.triggered!==a.type)?p.event.dispatch.apply(h.elem,arguments):b},h.elem=a),c=p.trim(_(c)).split(" ");for(j=0;j<c.length;j++){k=W.exec(c[j])||[],l=k[1],m=(k[2]||"").split(".").sort(),r=p.event.special[l]||{},l=(f?r.delegateType:r.bindType)||l,r=p.event.special[l]||{},n=p.extend({type:l,origType:k[1],data:e,handler:d,guid:d.guid,selector:f,namespace:m.join(".")},o),q=i[l];if(!q){q=i[l]=[],q.delegateCount=0;if(!r.setup||r.setup.call(a,e,m,h)===!1)a.addEventListener?a.addEventListener(l,h,!1):a.attachEvent&&a.attachEvent("on"+l,h)}r.add&&(r.add.call(a,n),n.handler.guid||(n.handler.guid=d.guid)),f?q.splice(q.delegateCount++,0,n):q.push(n),p.event.global[l]=!0}a=null},global:{},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,q,r=p.hasData(a)&&p._data(a);if(!r||!(m=r.events))return;b=p.trim(_(b||"")).split(" ");for(f=0;f<b.length;f++){g=W.exec(b[f])||[],h=i=g[1],j=g[2];if(!h){for(h in m)p.event.remove(a,h+b[f],c,d,!0);continue}n=p.event.special[h]||{},h=(d?n.delegateType:n.bindType)||h,o=m[h]||[],k=o.length,j=j?new RegExp("(^|\\.)"+j.split(".").sort().join("\\.(?:.*\\.|)")+"(\\.|$)"):null;for(l=0;l<o.length;l++)q=o[l],(e||i===q.origType)&&(!c||c.guid===q.guid)&&(!j||j.test(q.namespace))&&(!d||d===q.selector||d==="**"&&q.selector)&&(o.splice(l--,1),q.selector&&o.delegateCount--,n.remove&&n.remove.call(a,q));o.length===0&&k!==o.length&&((!n.teardown||n.teardown.call(a,j,r.handle)===!1)&&p.removeEvent(a,h,r.handle),delete m[h])}p.isEmptyObject(m)&&(delete r.handle,p.removeData(a,"events",!0))},customEvent:{getData:!0,setData:!0,changeData:!0},trigger:function(c,d,f,g){if(!f||f.nodeType!==3&&f.nodeType!==8){var h,i,j,k,l,m,n,o,q,r,s=c.type||c,t=[];if($.test(s+p.event.triggered))return;s.indexOf("!")>=0&&(s=s.slice(0,-1),i=!0),s.indexOf(".")>=0&&(t=s.split("."),s=t.shift(),t.sort());if((!f||p.event.customEvent[s])&&!p.event.global[s])return;c=typeof c=="object"?c[p.expando]?c:new p.Event(s,c):new p.Event(s),c.type=s,c.isTrigger=!0,c.exclusive=i,c.namespace=t.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+t.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,m=s.indexOf(":")<0?"on"+s:"";if(!f){h=p.cache;for(j in h)h[j].events&&h[j].events[s]&&p.event.trigger(c,d,h[j].handle.elem,!0);return}c.result=b,c.target||(c.target=f),d=d!=null?p.makeArray(d):[],d.unshift(c),n=p.event.special[s]||{};if(n.trigger&&n.trigger.apply(f,d)===!1)return;q=[[f,n.bindType||s]];if(!g&&!n.noBubble&&!p.isWindow(f)){r=n.delegateType||s,k=$.test(r+s)?f:f.parentNode;for(l=f;k;k=k.parentNode)q.push([k,r]),l=k;l===(f.ownerDocument||e)&&q.push([l.defaultView||l.parentWindow||a,r])}for(j=0;j<q.length&&!c.isPropagationStopped();j++)k=q[j][0],c.type=q[j][1],o=(p._data(k,"events")||{})[c.type]&&p._data(k,"handle"),o&&o.apply(k,d),o=m&&k[m],o&&p.acceptData(k)&&o.apply(k,d)===!1&&c.preventDefault();return c.type=s,!g&&!c.isDefaultPrevented()&&(!n._default||n._default.apply(f.ownerDocument,d)===!1)&&(s!=="click"||!p.nodeName(f,"a"))&&p.acceptData(f)&&m&&f[s]&&(s!=="focus"&&s!=="blur"||c.target.offsetWidth!==0)&&!p.isWindow(f)&&(l=f[m],l&&(f[m]=null),p.event.triggered=s,f[s](),p.event.triggered=b,l&&(f[m]=l)),c.result}return},dispatch:function(c){c=p.event.fix(c||a.event);var d,e,f,g,h,i,j,k,l,m,n,o=(p._data(this,"events")||{})[c.type]||[],q=o.delegateCount,r=[].slice.call(arguments),s=!c.exclusive&&!c.namespace,t=p.event.special[c.type]||{},u=[];r[0]=c,c.delegateTarget=this;if(t.preDispatch&&t.preDispatch.call(this,c)===!1)return;if(q&&(!c.button||c.type!=="click")){g=p(this),g.context=this;for(f=c.target;f!=this;f=f.parentNode||this)if(f.disabled!==!0||c.type!=="click"){i={},k=[],g[0]=f;for(d=0;d<q;d++)l=o[d],m=l.selector,i[m]===b&&(i[m]=g.is(m)),i[m]&&k.push(l);k.length&&u.push({elem:f,matches:k})}}o.length>q&&u.push({elem:this,matches:o.slice(q)});for(d=0;d<u.length&&!c.isPropagationStopped();d++){j=u[d],c.currentTarget=j.elem;for(e=0;e<j.matches.length&&!c.isImmediatePropagationStopped();e++){l=j.matches[e];if(s||!c.namespace&&!l.namespace||c.namespace_re&&c.namespace_re.test(l.namespace))c.data=l.data,c.handleObj=l,h=((p.event.special[l.origType]||{}).handle||l.handler).apply(j.elem,r),h!==b&&(c.result=h,h===!1&&(c.preventDefault(),c.stopPropagation()))}}return t.postDispatch&&t.postDispatch.call(this,c),c.result},props:"attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(a,b){return a.which==null&&(a.which=b.charCode!=null?b.charCode:b.keyCode),a}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(a,c){var d,f,g,h=c.button,i=c.fromElement;return a.pageX==null&&c.clientX!=null&&(d=a.target.ownerDocument||e,f=d.documentElement,g=d.body,a.pageX=c.clientX+(f&&f.scrollLeft||g&&g.scrollLeft||0)-(f&&f.clientLeft||g&&g.clientLeft||0),a.pageY=c.clientY+(f&&f.scrollTop||g&&g.scrollTop||0)-(f&&f.clientTop||g&&g.clientTop||0)),!a.relatedTarget&&i&&(a.relatedTarget=i===a.target?c.toElement:i),!a.which&&h!==b&&(a.which=h&1?1:h&2?3:h&4?2:0),a}},fix:function(a){if(a[p.expando])return a;var b,c,d=a,f=p.event.fixHooks[a.type]||{},g=f.props?this.props.concat(f.props):this.props;a=p.Event(d);for(b=g.length;b;)c=g[--b],a[c]=d[c];return a.target||(a.target=d.srcElement||e),a.target.nodeType===3&&(a.target=a.target.parentNode),a.metaKey=!!a.metaKey,f.filter?f.filter(a,d):a},special:{ready:{setup:p.bindReady},load:{noBubble:!0},focus:{delegateType:"focusin"},blur:{delegateType:"focusout"},beforeunload:{setup:function(a,b,c){p.isWindow(this)&&(this.onbeforeunload=c)},teardown:function(a,b){this.onbeforeunload===b&&(this.onbeforeunload=null)}}},simulate:function(a,b,c,d){var e=p.extend(new p.Event,c,{type:a,isSimulated:!0,originalEvent:{}});d?p.event.trigger(e,null,b):p.event.dispatch.call(b,e),e.isDefaultPrevented()&&c.preventDefault()}},p.event.handle=p.event.dispatch,p.removeEvent=e.removeEventListener?function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c,!1)}:function(a,b,c){var d="on"+b;a.detachEvent&&(typeof a[d]=="undefined"&&(a[d]=null),a.detachEvent(d,c))},p.Event=function(a,b){if(this instanceof p.Event)a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||a.returnValue===!1||a.getPreventDefault&&a.getPreventDefault()?bb:ba):this.type=a,b&&p.extend(this,b),this.timeStamp=a&&a.timeStamp||p.now(),this[p.expando]=!0;else return new p.Event(a,b)},p.Event.prototype={preventDefault:function(){this.isDefaultPrevented=bb;var a=this.originalEvent;if(!a)return;a.preventDefault?a.preventDefault():a.returnValue=!1},stopPropagation:function(){this.isPropagationStopped=bb;var a=this.originalEvent;if(!a)return;a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=bb,this.stopPropagation()},isDefaultPrevented:ba,isPropagationStopped:ba,isImmediatePropagationStopped:ba},p.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){p.event.special[a]={delegateType:b,bindType:b,handle:function(a){var c,d=this,e=a.relatedTarget,f=a.handleObj,g=f.selector;if(!e||e!==d&&!p.contains(d,e))a.type=f.origType,c=f.handler.apply(this,arguments),a.type=b;return c}}}),p.support.submitBubbles||(p.event.special.submit={setup:function(){if(p.nodeName(this,"form"))return!1;p.event.add(this,"click._submit keypress._submit",function(a){var c=a.target,d=p.nodeName(c,"input")||p.nodeName(c,"button")?c.form:b;d&&!p._data(d,"_submit_attached")&&(p.event.add(d,"submit._submit",function(a){a._submit_bubble=!0}),p._data(d,"_submit_attached",!0))})},postDispatch:function(a){a._submit_bubble&&(delete a._submit_bubble,this.parentNode&&!a.isTrigger&&p.event.simulate("submit",this.parentNode,a,!0))},teardown:function(){if(p.nodeName(this,"form"))return!1;p.event.remove(this,"._submit")}}),p.support.changeBubbles||(p.event.special.change={setup:function(){if(V.test(this.nodeName)){if(this.type==="checkbox"||this.type==="radio")p.event.add(this,"propertychange._change",function(a){a.originalEvent.propertyName==="checked"&&(this._just_changed=!0)}),p.event.add(this,"click._change",function(a){this._just_changed&&!a.isTrigger&&(this._just_changed=!1),p.event.simulate("change",this,a,!0)});return!1}p.event.add(this,"beforeactivate._change",function(a){var b=a.target;V.test(b.nodeName)&&!p._data(b,"_change_attached")&&(p.event.add(b,"change._change",function(a){this.parentNode&&!a.isSimulated&&!a.isTrigger&&p.event.simulate("change",this.parentNode,a,!0)}),p._data(b,"_change_attached",!0))})},handle:function(a){var b=a.target;if(this!==b||a.isSimulated||a.isTrigger||b.type!=="radio"&&b.type!=="checkbox")return a.handleObj.handler.apply(this,arguments)},teardown:function(){return p.event.remove(this,"._change"),V.test(this.nodeName)}}),p.support.focusinBubbles||p.each({focus:"focusin",blur:"focusout"},function(a,b){var c=0,d=function(a){p.event.simulate(b,a.target,p.event.fix(a),!0)};p.event.special[b]={setup:function(){c++===0&&e.addEventListener(a,d,!0)},teardown:function(){--c===0&&e.removeEventListener(a,d,!0)}}}),p.fn.extend({on:function(a,c,d,e,f){var g,h;if(typeof a=="object"){typeof c!="string"&&(d=d||c,c=b);for(h in a)this.on(h,c,d,a[h],f);return this}d==null&&e==null?(e=c,d=c=b):e==null&&(typeof c=="string"?(e=d,d=b):(e=d,d=c,c=b));if(e===!1)e=ba;else if(!e)return this;return f===1&&(g=e,e=function(a){return p().off(a),g.apply(this,arguments)},e.guid=g.guid||(g.guid=p.guid++)),this.each(function(){p.event.add(this,a,e,d,c)})},one:function(a,b,c,d){return this.on(a,b,c,d,1)},off:function(a,c,d){var e,f;if(a&&a.preventDefault&&a.handleObj)return e=a.handleObj,p(a.delegateTarget).off(e.namespace?e.origType+"."+e.namespace:e.origType,e.selector,e.handler),this;if(typeof a=="object"){for(f in a)this.off(f,c,a[f]);return this}if(c===!1||typeof c=="function")d=c,c=b;return d===!1&&(d=ba),this.each(function(){p.event.remove(this,a,d,c)})},bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},live:function(a,b,c){return p(this.context).on(a,this.selector,b,c),this},die:function(a,b){return p(this.context).off(a,this.selector||"**",b),this},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return arguments.length==1?this.off(a,"**"):this.off(b,a||"**",c)},trigger:function(a,b){return this.each(function(){p.event.trigger(a,b,this)})},triggerHandler:function(a,b){if(this[0])return p.event.trigger(a,b,this[0],!0)},toggle:function(a){var b=arguments,c=a.guid||p.guid++,d=0,e=function(c){var e=(p._data(this,"lastToggle"+a.guid)||0)%d;return p._data(this,"lastToggle"+a.guid,e+1),c.preventDefault(),b[e].apply(this,arguments)||!1};e.guid=c;while(d<b.length)b[d++].guid=c;return this.click(e)},hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}}),p.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){p.fn[b]=function(a,c){return c==null&&(c=a,a=null),arguments.length>0?this.on(b,null,a,c):this.trigger(b)},Y.test(b)&&(p.event.fixHooks[b]=p.event.keyHooks),Z.test(b)&&(p.event.fixHooks[b]=p.event.mouseHooks)}),function(a,b){function bd(a,b,c,d){var e=0,f=b.length;for(;e<f;e++)Z(a,b[e],c,d)}function be(a,b,c,d,e,f){var g,h=$.setFilters[b.toLowerCase()];return h||Z.error(b),(a||!(g=e))&&bd(a||"*",d,g=[],e),g.length>0?h(g,c,f):[]}function bf(a,c,d,e,f){var g,h,i,j,k,l,m,n,p=0,q=f.length,s=L.POS,t=new RegExp("^"+s.source+"(?!"+r+")","i"),u=function(){var a=1,c=arguments.length-2;for(;a<c;a++)arguments[a]===b&&(g[a]=b)};for(;p<q;p++){s.exec(""),a=f[p],j=[],i=0,k=e;while(g=s.exec(a)){n=s.lastIndex=g.index+g[0].length;if(n>i){m=a.slice(i,g.index),i=n,l=[c],B.test(m)&&(k&&(l=k),k=e);if(h=H.test(m))m=m.slice(0,-5).replace(B,"$&*");g.length>1&&g[0].replace(t,u),k=be(m,g[1],g[2],l,k,h)}}k?(j=j.concat(k),(m=a.slice(i))&&m!==")"?B.test(m)?bd(m,j,d,e):Z(m,c,d,e?e.concat(k):k):o.apply(d,j)):Z(a,c,d,e)}return q===1?d:Z.uniqueSort(d)}function bg(a,b,c){var d,e,f,g=[],i=0,j=D.exec(a),k=!j.pop()&&!j.pop(),l=k&&a.match(C)||[""],m=$.preFilter,n=$.filter,o=!c&&b!==h;for(;(e=l[i])!=null&&k;i++){g.push(d=[]),o&&(e=" "+e);while(e){k=!1;if(j=B.exec(e))e=e.slice(j[0].length),k=d.push({part:j.pop().replace(A," "),captures:j});for(f in n)(j=L[f].exec(e))&&(!m[f]||(j=m[f](j,b,c)))&&(e=e.slice(j.shift().length),k=d.push({part:f,captures:j}));if(!k)break}}return k||Z.error(a),g}function bh(a,b,e){var f=b.dir,g=m++;return a||(a=function(a){return a===e}),b.first?function(b,c){while(b=b[f])if(b.nodeType===1)return a(b,c)&&b}:function(b,e){var h,i=g+"."+d,j=i+"."+c;while(b=b[f])if(b.nodeType===1){if((h=b[q])===j)return b.sizset;if(typeof h=="string"&&h.indexOf(i)===0){if(b.sizset)return b}else{b[q]=j;if(a(b,e))return b.sizset=!0,b;b.sizset=!1}}}}function bi(a,b){return a?function(c,d){var e=b(c,d);return e&&a(e===!0?c:e,d)}:b}function bj(a,b,c){var d,e,f=0;for(;d=a[f];f++)$.relative[d.part]?e=bh(e,$.relative[d.part],b):(d.captures.push(b,c),e=bi(e,$.filter[d.part].apply(null,d.captures)));return e}function bk(a){return function(b,c){var d,e=0;for(;d=a[e];e++)if(d(b,c))return!0;return!1}}var c,d,e,f,g,h=a.document,i=h.documentElement,j="undefined",k=!1,l=!0,m=0,n=[].slice,o=[].push,q=("sizcache"+Math.random()).replace(".",""),r="[\\x20\\t\\r\\n\\f]",s="(?:\\\\.|[-\\w]|[^\\x00-\\xa0])+",t=s.replace("w","w#"),u="([*^$|!~]?=)",v="\\["+r+"*("+s+")"+r+"*(?:"+u+r+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+t+")|)|)"+r+"*\\]",w=":("+s+")(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|((?:[^,]|\\\\,|(?:,(?=[^\\[]*\\]))|(?:,(?=[^\\(]*\\))))*))\\)|)",x=":(nth|eq|gt|lt|first|last|even|odd)(?:\\((\\d*)\\)|)(?=[^-]|$)",y=r+"*([\\x20\\t\\r\\n\\f>+~])"+r+"*",z="(?=[^\\x20\\t\\r\\n\\f])(?:\\\\.|"+v+"|"+w.replace(2,7)+"|[^\\\\(),])+",A=new RegExp("^"+r+"+|((?:^|[^\\\\])(?:\\\\.)*)"+r+"+$","g"),B=new RegExp("^"+y),C=new RegExp(z+"?(?="+r+"*,|$)","g"),D=new RegExp("^(?:(?!,)(?:(?:^|,)"+r+"*"+z+")*?|"+r+"*(.*?))(\\)|$)"),E=new RegExp(z.slice(19,-6)+"\\x20\\t\\r\\n\\f>+~])+|"+y,"g"),F=/^(?:#([\w\-]+)|(\w+)|\.([\w\-]+))$/,G=/[\x20\t\r\n\f]*[+~]/,H=/:not\($/,I=/h\d/i,J=/input|select|textarea|button/i,K=/\\(?!\\)/g,L={ID:new RegExp("^#("+s+")"),CLASS:new RegExp("^\\.("+s+")"),NAME:new RegExp("^\\[name=['\"]?("+s+")['\"]?\\]"),TAG:new RegExp("^("+s.replace("[-","[-\\*")+")"),ATTR:new RegExp("^"+v),PSEUDO:new RegExp("^"+w),CHILD:new RegExp("^:(only|nth|last|first)-child(?:\\("+r+"*(even|odd|(([+-]|)(\\d*)n|)"+r+"*(?:([+-]|)"+r+"*(\\d+)|))"+r+"*\\)|)","i"),POS:new RegExp(x,"ig"),needsContext:new RegExp("^"+r+"*[>+~]|"+x,"i")},M={},N=[],O={},P=[],Q=function(a){return a.sizzleFilter=!0,a},R=function(a){return function(b){return b.nodeName.toLowerCase()==="input"&&b.type===a}},S=function(a){return function(b){var c=b.nodeName.toLowerCase();return(c==="input"||c==="button")&&b.type===a}},T=function(a){var b=!1,c=h.createElement("div");try{b=a(c)}catch(d){}return c=null,b},U=T(function(a){a.innerHTML="<select></select>";var b=typeof a.lastChild.getAttribute("multiple");return b!=="boolean"&&b!=="string"}),V=T(function(a){a.id=q+0,a.innerHTML="<a name='"+q+"'></a><div name='"+q+"'></div>",i.insertBefore(a,i.firstChild);var b=h.getElementsByName&&h.getElementsByName(q).length===2+h.getElementsByName(q+0).length;return g=!h.getElementById(q),i.removeChild(a),b}),W=T(function(a){return a.appendChild(h.createComment("")),a.getElementsByTagName("*").length===0}),X=T(function(a){return a.innerHTML="<a href='#'></a>",a.firstChild&&typeof a.firstChild.getAttribute!==j&&a.firstChild.getAttribute("href")==="#"}),Y=T(function(a){return a.innerHTML="<div class='hidden e'></div><div class='hidden'></div>",!a.getElementsByClassName||a.getElementsByClassName("e").length===0?!1:(a.lastChild.className="e",a.getElementsByClassName("e").length!==1)}),Z=function(a,b,c,d){c=c||[],b=b||h;var e,f,g,i,j=b.nodeType;if(j!==1&&j!==9)return[];if(!a||typeof a!="string")return c;g=ba(b);if(!g&&!d)if(e=F.exec(a))if(i=e[1]){if(j===9){f=b.getElementById(i);if(!f||!f.parentNode)return c;if(f.id===i)return c.push(f),c}else if(b.ownerDocument&&(f=b.ownerDocument.getElementById(i))&&bb(b,f)&&f.id===i)return c.push(f),c}else{if(e[2])return o.apply(c,n.call(b.getElementsByTagName(a),0)),c;if((i=e[3])&&Y&&b.getElementsByClassName)return o.apply(c,n.call(b.getElementsByClassName(i),0)),c}return bm(a,b,c,d,g)},$=Z.selectors={cacheLength:50,match:L,order:["ID","TAG"],attrHandle:{},createPseudo:Q,find:{ID:g?function(a,b,c){if(typeof b.getElementById!==j&&!c){var d=b.getElementById(a);return d&&d.parentNode?[d]:[]}}:function(a,c,d){if(typeof c.getElementById!==j&&!d){var e=c.getElementById(a);return e?e.id===a||typeof e.getAttributeNode!==j&&e.getAttributeNode("id").value===a?[e]:b:[]}},TAG:W?function(a,b){if(typeof b.getElementsByTagName!==j)return b.getElementsByTagName(a)}:function(a,b){var c=b.getElementsByTagName(a);if(a==="*"){var d,e=[],f=0;for(;d=c[f];f++)d.nodeType===1&&e.push(d);return e}return c}},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(K,""),a[3]=(a[4]||a[5]||"").replace(K,""),a[2]==="~="&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),a[1]==="nth"?(a[2]||Z.error(a[0]),a[3]=+(a[3]?a[4]+(a[5]||1):2*(a[2]==="even"||a[2]==="odd")),a[4]=+(a[6]+a[7]||a[2]==="odd")):a[2]&&Z.error(a[0]),a},PSEUDO:function(a){var b,c=a[4];return L.CHILD.test(a[0])?null:(c&&(b=D.exec(c))&&b.pop()&&(a[0]=a[0].slice(0,b[0].length-c.length-1),c=b[0].slice(0,-1)),a.splice(2,3,c||a[3]),a)}},filter:{ID:g?function(a){return a=a.replace(K,""),function(b){return b.getAttribute("id")===a}}:function(a){return a=a.replace(K,""),function(b){var c=typeof b.getAttributeNode!==j&&b.getAttributeNode("id");return c&&c.value===a}},TAG:function(a){return a==="*"?function(){return!0}:(a=a.replace(K,"").toLowerCase(),function(b){return b.nodeName&&b.nodeName.toLowerCase()===a})},CLASS:function(a){var b=M[a];return b||(b=M[a]=new RegExp("(^|"+r+")"+a+"("+r+"|$)"),N.push(a),N.length>$.cacheLength&&delete M[N.shift()]),function(a){return b.test(a.className||typeof a.getAttribute!==j&&a.getAttribute("class")||"")}},ATTR:function(a,b,c){return b?function(d){var e=Z.attr(d,a),f=e+"";if(e==null)return b==="!=";switch(b){case"=":return f===c;case"!=":return f!==c;case"^=":return c&&f.indexOf(c)===0;case"*=":return c&&f.indexOf(c)>-1;case"$=":return c&&f.substr(f.length-c.length)===c;case"~=":return(" "+f+" ").indexOf(c)>-1;case"|=":return f===c||f.substr(0,c.length+1)===c+"-"}}:function(b){return Z.attr(b,a)!=null}},CHILD:function(a,b,c,d){if(a==="nth"){var e=m++;return function(a){var b,f,g=0,h=a;if(c===1&&d===0)return!0;b=a.parentNode;if(b&&(b[q]!==e||!a.sizset)){for(h=b.firstChild;h;h=h.nextSibling)if(h.nodeType===1){h.sizset=++g;if(h===a)break}b[q]=e}return f=a.sizset-d,c===0?f===0:f%c===0&&f/c>=0}}return function(b){var c=b;switch(a){case"only":case"first":while(c=c.previousSibling)if(c.nodeType===1)return!1;if(a==="first")return!0;c=b;case"last":while(c=c.nextSibling)if(c.nodeType===1)return!1;return!0}}},PSEUDO:function(a,b,c,d){var e=$.pseudos[a]||$.pseudos[a.toLowerCase()];return e||Z.error("unsupported pseudo: "+a),e.sizzleFilter?e(b,c,d):e}},pseudos:{not:Q(function(a,b,c){var d=bl(a.replace(A,"$1"),b,c);return function(a){return!d(a)}}),enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&!!a.checked||b==="option"&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},parent:function(a){return!$.pseudos.empty(a)},empty:function(a){var b;a=a.firstChild;while(a){if(a.nodeName>"@"||(b=a.nodeType)===3||b===4)return!1;a=a.nextSibling}return!0},contains:Q(function(a){return function(b){return(b.textContent||b.innerText||bc(b)).indexOf(a)>-1}}),has:Q(function(a){return function(b){return Z(a,b).length>0}}),header:function(a){return I.test(a.nodeName)},text:function(a){var b,c;return a.nodeName.toLowerCase()==="input"&&(b=a.type)==="text"&&((c=a.getAttribute("type"))==null||c.toLowerCase()===b)},radio:R("radio"),checkbox:R("checkbox"),file:R("file"),password:R("password"),image:R("image"),submit:S("submit"),reset:S("reset"),button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&a.type==="button"||b==="button"},input:function(a){return J.test(a.nodeName)},focus:function(a){var b=a.ownerDocument;return a===b.activeElement&&(!b.hasFocus||b.hasFocus())&&(!!a.type||!!a.href)},active:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b,c){return c?a.slice(1):[a[0]]},last:function(a,b,c){var d=a.pop();return c?a:[d]},even:function(a,b,c){var d=[],e=c?1:0,f=a.length;for(;e<f;e=e+2)d.push(a[e]);return d},odd:function(a,b,c){var d=[],e=c?0:1,f=a.length;for(;e<f;e=e+2)d.push(a[e]);return d},lt:function(a,b,c){return c?a.slice(+b):a.slice(0,+b)},gt:function(a,b,c){return c?a.slice(0,+b+1):a.slice(+b+1)},eq:function(a,b,c){var d=a.splice(+b,1);return c?a:d}}};$.setFilters.nth=$.setFilters.eq,$.filters=$.pseudos,X||($.attrHandle={href:function(a){return a.getAttribute("href",2)},type:function(a){return a.getAttribute("type")}}),V&&($.order.push("NAME"),$.find.NAME=function(a,b){if(typeof b.getElementsByName!==j)return b.getElementsByName(a)}),Y&&($.order.splice(1,0,"CLASS"),$.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!==j&&!c)return b.getElementsByClassName(a)});try{n.call(i.childNodes,0)[0].nodeType}catch(_){n=function(a){var b,c=[];for(;b=this[a];a++)c.push(b);return c}}var ba=Z.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?b.nodeName!=="HTML":!1},bb=Z.contains=i.compareDocumentPosition?function(a,b){return!!(a.compareDocumentPosition(b)&16)}:i.contains?function(a,b){var c=a.nodeType===9?a.documentElement:a,d=b.parentNode;return a===d||!!(d&&d.nodeType===1&&c.contains&&c.contains(d))}:function(a,b){while(b=b.parentNode)if(b===a)return!0;return!1},bc=Z.getText=function(a){var b,c="",d=0,e=a.nodeType;if(e){if(e===1||e===9||e===11){if(typeof a.textContent=="string")return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=bc(a)}else if(e===3||e===4)return a.nodeValue}else for(;b=a[d];d++)c+=bc(b);return c};Z.attr=function(a,b){var c,d=ba(a);return d||(b=b.toLowerCase()),$.attrHandle[b]?$.attrHandle[b](a):U||d?a.getAttribute(b):(c=a.getAttributeNode(b),c?typeof a[b]=="boolean"?a[b]?b:null:c.specified?c.value:null:null)},Z.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},[0,0].sort(function(){return l=0}),i.compareDocumentPosition?e=function(a,b){return a===b?(k=!0,0):(!a.compareDocumentPosition||!b.compareDocumentPosition?a.compareDocumentPosition:a.compareDocumentPosition(b)&4)?-1:1}:(e=function(a,b){if(a===b)return k=!0,0;if(a.sourceIndex&&b.sourceIndex)return a.sourceIndex-b.sourceIndex;var c,d,e=[],g=[],h=a.parentNode,i=b.parentNode,j=h;if(h===i)return f(a,b);if(!h)return-1;if(!i)return 1;while(j)e.unshift(j),j=j.parentNode;j=i;while(j)g.unshift(j),j=j.parentNode;c=e.length,d=g.length;for(var l=0;l<c&&l<d;l++)if(e[l]!==g[l])return f(e[l],g[l]);return l===c?f(a,g[l],-1):f(e[l],b,1)},f=function(a,b,c){if(a===b)return c;var d=a.nextSibling;while(d){if(d===b)return-1;d=d.nextSibling}return 1}),Z.uniqueSort=function(a){var b,c=1;if(e){k=l,a.sort(e);if(k)for(;b=a[c];c++)b===a[c-1]&&a.splice(c--,1)}return a};var bl=Z.compile=function(a,b,c){var d,e,f,g=O[a];if(g&&g.context===b)return g;e=bg(a,b,c);for(f=0;d=e[f];f++)e[f]=bj(d,b,c);return g=O[a]=bk(e),g.context=b,g.runs=g.dirruns=0,P.push(a),P.length>$.cacheLength&&delete O[P.shift()],g};Z.matches=function(a,b){return Z(a,null,null,b)},Z.matchesSelector=function(a,b){return Z(b,null,null,[a]).length>0};var bm=function(a,b,e,f,g){a=a.replace(A,"$1");var h,i,j,k,l,m,p,q,r,s=a.match(C),t=a.match(E),u=b.nodeType;if(L.POS.test(a))return bf(a,b,e,f,s);if(f)h=n.call(f,0);else if(s&&s.length===1){if(t.length>1&&u===9&&!g&&(s=L.ID.exec(t[0]))){b=$.find.ID(s[1],b,g)[0];if(!b)return e;a=a.slice(t.shift().length)}q=(s=G.exec(t[0]))&&!s.index&&b.parentNode||b,r=t.pop(),m=r.split(":not")[0];for(j=0,k=$.order.length;j<k;j++){p=$.order[j];if(s=L[p].exec(m)){h=$.find[p]((s[1]||"").replace(K,""),q,g);if(h==null)continue;m===r&&(a=a.slice(0,a.length-r.length)+m.replace(L[p],""),a||o.apply(e,n.call(h,0)));break}}}if(a){i=bl(a,b,g),d=i.dirruns++,h==null&&(h=$.find.TAG("*",G.test(a)&&b.parentNode||b));for(j=0;l=h[j];j++)c=i.runs++,i(l,b)&&e.push(l)}return e};h.querySelectorAll&&function(){var a,b=bm,c=/'|\\/g,d=/\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,e=[],f=[":active"],g=i.matchesSelector||i.mozMatchesSelector||i.webkitMatchesSelector||i.oMatchesSelector||i.msMatchesSelector;T(function(a){a.innerHTML="<select><option selected></option></select>",a.querySelectorAll("[selected]").length||e.push("\\["+r+"*(?:checked|disabled|ismap|multiple|readonly|selected|value)"),a.querySelectorAll(":checked").length||e.push(":checked")}),T(function(a){a.innerHTML="<p test=''></p>",a.querySelectorAll("[test^='']").length&&e.push("[*^$]="+r+"*(?:\"\"|'')"),a.innerHTML="<input type='hidden'>",a.querySelectorAll(":enabled").length||e.push(":enabled",":disabled")}),e=e.length&&new RegExp(e.join("|")),bm=function(a,d,f,g,h){if(!g&&!h&&(!e||!e.test(a)))if(d.nodeType===9)try{return o.apply(f,n.call(d.querySelectorAll(a),0)),f}catch(i){}else if(d.nodeType===1&&d.nodeName.toLowerCase()!=="object"){var j=d.getAttribute("id"),k=j||q,l=G.test(a)&&d.parentNode||d;j?k=k.replace(c,"\\$&"):d.setAttribute("id",k);try{return o.apply(f,n.call(l.querySelectorAll(a.replace(C,"[id='"+k+"'] $&")),0)),f}catch(i){}finally{j||d.removeAttribute("id")}}return b(a,d,f,g,h)},g&&(T(function(b){a=g.call(b,"div");try{g.call(b,"[test!='']:sizzle"),f.push($.match.PSEUDO)}catch(c){}}),f=new RegExp(f.join("|")),Z.matchesSelector=function(b,c){c=c.replace(d,"='$1']");if(!ba(b)&&!f.test(c)&&(!e||!e.test(c)))try{var h=g.call(b,c);if(h||a||b.document&&b.document.nodeType!==11)return h}catch(i){}return Z(c,null,null,[b]).length>0})}(),Z.attr=p.attr,p.find=Z,p.expr=Z.selectors,p.expr[":"]=p.expr.pseudos,p.unique=Z.uniqueSort,p.text=Z.getText,p.isXMLDoc=Z.isXML,p.contains=Z.contains}(a);var bc=/Until$/,bd=/^(?:parents|prev(?:Until|All))/,be=/^.[^:#\[\.,]*$/,bf=p.expr.match.needsContext,bg={children:!0,contents:!0,next:!0,prev:!0};p.fn.extend({find:function(a){var b,c,d,e,f,g,h=this;if(typeof a!="string")return p(a).filter(function(){for(b=0,c=h.length;b<c;b++)if(p.contains(h[b],this))return!0});g=this.pushStack("","find",a);for(b=0,c=this.length;b<c;b++){d=g.length,p.find(a,this[b],g);if(b>0)for(e=d;e<g.length;e++)for(f=0;f<d;f++)if(g[f]===g[e]){g.splice(e--,1);break}}return g},has:function(a){var b,c=p(a,this),d=c.length;return this.filter(function(){for(b=0;b<d;b++)if(p.contains(this,c[b]))return!0})},not:function(a){return this.pushStack(bj(this,a,!1),"not",a)},filter:function(a){return this.pushStack(bj(this,a,!0),"filter",a)},is:function(a){return!!a&&(typeof a=="string"?bf.test(a)?p(a,this.context).index(this[0])>=0:p.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c,d=0,e=this.length,f=[],g=bf.test(a)||typeof a!="string"?p(a,b||this.context):0;for(;d<e;d++){c=this[d];while(c&&c.ownerDocument&&c!==b&&c.nodeType!==11){if(g?g.index(c)>-1:p.find.matchesSelector(c,a)){f.push(c);break}c=c.parentNode}}return f=f.length>1?p.unique(f):f,this.pushStack(f,"closest",a)},index:function(a){return a?typeof a=="string"?p.inArray(this[0],p(a)):p.inArray(a.jquery?a[0]:a,this):this[0]&&this[0].parentNode?this.prevAll().length:-1},add:function(a,b){var c=typeof a=="string"?p(a,b):p.makeArray(a&&a.nodeType?[a]:a),d=p.merge(this.get(),c);return this.pushStack(bh(c[0])||bh(d[0])?d:p.unique(d))},addBack:function(a){return this.add(a==null?this.prevObject:this.prevObject.filter(a))}}),p.fn.andSelf=p.fn.addBack,p.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return p.dir(a,"parentNode")},parentsUntil:function(a,b,c){return p.dir(a,"parentNode",c)},next:function(a){return bi(a,"nextSibling")},prev:function(a){return bi(a,"previousSibling")},nextAll:function(a){return p.dir(a,"nextSibling")},prevAll:function(a){return p.dir(a,"previousSibling")},nextUntil:function(a,b,c){return p.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return p.dir(a,"previousSibling",c)},siblings:function(a){return p.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return p.sibling(a.firstChild)},contents:function(a){return p.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:p.merge([],a.childNodes)}},function(a,b){p.fn[a]=function(c,d){var e=p.map(this,b,c);return bc.test(a)||(d=c),d&&typeof d=="string"&&(e=p.filter(d,e)),e=this.length>1&&!bg[a]?p.unique(e):e,this.length>1&&bd.test(a)&&(e=e.reverse()),this.pushStack(e,a,k.call(arguments).join(","))}}),p.extend({filter:function(a,b,c){return c&&(a=":not("+a+")"),b.length===1?p.find.matchesSelector(b[0],a)?[b[0]]:[]:p.find.matches(a,b)},dir:function(a,c,d){var e=[],f=a[c];while(f&&f.nodeType!==9&&(d===b||f.nodeType!==1||!p(f).is(d)))f.nodeType===1&&e.push(f),f=f[c];return e},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var bl="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",bm=/ jQuery\d+="(?:null|\d+)"/g,bn=/^\s+/,bo=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,bp=/<([\w:]+)/,bq=/<tbody/i,br=/<|&#?\w+;/,bs=/<(?:script|style|link)/i,bt=/<(?:script|object|embed|option|style)/i,bu=new RegExp("<(?:"+bl+")[\\s/>]","i"),bv=/^(?:checkbox|radio)$/,bw=/checked\s*(?:[^=]|=\s*.checked.)/i,bx=/\/(java|ecma)script/i,by=/^\s*<!(?:\[CDATA\[|\-\-)|[\]\-]{2}>\s*$/g,bz={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]},bA=bk(e),bB=bA.appendChild(e.createElement("div"));bz.optgroup=bz.option,bz.tbody=bz.tfoot=bz.colgroup=bz.caption=bz.thead,bz.th=bz.td,p.support.htmlSerialize||(bz._default=[1,"X<div>","</div>"]),p.fn.extend({text:function(a){return p.access(this,function(a){return a===b?p.text(this):this.empty().append((this[0]&&this[0].ownerDocument||e).createTextNode(a))},null,a,arguments.length)},wrapAll:function(a){if(p.isFunction(a))return this.each(function(b){p(this).wrapAll(a.call(this,b))});if(this[0]){var b=p(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){return p.isFunction(a)?this.each(function(b){p(this).wrapInner(a.call(this,b))}):this.each(function(){var b=p(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=p.isFunction(a);return this.each(function(c){p(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){p.nodeName(this,"body")||p(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){(this.nodeType===1||this.nodeType===11)&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){(this.nodeType===1||this.nodeType===11)&&this.insertBefore(a,this.firstChild)})},before:function(){if(!bh(this[0]))return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=p.clean(arguments);return this.pushStack(p.merge(a,this),"before",this.selector)}},after:function(){if(!bh(this[0]))return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=p.clean(arguments);return this.pushStack(p.merge(this,a),"after",this.selector)}},remove:function(a,b){var c,d=0;for(;(c=this[d])!=null;d++)if(!a||p.filter(a,[c]).length)!b&&c.nodeType===1&&(p.cleanData(c.getElementsByTagName("*")),p.cleanData([c])),c.parentNode&&c.parentNode.removeChild(c);return this},empty:function(){var a,b=0;for(;(a=this[b])!=null;b++){a.nodeType===1&&p.cleanData(a.getElementsByTagName("*"));while(a.firstChild)a.removeChild(a.firstChild)}return this},clone:function(a,b){return a=a==null?!1:a,b=b==null?a:b,this.map(function(){return p.clone(this,a,b)})},html:function(a){return p.access(this,function(a){var c=this[0]||{},d=0,e=this.length;if(a===b)return c.nodeType===1?c.innerHTML.replace(bm,""):b;if(typeof a=="string"&&!bs.test(a)&&(p.support.htmlSerialize||!bu.test(a))&&(p.support.leadingWhitespace||!bn.test(a))&&!bz[(bp.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(bo,"<$1></$2>");try{for(;d<e;d++)c=this[d]||{},c.nodeType===1&&(p.cleanData(c.getElementsByTagName("*")),c.innerHTML=a);c=0}catch(f){}}c&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(a){return bh(this[0])?this.length?this.pushStack(p(p.isFunction(a)?a():a),"replaceWith",a):this:p.isFunction(a)?this.each(function(b){var c=p(this),d=c.html();c.replaceWith(a.call(this,b,d))}):(typeof a!="string"&&(a=p(a).detach()),this.each(function(){var b=this.nextSibling,c=this.parentNode;p(this).remove(),b?p(b).before(a):p(c).append(a)}))},detach:function(a){return this.remove(a,!0)},domManip:function(a,c,d){a=[].concat.apply([],a);var e,f,g,h,i=0,j=a[0],k=[],l=this.length;if(!p.support.checkClone&&l>1&&typeof j=="string"&&bw.test(j))return this.each(function(){p(this).domManip(a,c,d)});if(p.isFunction(j))return this.each(function(e){var f=p(this);a[0]=j.call(this,e,c?f.html():b),f.domManip(a,c,d)});if(this[0]){e=p.buildFragment(a,this,k),g=e.fragment,f=g.firstChild,g.childNodes.length===1&&(g=f);if(f){c=c&&p.nodeName(f,"tr");for(h=e.cacheable||l-1;i<l;i++)d.call(c&&p.nodeName(this[i],"table")?bC(this[i],"tbody"):this[i],i===h?g:p.clone(g,!0,!0))}g=f=null,k.length&&p.each(k,function(a,b){b.src?p.ajax?p.ajax({url:b.src,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0}):p.error("no ajax"):p.globalEval((b.text||b.textContent||b.innerHTML||"").replace(by,"")),b.parentNode&&b.parentNode.removeChild(b)})}return this}}),p.buildFragment=function(a,c,d){var f,g,h,i=a[0];return c=c||e,c=(c[0]||c).ownerDocument||c[0]||c,typeof c.createDocumentFragment=="undefined"&&(c=e),a.length===1&&typeof i=="string"&&i.length<512&&c===e&&i.charAt(0)==="<"&&!bt.test(i)&&(p.support.checkClone||!bw.test(i))&&(p.support.html5Clone||!bu.test(i))&&(g=!0,f=p.fragments[i],h=f!==b),f||(f=c.createDocumentFragment(),p.clean(a,c,f,d),g&&(p.fragments[i]=h&&f)),{fragment:f,cacheable:g}},p.fragments={},p.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){p.fn[a]=function(c){var d,e=0,f=[],g=p(c),h=g.length,i=this.length===1&&this[0].parentNode;if((i==null||i&&i.nodeType===11&&i.childNodes.length===1)&&h===1)return g[b](this[0]),this;for(;e<h;e++)d=(e>0?this.clone(!0):this).get(),p(g[e])[b](d),f=f.concat(d);return this.pushStack(f,a,g.selector)}}),p.extend({clone:function(a,b,c){var d,e,f,g;p.support.html5Clone||p.isXMLDoc(a)||!bu.test("<"+a.nodeName+">")?g=a.cloneNode(!0):(bB.innerHTML=a.outerHTML,bB.removeChild(g=bB.firstChild));if((!p.support.noCloneEvent||!p.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!p.isXMLDoc(a)){bE(a,g),d=bF(a),e=bF(g);for(f=0;d[f];++f)e[f]&&bE(d[f],e[f])}if(b){bD(a,g);if(c){d=bF(a),e=bF(g);for(f=0;d[f];++f)bD(d[f],e[f])}}return d=e=null,g},clean:function(a,b,c,d){var f,g,h,i,j,k,l,m,n,o,q,r,s=0,t=[];if(!b||typeof b.createDocumentFragment=="undefined")b=e;for(g=b===e&&bA;(h=a[s])!=null;s++){typeof h=="number"&&(h+="");if(!h)continue;if(typeof h=="string")if(!br.test(h))h=b.createTextNode(h);else{g=g||bk(b),l=l||g.appendChild(b.createElement("div")),h=h.replace(bo,"<$1></$2>"),i=(bp.exec(h)||["",""])[1].toLowerCase(),j=bz[i]||bz._default,k=j[0],l.innerHTML=j[1]+h+j[2];while(k--)l=l.lastChild;if(!p.support.tbody){m=bq.test(h),n=i==="table"&&!m?l.firstChild&&l.firstChild.childNodes:j[1]==="<table>"&&!m?l.childNodes:[];for(f=n.length-1;f>=0;--f)p.nodeName(n[f],"tbody")&&!n[f].childNodes.length&&n[f].parentNode.removeChild(n[f])}!p.support.leadingWhitespace&&bn.test(h)&&l.insertBefore(b.createTextNode(bn.exec(h)[0]),l.firstChild),h=l.childNodes,l=g.lastChild}h.nodeType?t.push(h):t=p.merge(t,h)}l&&(g.removeChild(l),h=l=g=null);if(!p.support.appendChecked)for(s=0;(h=t[s])!=null;s++)p.nodeName(h,"input")?bG(h):typeof h.getElementsByTagName!="undefined"&&p.grep(h.getElementsByTagName("input"),bG);if(c){q=function(a){if(!a.type||bx.test(a.type))return d?d.push(a.parentNode?a.parentNode.removeChild(a):a):c.appendChild(a)};for(s=0;(h=t[s])!=null;s++)if(!p.nodeName(h,"script")||!q(h))c.appendChild(h),typeof h.getElementsByTagName!="undefined"&&(r=p.grep(p.merge([],h.getElementsByTagName("script")),q),t.splice.apply(t,[s+1,0].concat(r)),s+=r.length)}return t},cleanData:function(a,b){var c,d,e,f,g=0,h=p.expando,i=p.cache,j=p.support.deleteExpando,k=p.event.special;for(;(e=a[g])!=null;g++)if(b||p.acceptData(e)){d=e[h],c=d&&i[d];if(c){if(c.events)for(f in c.events)k[f]?p.event.remove(e,f):p.removeEvent(e,f,c.handle);i[d]&&(delete i[d],j?delete e[h]:e.removeAttribute?e.removeAttribute(h):e[h]=null,p.deletedIds.push(d))}}}}),function(){var a,b;p.uaMatch=function(a){a=a.toLowerCase();var b=/(chrome)[ \/]([\w.]+)/.exec(a)||/(webkit)[ \/]([\w.]+)/.exec(a)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(a)||/(msie) ([\w.]+)/.exec(a)||a.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(a)||[];return{browser:b[1]||"",version:b[2]||"0"}},a=p.uaMatch(g.userAgent),b={},a.browser&&(b[a.browser]=!0,b.version=a.version),b.webkit&&(b.safari=!0),p.browser=b,p.sub=function(){function a(b,c){return new a.fn.init(b,c)}p.extend(!0,a,this),a.superclass=this,a.fn=a.prototype=this(),a.fn.constructor=a,a.sub=this.sub,a.fn.init=function c(c,d){return d&&d instanceof p&&!(d instanceof a)&&(d=a(d)),p.fn.init.call(this,c,d,b)},a.fn.init.prototype=a.fn;var b=a(e);return a}}();var bH,bI,bJ,bK=/alpha\([^)]*\)/i,bL=/opacity=([^)]*)/,bM=/^(top|right|bottom|left)$/,bN=/^margin/,bO=new RegExp("^("+q+")(.*)$","i"),bP=new RegExp("^("+q+")(?!px)[a-z%]+$","i"),bQ=new RegExp("^([-+])=("+q+")","i"),bR={},bS={position:"absolute",visibility:"hidden",display:"block"},bT={letterSpacing:0,fontWeight:400,lineHeight:1},bU=["Top","Right","Bottom","Left"],bV=["Webkit","O","Moz","ms"],bW=p.fn.toggle;p.fn.extend({css:function(a,c){return p.access(this,function(a,c,d){return d!==b?p.style(a,c,d):p.css(a,c)},a,c,arguments.length>1)},show:function(){return bZ(this,!0)},hide:function(){return bZ(this)},toggle:function(a,b){var c=typeof a=="boolean";return p.isFunction(a)&&p.isFunction(b)?bW.apply(this,arguments):this.each(function(){(c?a:bY(this))?p(this).show():p(this).hide()})}}),p.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=bH(a,"opacity");return c===""?"1":c}}}},cssNumber:{fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":p.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,d,e){if(!a||a.nodeType===3||a.nodeType===8||!a.style)return;var f,g,h,i=p.camelCase(c),j=a.style;c=p.cssProps[i]||(p.cssProps[i]=bX(j,i)),h=p.cssHooks[c]||p.cssHooks[i];if(d===b)return h&&"get"in h&&(f=h.get(a,!1,e))!==b?f:j[c];g=typeof d,g==="string"&&(f=bQ.exec(d))&&(d=(f[1]+1)*f[2]+parseFloat(p.css(a,c)),g="number");if(d==null||g==="number"&&isNaN(d))return;g==="number"&&!p.cssNumber[i]&&(d+="px");if(!h||!("set"in h)||(d=h.set(a,d,e))!==b)try{j[c]=d}catch(k){}},css:function(a,c,d,e){var f,g,h,i=p.camelCase(c);return c=p.cssProps[i]||(p.cssProps[i]=bX(a.style,i)),h=p.cssHooks[c]||p.cssHooks[i],h&&"get"in h&&(f=h.get(a,!0,e)),f===b&&(f=bH(a,c)),f==="normal"&&c in bT&&(f=bT[c]),d||e!==b?(g=parseFloat(f),d||p.isNumeric(g)?g||0:f):f},swap:function(a,b,c){var d,e,f={};for(e in b)f[e]=a.style[e],a.style[e]=b[e];d=c.call(a);for(e in b)a.style[e]=f[e];return d}}),a.getComputedStyle?bH=function(a,b){var c,d,e,f,g=getComputedStyle(a,null),h=a.style;return g&&(c=g[b],c===""&&!p.contains(a.ownerDocument.documentElement,a)&&(c=p.style(a,b)),bP.test(c)&&bN.test(b)&&(d=h.width,e=h.minWidth,f=h.maxWidth,h.minWidth=h.maxWidth=h.width=c,c=g.width,h.width=d,h.minWidth=e,h.maxWidth=f)),c}:e.documentElement.currentStyle&&(bH=function(a,b){var c,d,e=a.currentStyle&&a.currentStyle[b],f=a.style;return e==null&&f&&f[b]&&(e=f[b]),bP.test(e)&&!bM.test(b)&&(c=f.left,d=a.runtimeStyle&&a.runtimeStyle.left,d&&(a.runtimeStyle.left=a.currentStyle.left),f.left=b==="fontSize"?"1em":e,e=f.pixelLeft+"px",f.left=c,d&&(a.runtimeStyle.left=d)),e===""?"auto":e}),p.each(["height","width"],function(a,b){p.cssHooks[b]={get:function(a,c,d){if(c)return a.offsetWidth!==0||bH(a,"display")!=="none"?ca(a,b,d):p.swap(a,bS,function(){return ca(a,b,d)})},set:function(a,c,d){return b$(a,c,d?b_(a,b,d,p.support.boxSizing&&p.css(a,"boxSizing")==="border-box"):0)}}}),p.support.opacity||(p.cssHooks.opacity={get:function(a,b){return bL.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=p.isNumeric(b)?"alpha(opacity="+b*100+")":"",f=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&p.trim(f.replace(bK,""))===""&&c.removeAttribute){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bK.test(f)?f.replace(bK,e):f+" "+e}}),p(function(){p.support.reliableMarginRight||(p.cssHooks.marginRight={get:function(a,b){return p.swap(a,{display:"inline-block"},function(){if(b)return bH(a,"marginRight")})}}),!p.support.pixelPosition&&p.fn.position&&p.each(["top","left"],function(a,b){p.cssHooks[b]={get:function(a,c){if(c){var d=bH(a,b);return bP.test(d)?p(a).position()[b]+"px":d}}}})}),p.expr&&p.expr.filters&&(p.expr.filters.hidden=function(a){return a.offsetWidth===0&&a.offsetHeight===0||!p.support.reliableHiddenOffsets&&(a.style&&a.style.display||bH(a,"display"))==="none"},p.expr.filters.visible=function(a){return!p.expr.filters.hidden(a)}),p.each({margin:"",padding:"",border:"Width"},function(a,b){p.cssHooks[a+b]={expand:function(c){var d,e=typeof c=="string"?c.split(" "):[c],f={};for(d=0;d<4;d++)f[a+bU[d]+b]=e[d]||e[d-2]||e[0];return f}},bN.test(a)||(p.cssHooks[a+b].set=b$)});var cc=/%20/g,cd=/\[\]$/,ce=/\r?\n/g,cf=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,cg=/^(?:select|textarea)/i;p.fn.extend({serialize:function(){return p.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?p.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||cg.test(this.nodeName)||cf.test(this.type))}).map(function(a,b){var c=p(this).val();return c==null?null:p.isArray(c)?p.map(c,function(a,c){return{name:b.name,value:a.replace(ce,"\r\n")}}):{name:b.name,value:c.replace(ce,"\r\n")}}).get()}}),p.param=function(a,c){var d,e=[],f=function(a,b){b=p.isFunction(b)?b():b==null?"":b,e[e.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=p.ajaxSettings&&p.ajaxSettings.traditional);if(p.isArray(a)||a.jquery&&!p.isPlainObject(a))p.each(a,function(){f(this.name,this.value)});else for(d in a)ch(d,a[d],c,f);return e.join("&").replace(cc,"+")};var ci,cj,ck=/#.*$/,cl=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,cm=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,cn=/^(?:GET|HEAD)$/,co=/^\/\//,cp=/\?/,cq=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,cr=/([?&])_=[^&]*/,cs=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,ct=p.fn.load,cu={},cv={},cw=["*/"]+["*"];try{ci=f.href}catch(cx){ci=e.createElement("a"),ci.href="",ci=ci.href}cj=cs.exec(ci.toLowerCase())||[],p.fn.load=function(a,c,d){if(typeof a!="string"&&ct)return ct.apply(this,arguments);if(!this.length)return this;var e,f,g,h=this,i=a.indexOf(" ");return i>=0&&(e=a.slice(i,a.length),a=a.slice(0,i)),p.isFunction(c)?(d=c,c=b):typeof c=="object"&&(f="POST"),p.ajax({url:a,type:f,dataType:"html",data:c,complete:function(a,b){d&&h.each(d,g||[a.responseText,b,a])}}).done(function(a){g=arguments,h.html(e?p("<div>").append(a.replace(cq,"")).find(e):a)}),this},p.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){p.fn[b]=function(a){return this.on(b,a)}}),p.each(["get","post"],function(a,c){p[c]=function(a,d,e,f){return p.isFunction(d)&&(f=f||e,e=d,d=b),p.ajax({type:c,url:a,data:d,success:e,dataType:f})}}),p.extend({getScript:function(a,c){return p.get(a,b,c,"script")},getJSON:function(a,b,c){return p.get(a,b,c,"json")},ajaxSetup:function(a,b){return b?cA(a,p.ajaxSettings):(b=a,a=p.ajaxSettings),cA(a,b),a},ajaxSettings:{url:ci,isLocal:cm.test(cj[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded; charset=UTF-8",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":cw},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":p.parseJSON,"text xml":p.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:cy(cu),ajaxTransport:cy(cv),ajax:function(a,c){function y(a,c,f,i){var k,s,t,u,w,y=c;if(v===2)return;v=2,h&&clearTimeout(h),g=b,e=i||"",x.readyState=a>0?4:0,f&&(u=cB(l,x,f));if(a>=200&&a<300||a===304)l.ifModified&&(w=x.getResponseHeader("Last-Modified"),w&&(p.lastModified[d]=w),w=x.getResponseHeader("Etag"),w&&(p.etag[d]=w)),a===304?(y="notmodified",k=!0):(k=cC(l,u),y=k.state,s=k.data,t=k.error,k=!t);else{t=y;if(!y||a)y="error",a<0&&(a=0)}x.status=a,x.statusText=""+(c||y),k?o.resolveWith(m,[s,y,x]):o.rejectWith(m,[x,y,t]),x.statusCode(r),r=b,j&&n.trigger("ajax"+(k?"Success":"Error"),[x,l,k?s:t]),q.fireWith(m,[x,y]),j&&(n.trigger("ajaxComplete",[x,l]),--p.active||p.event.trigger("ajaxStop"))}typeof a=="object"&&(c=a,a=b),c=c||{};var d,e,f,g,h,i,j,k,l=p.ajaxSetup({},c),m=l.context||l,n=m!==l&&(m.nodeType||m instanceof p)?p(m):p.event,o=p.Deferred(),q=p.Callbacks("once memory"),r=l.statusCode||{},t={},u={},v=0,w="canceled",x={readyState:0,setRequestHeader:function(a,b){if(!v){var c=a.toLowerCase();a=u[c]=u[c]||a,t[a]=b}return this},getAllResponseHeaders:function(){return v===2?e:null},getResponseHeader:function(a){var c;if(v===2){if(!f){f={};while(c=cl.exec(e))f[c[1].toLowerCase()]=c[2]}c=f[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){return v||(l.mimeType=a),this},abort:function(a){return a=a||w,g&&g.abort(a),y(0,a),this}};o.promise(x),x.success=x.done,x.error=x.fail,x.complete=q.add,x.statusCode=function(a){if(a){var b;if(v<2)for(b in a)r[b]=[r[b],a[b]];else b=a[x.status],x.always(b)}return this},l.url=((a||l.url)+"").replace(ck,"").replace(co,cj[1]+"//"),l.dataTypes=p.trim(l.dataType||"*").toLowerCase().split(s),l.crossDomain==null&&(i=cs.exec(l.url.toLowerCase()),l.crossDomain=!(!i||i[1]==cj[1]&&i[2]==cj[2]&&(i[3]||(i[1]==="http:"?80:443))==(cj[3]||(cj[1]==="http:"?80:443)))),l.data&&l.processData&&typeof l.data!="string"&&(l.data=p.param(l.data,l.traditional)),cz(cu,l,c,x);if(v===2)return x;j=l.global,l.type=l.type.toUpperCase(),l.hasContent=!cn.test(l.type),j&&p.active++===0&&p.event.trigger("ajaxStart");if(!l.hasContent){l.data&&(l.url+=(cp.test(l.url)?"&":"?")+l.data,delete l.data),d=l.url;if(l.cache===!1){var z=p.now(),A=l.url.replace(cr,"$1_="+z);l.url=A+(A===l.url?(cp.test(l.url)?"&":"?")+"_="+z:"")}}(l.data&&l.hasContent&&l.contentType!==!1||c.contentType)&&x.setRequestHeader("Content-Type",l.contentType),l.ifModified&&(d=d||l.url,p.lastModified[d]&&x.setRequestHeader("If-Modified-Since",p.lastModified[d]),p.etag[d]&&x.setRequestHeader("If-None-Match",p.etag[d])),x.setRequestHeader("Accept",l.dataTypes[0]&&l.accepts[l.dataTypes[0]]?l.accepts[l.dataTypes[0]]+(l.dataTypes[0]!=="*"?", "+cw+"; q=0.01":""):l.accepts["*"]);for(k in l.headers)x.setRequestHeader(k,l.headers[k]);if(!l.beforeSend||l.beforeSend.call(m,x,l)!==!1&&v!==2){w="abort";for(k in{success:1,error:1,complete:1})x[k](l[k]);g=cz(cv,l,c,x);if(!g)y(-1,"No Transport");else{x.readyState=1,j&&n.trigger("ajaxSend",[x,l]),l.async&&l.timeout>0&&(h=setTimeout(function(){x.abort("timeout")},l.timeout));try{v=1,g.send(t,y)}catch(B){if(v<2)y(-1,B);else throw B}}return x}return x.abort()},active:0,lastModified:{},etag:{}});var cD=[],cE=/\?/,cF=/(=)\?(?=&|$)|\?\?/,cG=p.now();p.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var a=cD.pop()||p.expando+"_"+cG++;return this[a]=!0,a}}),p.ajaxPrefilter("json jsonp",function(c,d,e){var f,g,h,i=c.data,j=c.url,k=c.jsonp!==!1,l=k&&cF.test(j),m=k&&!l&&typeof i=="string"&&!(c.contentType||"").indexOf("application/x-www-form-urlencoded")&&cF.test(i);if(c.dataTypes[0]==="jsonp"||l||m)return f=c.jsonpCallback=p.isFunction(c.jsonpCallback)?c.jsonpCallback():c.jsonpCallback,g=a[f],l?c.url=j.replace(cF,"$1"+f):m?c.data=i.replace(cF,"$1"+f):k&&(c.url+=(cE.test(j)?"&":"?")+c.jsonp+"="+f),c.converters["script json"]=function(){return h||p.error(f+" was not called"),h[0]},c.dataTypes[0]="json",a[f]=function(){h=arguments},e.always(function(){a[f]=g,c[f]&&(c.jsonpCallback=d.jsonpCallback,cD.push(f)),h&&p.isFunction(g)&&g(h[0]),h=g=b}),"script"}),p.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){return p.globalEval(a),a}}}),p.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),p.ajaxTransport("script",function(a){if(a.crossDomain){var c,d=e.head||e.getElementsByTagName("head")[0]||e.documentElement;return{send:function(f,g){c=e.createElement("script"),c.async="async",a.scriptCharset&&(c.charset=a.scriptCharset),c.src=a.url,c.onload=c.onreadystatechange=function(a,e){if(e||!c.readyState||/loaded|complete/.test(c.readyState))c.onload=c.onreadystatechange=null,d&&c.parentNode&&d.removeChild(c),c=b,e||g(200,"success")},d.insertBefore(c,d.firstChild)},abort:function(){c&&c.onload(0,1)}}}});var cH,cI=a.ActiveXObject?function(){for(var a in cH)cH[a](0,1)}:!1,cJ=0;p.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&cK()||cL()}:cK,function(a){p.extend(p.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(p.ajaxSettings.xhr()),p.support.ajax&&p.ajaxTransport(function(c){if(!c.crossDomain||p.support.cors){var d;return{send:function(e,f){var g,h,i=c.xhr();c.username?i.open(c.type,c.url,c.async,c.username,c.password):i.open(c.type,c.url,c.async);if(c.xhrFields)for(h in c.xhrFields)i[h]=c.xhrFields[h];c.mimeType&&i.overrideMimeType&&i.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(h in e)i.setRequestHeader(h,e[h])}catch(j){}i.send(c.hasContent&&c.data||null),d=function(a,e){var h,j,k,l,m;try{if(d&&(e||i.readyState===4)){d=b,g&&(i.onreadystatechange=p.noop,cI&&delete cH[g]);if(e)i.readyState!==4&&i.abort();else{h=i.status,k=i.getAllResponseHeaders(),l={},m=i.responseXML,m&&m.documentElement&&(l.xml=m);try{l.text=i.responseText}catch(a){}try{j=i.statusText}catch(n){j=""}!h&&c.isLocal&&!c.crossDomain?h=l.text?200:404:h===1223&&(h=204)}}}catch(o){e||f(-1,o)}l&&f(h,j,l,k)},c.async?i.readyState===4?setTimeout(d,0):(g=++cJ,cI&&(cH||(cH={},p(a).unload(cI)),cH[g]=d),i.onreadystatechange=d):d()},abort:function(){d&&d(0,1)}}}});var cM,cN,cO=/^(?:toggle|show|hide)$/,cP=new RegExp("^(?:([-+])=|)("+q+")([a-z%]*)$","i"),cQ=/queueHooks$/,cR=[cX],cS={"*":[function(a,b){var c,d,e,f=this.createTween(a,b),g=cP.exec(b),h=f.cur(),i=+h||0,j=1;if(g){c=+g[2],d=g[3]||(p.cssNumber[a]?"":"px");if(d!=="px"&&i){i=p.css(f.elem,a,!0)||c||1;do e=j=j||".5",i=i/j,p.style(f.elem,a,i+d),j=f.cur()/h;while(j!==1&&j!==e)}f.unit=d,f.start=i,f.end=g[1]?i+(g[1]+1)*c:c}return f}]};p.Animation=p.extend(cV,{tweener:function(a,b){p.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");var c,d=0,e=a.length;for(;d<e;d++)c=a[d],cS[c]=cS[c]||[],cS[c].unshift(b)},prefilter:function(a,b){b?cR.unshift(a):cR.push(a)}}),p.Tween=cY,cY.prototype={constructor:cY,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||"swing",this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(p.cssNumber[c]?"":"px")},cur:function(){var a=cY.propHooks[this.prop];return a&&a.get?a.get(this):cY.propHooks._default.get(this)},run:function(a){var b,c=cY.propHooks[this.prop];return this.pos=b=p.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration),this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):cY.propHooks._default.set(this),this}},cY.prototype.init.prototype=cY.prototype,cY.propHooks={_default:{get:function(a){var b;return a.elem[a.prop]==null||!!a.elem.style&&a.elem.style[a.prop]!=null?(b=p.css(a.elem,a.prop,!1,""),!b||b==="auto"?0:b):a.elem[a.prop]},set:function(a){p.fx.step[a.prop]?p.fx.step[a.prop](a):a.elem.style&&(a.elem.style[p.cssProps[a.prop]]!=null||p.cssHooks[a.prop])?p.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},cY.propHooks.scrollTop=cY.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},p.each(["toggle","show","hide"],function(a,b){var c=p.fn[b];p.fn[b]=function(d,e,f){return d==null||typeof d=="boolean"||!a&&p.isFunction(d)&&p.isFunction(e)?c.apply(this,arguments):this.animate(cZ(b,!0),d,e,f)}}),p.fn.extend({fadeTo:function(a,b,c,d){return this.filter(bY).css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=p.isEmptyObject(a),f=p.speed(b,c,d),g=function(){var b=cV(this,p.extend({},a),f);e&&b.stop(!0)};return e||f.queue===!1?this.each(g):this.queue(f.queue,g)},stop:function(a,c,d){var e=function(a){var b=a.stop;delete a.stop,b(d)};return typeof a!="string"&&(d=c,c=a,a=b),c&&a!==!1&&this.queue(a||"fx",[]),this.each(function(){var b=!0,c=a!=null&&a+"queueHooks",f=p.timers,g=p._data(this);if(c)g[c]&&g[c].stop&&e(g[c]);else for(c in g)g[c]&&g[c].stop&&cQ.test(c)&&e(g[c]);for(c=f.length;c--;)f[c].elem===this&&(a==null||f[c].queue===a)&&(f[c].anim.stop(d),b=!1,f.splice(c,1));(b||!d)&&p.dequeue(this,a)})}}),p.each({slideDown:cZ("show"),slideUp:cZ("hide"),slideToggle:cZ("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){p.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),p.speed=function(a,b,c){var d=a&&typeof a=="object"?p.extend({},a):{complete:c||!c&&b||p.isFunction(a)&&a,duration:a,easing:c&&b||b&&!p.isFunction(b)&&b};d.duration=p.fx.off?0:typeof d.duration=="number"?d.duration:d.duration in p.fx.speeds?p.fx.speeds[d.duration]:p.fx.speeds._default;if(d.queue==null||d.queue===!0)d.queue="fx";return d.old=d.complete,d.complete=function(){p.isFunction(d.old)&&d.old.call(this),d.queue&&p.dequeue(this,d.queue)},d},p.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},p.timers=[],p.fx=cY.prototype.init,p.fx.tick=function(){var a,b=p.timers,c=0;for(;c<b.length;c++)a=b[c],!a()&&b[c]===a&&b.splice(c--,1);b.length||p.fx.stop()},p.fx.timer=function(a){a()&&p.timers.push(a)&&!cN&&(cN=setInterval(p.fx.tick,p.fx.interval))},p.fx.interval=13,p.fx.stop=function(){clearInterval(cN),cN=null},p.fx.speeds={slow:600,fast:200,_default:400},p.fx.step={},p.expr&&p.expr.filters&&(p.expr.filters.animated=function(a){return p.grep(p.timers,function(b){return a===b.elem}).length});var c$=/^(?:body|html)$/i;p.fn.offset=function(a){if(arguments.length)return a===b?this:this.each(function(b){p.offset.setOffset(this,a,b)});var c,d,e,f,g,h,i,j,k,l,m=this[0],n=m&&m.ownerDocument;if(!n)return;return(e=n.body)===m?p.offset.bodyOffset(m):(d=n.documentElement,p.contains(d,m)?(c=m.getBoundingClientRect(),f=c_(n),g=d.clientTop||e.clientTop||0,h=d.clientLeft||e.clientLeft||0,i=f.pageYOffset||d.scrollTop,j=f.pageXOffset||d.scrollLeft,k=c.top+i-g,l=c.left+j-h,{top:k,left:l}):{top:0,left:0})},p.offset={bodyOffset:function(a){var b=a.offsetTop,c=a.offsetLeft;return p.support.doesNotIncludeMarginInBodyOffset&&(b+=parseFloat(p.css(a,"marginTop"))||0,c+=parseFloat(p.css(a,"marginLeft"))||0),{top:b,left:c}},setOffset:function(a,b,c){var d=p.css(a,"position");d==="static"&&(a.style.position="relative");var e=p(a),f=e.offset(),g=p.css(a,"top"),h=p.css(a,"left"),i=(d==="absolute"||d==="fixed")&&p.inArray("auto",[g,h])>-1,j={},k={},l,m;i?(k=e.position(),l=k.top,m=k.left):(l=parseFloat(g)||0,m=parseFloat(h)||0),p.isFunction(b)&&(b=b.call(a,c,f)),b.top!=null&&(j.top=b.top-f.top+l),b.left!=null&&(j.left=b.left-f.left+m),"using"in b?b.using.call(a,j):e.css(j)}},p.fn.extend({position:function(){if(!this[0])return;var a=this[0],b=this.offsetParent(),c=this.offset(),d=c$.test(b[0].nodeName)?{top:0,left:0}:b.offset();return c.top-=parseFloat(p.css(a,"marginTop"))||0,c.left-=parseFloat(p.css(a,"marginLeft"))||0,d.top+=parseFloat(p.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(p.css(b[0],"borderLeftWidth"))||0,{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||e.body;while(a&&!c$.test(a.nodeName)&&p.css(a,"position")==="static")a=a.offsetParent;return a||e.body})}}),p.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,c){var d=/Y/.test(c);p.fn[a]=function(e){return p.access(this,function(a,e,f){var g=c_(a);if(f===b)return g?c in g?g[c]:g.document.documentElement[e]:a[e];g?g.scrollTo(d?p(g).scrollLeft():f,d?f:p(g).scrollTop()):a[e]=f},a,e,arguments.length,null)}}),p.each({Height:"height",Width:"width"},function(a,c){p.each({padding:"inner"+a,content:c,"":"outer"+a},function(d,e){p.fn[e]=function(e,f){var g=arguments.length&&(d||typeof e!="boolean"),h=d||(e===!0||f===!0?"margin":"border");return p.access(this,function(c,d,e){var f;return p.isWindow(c)?c.document.documentElement["client"+a]:c.nodeType===9?(f=c.documentElement,Math.max(c.body["scroll"+a],f["scroll"+a],c.body["offset"+a],f["offset"+a],f["client"+a])):e===b?p.css(c,d,e,h):p.style(c,d,e,h)},c,g?e:b,g)}})}),a.jQuery=a.$=p,typeof define=="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return p})})(window);
\ No newline at end of file
profiles/killbill/src/main/webapp/lib/shred.bundle.js 2765(+2765 -0)
diff --git a/profiles/killbill/src/main/webapp/lib/shred.bundle.js b/profiles/killbill/src/main/webapp/lib/shred.bundle.js
new file mode 100644
index 0000000..74d0816
--- /dev/null
+++ b/profiles/killbill/src/main/webapp/lib/shred.bundle.js
@@ -0,0 +1,2765 @@
+var require = function (file, cwd) {
+ var resolved = require.resolve(file, cwd || '/');
+ var mod = require.modules[resolved];
+ if (!mod) throw new Error(
+ 'Failed to resolve module ' + file + ', tried ' + resolved
+ );
+ var res = mod._cached ? mod._cached : mod();
+ return res;
+}
+
+require.paths = [];
+require.modules = {};
+require.extensions = [".js",".coffee"];
+
+require._core = {
+ 'assert': true,
+ 'events': true,
+ 'fs': true,
+ 'path': true,
+ 'vm': true
+};
+
+require.resolve = (function () {
+ return function (x, cwd) {
+ if (!cwd) cwd = '/';
+
+ if (require._core[x]) return x;
+ var path = require.modules.path();
+ var y = cwd || '.';
+
+ if (x.match(/^(?:\.\.?\/|\/)/)) {
+ var m = loadAsFileSync(path.resolve(y, x))
+ || loadAsDirectorySync(path.resolve(y, x));
+ if (m) return m;
+ }
+
+ var n = loadNodeModulesSync(x, y);
+ if (n) return n;
+
+ throw new Error("Cannot find module '" + x + "'");
+
+ function loadAsFileSync (x) {
+ if (require.modules[x]) {
+ return x;
+ }
+
+ for (var i = 0; i < require.extensions.length; i++) {
+ var ext = require.extensions[i];
+ if (require.modules[x + ext]) return x + ext;
+ }
+ }
+
+ function loadAsDirectorySync (x) {
+ x = x.replace(/\/+$/, '');
+ var pkgfile = x + '/package.json';
+ if (require.modules[pkgfile]) {
+ var pkg = require.modules[pkgfile]();
+ var b = pkg.browserify;
+ if (typeof b === 'object' && b.main) {
+ var m = loadAsFileSync(path.resolve(x, b.main));
+ if (m) return m;
+ }
+ else if (typeof b === 'string') {
+ var m = loadAsFileSync(path.resolve(x, b));
+ if (m) return m;
+ }
+ else if (pkg.main) {
+ var m = loadAsFileSync(path.resolve(x, pkg.main));
+ if (m) return m;
+ }
+ }
+
+ return loadAsFileSync(x + '/index');
+ }
+
+ function loadNodeModulesSync (x, start) {
+ var dirs = nodeModulesPathsSync(start);
+ for (var i = 0; i < dirs.length; i++) {
+ var dir = dirs[i];
+ var m = loadAsFileSync(dir + '/' + x);
+ if (m) return m;
+ var n = loadAsDirectorySync(dir + '/' + x);
+ if (n) return n;
+ }
+
+ var m = loadAsFileSync(x);
+ if (m) return m;
+ }
+
+ function nodeModulesPathsSync (start) {
+ var parts;
+ if (start === '/') parts = [ '' ];
+ else parts = path.normalize(start).split('/');
+
+ var dirs = [];
+ for (var i = parts.length - 1; i >= 0; i--) {
+ if (parts[i] === 'node_modules') continue;
+ var dir = parts.slice(0, i + 1).join('/') + '/node_modules';
+ dirs.push(dir);
+ }
+
+ return dirs;
+ }
+ };
+})();
+
+require.alias = function (from, to) {
+ var path = require.modules.path();
+ var res = null;
+ try {
+ res = require.resolve(from + '/package.json', '/');
+ }
+ catch (err) {
+ res = require.resolve(from, '/');
+ }
+ var basedir = path.dirname(res);
+
+ var keys = (Object.keys || function (obj) {
+ var res = [];
+ for (var key in obj) res.push(key)
+ return res;
+ })(require.modules);
+
+ for (var i = 0; i < keys.length; i++) {
+ var key = keys[i];
+ if (key.slice(0, basedir.length + 1) === basedir + '/') {
+ var f = key.slice(basedir.length);
+ require.modules[to + f] = require.modules[basedir + f];
+ }
+ else if (key === basedir) {
+ require.modules[to] = require.modules[basedir];
+ }
+ }
+};
+
+require.define = function (filename, fn) {
+ var dirname = require._core[filename]
+ ? ''
+ : require.modules.path().dirname(filename)
+ ;
+
+ var require_ = function (file) {
+ return require(file, dirname)
+ };
+ require_.resolve = function (name) {
+ return require.resolve(name, dirname);
+ };
+ require_.modules = require.modules;
+ require_.define = require.define;
+ var module_ = { exports : {} };
+
+ require.modules[filename] = function () {
+ require.modules[filename]._cached = module_.exports;
+ fn.call(
+ module_.exports,
+ require_,
+ module_,
+ module_.exports,
+ dirname,
+ filename
+ );
+ require.modules[filename]._cached = module_.exports;
+ return module_.exports;
+ };
+};
+
+if (typeof process === 'undefined') process = {};
+
+if (!process.nextTick) process.nextTick = (function () {
+ var queue = [];
+ var canPost = typeof window !== 'undefined'
+ && window.postMessage && window.addEventListener
+ ;
+
+ if (canPost) {
+ window.addEventListener('message', function (ev) {
+ if (ev.source === window && ev.data === 'browserify-tick') {
+ ev.stopPropagation();
+ if (queue.length > 0) {
+ var fn = queue.shift();
+ fn();
+ }
+ }
+ }, true);
+ }
+
+ return function (fn) {
+ if (canPost) {
+ queue.push(fn);
+ window.postMessage('browserify-tick', '*');
+ }
+ else setTimeout(fn, 0);
+ };
+})();
+
+if (!process.title) process.title = 'browser';
+
+if (!process.binding) process.binding = function (name) {
+ if (name === 'evals') return require('vm')
+ else throw new Error('No such module')
+};
+
+if (!process.cwd) process.cwd = function () { return '.' };
+
+require.define("path", function (require, module, exports, __dirname, __filename) {
+ function filter (xs, fn) {
+ var res = [];
+ for (var i = 0; i < xs.length; i++) {
+ if (fn(xs[i], i, xs)) res.push(xs[i]);
+ }
+ return res;
+}
+
+// resolves . and .. elements in a path array with directory names there
+// must be no slashes, empty elements, or device names (c:\) in the array
+// (so also no leading and trailing slashes - it does not distinguish
+// relative and absolute paths)
+function normalizeArray(parts, allowAboveRoot) {
+ // if the path tries to go above the root, `up` ends up > 0
+ var up = 0;
+ for (var i = parts.length; i >= 0; i--) {
+ var last = parts[i];
+ if (last == '.') {
+ parts.splice(i, 1);
+ } else if (last === '..') {
+ parts.splice(i, 1);
+ up++;
+ } else if (up) {
+ parts.splice(i, 1);
+ up--;
+ }
+ }
+
+ // if the path is allowed to go above the root, restore leading ..s
+ if (allowAboveRoot) {
+ for (; up--; up) {
+ parts.unshift('..');
+ }
+ }
+
+ return parts;
+}
+
+// Regex to split a filename into [*, dir, basename, ext]
+// posix version
+var splitPathRe = /^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;
+
+// path.resolve([from ...], to)
+// posix version
+exports.resolve = function() {
+var resolvedPath = '',
+ resolvedAbsolute = false;
+
+for (var i = arguments.length; i >= -1 && !resolvedAbsolute; i--) {
+ var path = (i >= 0)
+ ? arguments[i]
+ : process.cwd();
+
+ // Skip empty and invalid entries
+ if (typeof path !== 'string' || !path) {
+ continue;
+ }
+
+ resolvedPath = path + '/' + resolvedPath;
+ resolvedAbsolute = path.charAt(0) === '/';
+}
+
+// At this point the path should be resolved to a full absolute path, but
+// handle relative paths to be safe (might happen when process.cwd() fails)
+
+// Normalize the path
+resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
+ return !!p;
+ }), !resolvedAbsolute).join('/');
+
+ return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
+};
+
+// path.normalize(path)
+// posix version
+exports.normalize = function(path) {
+var isAbsolute = path.charAt(0) === '/',
+ trailingSlash = path.slice(-1) === '/';
+
+// Normalize the path
+path = normalizeArray(filter(path.split('/'), function(p) {
+ return !!p;
+ }), !isAbsolute).join('/');
+
+ if (!path && !isAbsolute) {
+ path = '.';
+ }
+ if (path && trailingSlash) {
+ path += '/';
+ }
+
+ return (isAbsolute ? '/' : '') + path;
+};
+
+
+// posix version
+exports.join = function() {
+ var paths = Array.prototype.slice.call(arguments, 0);
+ return exports.normalize(filter(paths, function(p, index) {
+ return p && typeof p === 'string';
+ }).join('/'));
+};
+
+
+exports.dirname = function(path) {
+ var dir = splitPathRe.exec(path)[1] || '';
+ var isWindows = false;
+ if (!dir) {
+ // No dirname
+ return '.';
+ } else if (dir.length === 1 ||
+ (isWindows && dir.length <= 3 && dir.charAt(1) === ':')) {
+ // It is just a slash or a drive letter with a slash
+ return dir;
+ } else {
+ // It is a full dirname, strip trailing slash
+ return dir.substring(0, dir.length - 1);
+ }
+};
+
+
+exports.basename = function(path, ext) {
+ var f = splitPathRe.exec(path)[2] || '';
+ // TODO: make this comparison case-insensitive on windows?
+ if (ext && f.substr(-1 * ext.length) === ext) {
+ f = f.substr(0, f.length - ext.length);
+ }
+ return f;
+};
+
+
+exports.extname = function(path) {
+ return splitPathRe.exec(path)[3] || '';
+};
+
+});
+
+require.define("/shred.js", function (require, module, exports, __dirname, __filename) {
+ // Shred is an HTTP client library intended to simplify the use of Node's
+// built-in HTTP library. In particular, we wanted to make it easier to interact
+// with HTTP-based APIs.
+//
+// See the [examples](./examples.html) for more details.
+
+// Ax is a nice logging library we wrote. You can use any logger, providing it
+// has `info`, `warn`, `debug`, and `error` methods that take a string.
+var Ax = require("ax")
+ , CookieJarLib = require( "cookiejar" )
+ , CookieJar = CookieJarLib.CookieJar
+;
+
+// Shred takes some options, including a logger and request defaults.
+
+var Shred = function(options) {
+ options = (options||{});
+ this.agent = options.agent;
+ this.defaults = options.defaults||{};
+ this.log = options.logger||(new Ax({ level: "info" }));
+ this._sharedCookieJar = new CookieJar();
+ this.logCurl = options.logCurl || false;
+};
+
+// Most of the real work is done in the request and reponse classes.
+
+Shred.Request = require("./shred/request");
+Shred.Response = require("./shred/response");
+
+// The `request` method kicks off a new request, instantiating a new `Request`
+// object and passing along whatever default options we were given.
+
+Shred.prototype = {
+ request: function(options) {
+ options.logger = this.log;
+ options.logCurl = options.logCurl || this.logCurl;
+ options.cookieJar = ( 'cookieJar' in options ) ? options.cookieJar : this._sharedCookieJar; // let them set cookieJar = null
+ options.agent = options.agent || this.agent;
+ // fill in default options
+ for (var key in this.defaults) {
+ if (this.defaults.hasOwnProperty(key) && !options[key]) {
+ options[key] = this.defaults[key]
+ }
+ }
+ return new Shred.Request(options);
+ }
+};
+
+// Define a bunch of convenience methods so that you don't have to include
+// a `method` property in your request options.
+
+"get put post delete".split(" ").forEach(function(method) {
+ Shred.prototype[method] = function(options) {
+ options.method = method;
+ return this.request(options);
+ };
+});
+
+
+module.exports = Shred;
+
+});
+
+require.define("/node_modules/ax/package.json", function (require, module, exports, __dirname, __filename) {
+ module.exports = {"main":"./lib/ax.js"}
+});
+
+require.define("/node_modules/ax/lib/ax.js", function (require, module, exports, __dirname, __filename) {
+ var inspect = require("util").inspect
+ , fs = require("fs")
+;
+
+
+// this is a quick-and-dirty logger. there are other nicer loggers out there
+// but the ones i found were also somewhat involved. this one has a Ruby
+// logger type interface
+//
+// we can easily replace this, provide the info, debug, etc. methods are the
+// same. or, we can change Haiku to use a more standard node.js interface
+
+var format = function(level,message) {
+ var debug = (level=="debug"||level=="error");
+ if (!message) { return message.toString(); }
+ if (typeof(message) == "object") {
+ if (message instanceof Error && debug) {
+ return message.stack;
+ } else {
+ return inspect(message);
+ }
+ } else {
+ return message.toString();
+ }
+};
+
+var noOp = function(message) { return this; }
+var makeLogger = function(level,fn) {
+ return function(message) {
+ this.stream.write(this.format(level, message)+"\n");
+ return this;
+ }
+};
+
+var Logger = function(options) {
+ var logger = this;
+ var options = options||{};
+
+ // Default options
+ options.level = options.level || "info";
+ options.timestamp = options.timestamp || true;
+ options.prefix = options.prefix || "";
+ logger.options = options;
+
+ // Allows a prefix to be added to the message.
+ //
+ // var logger = new Ax({ module: 'Haiku' })
+ // logger.warn('this is going to be awesome!');
+ // //=> Haiku: this is going to be awesome!
+ //
+ if (logger.options.module){
+ logger.options.prefix = logger.options.module;
+ }
+
+ // Write to stderr or a file
+ if (logger.options.file){
+ logger.stream = fs.createWriteStream(logger.options.file, {"flags": "a"});
+ } else {
+ if(process.title === "node")
+ logger.stream = process.stderr;
+ else if(process.title === "browser")
+ logger.stream = function () {
+ // Work around weird console context issue: http://code.google.com/p/chromium/issues/detail?id=48662
+ return console[logger.options.level].apply(console, arguments);
+ };
+ }
+
+ switch(logger.options.level){
+ case 'debug':
+ ['debug', 'info', 'warn'].forEach(function (level) {
+ logger[level] = Logger.writer(level);
+ });
+ case 'info':
+ ['info', 'warn'].forEach(function (level) {
+ logger[level] = Logger.writer(level);
+ });
+ case 'warn':
+ logger.warn = Logger.writer('warn');
+ }
+}
+
+// Used to define logger methods
+Logger.writer = function(level){
+ return function(message){
+ var logger = this;
+
+ if(process.title === "node")
+ logger.stream.write(logger.format(level, message) + '\n');
+ else if(process.title === "browser")
+ logger.stream(logger.format(level, message) + '\n');
+
+ };
+}
+
+
+Logger.prototype = {
+ info: function(){},
+ debug: function(){},
+ warn: function(){},
+ error: Logger.writer('error'),
+ format: function(level, message){
+ if (! message) return '';
+
+ var logger = this
+ , prefix = logger.options.prefix
+ , timestamp = logger.options.timestamp ? " " + (new Date().toISOString()) : ""
+ ;
+
+ return (prefix + timestamp + ": " + message);
+ }
+};
+
+module.exports = Logger;
+
+});
+
+require.define("util", function (require, module, exports, __dirname, __filename) {
+ // todo
+
+});
+
+require.define("fs", function (require, module, exports, __dirname, __filename) {
+ // nothing to see here... no file methods for the browser
+
+});
+
+require.define("/node_modules/cookiejar/package.json", function (require, module, exports, __dirname, __filename) {
+ module.exports = {"main":"cookiejar.js"}
+});
+
+require.define("/node_modules/cookiejar/cookiejar.js", function (require, module, exports, __dirname, __filename) {
+ exports.CookieAccessInfo=CookieAccessInfo=function CookieAccessInfo(domain,path,secure,script) {
+ if(this instanceof CookieAccessInfo) {
+ this.domain=domain||undefined;
+ this.path=path||"/";
+ this.secure=!!secure;
+ this.script=!!script;
+ return this;
+ }
+ else {
+ return new CookieAccessInfo(domain,path,secure,script)
+ }
+}
+
+exports.Cookie=Cookie=function Cookie(cookiestr) {
+ if(cookiestr instanceof Cookie) {
+ return cookiestr;
+ }
+ else {
+ if(this instanceof Cookie) {
+ this.name = null;
+ this.value = null;
+ this.expiration_date = Infinity;
+ this.path = "/";
+ this.domain = null;
+ this.secure = false; //how to define?
+ this.noscript = false; //httponly
+ if(cookiestr) {
+ this.parse(cookiestr)
+ }
+ return this;
+ }
+ return new Cookie(cookiestr)
+ }
+}
+
+Cookie.prototype.toString = function toString() {
+ var str=[this.name+"="+this.value];
+ if(this.expiration_date !== Infinity) {
+ str.push("expires="+(new Date(this.expiration_date)).toGMTString());
+ }
+ if(this.domain) {
+ str.push("domain="+this.domain);
+ }
+ if(this.path) {
+ str.push("path="+this.path);
+ }
+ if(this.secure) {
+ str.push("secure");
+ }
+ if(this.noscript) {
+ str.push("httponly");
+ }
+ return str.join("; ");
+}
+
+Cookie.prototype.toValueString = function toValueString() {
+ return this.name+"="+this.value;
+}
+
+var cookie_str_splitter=/[:](?=\s*[a-zA-Z0-9_\-]+\s*[=])/g
+Cookie.prototype.parse = function parse(str) {
+ if(this instanceof Cookie) {
+ var parts=str.split(";")
+ , pair=parts[0].match(/([^=]+)=((?:.|\n)*)/)
+ , key=pair[1]
+ , value=pair[2];
+ this.name = key;
+ this.value = value;
+
+ for(var i=1;i<parts.length;i++) {
+ pair=parts[i].match(/([^=]+)(?:=((?:.|\n)*))?/)
+ , key=pair[1].trim().toLowerCase()
+ , value=pair[2];
+ switch(key) {
+ case "httponly":
+ this.noscript = true;
+ break;
+ case "expires":
+ this.expiration_date = value
+ ? Number(Date.parse(value))
+ : Infinity;
+ break;
+ case "path":
+ this.path = value
+ ? value.trim()
+ : "";
+ break;
+ case "domain":
+ this.domain = value
+ ? value.trim()
+ : "";
+ break;
+ case "secure":
+ this.secure = true;
+ break
+ }
+ }
+
+ return this;
+ }
+ return new Cookie().parse(str)
+}
+
+Cookie.prototype.matches = function matches(access_info) {
+ if(this.noscript && access_info.script
+ || this.secure && !access_info.secure
+ || !this.collidesWith(access_info)) {
+ return false
+ }
+ return true;
+}
+
+Cookie.prototype.collidesWith = function collidesWith(access_info) {
+ if((this.path && !access_info.path) || (this.domain && !access_info.domain)) {
+ return false
+ }
+ if(this.path && access_info.path.indexOf(this.path) !== 0) {
+ return false;
+ }
+ if (this.domain===access_info.domain) {
+ return true;
+ }
+ else if(this.domain && this.domain.charAt(0)===".")
+ {
+ var wildcard=access_info.domain.indexOf(this.domain.slice(1))
+ if(wildcard===-1 || wildcard!==access_info.domain.length-this.domain.length+1) {
+ return false;
+ }
+ }
+ else if(this.domain){
+ return false
+ }
+ return true;
+}
+
+exports.CookieJar=CookieJar=function CookieJar() {
+ if(this instanceof CookieJar) {
+ var cookies = {} //name: [Cookie]
+
+ this.setCookie = function setCookie(cookie) {
+ cookie = Cookie(cookie);
+ //Delete the cookie if the set is past the current time
+ var remove = cookie.expiration_date <= Date.now();
+ if(cookie.name in cookies) {
+ var cookies_list = cookies[cookie.name];
+ for(var i=0;i<cookies_list.length;i++) {
+ var collidable_cookie = cookies_list[i];
+ if(collidable_cookie.collidesWith(cookie)) {
+ if(remove) {
+ cookies_list.splice(i,1);
+ if(cookies_list.length===0) {
+ delete cookies[cookie.name]
+ }
+ return false;
+ }
+ else {
+ return cookies_list[i]=cookie;
+ }
+ }
+ }
+ if(remove) {
+ return false;
+ }
+ cookies_list.push(cookie);
+ return cookie;
+ }
+ else if(remove){
+ return false;
+ }
+ else {
+ return cookies[cookie.name]=[cookie];
+ }
+ }
+ //returns a cookie
+ this.getCookie = function getCookie(cookie_name,access_info) {
+ var cookies_list = cookies[cookie_name];
+ for(var i=0;i<cookies_list.length;i++) {
+ var cookie = cookies_list[i];
+ if(cookie.expiration_date <= Date.now()) {
+ if(cookies_list.length===0) {
+ delete cookies[cookie.name]
+ }
+ continue;
+ }
+ if(cookie.matches(access_info)) {
+ return cookie;
+ }
+ }
+ }
+ //returns a list of cookies
+ this.getCookies = function getCookies(access_info) {
+ var matches=[];
+ for(var cookie_name in cookies) {
+ var cookie=this.getCookie(cookie_name,access_info);
+ if (cookie) {
+ matches.push(cookie);
+ }
+ }
+ matches.toString=function toString(){return matches.join(":");}
+ matches.toValueString=function() {return matches.map(function(c){return c.toValueString();}).join(';');}
+ return matches;
+ }
+
+ return this;
+ }
+ return new CookieJar()
+}
+
+
+//returns list of cookies that were set correctly
+CookieJar.prototype.setCookies = function setCookies(cookies) {
+ cookies=Array.isArray(cookies)
+ ?cookies
+ :cookies.split(cookie_str_splitter);
+ var successful=[]
+ for(var i=0;i<cookies.length;i++) {
+ var cookie = Cookie(cookies[i]);
+ if(this.setCookie(cookie)) {
+ successful.push(cookie);
+ }
+ }
+ return successful;
+}
+
+});
+
+require.define("/shred/request.js", function (require, module, exports, __dirname, __filename) {
+ // The request object encapsulates a request, creating a Node.js HTTP request and
+// then handling the response.
+
+var HTTP = require("http")
+ , HTTPS = require("https")
+ , parseUri = require("./parseUri")
+ , Emitter = require('events').EventEmitter
+ , sprintf = require("sprintf").sprintf
+ , Response = require("./response")
+ , HeaderMixins = require("./mixins/headers")
+ , Content = require("./content")
+;
+
+var STATUS_CODES = HTTP.STATUS_CODES || {
+ 100 : 'Continue',
+ 101 : 'Switching Protocols',
+ 102 : 'Processing', // RFC 2518, obsoleted by RFC 4918
+ 200 : 'OK',
+ 201 : 'Created',
+ 202 : 'Accepted',
+ 203 : 'Non-Authoritative Information',
+ 204 : 'No Content',
+ 205 : 'Reset Content',
+ 206 : 'Partial Content',
+ 207 : 'Multi-Status', // RFC 4918
+ 300 : 'Multiple Choices',
+ 301 : 'Moved Permanently',
+ 302 : 'Moved Temporarily',
+ 303 : 'See Other',
+ 304 : 'Not Modified',
+ 305 : 'Use Proxy',
+ 307 : 'Temporary Redirect',
+ 400 : 'Bad Request',
+ 401 : 'Unauthorized',
+ 402 : 'Payment Required',
+ 403 : 'Forbidden',
+ 404 : 'Not Found',
+ 405 : 'Method Not Allowed',
+ 406 : 'Not Acceptable',
+ 407 : 'Proxy Authentication Required',
+ 408 : 'Request Time-out',
+ 409 : 'Conflict',
+ 410 : 'Gone',
+ 411 : 'Length Required',
+ 412 : 'Precondition Failed',
+ 413 : 'Request Entity Too Large',
+ 414 : 'Request-URI Too Large',
+ 415 : 'Unsupported Media Type',
+ 416 : 'Requested Range Not Satisfiable',
+ 417 : 'Expectation Failed',
+ 418 : 'I\'m a teapot', // RFC 2324
+ 422 : 'Unprocessable Entity', // RFC 4918
+ 423 : 'Locked', // RFC 4918
+ 424 : 'Failed Dependency', // RFC 4918
+ 425 : 'Unordered Collection', // RFC 4918
+ 426 : 'Upgrade Required', // RFC 2817
+ 500 : 'Internal Server Error',
+ 501 : 'Not Implemented',
+ 502 : 'Bad Gateway',
+ 503 : 'Service Unavailable',
+ 504 : 'Gateway Time-out',
+ 505 : 'HTTP Version not supported',
+ 506 : 'Variant Also Negotiates', // RFC 2295
+ 507 : 'Insufficient Storage', // RFC 4918
+ 509 : 'Bandwidth Limit Exceeded',
+ 510 : 'Not Extended' // RFC 2774
+};
+
+// The Shred object itself constructs the `Request` object. You should rarely
+// need to do this directly.
+
+var Request = function(options) {
+ this.log = options.logger;
+ this.cookieJar = options.cookieJar;
+ this.encoding = options.encoding;
+ this.logCurl = options.logCurl;
+ processOptions(this,options||{});
+ createRequest(this);
+};
+
+// A `Request` has a number of properties, many of which help with details like
+// URL parsing or defaulting the port for the request.
+
+Object.defineProperties(Request.prototype, {
+
+// - **url**. You can set the `url` property with a valid URL string and all the
+// URL-related properties (host, port, etc.) will be automatically set on the
+// request object.
+
+ url: {
+ get: function() {
+ if (!this.scheme) { return null; }
+ return sprintf("%s://%s:%s%s",
+ this.scheme, this.host, this.port,
+ (this.proxy ? "/" : this.path) +
+ (this.query ? ("?" + this.query) : ""));
+ },
+ set: function(_url) {
+ _url = parseUri(_url);
+ this.scheme = _url.protocol;
+ this.host = _url.host;
+ this.port = _url.port;
+ this.path = _url.path;
+ this.query = _url.query;
+ return this;
+ },
+ enumerable: true
+ },
+
+// - **headers**. Returns a hash representing the request headers. You can't set
+// this directly, only get it. You can add or modify headers by using the
+// `setHeader` or `setHeaders` method. This ensures that the headers are
+// normalized - that is, you don't accidentally send `Content-Type` and
+// `content-type` headers. Keep in mind that if you modify the returned hash,
+// it will *not* modify the request headers.
+
+ headers: {
+ get: function() {
+ return this.getHeaders();
+ },
+ enumerable: true
+ },
+
+// - **port**. Unless you set the `port` explicitly or include it in the URL, it
+// will default based on the scheme.
+
+ port: {
+ get: function() {
+ if (!this._port) {
+ switch(this.scheme) {
+ case "https": return this._port = 443;
+ case "http":
+ default: return this._port = 80;
+ }
+ }
+ return this._port;
+ },
+ set: function(value) { this._port = value; return this; },
+ enumerable: true
+ },
+
+// - **method**. The request method - `get`, `put`, `post`, etc. that will be
+// used to make the request. Defaults to `get`.
+
+ method: {
+ get: function() {
+ return this._method = (this._method||"GET");
+ },
+ set: function(value) {
+ this._method = value; return this;
+ },
+ enumerable: true
+ },
+
+// - **query**. Can be set either with a query string or a hash (object). Get
+// will always return a properly escaped query string or null if there is no
+// query component for the request.
+
+ query: {
+ get: function() {return this._query;},
+ set: function(value) {
+ var stringify = function (hash) {
+ var query = "";
+ for (var key in hash) {
+ query += encodeURIComponent(key) + '=' + encodeURIComponent(hash[key]) + '&';
+ }
+ // Remove the last '&'
+ query = query.slice(0, -1);
+ return query;
+ }
+
+ if (value) {
+ if (typeof value === 'object') {
+ value = stringify(value);
+ }
+ this._query = value;
+ } else {
+ this._query = "";
+ }
+ return this;
+ },
+ enumerable: true
+ },
+
+// - **parameters**. This will return the query parameters in the form of a hash
+// (object).
+
+ parameters: {
+ get: function() { return QueryString.parse(this._query||""); },
+ enumerable: true
+ },
+
+// - **content**. (Aliased as `body`.) Set this to add a content entity to the
+// request. Attempts to use the `content-type` header to determine what to do
+// with the content value. Get this to get back a [`Content`
+// object](./content.html).
+
+ body: {
+ get: function() { return this._body; },
+ set: function(value) {
+ this._body = new Content({
+ data: value,
+ type: this.getHeader("Content-Type")
+ });
+ this.setHeader("Content-Type",this.content.type);
+ this.setHeader("Content-Length",this.content.length);
+ return this;
+ },
+ enumerable: true
+ },
+
+// - **timeout**. Used to determine how long to wait for a response. Does not
+// distinguish between connect timeouts versus request timeouts. Set either in
+// milliseconds or with an object with temporal attributes (hours, minutes,
+// seconds) and convert it into milliseconds. Get will always return
+// milliseconds.
+
+ timeout: {
+ get: function() { return this._timeout; }, // in milliseconds
+ set: function(timeout) {
+ var request = this
+ , milliseconds = 0;
+ ;
+ if (!timeout) return this;
+ if (typeof timeout==="number") { milliseconds = timeout; }
+ else {
+ milliseconds = (timeout.milliseconds||0) +
+ (1000 * ((timeout.seconds||0) +
+ (60 * ((timeout.minutes||0) +
+ (60 * (timeout.hours||0))))));
+ }
+ this._timeout = milliseconds;
+ return this;
+ },
+ enumerable: true
+ }
+});
+
+// Alias `body` property to `content`. Since the [content object](./content.html)
+// has a `body` attribute, it's preferable to use `content` since you can then
+// access the raw content data using `content.body`.
+
+Object.defineProperty(Request.prototype,"content",
+ Object.getOwnPropertyDescriptor(Request.prototype, "body"));
+
+// The `Request` object can be pretty overwhelming to view using the built-in
+// Node.js inspect method. We want to make it a bit more manageable. This
+// probably goes [too far in the other
+// direction](https://github.com/spire-io/shred/issues/2).
+
+Request.prototype.inspect = function () {
+ var request = this;
+ var headers = this.format_headers();
+ var summary = ["<Shred Request> ", request.method.toUpperCase(),
+ request.url].join(" ")
+ return [ summary, "- Headers:", headers].join("\n");
+};
+
+Request.prototype.format_headers = function () {
+ var array = []
+ var headers = this._headers
+ for (var key in headers) {
+ if (headers.hasOwnProperty(key)) {
+ var value = headers[key]
+ array.push("\t" + key + ": " + value);
+ }
+ }
+ return array.join("\n");
+};
+
+// Allow chainable 'on's: shred.get({ ... }).on( ... ). You can pass in a
+// single function, a pair (event, function), or a hash:
+// { event: function, event: function }
+Request.prototype.on = function (eventOrHash, listener) {
+ var emitter = this.emitter;
+ // Pass in a single argument as a function then make it the default response handler
+ if (arguments.length === 1 && typeof(eventOrHash) === 'function') {
+ emitter.on('response', eventOrHash);
+ } else if (arguments.length === 1 && typeof(eventOrHash) === 'object') {
+ for (var key in eventOrHash) {
+ if (eventOrHash.hasOwnProperty(key)) {
+ emitter.on(key, eventOrHash[key]);
+ }
+ }
+ } else {
+ emitter.on(eventOrHash, listener);
+ }
+ return this;
+};
+
+// Add in the header methods. Again, these ensure we don't get the same header
+// multiple times with different case conventions.
+HeaderMixins.gettersAndSetters(Request);
+
+// `processOptions` is called from the constructor to handle all the work
+// associated with making sure we do our best to ensure we have a valid request.
+
+var processOptions = function(request,options) {
+
+ request.log.debug("Processing request options ..");
+
+ // We'll use `request.emitter` to manage the `on` event handlers.
+ request.emitter = (new Emitter);
+
+ request.agent = options.agent;
+
+ // Set up the handlers ...
+ if (options.on) {
+ for (var key in options.on) {
+ if (options.on.hasOwnProperty(key)) {
+ request.emitter.on(key, options.on[key]);
+ }
+ }
+ }
+
+ // Make sure we were give a URL or a host
+ if (!options.url && !options.host) {
+ request.emitter.emit("request_error",
+ new Error("No url or url options (host, port, etc.)"));
+ return;
+ }
+
+ // Allow for the [use of a proxy](http://www.jmarshall.com/easy/http/#proxies).
+
+ if (options.url) {
+ if (options.proxy) {
+ request.url = options.proxy;
+ request.path = options.url;
+ } else {
+ request.url = options.url;
+ }
+ }
+
+ // Set the remaining options.
+ request.query = options.query||options.parameters||request.query ;
+ request.method = options.method;
+ request.setHeader("user-agent",options.agent||"Shred");
+ request.setHeaders(options.headers);
+
+ if (request.cookieJar) {
+ var cookies = request.cookieJar.getCookies( CookieAccessInfo( request.host, request.path ) );
+ if (cookies.length) {
+ var cookieString = request.getHeader('cookie')||'';
+ for (var cookieIndex = 0; cookieIndex < cookies.length; ++cookieIndex) {
+ if ( cookieString.length && cookieString[ cookieString.length - 1 ] != ';' )
+ {
+ cookieString += ';';
+ }
+ cookieString += cookies[ cookieIndex ].name + '=' + cookies[ cookieIndex ].value + ';';
+ }
+ request.setHeader("cookie", cookieString);
+ }
+ }
+
+ // The content entity can be set either using the `body` or `content` attributes.
+ if (options.body||options.content) {
+ request.content = options.body||options.content;
+ }
+ request.timeout = options.timeout;
+
+};
+
+// `createRequest` is also called by the constructor, after `processOptions`.
+// This actually makes the request and processes the response, so `createRequest`
+// is a bit of a misnomer.
+
+var createRequest = function(request) {
+ var timeout ;
+
+ request.log.debug("Creating request ..");
+ request.log.debug(request);
+
+ var reqParams = {
+ host: request.host,
+ port: request.port,
+ method: request.method,
+ path: request.path + (request.query ? '?'+request.query : ""),
+ headers: request.getHeaders(),
+ // Node's HTTP/S modules will ignore this, but we are using the
+ // browserify-http module in the browser for both HTTP and HTTPS, and this
+ // is how you differentiate the two.
+ scheme: request.scheme,
+ // Use a provided agent. 'Undefined' is the default, which uses a global
+ // agent.
+ agent: request.agent
+ };
+
+ if (request.logCurl) {
+ logCurl(request);
+ }
+
+ var http = request.scheme == "http" ? HTTP : HTTPS;
+
+ // Set up the real request using the selected library. The request won't be
+ // sent until we call `.end()`.
+ request._raw = http.request(reqParams, function(response) {
+ request.log.debug("Received response ..");
+
+ // We haven't timed out and we have a response, so make sure we clear the
+ // timeout so it doesn't fire while we're processing the response.
+ clearTimeout(timeout);
+
+ // Construct a Shred `Response` object from the response. This will stream
+ // the response, thus the need for the callback. We can access the response
+ // entity safely once we're in the callback.
+ response = new Response(response, request, function(response) {
+
+ // Set up some event magic. The precedence is given first to
+ // status-specific handlers, then to responses for a given event, and then
+ // finally to the more general `response` handler. In the last case, we
+ // need to first make sure we're not dealing with a a redirect.
+ var emit = function(event) {
+ var emitter = request.emitter;
+ var textStatus = STATUS_CODES[response.status] ? STATUS_CODES[response.status].toLowerCase() : null;
+ if (emitter.listeners(response.status).length > 0 || emitter.listeners(textStatus).length > 0) {
+ emitter.emit(response.status, response);
+ emitter.emit(textStatus, response);
+ } else {
+ if (emitter.listeners(event).length>0) {
+ emitter.emit(event, response);
+ } else if (!response.isRedirect) {
+ emitter.emit("response", response);
+ //console.warn("Request has no event listener for status code " + response.status);
+ }
+ }
+ };
+
+ // Next, check for a redirect. We simply repeat the request with the URL
+ // given in the `Location` header. We fire a `redirect` event.
+ if (response.isRedirect) {
+ request.log.debug("Redirecting to "
+ + response.getHeader("Location"));
+ request.url = response.getHeader("Location");
+ emit("redirect");
+ createRequest(request);
+
+ // Okay, it's not a redirect. Is it an error of some kind?
+ } else if (response.isError) {
+ emit("error");
+ } else {
+ // It looks like we're good shape. Trigger the `success` event.
+ emit("success");
+ }
+ });
+ });
+
+ // We're still setting up the request. Next, we're going to handle error cases
+ // where we have no response. We don't emit an error event because that event
+ // takes a response. We don't response handlers to have to check for a null
+ // value. However, we [should introduce a different event
+ // type](https://github.com/spire-io/shred/issues/3) for this type of error.
+ request._raw.on("error", function(error) {
+ request.emitter.emit("request_error", error);
+ });
+
+ request._raw.on("socket", function(socket) {
+ request.emitter.emit("socket", socket);
+ });
+
+ // TCP timeouts should also trigger the "response_error" event.
+ request._raw.on('socket', function () {
+ request._raw.socket.on('timeout', function () {
+ // This should trigger the "error" event on the raw request, which will
+ // trigger the "response_error" on the shred request.
+ request._raw.abort();
+ });
+ });
+
+
+ // We're almost there. Next, we need to write the request entity to the
+ // underlying request object.
+ if (request.content) {
+ request.log.debug("Streaming body: '" +
+ request.content.data.slice(0,59) + "' ... ");
+ request._raw.write(request.content.data);
+ }
+
+ // Finally, we need to set up the timeout. We do this last so that we don't
+ // start the clock ticking until the last possible moment.
+ if (request.timeout) {
+ timeout = setTimeout(function() {
+ request.log.debug("Timeout fired, aborting request ...");
+ request._raw.abort();
+ request.emitter.emit("timeout", request);
+ },request.timeout);
+ }
+
+ // The `.end()` method will cause the request to fire. Technically, it might
+ // have already sent the headers and body.
+ request.log.debug("Sending request ...");
+ request._raw.end();
+};
+
+// Logs the curl command for the request.
+var logCurl = function (req) {
+ var headers = req.getHeaders();
+ var headerString = "";
+
+ for (var key in headers) {
+ headerString += '-H "' + key + ": " + headers[key] + '" ';
+ }
+
+ var bodyString = ""
+
+ if (req.content) {
+ bodyString += "-d '" + req.content.body + "' ";
+ }
+
+ var query = req.query ? '?' + req.query : "";
+
+ console.log("curl " +
+ "-X " + req.method.toUpperCase() + " " +
+ req.scheme + "://" + req.host + ":" + req.port + req.path + query + " " +
+ headerString +
+ bodyString
+ );
+};
+
+
+module.exports = Request;
+
+});
+
+require.define("http", function (require, module, exports, __dirname, __filename) {
+ // todo
+
+});
+
+require.define("https", function (require, module, exports, __dirname, __filename) {
+ // todo
+
+});
+
+require.define("/shred/parseUri.js", function (require, module, exports, __dirname, __filename) {
+ // parseUri 1.2.2
+// (c) Steven Levithan <stevenlevithan.com>
+// MIT License
+
+function parseUri (str) {
+ var o = parseUri.options,
+ m = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
+ uri = {},
+ i = 14;
+
+ while (i--) uri[o.key[i]] = m[i] || "";
+
+ uri[o.q.name] = {};
+ uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
+ if ($1) uri[o.q.name][$1] = $2;
+ });
+
+ return uri;
+};
+
+parseUri.options = {
+ strictMode: false,
+ key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
+ q: {
+ name: "queryKey",
+ parser: /(?:^|&)([^&=]*)=?([^&]*)/g
+ },
+ parser: {
+ strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
+ loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
+ }
+};
+
+module.exports = parseUri;
+
+});
+
+require.define("events", function (require, module, exports, __dirname, __filename) {
+ if (!process.EventEmitter) process.EventEmitter = function () {};
+
+var EventEmitter = exports.EventEmitter = process.EventEmitter;
+var isArray = typeof Array.isArray === 'function'
+ ? Array.isArray
+ : function (xs) {
+ return Object.toString.call(xs) === '[object Array]'
+ }
+;
+
+// By default EventEmitters will print a warning if more than
+// 10 listeners are added to it. This is a useful default which
+// helps finding memory leaks.
+//
+// Obviously not all Emitters should be limited to 10. This function allows
+// that to be increased. Set to zero for unlimited.
+var defaultMaxListeners = 10;
+EventEmitter.prototype.setMaxListeners = function(n) {
+ if (!this._events) this._events = {};
+ this._events.maxListeners = n;
+};
+
+
+EventEmitter.prototype.emit = function(type) {
+ // If there is no 'error' event listener then throw.
+ if (type === 'error') {
+ if (!this._events || !this._events.error ||
+ (isArray(this._events.error) && !this._events.error.length))
+ {
+ if (arguments[1] instanceof Error) {
+ throw arguments[1]; // Unhandled 'error' event
+ } else {
+ throw new Error("Uncaught, unspecified 'error' event.");
+ }
+ return false;
+ }
+ }
+
+ if (!this._events) return false;
+ var handler = this._events[type];
+ if (!handler) return false;
+
+ if (typeof handler == 'function') {
+ switch (arguments.length) {
+ // fast cases
+ case 1:
+ handler.call(this);
+ break;
+ case 2:
+ handler.call(this, arguments[1]);
+ break;
+ case 3:
+ handler.call(this, arguments[1], arguments[2]);
+ break;
+ // slower
+ default:
+ var args = Array.prototype.slice.call(arguments, 1);
+ handler.apply(this, args);
+ }
+ return true;
+
+ } else if (isArray(handler)) {
+ var args = Array.prototype.slice.call(arguments, 1);
+
+ var listeners = handler.slice();
+ for (var i = 0, l = listeners.length; i < l; i++) {
+ listeners[i].apply(this, args);
+ }
+ return true;
+
+ } else {
+ return false;
+ }
+};
+
+// EventEmitter is defined in src/node_events.cc
+// EventEmitter.prototype.emit() is also defined there.
+EventEmitter.prototype.addListener = function(type, listener) {
+ if ('function' !== typeof listener) {
+ throw new Error('addListener only takes instances of Function');
+ }
+
+ if (!this._events) this._events = {};
+
+ // To avoid recursion in the case that type == "newListeners"! Before
+ // adding it to the listeners, first emit "newListeners".
+ this.emit('newListener', type, listener);
+
+ if (!this._events[type]) {
+ // Optimize the case of one listener. Don't need the extra array object.
+ this._events[type] = listener;
+ } else if (isArray(this._events[type])) {
+
+ // Check for listener leak
+ if (!this._events[type].warned) {
+ var m;
+ if (this._events.maxListeners !== undefined) {
+ m = this._events.maxListeners;
+ } else {
+ m = defaultMaxListeners;
+ }
+
+ if (m && m > 0 && this._events[type].length > m) {
+ this._events[type].warned = true;
+ console.error('(node) warning: possible EventEmitter memory ' +
+ 'leak detected. %d listeners added. ' +
+ 'Use emitter.setMaxListeners() to increase limit.',
+ this._events[type].length);
+ console.trace();
+ }
+ }
+
+ // If we've already got an array, just append.
+ this._events[type].push(listener);
+ } else {
+ // Adding the second element, need to change to array.
+ this._events[type] = [this._events[type], listener];
+ }
+
+ return this;
+};
+
+EventEmitter.prototype.on = EventEmitter.prototype.addListener;
+
+EventEmitter.prototype.once = function(type, listener) {
+ var self = this;
+ self.on(type, function g() {
+ self.removeListener(type, g);
+ listener.apply(this, arguments);
+ });
+
+ return this;
+};
+
+EventEmitter.prototype.removeListener = function(type, listener) {
+ if ('function' !== typeof listener) {
+ throw new Error('removeListener only takes instances of Function');
+ }
+
+ // does not use listeners(), so no side effect of creating _events[type]
+ if (!this._events || !this._events[type]) return this;
+
+ var list = this._events[type];
+
+ if (isArray(list)) {
+ var i = list.indexOf(listener);
+ if (i < 0) return this;
+ list.splice(i, 1);
+ if (list.length == 0)
+ delete this._events[type];
+ } else if (this._events[type] === listener) {
+ delete this._events[type];
+ }
+
+ return this;
+};
+
+EventEmitter.prototype.removeAllListeners = function(type) {
+ // does not use listeners(), so no side effect of creating _events[type]
+ if (type && this._events && this._events[type]) this._events[type] = null;
+ return this;
+};
+
+EventEmitter.prototype.listeners = function(type) {
+ if (!this._events) this._events = {};
+ if (!this._events[type]) this._events[type] = [];
+ if (!isArray(this._events[type])) {
+ this._events[type] = [this._events[type]];
+ }
+ return this._events[type];
+};
+
+});
+
+require.define("/node_modules/sprintf/package.json", function (require, module, exports, __dirname, __filename) {
+ module.exports = {"main":"./lib/sprintf"}
+});
+
+require.define("/node_modules/sprintf/lib/sprintf.js", function (require, module, exports, __dirname, __filename) {
+ /**
+sprintf() for JavaScript 0.7-beta1
+http://www.diveintojavascript.com/projects/javascript-sprintf
+
+Copyright (c) Alexandru Marasteanu <alexaholic [at) gmail (dot] com>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of sprintf() for JavaScript nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL Alexandru Marasteanu BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+Changelog:
+2010.11.07 - 0.7-beta1-node
+ - converted it to a node.js compatible module
+
+2010.09.06 - 0.7-beta1
+ - features: vsprintf, support for named placeholders
+ - enhancements: format cache, reduced global namespace pollution
+
+2010.05.22 - 0.6:
+ - reverted to 0.4 and fixed the bug regarding the sign of the number 0
+ Note:
+ Thanks to Raphael Pigulla <raph (at] n3rd [dot) org> (http://www.n3rd.org/)
+ who warned me about a bug in 0.5, I discovered that the last update was
+ a regress. I appologize for that.
+
+2010.05.09 - 0.5:
+ - bug fix: 0 is now preceeded with a + sign
+ - bug fix: the sign was not at the right position on padded results (Kamal Abdali)
+ - switched from GPL to BSD license
+
+2007.10.21 - 0.4:
+ - unit test and patch (David Baird)
+
+2007.09.17 - 0.3:
+ - bug fix: no longer throws exception on empty paramenters (Hans Pufal)
+
+2007.09.11 - 0.2:
+ - feature: added argument swapping
+
+2007.04.03 - 0.1:
+ - initial release
+**/
+
+var sprintf = (function() {
+ function get_type(variable) {
+ return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase();
+ }
+ function str_repeat(input, multiplier) {
+ for (var output = []; multiplier > 0; output[--multiplier] = input) {/* do nothing */}
+ return output.join('');
+ }
+
+ var str_format = function() {
+ if (!str_format.cache.hasOwnProperty(arguments[0])) {
+ str_format.cache[arguments[0]] = str_format.parse(arguments[0]);
+ }
+ return str_format.format.call(null, str_format.cache[arguments[0]], arguments);
+ };
+
+ str_format.format = function(parse_tree, argv) {
+ var cursor = 1, tree_length = parse_tree.length, node_type = '', arg, output = [], i, k, match, pad, pad_character, pad_length;
+ for (i = 0; i < tree_length; i++) {
+ node_type = get_type(parse_tree[i]);
+ if (node_type === 'string') {
+ output.push(parse_tree[i]);
+ }
+ else if (node_type === 'array') {
+ match = parse_tree[i]; // convenience purposes only
+ if (match[2]) { // keyword argument
+ arg = argv[cursor];
+ for (k = 0; k < match[2].length; k++) {
+ if (!arg.hasOwnProperty(match[2][k])) {
+ throw(sprintf('[sprintf] property "%s" does not exist', match[2][k]));
+ }
+ arg = arg[match[2][k]];
+ }
+ }
+ else if (match[1]) { // positional argument (explicit)
+ arg = argv[match[1]];
+ }
+ else { // positional argument (implicit)
+ arg = argv[cursor++];
+ }
+
+ if (/[^s]/.test(match[8]) && (get_type(arg) != 'number')) {
+ throw(sprintf('[sprintf] expecting number but found %s', get_type(arg)));
+ }
+ switch (match[8]) {
+ case 'b': arg = arg.toString(2); break;
+ case 'c': arg = String.fromCharCode(arg); break;
+ case 'd': arg = parseInt(arg, 10); break;
+ case 'e': arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential(); break;
+ case 'f': arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg); break;
+ case 'o': arg = arg.toString(8); break;
+ case 's': arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg); break;
+ case 'u': arg = Math.abs(arg); break;
+ case 'x': arg = arg.toString(16); break;
+ case 'X': arg = arg.toString(16).toUpperCase(); break;
+ }
+ arg = (/[def]/.test(match[8]) && match[3] && arg >= 0 ? '+'+ arg : arg);
+ pad_character = match[4] ? match[4] == '0' ? '0' : match[4].charAt(1) : ' ';
+ pad_length = match[6] - String(arg).length;
+ pad = match[6] ? str_repeat(pad_character, pad_length) : '';
+ output.push(match[5] ? arg + pad : pad + arg);
+ }
+ }
+ return output.join('');
+ };
+
+ str_format.cache = {};
+
+ str_format.parse = function(fmt) {
+ var _fmt = fmt, match = [], parse_tree = [], arg_names = 0;
+ while (_fmt) {
+ if ((match = /^[^\x25]+/.exec(_fmt)) !== null) {
+ parse_tree.push(match[0]);
+ }
+ else if ((match = /^\x25{2}/.exec(_fmt)) !== null) {
+ parse_tree.push('%');
+ }
+ else if ((match = /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(_fmt)) !== null) {
+ if (match[2]) {
+ arg_names |= 1;
+ var field_list = [], replacement_field = match[2], field_match = [];
+ if ((field_match = /^([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
+ field_list.push(field_match[1]);
+ while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') {
+ if ((field_match = /^\.([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
+ field_list.push(field_match[1]);
+ }
+ else if ((field_match = /^\[(\d+)\]/.exec(replacement_field)) !== null) {
+ field_list.push(field_match[1]);
+ }
+ else {
+ throw('[sprintf] huh?');
+ }
+ }
+ }
+ else {
+ throw('[sprintf] huh?');
+ }
+ match[2] = field_list;
+ }
+ else {
+ arg_names |= 2;
+ }
+ if (arg_names === 3) {
+ throw('[sprintf] mixing positional and named placeholders is not (yet) supported');
+ }
+ parse_tree.push(match);
+ }
+ else {
+ throw('[sprintf] huh?');
+ }
+ _fmt = _fmt.substring(match[0].length);
+ }
+ return parse_tree;
+ };
+
+ return str_format;
+})();
+
+var vsprintf = function(fmt, argv) {
+ argv.unshift(fmt);
+ return sprintf.apply(null, argv);
+};
+
+exports.sprintf = sprintf;
+exports.vsprintf = vsprintf;
+});
+
+require.define("/shred/response.js", function (require, module, exports, __dirname, __filename) {
+ // The `Response object` encapsulates a Node.js HTTP response.
+
+var Content = require("./content")
+ , HeaderMixins = require("./mixins/headers")
+ , CookieJarLib = require( "cookiejar" )
+ , Cookie = CookieJarLib.Cookie
+;
+
+// Browser doesn't have zlib.
+var zlib = null;
+try {
+ zlib = require('zlib');
+} catch (e) {
+ console.warn("no zlib library");
+}
+
+// Iconv doesn't work in browser
+var Iconv = null;
+try {
+ Iconv = require('iconv-lite');
+} catch (e) {
+ console.warn("no iconv library");
+}
+
+// Construct a `Response` object. You should never have to do this directly. The
+// `Request` object handles this, getting the raw response object and passing it
+// in here, along with the request. The callback allows us to stream the response
+// and then use the callback to let the request know when it's ready.
+var Response = function(raw, request, callback) {
+ var response = this;
+ this._raw = raw;
+
+ // The `._setHeaders` method is "private"; you can't otherwise set headers on
+ // the response.
+ this._setHeaders.call(this,raw.headers);
+
+ // store any cookies
+ if (request.cookieJar && this.getHeader('set-cookie')) {
+ var cookieStrings = this.getHeader('set-cookie');
+ var cookieObjs = []
+ , cookie;
+
+ for (var i = 0; i < cookieStrings.length; i++) {
+ var cookieString = cookieStrings[i];
+ if (!cookieString) {
+ continue;
+ }
+
+ if (!cookieString.match(/domain\=/i)) {
+ cookieString += '; domain=' + request.host;
+ }
+
+ if (!cookieString.match(/path\=/i)) {
+ cookieString += '; path=' + request.path;
+ }
+
+ try {
+ cookie = new Cookie(cookieString);
+ if (cookie) {
+ cookieObjs.push(cookie);
+ }
+ } catch (e) {
+ console.warn("Tried to set bad cookie: " + cookieString);
+ }
+ }
+
+ request.cookieJar.setCookies(cookieObjs);
+ }
+
+ this.request = request;
+ this.client = request.client;
+ this.log = this.request.log;
+
+ // Stream the response content entity and fire the callback when we're done.
+ // Store the incoming data in a array of Buffers which we concatinate into one
+ // buffer at the end. We need to use buffers instead of strings here in order
+ // to preserve binary data.
+ var chunkBuffers = [];
+ var dataLength = 0;
+ raw.on("data", function(chunk) {
+ chunkBuffers.push(chunk);
+ dataLength += chunk.length;
+ });
+ raw.on("end", function() {
+ var body;
+ if (typeof Buffer === 'undefined') {
+ // Just concatinate into a string
+ body = chunkBuffers.join('');
+ } else {
+ // Initialize new buffer and add the chunks one-at-a-time.
+ body = new Buffer(dataLength);
+ for (var i = 0, pos = 0; i < chunkBuffers.length; i++) {
+ chunkBuffers[i].copy(body, pos);
+ pos += chunkBuffers[i].length;
+ }
+ }
+
+ var setBodyAndFinish = function (body) {
+ response._body = new Content({
+ body: body,
+ type: response.getHeader("Content-Type")
+ });
+ callback(response);
+ }
+
+ if (zlib && response.getHeader("Content-Encoding") === 'gzip'){
+ zlib.gunzip(body, function (err, gunzippedBody) {
+ if (Iconv && response.request.encoding){
+ body = Iconv.fromEncoding(gunzippedBody,response.request.encoding);
+ } else {
+ body = gunzippedBody.toString();
+ }
+ setBodyAndFinish(body);
+ })
+ }
+ else{
+ if (response.request.encoding){
+ body = Iconv.fromEncoding(body,response.request.encoding);
+ }
+ setBodyAndFinish(body);
+ }
+ });
+};
+
+// The `Response` object can be pretty overwhelming to view using the built-in
+// Node.js inspect method. We want to make it a bit more manageable. This
+// probably goes [too far in the other
+// direction](https://github.com/spire-io/shred/issues/2).
+
+Response.prototype = {
+ inspect: function() {
+ var response = this;
+ var headers = this.format_headers();
+ var summary = ["<Shred Response> ", response.status].join(" ")
+ return [ summary, "- Headers:", headers].join("\n");
+ },
+ format_headers: function () {
+ var array = []
+ var headers = this._headers
+ for (var key in headers) {
+ if (headers.hasOwnProperty(key)) {
+ var value = headers[key]
+ array.push("\t" + key + ": " + value);
+ }
+ }
+ return array.join("\n");
+ }
+};
+
+// `Response` object properties, all of which are read-only:
+Object.defineProperties(Response.prototype, {
+
+// - **status**. The HTTP status code for the response.
+ status: {
+ get: function() { return this._raw.statusCode; },
+ enumerable: true
+ },
+
+// - **content**. The HTTP content entity, if any. Provided as a [content
+// object](./content.html), which will attempt to convert the entity based upon
+// the `content-type` header. The converted value is available as
+// `content.data`. The original raw content entity is available as
+// `content.body`.
+ body: {
+ get: function() { return this._body; }
+ },
+ content: {
+ get: function() { return this.body; },
+ enumerable: true
+ },
+
+// - **isRedirect**. Is the response a redirect? These are responses with 3xx
+// status and a `Location` header.
+ isRedirect: {
+ get: function() {
+ return (this.status>299
+ &&this.status<400
+ &&this.getHeader("Location"));
+ },
+ enumerable: true
+ },
+
+// - **isError**. Is the response an error? These are responses with status of
+// 400 or greater.
+ isError: {
+ get: function() {
+ return (this.status === 0 || this.status > 399)
+ },
+ enumerable: true
+ }
+});
+
+// Add in the [getters for accessing the normalized headers](./headers.js).
+HeaderMixins.getters(Response);
+HeaderMixins.privateSetters(Response);
+
+// Work around Mozilla bug #608735 [https://bugzil.la/608735], which causes
+// getAllResponseHeaders() to return {} if the response is a CORS request.
+// xhr.getHeader still works correctly.
+var getHeader = Response.prototype.getHeader;
+Response.prototype.getHeader = function (name) {
+ return (getHeader.call(this,name) ||
+ (typeof this._raw.getHeader === 'function' && this._raw.getHeader(name)));
+};
+
+module.exports = Response;
+
+});
+
+require.define("/shred/content.js", function (require, module, exports, __dirname, __filename) {
+
+// The purpose of the `Content` object is to abstract away the data conversions
+// to and from raw content entities as strings. For example, you want to be able
+// to pass in a Javascript object and have it be automatically converted into a
+// JSON string if the `content-type` is set to a JSON-based media type.
+// Conversely, you want to be able to transparently get back a Javascript object
+// in the response if the `content-type` is a JSON-based media-type.
+
+// One limitation of the current implementation is that it [assumes the `charset` is UTF-8](https://github.com/spire-io/shred/issues/5).
+
+// The `Content` constructor takes an options object, which *must* have either a
+// `body` or `data` property and *may* have a `type` property indicating the
+// media type. If there is no `type` attribute, a default will be inferred.
+var Content = function(options) {
+ this.body = options.body;
+ this.data = options.data;
+ this.type = options.type;
+};
+
+Content.prototype = {
+ // Treat `toString()` as asking for the `content.body`. That is, the raw content entity.
+ //
+ // toString: function() { return this.body; }
+ //
+ // Commented out, but I've forgotten why. :/
+};
+
+
+// `Content` objects have the following attributes:
+Object.defineProperties(Content.prototype,{
+
+// - **type**. Typically accessed as `content.type`, reflects the `content-type`
+// header associated with the request or response. If not passed as an options
+// to the constructor or set explicitly, it will infer the type the `data`
+// attribute, if possible, and, failing that, will default to `text/plain`.
+ type: {
+ get: function() {
+ if (this._type) {
+ return this._type;
+ } else {
+ if (this._data) {
+ switch(typeof this._data) {
+ case "string": return "text/plain";
+ case "object": return "application/json";
+ }
+ }
+ }
+ return "text/plain";
+ },
+ set: function(value) {
+ this._type = value;
+ return this;
+ },
+ enumerable: true
+ },
+
+// - **data**. Typically accessed as `content.data`, reflects the content entity
+// converted into Javascript data. This can be a string, if the `type` is, say,
+// `text/plain`, but can also be a Javascript object. The conversion applied is
+// based on the `processor` attribute. The `data` attribute can also be set
+// directly, in which case the conversion will be done the other way, to infer
+// the `body` attribute.
+ data: {
+ get: function() {
+ if (this._body) {
+ return this.processor.parser(this._body);
+ } else {
+ return this._data;
+ }
+ },
+ set: function(data) {
+ if (this._body&&data) Errors.setDataWithBody(this);
+ this._data = data;
+ return this;
+ },
+ enumerable: true
+ },
+
+// - **body**. Typically accessed as `content.body`, reflects the content entity
+// as a UTF-8 string. It is the mirror of the `data` attribute. If you set the
+// `data` attribute, the `body` attribute will be inferred and vice-versa. If
+// you attempt to set both, an exception is raised.
+ body: {
+ get: function() {
+ if (this._data) {
+ return this.processor.stringify(this._data);
+ } else {
+ return this.processor.stringify(this._body);
+ }
+ },
+ set: function(body) {
+ if (this._data&&body) Errors.setBodyWithData(this);
+ this._body = body;
+ return this;
+ },
+ enumerable: true
+ },
+
+// - **processor**. The functions that will be used to convert to/from `data` and
+// `body` attributes. You can add processors. The two that are built-in are for
+// `text/plain`, which is basically an identity transformation and
+// `application/json` and other JSON-based media types (including custom media
+// types with `+json`). You can add your own processors. See below.
+ processor: {
+ get: function() {
+ var processor = Content.processors[this.type];
+ if (processor) {
+ return processor;
+ } else {
+ // Return the first processor that matches any part of the
+ // content type. ex: application/vnd.foobar.baz+json will match json.
+ var main = this.type.split(";")[0];
+ var parts = main.split(/\+|\//);
+ for (var i=0, l=parts.length; i < l; i++) {
+ processor = Content.processors[parts[i]]
+ }
+ return processor || {parser:identity,stringify:toString};
+ }
+ },
+ enumerable: true
+ },
+
+// - **length**. Typically accessed as `content.length`, returns the length in
+// bytes of the raw content entity.
+ length: {
+ get: function() {
+ if (typeof Buffer !== 'undefined') {
+ return Buffer.byteLength(this.body);
+ }
+ return this.body.length;
+ }
+ }
+});
+
+Content.processors = {};
+
+// The `registerProcessor` function allows you to add your own processors to
+// convert content entities. Each processor consists of a Javascript object with
+// two properties:
+// - **parser**. The function used to parse a raw content entity and convert it
+// into a Javascript data type.
+// - **stringify**. The function used to convert a Javascript data type into a
+// raw content entity.
+Content.registerProcessor = function(types,processor) {
+
+// You can pass an array of types that will trigger this processor, or just one.
+// We determine the array via duck-typing here.
+ if (types.forEach) {
+ types.forEach(function(type) {
+ Content.processors[type] = processor;
+ });
+ } else {
+ // If you didn't pass an array, we just use what you pass in.
+ Content.processors[types] = processor;
+ }
+};
+
+// Register the identity processor, which is used for text-based media types.
+var identity = function(x) { return x; }
+ , toString = function(x) { return x.toString(); }
+Content.registerProcessor(
+ ["text/html","text/plain","text"],
+ { parser: identity, stringify: toString });
+
+// Register the JSON processor, which is used for JSON-based media types.
+Content.registerProcessor(
+ ["application/json; charset=utf-8","application/json","json"],
+ {
+ parser: function(string) {
+ return JSON.parse(string);
+ },
+ stringify: function(data) {
+ return JSON.stringify(data); }});
+
+// Error functions are defined separately here in an attempt to make the code
+// easier to read.
+var Errors = {
+ setDataWithBody: function(object) {
+ throw new Error("Attempt to set data attribute of a content object " +
+ "when the body attributes was already set.");
+ },
+ setBodyWithData: function(object) {
+ throw new Error("Attempt to set body attribute of a content object " +
+ "when the data attributes was already set.");
+ }
+}
+module.exports = Content;
+
+});
+
+require.define("/shred/mixins/headers.js", function (require, module, exports, __dirname, __filename) {
+ // The header mixins allow you to add HTTP header support to any object. This
+// might seem pointless: why not simply use a hash? The main reason is that, per
+// the [HTTP spec](http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2),
+// headers are case-insensitive. So, for example, `content-type` is the same as
+// `CONTENT-TYPE` which is the same as `Content-Type`. Since there is no way to
+// overload the index operator in Javascript, using a hash to represent the
+// headers means it's possible to have two conflicting values for a single
+// header.
+//
+// The solution to this is to provide explicit methods to set or get headers.
+// This also has the benefit of allowing us to introduce additional variations,
+// including snake case, which we automatically convert to what Matthew King has
+// dubbed "corset case" - the hyphen-separated names with initial caps:
+// `Content-Type`. We use corset-case just in case we're dealing with servers
+// that haven't properly implemented the spec.
+
+// Convert headers to corset-case. **Example:** `CONTENT-TYPE` will be converted
+// to `Content-Type`.
+
+var corsetCase = function(string) {
+ return string.toLowerCase()
+ //.replace("_","-")
+ .replace(/(^|-)(\w)/g,
+ function(s) { return s.toUpperCase(); });
+};
+
+// We suspect that `initializeHeaders` was once more complicated ...
+var initializeHeaders = function(object) {
+ return {};
+};
+
+// Access the `_headers` property using lazy initialization. **Warning:** If you
+// mix this into an object that is using the `_headers` property already, you're
+// going to have trouble.
+var $H = function(object) {
+ return object._headers||(object._headers=initializeHeaders(object));
+};
+
+// Hide the implementations as private functions, separate from how we expose them.
+
+// The "real" `getHeader` function: get the header after normalizing the name.
+var getHeader = function(object,name) {
+ return $H(object)[corsetCase(name)];
+};
+
+// The "real" `getHeader` function: get one or more headers, or all of them
+// if you don't ask for any specifics.
+var getHeaders = function(object,names) {
+ var keys = (names && names.length>0) ? names : Object.keys($H(object));
+ var hash = keys.reduce(function(hash,key) {
+ hash[key] = getHeader(object,key);
+ return hash;
+ },{});
+ // Freeze the resulting hash so you don't mistakenly think you're modifying
+ // the real headers.
+ Object.freeze(hash);
+ return hash;
+};
+
+// The "real" `setHeader` function: set a header, after normalizing the name.
+var setHeader = function(object,name,value) {
+ $H(object)[corsetCase(name)] = value;
+ return object;
+};
+
+// The "real" `setHeaders` function: set multiple headers based on a hash.
+var setHeaders = function(object,hash) {
+ for( var key in hash ) { setHeader(object,key,hash[key]); };
+ return this;
+};
+
+// Here's where we actually bind the functionality to an object. These mixins work by
+// exposing mixin functions. Each function mixes in a specific batch of features.
+module.exports = {
+
+ // Add getters.
+ getters: function(constructor) {
+ constructor.prototype.getHeader = function(name) { return getHeader(this,name); };
+ constructor.prototype.getHeaders = function() { return getHeaders(this,arguments); };
+ },
+ // Add setters but as "private" methods.
+ privateSetters: function(constructor) {
+ constructor.prototype._setHeader = function(key,value) { return setHeader(this,key,value); };
+ constructor.prototype._setHeaders = function(hash) { return setHeaders(this,hash); };
+ },
+ // Add setters.
+ setters: function(constructor) {
+ constructor.prototype.setHeader = function(key,value) { return setHeader(this,key,value); };
+ constructor.prototype.setHeaders = function(hash) { return setHeaders(this,hash); };
+ },
+ // Add both getters and setters.
+ gettersAndSetters: function(constructor) {
+ constructor.prototype.getHeader = function(name) { return getHeader(this,name); };
+ constructor.prototype.getHeaders = function() { return getHeaders(this,arguments); };
+ constructor.prototype.setHeader = function(key,value) { return setHeader(this,key,value); };
+ constructor.prototype.setHeaders = function(hash) { return setHeaders(this,hash); };
+ },
+};
+
+});
+
+require.define("/node_modules/iconv-lite/package.json", function (require, module, exports, __dirname, __filename) {
+ module.exports = {}
+});
+
+require.define("/node_modules/iconv-lite/index.js", function (require, module, exports, __dirname, __filename) {
+ // Module exports
+var iconv = module.exports = {
+ toEncoding: function(str, encoding) {
+ return iconv.getCodec(encoding).toEncoding(str);
+ },
+ fromEncoding: function(buf, encoding) {
+ return iconv.getCodec(encoding).fromEncoding(buf);
+ },
+
+ defaultCharUnicode: '�',
+ defaultCharSingleByte: '?',
+
+ // Get correct codec for given encoding.
+ getCodec: function(encoding) {
+ var enc = encoding || "utf8";
+ var codecOptions = undefined;
+ while (1) {
+ if (getType(enc) === "String")
+ enc = enc.replace(/[- ]/g, "").toLowerCase();
+ var codec = iconv.encodings[enc];
+ var type = getType(codec);
+ if (type === "String") {
+ // Link to other encoding.
+ codecOptions = {originalEncoding: enc};
+ enc = codec;
+ }
+ else if (type === "Object" && codec.type != undefined) {
+ // Options for other encoding.
+ codecOptions = codec;
+ enc = codec.type;
+ }
+ else if (type === "Function")
+ // Codec itself.
+ return codec(codecOptions);
+ else
+ throw new Error("Encoding not recognized: '" + encoding + "' (searched as: '"+enc+"')");
+ }
+ },
+
+ // Define basic encodings
+ encodings: {
+ internal: function(options) {
+ return {
+ toEncoding: function(str) {
+ return new Buffer(ensureString(str), options.originalEncoding);
+ },
+ fromEncoding: function(buf) {
+ return ensureBuffer(buf).toString(options.originalEncoding);
+ }
+ };
+ },
+ utf8: "internal",
+ ucs2: "internal",
+ binary: "internal",
+ ascii: "internal",
+ base64: "internal",
+
+ // Codepage single-byte encodings.
+ singlebyte: function(options) {
+ // Prepare chars if needed
+ if (!options.chars || (options.chars.length !== 128 && options.chars.length !== 256))
+ throw new Error("Encoding '"+options.type+"' has incorrect 'chars' (must be of len 128 or 256)");
+
+ if (options.chars.length === 128)
+ options.chars = asciiString + options.chars;
+
+ if (!options.charsBuf) {
+ options.charsBuf = new Buffer(options.chars, 'ucs2');
+ }
+
+ if (!options.revCharsBuf) {
+ options.revCharsBuf = new Buffer(65536);
+ var defChar = iconv.defaultCharSingleByte.charCodeAt(0);
+ for (var i = 0; i < options.revCharsBuf.length; i++)
+ options.revCharsBuf[i] = defChar;
+ for (var i = 0; i < options.chars.length; i++)
+ options.revCharsBuf[options.chars.charCodeAt(i)] = i;
+ }
+
+ return {
+ toEncoding: function(str) {
+ str = ensureString(str);
+
+ var buf = new Buffer(str.length);
+ var revCharsBuf = options.revCharsBuf;
+ for (var i = 0; i < str.length; i++)
+ buf[i] = revCharsBuf[str.charCodeAt(i)];
+
+ return buf;
+ },
+ fromEncoding: function(buf) {
+ buf = ensureBuffer(buf);
+
+ // Strings are immutable in JS -> we use ucs2 buffer to speed up computations.
+ var charsBuf = options.charsBuf;
+ var newBuf = new Buffer(buf.length*2);
+ var idx1 = 0, idx2 = 0;
+ for (var i = 0, _len = buf.length; i < _len; i++) {
+ idx1 = buf[i]*2; idx2 = i*2;
+ newBuf[idx2] = charsBuf[idx1];
+ newBuf[idx2+1] = charsBuf[idx1+1];
+ }
+ return newBuf.toString('ucs2');
+ }
+ };
+ },
+
+ // Codepage double-byte encodings.
+ table: function(options) {
+ var table = options.table, key, revCharsTable = options.revCharsTable;
+ if (!table) {
+ throw new Error("Encoding '" + options.type +"' has incorect 'table' option");
+ }
+ if(!revCharsTable) {
+ revCharsTable = options.revCharsTable = {};
+ for (key in table) {
+ revCharsTable[table[key]] = parseInt(key);
+ }
+ }
+
+ return {
+ toEncoding: function(str) {
+ str = ensureString(str);
+ var strLen = str.length;
+ var bufLen = strLen;
+ for (var i = 0; i < strLen; i++)
+ if (str.charCodeAt(i) >> 7)
+ bufLen++;
+
+ var newBuf = new Buffer(bufLen), gbkcode, unicode,
+ defaultChar = revCharsTable[iconv.defaultCharUnicode.charCodeAt(0)];
+
+ for (var i = 0, j = 0; i < strLen; i++) {
+ unicode = str.charCodeAt(i);
+ if (unicode >> 7) {
+ gbkcode = revCharsTable[unicode] || defaultChar;
+ newBuf[j++] = gbkcode >> 8; //high byte;
+ newBuf[j++] = gbkcode & 0xFF; //low byte
+ } else {//ascii
+ newBuf[j++] = unicode;
+ }
+ }
+ return newBuf;
+ },
+ fromEncoding: function(buf) {
+ buf = ensureBuffer(buf);
+ var bufLen = buf.length, strLen = 0;
+ for (var i = 0; i < bufLen; i++) {
+ strLen++;
+ if (buf[i] & 0x80) //the high bit is 1, so this byte is gbkcode's high byte.skip next byte
+ i++;
+ }
+ var newBuf = new Buffer(strLen*2), unicode, gbkcode,
+ defaultChar = iconv.defaultCharUnicode.charCodeAt(0);
+
+ for (var i = 0, j = 0; i < bufLen; i++, j+=2) {
+ gbkcode = buf[i];
+ if (gbkcode & 0x80) {
+ gbkcode = (gbkcode << 8) + buf[++i];
+ unicode = table[gbkcode] || defaultChar;
+ } else {
+ unicode = gbkcode;
+ }
+ newBuf[j] = unicode & 0xFF; //low byte
+ newBuf[j+1] = unicode >> 8; //high byte
+ }
+ return newBuf.toString('ucs2');
+ }
+ }
+ }
+ }
+};
+
+// Add aliases to convert functions
+iconv.encode = iconv.toEncoding;
+iconv.decode = iconv.fromEncoding;
+
+// Load other encodings from files in /encodings dir.
+var encodingsDir = __dirname+"/encodings/",
+ fs = require('fs');
+fs.readdirSync(encodingsDir).forEach(function(file) {
+ if(fs.statSync(encodingsDir + file).isDirectory()) return;
+ var encodings = require(encodingsDir + file)
+ for (var key in encodings)
+ iconv.encodings[key] = encodings[key]
+});
+
+// Utilities
+var asciiString = '\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f'+
+ ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f';
+
+var ensureBuffer = function(buf) {
+ buf = buf || new Buffer(0);
+ return (buf instanceof Buffer) ? buf : new Buffer(buf.toString(), "utf8");
+}
+
+var ensureString = function(str) {
+ str = str || "";
+ return (str instanceof String) ? str : str.toString((str instanceof Buffer) ? 'utf8' : undefined);
+}
+
+var getType = function(obj) {
+ return Object.prototype.toString.call(obj).slice(8, -1);
+}
+
+
+});
+
+require.define("/node_modules/http-browserify/package.json", function (require, module, exports, __dirname, __filename) {
+ module.exports = {"main":"index.js","browserify":"browser.js"}
+});
+
+require.define("/node_modules/http-browserify/browser.js", function (require, module, exports, __dirname, __filename) {
+ var http = module.exports;
+var EventEmitter = require('events').EventEmitter;
+var Request = require('./lib/request');
+
+http.request = function (params, cb) {
+ if (!params) params = {};
+ if (!params.host) params.host = window.location.host.split(':')[0];
+ if (!params.port) params.port = window.location.port;
+
+ var req = new Request(new xhrHttp, params);
+ if (cb) req.on('response', cb);
+ return req;
+};
+
+http.get = function (params, cb) {
+ params.method = 'GET';
+ var req = http.request(params, cb);
+ req.end();
+ return req;
+};
+
+var xhrHttp = (function () {
+ if (typeof window === 'undefined') {
+ throw new Error('no window object present');
+ }
+ else if (window.XMLHttpRequest) {
+ return window.XMLHttpRequest;
+ }
+ else if (window.ActiveXObject) {
+ var axs = [
+ 'Msxml2.XMLHTTP.6.0',
+ 'Msxml2.XMLHTTP.3.0',
+ 'Microsoft.XMLHTTP'
+ ];
+ for (var i = 0; i < axs.length; i++) {
+ try {
+ var ax = new(window.ActiveXObject)(axs[i]);
+ return function () {
+ if (ax) {
+ var ax_ = ax;
+ ax = null;
+ return ax_;
+ }
+ else {
+ return new(window.ActiveXObject)(axs[i]);
+ }
+ };
+ }
+ catch (e) {}
+ }
+ throw new Error('ajax not supported in this browser')
+ }
+ else {
+ throw new Error('ajax not supported in this browser');
+ }
+})();
+
+http.STATUS_CODES = {
+ 100 : 'Continue',
+ 101 : 'Switching Protocols',
+ 102 : 'Processing', // RFC 2518, obsoleted by RFC 4918
+ 200 : 'OK',
+ 201 : 'Created',
+ 202 : 'Accepted',
+ 203 : 'Non-Authoritative Information',
+ 204 : 'No Content',
+ 205 : 'Reset Content',
+ 206 : 'Partial Content',
+ 207 : 'Multi-Status', // RFC 4918
+ 300 : 'Multiple Choices',
+ 301 : 'Moved Permanently',
+ 302 : 'Moved Temporarily',
+ 303 : 'See Other',
+ 304 : 'Not Modified',
+ 305 : 'Use Proxy',
+ 307 : 'Temporary Redirect',
+ 400 : 'Bad Request',
+ 401 : 'Unauthorized',
+ 402 : 'Payment Required',
+ 403 : 'Forbidden',
+ 404 : 'Not Found',
+ 405 : 'Method Not Allowed',
+ 406 : 'Not Acceptable',
+ 407 : 'Proxy Authentication Required',
+ 408 : 'Request Time-out',
+ 409 : 'Conflict',
+ 410 : 'Gone',
+ 411 : 'Length Required',
+ 412 : 'Precondition Failed',
+ 413 : 'Request Entity Too Large',
+ 414 : 'Request-URI Too Large',
+ 415 : 'Unsupported Media Type',
+ 416 : 'Requested Range Not Satisfiable',
+ 417 : 'Expectation Failed',
+ 418 : 'I\'m a teapot', // RFC 2324
+ 422 : 'Unprocessable Entity', // RFC 4918
+ 423 : 'Locked', // RFC 4918
+ 424 : 'Failed Dependency', // RFC 4918
+ 425 : 'Unordered Collection', // RFC 4918
+ 426 : 'Upgrade Required', // RFC 2817
+ 500 : 'Internal Server Error',
+ 501 : 'Not Implemented',
+ 502 : 'Bad Gateway',
+ 503 : 'Service Unavailable',
+ 504 : 'Gateway Time-out',
+ 505 : 'HTTP Version not supported',
+ 506 : 'Variant Also Negotiates', // RFC 2295
+ 507 : 'Insufficient Storage', // RFC 4918
+ 509 : 'Bandwidth Limit Exceeded',
+ 510 : 'Not Extended' // RFC 2774
+};
+
+});
+
+require.define("/node_modules/http-browserify/lib/request.js", function (require, module, exports, __dirname, __filename) {
+ var EventEmitter = require('events').EventEmitter;
+var Response = require('./response');
+var isSafeHeader = require('./isSafeHeader');
+
+var Request = module.exports = function (xhr, params) {
+ var self = this;
+ self.xhr = xhr;
+ self.body = '';
+
+ var uri = params.host + ':' + params.port + (params.path || '/');
+
+ xhr.open(
+ params.method || 'GET',
+ (params.scheme || 'http') + '://' + uri,
+ true
+ );
+
+ if (params.headers) {
+ Object.keys(params.headers).forEach(function (key) {
+ if (!isSafeHeader(key)) return;
+ var value = params.headers[key];
+ if (Array.isArray(value)) {
+ value.forEach(function (v) {
+ xhr.setRequestHeader(key, v);
+ });
+ }
+ else xhr.setRequestHeader(key, value)
+ });
+ }
+
+ var res = new Response(xhr);
+ res.on('ready', function () {
+ self.emit('response', res);
+ });
+
+ xhr.onreadystatechange = function () {
+ res.handle(xhr);
+ };
+};
+
+Request.prototype = new EventEmitter;
+
+Request.prototype.setHeader = function (key, value) {
+ if ((Array.isArray && Array.isArray(value))
+ || value instanceof Array) {
+ for (var i = 0; i < value.length; i++) {
+ this.xhr.setRequestHeader(key, value[i]);
+ }
+ }
+ else {
+ this.xhr.setRequestHeader(key, value);
+ }
+};
+
+Request.prototype.write = function (s) {
+ this.body += s;
+};
+
+Request.prototype.end = function (s) {
+ if (s !== undefined) this.write(s);
+ this.xhr.send(this.body);
+};
+
+});
+
+require.define("/node_modules/http-browserify/lib/response.js", function (require, module, exports, __dirname, __filename) {
+ var EventEmitter = require('events').EventEmitter;
+var isSafeHeader = require('./isSafeHeader');
+
+var Response = module.exports = function (xhr) {
+ this.xhr = xhr;
+ this.offset = 0;
+};
+
+Response.prototype = new EventEmitter;
+
+var capable = {
+ streaming : true,
+ status2 : true
+};
+
+function parseHeaders (xhr) {
+ var lines = xhr.getAllResponseHeaders().split(/\r?\n/);
+ var headers = {};
+ for (var i = 0; i < lines.length; i++) {
+ var line = lines[i];
+ if (line === '') continue;
+
+ var m = line.match(/^([^:]+):\s*(.*)/);
+ if (m) {
+ var key = m[1].toLowerCase(), value = m[2];
+
+ if (headers[key] !== undefined) {
+ if ((Array.isArray && Array.isArray(headers[key]))
+ || headers[key] instanceof Array) {
+ headers[key].push(value);
+ }
+ else {
+ headers[key] = [ headers[key], value ];
+ }
+ }
+ else {
+ headers[key] = value;
+ }
+ }
+ else {
+ headers[line] = true;
+ }
+ }
+ return headers;
+}
+
+Response.prototype.getHeader = function (key) {
+ var header = this.headers ? this.headers[key.toLowerCase()] : null;
+ if (header) return header;
+
+ // Work around Mozilla bug #608735 [https://bugzil.la/608735], which causes
+ // getAllResponseHeaders() to return {} if the response is a CORS request.
+ // xhr.getHeader still works correctly.
+ if (isSafeHeader(key)) {
+ return this.xhr.getResponseHeader(key);
+ }
+ return null;
+};
+
+Response.prototype.handle = function () {
+ var xhr = this.xhr;
+ if (xhr.readyState === 2 && capable.status2) {
+ try {
+ this.statusCode = xhr.status;
+ this.headers = parseHeaders(xhr);
+ }
+ catch (err) {
+ capable.status2 = false;
+ }
+
+ if (capable.status2) {
+ this.emit('ready');
+ }
+ }
+ else if (capable.streaming && xhr.readyState === 3) {
+ try {
+ if (!this.statusCode) {
+ this.statusCode = xhr.status;
+ this.headers = parseHeaders(xhr);
+ this.emit('ready');
+ }
+ }
+ catch (err) {}
+
+ try {
+ this.write();
+ }
+ catch (err) {
+ capable.streaming = false;
+ }
+ }
+ else if (xhr.readyState === 4) {
+ if (!this.statusCode) {
+ this.statusCode = xhr.status;
+ this.emit('ready');
+ }
+ this.write();
+
+ if (xhr.error) {
+ this.emit('error', xhr.responseText);
+ }
+ else this.emit('end');
+ }
+};
+
+Response.prototype.write = function () {
+ var xhr = this.xhr;
+ if (xhr.responseText.length > this.offset) {
+ this.emit('data', xhr.responseText.slice(this.offset));
+ this.offset = xhr.responseText.length;
+ }
+};
+
+});
+
+require.define("/node_modules/http-browserify/lib/isSafeHeader.js", function (require, module, exports, __dirname, __filename) {
+ // Taken from http://dxr.mozilla.org/mozilla/mozilla-central/content/base/src/nsXMLHttpRequest.cpp.html
+var unsafeHeaders = [
+ "accept-charset",
+ "accept-encoding",
+ "access-control-request-headers",
+ "access-control-request-method",
+ "connection",
+ "content-length",
+ "cookie",
+ "cookie2",
+ "content-transfer-encoding",
+ "date",
+ "expect",
+ "host",
+ "keep-alive",
+ "origin",
+ "referer",
+ "set-cookie",
+ "te",
+ "trailer",
+ "transfer-encoding",
+ "upgrade",
+ "user-agent",
+ "via"
+];
+
+module.exports = function (headerName) {
+ if (!headerName) return false;
+ return (unsafeHeaders.indexOf(headerName.toLowerCase()) === -1)
+};
+
+});
+
+require.alias("http-browserify", "/node_modules/http");
+
+require.alias("http-browserify", "/node_modules/https");
\ No newline at end of file
diff --git a/profiles/killbill/src/main/webapp/lib/shred/content.js b/profiles/killbill/src/main/webapp/lib/shred/content.js
new file mode 100644
index 0000000..b8051fe
--- /dev/null
+++ b/profiles/killbill/src/main/webapp/lib/shred/content.js
@@ -0,0 +1,193 @@
+
+// The purpose of the `Content` object is to abstract away the data conversions
+// to and from raw content entities as strings. For example, you want to be able
+// to pass in a Javascript object and have it be automatically converted into a
+// JSON string if the `content-type` is set to a JSON-based media type.
+// Conversely, you want to be able to transparently get back a Javascript object
+// in the response if the `content-type` is a JSON-based media-type.
+
+// One limitation of the current implementation is that it [assumes the `charset` is UTF-8](https://github.com/spire-io/shred/issues/5).
+
+// The `Content` constructor takes an options object, which *must* have either a
+// `body` or `data` property and *may* have a `type` property indicating the
+// media type. If there is no `type` attribute, a default will be inferred.
+var Content = function(options) {
+ this.body = options.body;
+ this.data = options.data;
+ this.type = options.type;
+};
+
+Content.prototype = {
+ // Treat `toString()` as asking for the `content.body`. That is, the raw content entity.
+ //
+ // toString: function() { return this.body; }
+ //
+ // Commented out, but I've forgotten why. :/
+};
+
+
+// `Content` objects have the following attributes:
+Object.defineProperties(Content.prototype,{
+
+// - **type**. Typically accessed as `content.type`, reflects the `content-type`
+// header associated with the request or response. If not passed as an options
+// to the constructor or set explicitly, it will infer the type the `data`
+// attribute, if possible, and, failing that, will default to `text/plain`.
+ type: {
+ get: function() {
+ if (this._type) {
+ return this._type;
+ } else {
+ if (this._data) {
+ switch(typeof this._data) {
+ case "string": return "text/plain";
+ case "object": return "application/json";
+ }
+ }
+ }
+ return "text/plain";
+ },
+ set: function(value) {
+ this._type = value;
+ return this;
+ },
+ enumerable: true
+ },
+
+// - **data**. Typically accessed as `content.data`, reflects the content entity
+// converted into Javascript data. This can be a string, if the `type` is, say,
+// `text/plain`, but can also be a Javascript object. The conversion applied is
+// based on the `processor` attribute. The `data` attribute can also be set
+// directly, in which case the conversion will be done the other way, to infer
+// the `body` attribute.
+ data: {
+ get: function() {
+ if (this._body) {
+ return this.processor.parser(this._body);
+ } else {
+ return this._data;
+ }
+ },
+ set: function(data) {
+ if (this._body&&data) Errors.setDataWithBody(this);
+ this._data = data;
+ return this;
+ },
+ enumerable: true
+ },
+
+// - **body**. Typically accessed as `content.body`, reflects the content entity
+// as a UTF-8 string. It is the mirror of the `data` attribute. If you set the
+// `data` attribute, the `body` attribute will be inferred and vice-versa. If
+// you attempt to set both, an exception is raised.
+ body: {
+ get: function() {
+ if (this._data) {
+ return this.processor.stringify(this._data);
+ } else {
+ return this._body.toString();
+ }
+ },
+ set: function(body) {
+ if (this._data&&body) Errors.setBodyWithData(this);
+ this._body = body;
+ return this;
+ },
+ enumerable: true
+ },
+
+// - **processor**. The functions that will be used to convert to/from `data` and
+// `body` attributes. You can add processors. The two that are built-in are for
+// `text/plain`, which is basically an identity transformation and
+// `application/json` and other JSON-based media types (including custom media
+// types with `+json`). You can add your own processors. See below.
+ processor: {
+ get: function() {
+ var processor = Content.processors[this.type];
+ if (processor) {
+ return processor;
+ } else {
+ // Return the first processor that matches any part of the
+ // content type. ex: application/vnd.foobar.baz+json will match json.
+ var main = this.type.split(";")[0];
+ var parts = main.split(/\+|\//);
+ for (var i=0, l=parts.length; i < l; i++) {
+ processor = Content.processors[parts[i]]
+ }
+ return processor || {parser:identity,stringify:toString};
+ }
+ },
+ enumerable: true
+ },
+
+// - **length**. Typically accessed as `content.length`, returns the length in
+// bytes of the raw content entity.
+ length: {
+ get: function() {
+ if (typeof Buffer !== 'undefined') {
+ return Buffer.byteLength(this.body);
+ }
+ return this.body.length;
+ }
+ }
+});
+
+Content.processors = {};
+
+// The `registerProcessor` function allows you to add your own processors to
+// convert content entities. Each processor consists of a Javascript object with
+// two properties:
+// - **parser**. The function used to parse a raw content entity and convert it
+// into a Javascript data type.
+// - **stringify**. The function used to convert a Javascript data type into a
+// raw content entity.
+Content.registerProcessor = function(types,processor) {
+
+// You can pass an array of types that will trigger this processor, or just one.
+// We determine the array via duck-typing here.
+ if (types.forEach) {
+ types.forEach(function(type) {
+ Content.processors[type] = processor;
+ });
+ } else {
+ // If you didn't pass an array, we just use what you pass in.
+ Content.processors[types] = processor;
+ }
+};
+
+// Register the identity processor, which is used for text-based media types.
+var identity = function(x) { return x; }
+ , toString = function(x) { return x.toString(); }
+Content.registerProcessor(
+ ["text/html","text/plain","text"],
+ { parser: identity, stringify: toString });
+
+// Register the JSON processor, which is used for JSON-based media types.
+Content.registerProcessor(
+ ["application/json; charset=utf-8","application/json","json"],
+ {
+ parser: function(string) {
+ return JSON.parse(string);
+ },
+ stringify: function(data) {
+ return JSON.stringify(data); }});
+
+var qs = require('querystring');
+// Register the post processor, which is used for JSON-based media types.
+Content.registerProcessor(
+ ["application/x-www-form-urlencoded"],
+ { parser : qs.parse, stringify : qs.stringify });
+
+// Error functions are defined separately here in an attempt to make the code
+// easier to read.
+var Errors = {
+ setDataWithBody: function(object) {
+ throw new Error("Attempt to set data attribute of a content object " +
+ "when the body attributes was already set.");
+ },
+ setBodyWithData: function(object) {
+ throw new Error("Attempt to set body attribute of a content object " +
+ "when the data attributes was already set.");
+ }
+}
+module.exports = Content;
\ No newline at end of file
profiles/killbill/src/main/webapp/lib/swagger.js 1665(+1665 -0)
diff --git a/profiles/killbill/src/main/webapp/lib/swagger.js b/profiles/killbill/src/main/webapp/lib/swagger.js
new file mode 100644
index 0000000..2871608
--- /dev/null
+++ b/profiles/killbill/src/main/webapp/lib/swagger.js
@@ -0,0 +1,1665 @@
+// swagger.js
+// version 2.0.41
+
+(function () {
+
+ var __bind = function (fn, me) {
+ return function () {
+ return fn.apply(me, arguments);
+ };
+ };
+
+ var log = function () {
+ log.history = log.history || [];
+ log.history.push(arguments);
+ if (this.console) {
+ console.log(Array.prototype.slice.call(arguments)[0]);
+ }
+ };
+
+ // if you want to apply conditional formatting of parameter values
+ var parameterMacro = function (value) {
+ return value;
+ }
+
+ // if you want to apply conditional formatting of model property values
+ var modelPropertyMacro = function (value) {
+ return value;
+ }
+
+ if (!Array.prototype.indexOf) {
+ Array.prototype.indexOf = function (obj, start) {
+ for (var i = (start || 0), j = this.length; i < j; i++) {
+ if (this[i] === obj) { return i; }
+ }
+ return -1;
+ }
+ }
+
+ if (!('filter' in Array.prototype)) {
+ Array.prototype.filter = function (filter, that /*opt*/) {
+ var other = [], v;
+ for (var i = 0, n = this.length; i < n; i++)
+ if (i in this && filter.call(that, v = this[i], i, this))
+ other.push(v);
+ return other;
+ };
+ }
+
+ if (!('map' in Array.prototype)) {
+ Array.prototype.map = function (mapper, that /*opt*/) {
+ var other = new Array(this.length);
+ for (var i = 0, n = this.length; i < n; i++)
+ if (i in this)
+ other[i] = mapper.call(that, this[i], i, this);
+ return other;
+ };
+ }
+
+ Object.keys = Object.keys || (function () {
+ var hasOwnProperty = Object.prototype.hasOwnProperty,
+ hasDontEnumBug = !{ toString: null }.propertyIsEnumerable("toString"),
+ DontEnums = [
+ 'toString',
+ 'toLocaleString',
+ 'valueOf',
+ 'hasOwnProperty',
+ 'isPrototypeOf',
+ 'propertyIsEnumerable',
+ 'constructor'
+ ],
+ DontEnumsLength = DontEnums.length;
+
+ return function (o) {
+ if (typeof o != "object" && typeof o != "function" || o === null)
+ throw new TypeError("Object.keys called on a non-object");
+
+ var result = [];
+ for (var name in o) {
+ if (hasOwnProperty.call(o, name))
+ result.push(name);
+ }
+
+ if (hasDontEnumBug) {
+ for (var i = 0; i < DontEnumsLength; i++) {
+ if (hasOwnProperty.call(o, DontEnums[i]))
+ result.push(DontEnums[i]);
+ }
+ }
+
+ return result;
+ };
+ })();
+
+ var SwaggerApi = function (url, options) {
+ this.isBuilt = false;
+ this.url = null;
+ this.debug = false;
+ this.basePath = null;
+ this.authorizations = null;
+ this.authorizationScheme = null;
+ this.info = null;
+ this.useJQuery = false;
+ this.modelsArray = [];
+ this.isValid;
+
+ options = (options || {});
+ if (url)
+ if (url.url)
+ options = url;
+ else
+ this.url = url;
+ else
+ options = url;
+
+ if (options.url != null)
+ this.url = options.url;
+
+ if (options.success != null)
+ this.success = options.success;
+
+ if (typeof options.useJQuery === 'boolean')
+ this.useJQuery = options.useJQuery;
+
+ this.failure = options.failure != null ? options.failure : function () { };
+ this.progress = options.progress != null ? options.progress : function () { };
+ if (options.success != null) {
+ this.build();
+ this.isBuilt = true;
+ }
+ }
+
+ SwaggerApi.prototype.build = function () {
+ if (this.isBuilt)
+ return this;
+ var _this = this;
+ this.progress('fetching resource list: ' + this.url);
+ var obj = {
+ useJQuery: this.useJQuery,
+ url: this.url,
+ method: "get",
+ headers: {
+ accept: "application/json,application/json;charset=\"utf-8\",*/*"
+ },
+ on: {
+ error: function (response) {
+ if (_this.url.substring(0, 4) !== 'http') {
+ return _this.fail('Please specify the protocol for ' + _this.url);
+ } else if (response.status === 0) {
+ return _this.fail('Can\'t read from server. It may not have the appropriate access-control-origin settings.');
+ } else if (response.status === 404) {
+ return _this.fail('Can\'t read swagger JSON from ' + _this.url);
+ } else {
+ return _this.fail(response.status + ' : ' + response.statusText + ' ' + _this.url);
+ }
+ },
+ response: function (resp) {
+ var responseObj = resp.obj || JSON.parse(resp.data);
+ _this.swaggerVersion = responseObj.swaggerVersion;
+ if (_this.swaggerVersion === "1.2") {
+ return _this.buildFromSpec(responseObj);
+ } else {
+ return _this.buildFrom1_1Spec(responseObj);
+ }
+ }
+ }
+ };
+ var e = (typeof window !== 'undefined' ? window : exports);
+ e.authorizations.apply(obj);
+ new SwaggerHttp().execute(obj);
+ return this;
+ };
+
+ SwaggerApi.prototype.buildFromSpec = function (response) {
+ if (response.apiVersion != null) {
+ this.apiVersion = response.apiVersion;
+ }
+ this.apis = {};
+ this.apisArray = [];
+ this.consumes = response.consumes;
+ this.produces = response.produces;
+ this.authSchemes = response.authorizations;
+ if (response.info != null) {
+ this.info = response.info;
+ }
+ var isApi = false;
+ var i;
+ for (i = 0; i < response.apis.length; i++) {
+ var api = response.apis[i];
+ if (api.operations) {
+ var j;
+ for (j = 0; j < api.operations.length; j++) {
+ operation = api.operations[j];
+ isApi = true;
+ }
+ }
+ }
+ if (response.basePath)
+ this.basePath = response.basePath;
+ else if (this.url.indexOf('?') > 0)
+ this.basePath = this.url.substring(0, this.url.lastIndexOf('?'));
+ else
+ this.basePath = this.url;
+
+ if (isApi) {
+ var newName = response.resourcePath.replace(/\//g, '');
+ this.resourcePath = response.resourcePath;
+ var res = new SwaggerResource(response, this);
+ this.apis[newName] = res;
+ this.apisArray.push(res);
+ } else {
+ var k;
+ for (k = 0; k < response.apis.length; k++) {
+ var resource = response.apis[k];
+ var res = new SwaggerResource(resource, this);
+ this.apis[res.name] = res;
+ this.apisArray.push(res);
+ }
+ }
+ this.isValid = true;
+ if (this.success) {
+ this.success();
+ }
+ return this;
+ };
+
+ SwaggerApi.prototype.buildFrom1_1Spec = function (response) {
+ log("This API is using a deprecated version of Swagger! Please see http://github.com/wordnik/swagger-core/wiki for more info");
+ if (response.apiVersion != null)
+ this.apiVersion = response.apiVersion;
+ this.apis = {};
+ this.apisArray = [];
+ this.produces = response.produces;
+ if (response.info != null) {
+ this.info = response.info;
+ }
+ var isApi = false;
+ for (var i = 0; i < response.apis.length; i++) {
+ var api = response.apis[i];
+ if (api.operations) {
+ for (var j = 0; j < api.operations.length; j++) {
+ operation = api.operations[j];
+ isApi = true;
+ }
+ }
+ }
+ if (response.basePath) {
+ this.basePath = response.basePath;
+ } else if (this.url.indexOf('?') > 0) {
+ this.basePath = this.url.substring(0, this.url.lastIndexOf('?'));
+ } else {
+ this.basePath = this.url;
+ }
+ if (isApi) {
+ var newName = response.resourcePath.replace(/\//g, '');
+ this.resourcePath = response.resourcePath;
+ var res = new SwaggerResource(response, this);
+ this.apis[newName] = res;
+ this.apisArray.push(res);
+ } else {
+ for (k = 0; k < response.apis.length; k++) {
+ resource = response.apis[k];
+ var res = new SwaggerResource(resource, this);
+ this.apis[res.name] = res;
+ this.apisArray.push(res);
+ }
+ }
+ this.isValid = true;
+ if (this.success) {
+ this.success();
+ }
+ return this;
+ };
+
+ SwaggerApi.prototype.selfReflect = function () {
+ var resource, resource_name, _ref;
+ if (this.apis == null) {
+ return false;
+ }
+ _ref = this.apis;
+ for (resource_name in _ref) {
+ resource = _ref[resource_name];
+ if (resource.ready == null) {
+ return false;
+ }
+ }
+ this.setConsolidatedModels();
+ this.ready = true;
+ if (this.success != null) {
+ return this.success();
+ }
+ };
+
+ SwaggerApi.prototype.fail = function (message) {
+ this.failure(message);
+ throw message;
+ };
+
+ SwaggerApi.prototype.setConsolidatedModels = function () {
+ var model, modelName, resource, resource_name, _i, _len, _ref, _ref1, _results;
+ this.models = {};
+ _ref = this.apis;
+ for (resource_name in _ref) {
+ resource = _ref[resource_name];
+ for (modelName in resource.models) {
+ if (this.models[modelName] == null) {
+ this.models[modelName] = resource.models[modelName];
+ this.modelsArray.push(resource.models[modelName]);
+ }
+ }
+ }
+ _ref1 = this.modelsArray;
+ _results = [];
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
+ model = _ref1[_i];
+ _results.push(model.setReferencedModels(this.models));
+ }
+ return _results;
+ };
+
+ SwaggerApi.prototype.help = function () {
+ var operation, operation_name, parameter, resource, resource_name, _i, _len, _ref, _ref1, _ref2;
+ _ref = this.apis;
+ for (resource_name in _ref) {
+ resource = _ref[resource_name];
+ log(resource_name);
+ _ref1 = resource.operations;
+ for (operation_name in _ref1) {
+ operation = _ref1[operation_name];
+ log(" " + operation.nickname);
+ _ref2 = operation.parameters;
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
+ parameter = _ref2[_i];
+ log(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
+ }
+ }
+ }
+ return this;
+ };
+
+ var SwaggerResource = function (resourceObj, api) {
+ var _this = this;
+ this.api = api;
+ this.api = this.api;
+ var consumes = (this.consumes | []);
+ var produces = (this.produces | []);
+ this.path = this.api.resourcePath != null ? this.api.resourcePath : resourceObj.path;
+ this.description = resourceObj.description;
+
+ var parts = this.path.split("/");
+ this.name = parts[parts.length - 1].replace('.{format}', '');
+ this.basePath = this.api.basePath;
+ this.operations = {};
+ this.operationsArray = [];
+ this.modelsArray = [];
+ this.models = {};
+ this.rawModels = {};
+ this.useJQuery = (typeof api.useJQuery !== 'undefined' ? api.useJQuery : null);
+
+ if ((resourceObj.apis != null) && (this.api.resourcePath != null)) {
+ this.addApiDeclaration(resourceObj);
+ } else {
+ if (this.path == null) {
+ this.api.fail("SwaggerResources must have a path.");
+ }
+ if (this.path.substring(0, 4) === 'http') {
+ this.url = this.path.replace('{format}', 'json');
+ } else {
+ this.url = this.api.basePath + this.path.replace('{format}', 'json');
+ }
+ this.api.progress('fetching resource ' + this.name + ': ' + this.url);
+ var obj = {
+ url: this.url,
+ method: "get",
+ useJQuery: this.useJQuery,
+ headers: {
+ accept: "application/json,application/json;charset=\"utf-8\",*/*"
+ },
+ on: {
+ response: function (resp) {
+ var responseObj = resp.obj || JSON.parse(resp.data);
+ return _this.addApiDeclaration(responseObj);
+ },
+ error: function (response) {
+ return _this.api.fail("Unable to read api '" +
+ _this.name + "' from path " + _this.url + " (server returned " + response.statusText + ")");
+ }
+ }
+ };
+ var e = typeof window !== 'undefined' ? window : exports;
+ e.authorizations.apply(obj);
+ new SwaggerHttp().execute(obj);
+ }
+ }
+
+ SwaggerResource.prototype.getAbsoluteBasePath = function (relativeBasePath) {
+ var pos, url;
+ url = this.api.basePath;
+ pos = url.lastIndexOf(relativeBasePath);
+ var parts = url.split("/");
+ var rootUrl = parts[0] + "//" + parts[2];
+
+ if (relativeBasePath.indexOf("http") === 0)
+ return relativeBasePath;
+ if (relativeBasePath === "/")
+ return rootUrl;
+ if (relativeBasePath.substring(0, 1) == "/") {
+ // use root + relative
+ return rootUrl + relativeBasePath;
+ }
+ else {
+ var pos = this.basePath.lastIndexOf("/");
+ var base = this.basePath.substring(0, pos);
+ if (base.substring(base.length - 1) == "/")
+ return base + relativeBasePath;
+ else
+ return base + "/" + relativeBasePath;
+ }
+ };
+
+ SwaggerResource.prototype.addApiDeclaration = function (response) {
+ if (response.produces != null)
+ this.produces = response.produces;
+ if (response.consumes != null)
+ this.consumes = response.consumes;
+ if ((response.basePath != null) && response.basePath.replace(/\s/g, '').length > 0)
+ this.basePath = response.basePath.indexOf("http") === -1 ? this.getAbsoluteBasePath(response.basePath) : response.basePath;
+
+ this.addModels(response.models);
+ if (response.apis) {
+ for (var i = 0 ; i < response.apis.length; i++) {
+ var endpoint = response.apis[i];
+ this.addOperations(endpoint.path, endpoint.operations, response.consumes, response.produces);
+ }
+ }
+ this.api[this.name] = this;
+ this.ready = true;
+ return this.api.selfReflect();
+ };
+
+ SwaggerResource.prototype.addModels = function (models) {
+ if (models != null) {
+ var modelName;
+ for (modelName in models) {
+ if (this.models[modelName] == null) {
+ var swaggerModel = new SwaggerModel(modelName, models[modelName]);
+ this.modelsArray.push(swaggerModel);
+ this.models[modelName] = swaggerModel;
+ this.rawModels[modelName] = models[modelName];
+ }
+ }
+ var output = [];
+ for (var i = 0; i < this.modelsArray.length; i++) {
+ var model = this.modelsArray[i];
+ output.push(model.setReferencedModels(this.models));
+ }
+ return output;
+ }
+ };
+
+ SwaggerResource.prototype.addOperations = function (resource_path, ops, consumes, produces) {
+ if (ops) {
+ var output = [];
+ for (var i = 0; i < ops.length; i++) {
+ var o = ops[i];
+ consumes = this.consumes;
+ produces = this.produces;
+ if (o.consumes != null)
+ consumes = o.consumes;
+ else
+ consumes = this.consumes;
+
+ if (o.produces != null)
+ produces = o.produces;
+ else
+ produces = this.produces;
+ var type = (o.type || o.responseClass);
+
+ if (type === "array") {
+ ref = null;
+ if (o.items)
+ ref = o.items["type"] || o.items["$ref"];
+ type = "array[" + ref + "]";
+ }
+ var responseMessages = o.responseMessages;
+ var method = o.method;
+ if (o.httpMethod) {
+ method = o.httpMethod;
+ }
+ if (o.supportedContentTypes) {
+ consumes = o.supportedContentTypes;
+ }
+ if (o.errorResponses) {
+ responseMessages = o.errorResponses;
+ for (var j = 0; j < responseMessages.length; j++) {
+ r = responseMessages[j];
+ r.message = r.reason;
+ r.reason = null;
+ }
+ }
+ o.nickname = this.sanitize(o.nickname);
+ var op = new SwaggerOperation(o.nickname, resource_path, method, o.parameters, o.summary, o.notes, type, responseMessages, this, consumes, produces, o.authorizations);
+ this.operations[op.nickname] = op;
+ output.push(this.operationsArray.push(op));
+ }
+ return output;
+ }
+ };
+
+ SwaggerResource.prototype.sanitize = function (nickname) {
+ var op;
+ op = nickname.replace(/[\s!@#$%^&*()_+=\[{\]};:<>|.\/?,\\'""-]/g, '_');
+ op = op.replace(/((_){2,})/g, '_');
+ op = op.replace(/^(_)*/g, '');
+ op = op.replace(/([_])*$/g, '');
+ return op;
+ };
+
+ SwaggerResource.prototype.help = function () {
+ var op = this.operations;
+ var output = [];
+ var operation_name;
+ for (operation_name in op) {
+ operation = op[operation_name];
+ var msg = " " + operation.nickname;
+ for (var i = 0; i < operation.parameters; i++) {
+ parameter = operation.parameters[i];
+ msg.concat(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
+ }
+ output.push(msg);
+ }
+ return output;
+ };
+
+ var SwaggerModel = function (modelName, obj) {
+ this.name = obj.id != null ? obj.id : modelName;
+ this.properties = [];
+ var propertyName;
+ for (propertyName in obj.properties) {
+ if (obj.required != null) {
+ var value;
+ for (value in obj.required) {
+ if (propertyName === obj.required[value]) {
+ obj.properties[propertyName].required = true;
+ }
+ }
+ }
+ var prop = new SwaggerModelProperty(propertyName, obj.properties[propertyName]);
+ this.properties.push(prop);
+ }
+ }
+
+ SwaggerModel.prototype.setReferencedModels = function (allModels) {
+ var results = [];
+ for (var i = 0; i < this.properties.length; i++) {
+ var property = this.properties[i];
+ var type = property.type || property.dataType;
+ if (allModels[type] != null)
+ results.push(property.refModel = allModels[type]);
+ else if ((property.refDataType != null) && (allModels[property.refDataType] != null))
+ results.push(property.refModel = allModels[property.refDataType]);
+ else
+ results.push(void 0);
+ }
+ return results;
+ };
+
+ SwaggerModel.prototype.getMockSignature = function (modelsToIgnore) {
+ var propertiesStr = [];
+ for (var i = 0; i < this.properties.length; i++) {
+ var prop = this.properties[i];
+ propertiesStr.push(prop.toString());
+ }
+
+ var strong = '<span class="strong">';
+ var stronger = '<span class="stronger">';
+ var strongClose = '</span>';
+ var classOpen = strong + this.name + ' {' + strongClose;
+ var classClose = strong + '}' + strongClose;
+ var returnVal = classOpen + '<div>' + propertiesStr.join(',</div><div>') + '</div>' + classClose;
+ if (!modelsToIgnore)
+ modelsToIgnore = [];
+ modelsToIgnore.push(this.name);
+
+ for (var i = 0; i < this.properties.length; i++) {
+ var prop = this.properties[i];
+ if ((prop.refModel != null) && modelsToIgnore.indexOf(prop.refModel.name) === -1) {
+ returnVal = returnVal + ('<br>' + prop.refModel.getMockSignature(modelsToIgnore));
+ }
+ }
+ return returnVal;
+ };
+
+ SwaggerModel.prototype.createJSONSample = function (modelsToIgnore) {
+ if (sampleModels[this.name]) {
+ return sampleModels[this.name];
+ }
+ else {
+ var result = {};
+ var modelsToIgnore = (modelsToIgnore || [])
+ modelsToIgnore.push(this.name);
+ for (var i = 0; i < this.properties.length; i++) {
+ var prop = this.properties[i];
+ result[prop.name] = prop.getSampleValue(modelsToIgnore);
+ }
+ modelsToIgnore.pop(this.name);
+ return result;
+ }
+ };
+
+ var SwaggerModelProperty = function (name, obj) {
+ this.name = name;
+ this.dataType = obj.type || obj.dataType || obj["$ref"];
+ this.isCollection = this.dataType && (this.dataType.toLowerCase() === 'array' || this.dataType.toLowerCase() === 'list' || this.dataType.toLowerCase() === 'set');
+ this.descr = obj.description;
+ this.required = obj.required;
+ this.defaultValue = modelPropertyMacro(obj.defaultValue);
+ if (obj.items != null) {
+ if (obj.items.type != null) {
+ this.refDataType = obj.items.type;
+ }
+ if (obj.items.$ref != null) {
+ this.refDataType = obj.items.$ref;
+ }
+ }
+ this.dataTypeWithRef = this.refDataType != null ? (this.dataType + '[' + this.refDataType + ']') : this.dataType;
+ if (obj.allowableValues != null) {
+ this.valueType = obj.allowableValues.valueType;
+ this.values = obj.allowableValues.values;
+ if (this.values != null) {
+ this.valuesString = "'" + this.values.join("' or '") + "'";
+ }
+ }
+ if (obj["enum"] != null) {
+ this.valueType = "string";
+ this.values = obj["enum"];
+ if (this.values != null) {
+ this.valueString = "'" + this.values.join("' or '") + "'";
+ }
+ }
+ }
+
+ SwaggerModelProperty.prototype.getSampleValue = function (modelsToIgnore) {
+ var result;
+ if ((this.refModel != null) && (modelsToIgnore.indexOf(this.refModel.name) === -1)) {
+ result = this.refModel.createJSONSample(modelsToIgnore);
+ } else {
+ if (this.isCollection) {
+ result = this.toSampleValue(this.refDataType);
+ } else {
+ result = this.toSampleValue(this.dataType);
+ }
+ }
+ if (this.isCollection) {
+ return [result];
+ } else {
+ return result;
+ }
+ };
+
+ SwaggerModelProperty.prototype.toSampleValue = function (value) {
+ var result;
+ if ((typeof this.defaultValue !== 'undefined') && this.defaultValue !== null) {
+ result = this.defaultValue;
+ } else if (value === "integer") {
+ result = 0;
+ } else if (value === "boolean") {
+ result = false;
+ } else if (value === "double" || value === "number") {
+ result = 0.0;
+ } else if (value === "string") {
+ result = "";
+ } else {
+ result = value;
+ }
+ return result;
+ };
+
+ SwaggerModelProperty.prototype.toString = function () {
+ var req = this.required ? 'propReq' : 'propOpt';
+ var str = '<span class="propName ' + req + '">' + this.name + '</span> (<span class="propType">' + this.dataTypeWithRef + '</span>';
+ if (!this.required) {
+ str += ', <span class="propOptKey">optional</span>';
+ }
+ str += ')';
+ if (this.values != null) {
+ str += " = <span class='propVals'>['" + this.values.join("' or '") + "']</span>";
+ }
+ if (this.descr != null) {
+ str += ': <span class="propDesc">' + this.descr + '</span>';
+ }
+ return str;
+ };
+
+ var SwaggerOperation = function (nickname, path, method, parameters, summary, notes, type, responseMessages, resource, consumes, produces, authorizations) {
+ var _this = this;
+
+ var errors = [];
+ this.nickname = (nickname || errors.push("SwaggerOperations must have a nickname."));
+ this.path = (path || errors.push("SwaggerOperation " + nickname + " is missing path."));
+ this.method = (method || errors.push("SwaggerOperation " + nickname + " is missing method."));
+ this.parameters = parameters != null ? parameters : [];
+ this.summary = summary;
+ this.notes = notes;
+ this.type = type;
+ this.responseMessages = (responseMessages || []);
+ this.resource = (resource || errors.push("Resource is required"));
+ this.consumes = consumes;
+ this.produces = produces;
+ this.authorizations = authorizations;
+ this["do"] = __bind(this["do"], this);
+
+ if (errors.length > 0) {
+ console.error('SwaggerOperation errors', errors, arguments);
+ this.resource.api.fail(errors);
+ }
+
+ this.path = this.path.replace('{format}', 'json');
+ this.method = this.method.toLowerCase();
+ this.isGetMethod = this.method === "get";
+
+ this.resourceName = this.resource.name;
+ if (typeof this.type !== 'undefined' && this.type === 'void')
+ this.type = null;
+ else {
+ this.responseClassSignature = this.getSignature(this.type, this.resource.models);
+ this.responseSampleJSON = this.getSampleJSON(this.type, this.resource.models);
+ }
+
+ for (var i = 0; i < this.parameters.length; i++) {
+ var param = this.parameters[i];
+ // might take this away
+ param.name = param.name || param.type || param.dataType;
+
+ // for 1.1 compatibility
+ var type = param.type || param.dataType;
+ if (type === 'array') {
+ type = 'array[' + (param.items.$ref ? param.items.$ref : param.items.type) + ']';
+ }
+ param.type = type;
+
+ if (type.toLowerCase() === 'boolean') {
+ param.allowableValues = {};
+ param.allowableValues.values = ["true", "false"];
+ }
+ param.signature = this.getSignature(type, this.resource.models);
+ param.sampleJSON = this.getSampleJSON(type, this.resource.models);
+
+ var enumValue = param["enum"];
+ if (enumValue != null) {
+ param.isList = true;
+ param.allowableValues = {};
+ param.allowableValues.descriptiveValues = [];
+
+ for (var j = 0; j < enumValue.length; j++) {
+ var v = enumValue[j];
+ if (param.defaultValue != null) {
+ param.allowableValues.descriptiveValues.push({
+ value: String(v),
+ isDefault: (v === param.defaultValue)
+ });
+ }
+ else {
+ param.allowableValues.descriptiveValues.push({
+ value: String(v),
+ isDefault: false
+ });
+ }
+ }
+ }
+ else if (param.allowableValues != null) {
+ if (param.allowableValues.valueType === "RANGE")
+ param.isRange = true;
+ else
+ param.isList = true;
+ if (param.allowableValues != null) {
+ param.allowableValues.descriptiveValues = [];
+ if (param.allowableValues.values) {
+ for (var j = 0; j < param.allowableValues.values.length; j++) {
+ var v = param.allowableValues.values[j];
+ if (param.defaultValue != null) {
+ param.allowableValues.descriptiveValues.push({
+ value: String(v),
+ isDefault: (v === param.defaultValue)
+ });
+ }
+ else {
+ param.allowableValues.descriptiveValues.push({
+ value: String(v),
+ isDefault: false
+ });
+ }
+ }
+ }
+ }
+ }
+ param.defaultValue = parameterMacro(param.defaultValue);
+ }
+ this.resource[this.nickname] = function (args, callback, error) {
+ return _this["do"](args, callback, error);
+ };
+ this.resource[this.nickname].help = function () {
+ return _this.help();
+ };
+ }
+
+ SwaggerOperation.prototype.isListType = function (type) {
+ if (type && type.indexOf('[') >= 0) {
+ return type.substring(type.indexOf('[') + 1, type.indexOf(']'));
+ } else {
+ return void 0;
+ }
+ };
+
+ SwaggerOperation.prototype.getSignature = function (type, models) {
+ var isPrimitive, listType;
+ listType = this.isListType(type);
+ isPrimitive = ((listType != null) && models[listType]) || (models[type] != null) ? false : true;
+ if (isPrimitive) {
+ return type;
+ } else {
+ if (listType != null) {
+ return models[listType].getMockSignature();
+ } else {
+ return models[type].getMockSignature();
+ }
+ }
+ };
+
+ SwaggerOperation.prototype.getSampleJSON = function (type, models) {
+ var isPrimitive, listType, val;
+ listType = this.isListType(type);
+ isPrimitive = ((listType != null) && models[listType]) || (models[type] != null) ? false : true;
+ val = isPrimitive ? void 0 : (listType != null ? models[listType].createJSONSample() : models[type].createJSONSample());
+ if (val) {
+ val = listType ? [val] : val;
+ if (typeof val == "string")
+ return val;
+ else if (typeof val === "object") {
+ var t = val;
+ if (val instanceof Array && val.length > 0) {
+ t = val[0];
+ }
+ if (t.nodeName) {
+ var xmlString = new XMLSerializer().serializeToString(t);
+ return this.formatXml(xmlString);
+ }
+ else
+ return JSON.stringify(val, null, 2);
+ }
+ else
+ return val;
+ }
+ };
+
+ SwaggerOperation.prototype["do"] = function (args, opts, callback, error) {
+ var key, param, params, possibleParams, req, requestContentType, responseContentType, value, _i, _len, _ref;
+ if (args == null) {
+ args = {};
+ }
+ if (opts == null) {
+ opts = {};
+ }
+ requestContentType = null;
+ responseContentType = null;
+ if ((typeof args) === "function") {
+ error = opts;
+ callback = args;
+ args = {};
+ }
+ if ((typeof opts) === "function") {
+ error = callback;
+ callback = opts;
+ }
+ if (error == null) {
+ error = function (xhr, textStatus, error) {
+ return log(xhr, textStatus, error);
+ };
+ }
+ if (callback == null) {
+ callback = function (response) {
+ var content;
+ content = null;
+ if (response != null) {
+ content = response.data;
+ } else {
+ content = "no data";
+ }
+ return log("default callback: " + content);
+ };
+ }
+ params = {};
+ params.headers = [];
+ if (args.headers != null) {
+ params.headers = args.headers;
+ delete args.headers;
+ }
+
+ var possibleParams = [];
+ for (var i = 0; i < this.parameters.length; i++) {
+ var param = this.parameters[i];
+ if (param.paramType === 'header') {
+ if (args[param.name])
+ params.headers[param.name] = args[param.name];
+ }
+ else if (param.paramType === 'form' || param.paramType.toLowerCase() === 'file')
+ possibleParams.push(param);
+ }
+
+ if (args.body != null) {
+ params.body = args.body;
+ delete args.body;
+ }
+
+ if (possibleParams) {
+ var key;
+ for (key in possibleParams) {
+ var value = possibleParams[key];
+ if (args[value.name]) {
+ params[value.name] = args[value.name];
+ }
+ }
+ }
+
+ req = new SwaggerRequest(this.method, this.urlify(args), params, opts, callback, error, this);
+ if (opts.mock != null) {
+ return req;
+ } else {
+ return true;
+ }
+ };
+
+ SwaggerOperation.prototype.pathJson = function () {
+ return this.path.replace("{format}", "json");
+ };
+
+ SwaggerOperation.prototype.pathXml = function () {
+ return this.path.replace("{format}", "xml");
+ };
+
+ SwaggerOperation.prototype.encodePathParam = function (pathParam) {
+ var encParts, part, parts, _i, _len;
+ pathParam = pathParam.toString();
+ if (pathParam.indexOf("/") === -1) {
+ return encodeURIComponent(pathParam);
+ } else {
+ parts = pathParam.split("/");
+ encParts = [];
+ for (_i = 0, _len = parts.length; _i < _len; _i++) {
+ part = parts[_i];
+ encParts.push(encodeURIComponent(part));
+ }
+ return encParts.join("/");
+ }
+ };
+
+ SwaggerOperation.prototype.urlify = function (args) {
+ var url = this.resource.basePath + this.pathJson();
+ var params = this.parameters;
+ for (var i = 0; i < params.length; i++) {
+ var param = params[i];
+ if (param.paramType === 'path') {
+ if (args[param.name]) {
+ // apply path params and remove from args
+ var reg = new RegExp('\\{\\s*?' + param.name + '.*?\\}(?=\\s*?(\\/|$))', 'gi');
+ url = url.replace(reg, this.encodePathParam(args[param.name]));
+ delete args[param.name];
+ }
+ else
+ throw "" + param.name + " is a required path param.";
+ }
+ }
+
+ var queryParams = "";
+ for (var i = 0; i < params.length; i++) {
+ var param = params[i];
+ if (param.paramType === 'query') {
+ if (args[param.name] !== undefined) {
+ if (queryParams !== '')
+ queryParams += "&";
+ queryParams += encodeURIComponent(param.name) + '=' + encodeURIComponent(args[param.name]);
+ }
+ }
+ }
+ if ((queryParams != null) && queryParams.length > 0)
+ url += '?' + queryParams;
+ return url;
+ };
+
+ SwaggerOperation.prototype.supportHeaderParams = function () {
+ return this.resource.api.supportHeaderParams;
+ };
+
+ SwaggerOperation.prototype.supportedSubmitMethods = function () {
+ return this.resource.api.supportedSubmitMethods;
+ };
+
+ SwaggerOperation.prototype.getQueryParams = function (args) {
+ return this.getMatchingParams(['query'], args);
+ };
+
+ SwaggerOperation.prototype.getHeaderParams = function (args) {
+ return this.getMatchingParams(['header'], args);
+ };
+
+ SwaggerOperation.prototype.getMatchingParams = function (paramTypes, args) {
+ var matchingParams = {};
+ var params = this.parameters;
+ for (var i = 0; i < params.length; i++) {
+ param = params[i];
+ if (args && args[param.name])
+ matchingParams[param.name] = args[param.name];
+ }
+ var headers = this.resource.api.headers;
+ var name;
+ for (name in headers) {
+ var value = headers[name];
+ matchingParams[name] = value;
+ }
+ return matchingParams;
+ };
+
+ SwaggerOperation.prototype.help = function () {
+ var msg = "";
+ var params = this.parameters;
+ for (var i = 0; i < params.length; i++) {
+ var param = params[i];
+ if (msg !== "")
+ msg += "\n";
+ msg += "* " + param.name + (param.required ? ' (required)' : '') + " - " + param.description;
+ }
+ return msg;
+ };
+
+
+ SwaggerOperation.prototype.formatXml = function (xml) {
+ var contexp, formatted, indent, lastType, lines, ln, pad, reg, transitions, wsexp, _fn, _i, _len;
+ reg = /(>)(<)(\/*)/g;
+ wsexp = /[ ]*(.*)[ ]+\n/g;
+ contexp = /(<.+>)(.+\n)/g;
+ xml = xml.replace(reg, '$1\n$2$3').replace(wsexp, '$1\n').replace(contexp, '$1\n$2');
+ pad = 0;
+ formatted = '';
+ lines = xml.split('\n');
+ indent = 0;
+ lastType = 'other';
+ transitions = {
+ 'single->single': 0,
+ 'single->closing': -1,
+ 'single->opening': 0,
+ 'single->other': 0,
+ 'closing->single': 0,
+ 'closing->closing': -1,
+ 'closing->opening': 0,
+ 'closing->other': 0,
+ 'opening->single': 1,
+ 'opening->closing': 0,
+ 'opening->opening': 1,
+ 'opening->other': 1,
+ 'other->single': 0,
+ 'other->closing': -1,
+ 'other->opening': 0,
+ 'other->other': 0
+ };
+ _fn = function (ln) {
+ var fromTo, j, key, padding, type, types, value;
+ types = {
+ single: Boolean(ln.match(/<.+\/>/)),
+ closing: Boolean(ln.match(/<\/.+>/)),
+ opening: Boolean(ln.match(/<[^!?].*>/))
+ };
+ type = ((function () {
+ var _results;
+ _results = [];
+ for (key in types) {
+ value = types[key];
+ if (value) {
+ _results.push(key);
+ }
+ }
+ return _results;
+ })())[0];
+ type = type === void 0 ? 'other' : type;
+ fromTo = lastType + '->' + type;
+ lastType = type;
+ padding = '';
+ indent += transitions[fromTo];
+ padding = ((function () {
+ var _j, _ref5, _results;
+ _results = [];
+ for (j = _j = 0, _ref5 = indent; 0 <= _ref5 ? _j < _ref5 : _j > _ref5; j = 0 <= _ref5 ? ++_j : --_j) {
+ _results.push(' ');
+ }
+ return _results;
+ })()).join('');
+ if (fromTo === 'opening->closing') {
+ return formatted = formatted.substr(0, formatted.length - 1) + ln + '\n';
+ } else {
+ return formatted += padding + ln + '\n';
+ }
+ };
+ for (_i = 0, _len = lines.length; _i < _len; _i++) {
+ ln = lines[_i];
+ _fn(ln);
+ }
+ return formatted;
+ };
+
+ var SwaggerRequest = function (type, url, params, opts, successCallback, errorCallback, operation, execution) {
+ var _this = this;
+ var errors = [];
+ this.useJQuery = (typeof operation.resource.useJQuery !== 'undefined' ? operation.resource.useJQuery : null);
+ this.type = (type || errors.push("SwaggerRequest type is required (get/post/put/delete/patch/options)."));
+ this.url = (url || errors.push("SwaggerRequest url is required."));
+ this.params = params;
+ this.opts = opts;
+ this.successCallback = (successCallback || errors.push("SwaggerRequest successCallback is required."));
+ this.errorCallback = (errorCallback || errors.push("SwaggerRequest error callback is required."));
+ this.operation = (operation || errors.push("SwaggerRequest operation is required."));
+ this.execution = execution;
+ this.headers = (params.headers || {});
+
+ if (errors.length > 0) {
+ throw errors;
+ }
+
+ this.type = this.type.toUpperCase();
+
+ // set request, response content type headers
+ var headers = this.setHeaders(params, this.operation);
+ var body = params.body;
+
+ // encode the body for form submits
+ if (headers["Content-Type"]) {
+ var values = {};
+ var i;
+ var operationParams = this.operation.parameters;
+ for (i = 0; i < operationParams.length; i++) {
+ var param = operationParams[i];
+ if (param.paramType === "form")
+ values[param.name] = param;
+ }
+
+ if (headers["Content-Type"].indexOf("application/x-www-form-urlencoded") === 0) {
+ var encoded = "";
+ var key, value;
+ for (key in values) {
+ value = this.params[key];
+ if (typeof value !== 'undefined') {
+ if (encoded !== "")
+ encoded += "&";
+ encoded += encodeURIComponent(key) + '=' + encodeURIComponent(value);
+ }
+ }
+ body = encoded;
+ }
+ else if (headers["Content-Type"].indexOf("multipart/form-data") === 0) {
+ // encode the body for form submits
+ var data = "";
+ var boundary = "----SwaggerFormBoundary" + Date.now();
+ var key, value;
+ for (key in values) {
+ value = this.params[key];
+ if (typeof value !== 'undefined') {
+ data += '--' + boundary + '\n';
+ data += 'Content-Disposition: form-data; name="' + key + '"';
+ data += '\n\n';
+ data += value + "\n";
+ }
+ }
+ data += "--" + boundary + "--\n";
+ headers["Content-Type"] = "multipart/form-data; boundary=" + boundary;
+ body = data;
+ }
+ }
+
+ var obj;
+ if (!((this.headers != null) && (this.headers.mock != null))) {
+ obj = {
+ url: this.url,
+ method: this.type,
+ headers: headers,
+ body: body,
+ useJQuery: this.useJQuery,
+ on: {
+ error: function (response) {
+ return _this.errorCallback(response, _this.opts.parent);
+ },
+ redirect: function (response) {
+ return _this.successCallback(response, _this.opts.parent);
+ },
+ 307: function (response) {
+ return _this.successCallback(response, _this.opts.parent);
+ },
+ response: function (response) {
+ return _this.successCallback(response, _this.opts.parent);
+ }
+ }
+ };
+ var e;
+ if (typeof window !== 'undefined') {
+ e = window;
+ } else {
+ e = exports;
+ }
+ var status = e.authorizations.apply(obj, this.operation.authorizations);
+ if (opts.mock == null) {
+ if (status !== false) {
+ new SwaggerHttp().execute(obj);
+ } else {
+ obj.canceled = true;
+ }
+ } else {
+ return obj;
+ }
+ }
+ return obj;
+ };
+
+ SwaggerRequest.prototype.setHeaders = function (params, operation) {
+ // default type
+ var accepts = "application/json";
+ var consumes = "application/json";
+
+ var allDefinedParams = this.operation.parameters;
+ var definedFormParams = [];
+ var definedFileParams = [];
+ var body = params.body;
+ var headers = {};
+
+ // get params from the operation and set them in definedFileParams, definedFormParams, headers
+ var i;
+ for (i = 0; i < allDefinedParams.length; i++) {
+ var param = allDefinedParams[i];
+ if (param.paramType === "form")
+ definedFormParams.push(param);
+ else if (param.paramType === "file")
+ definedFileParams.push(param);
+ else if (param.paramType === "header" && this.params.headers) {
+ var key = param.name;
+ var headerValue = this.params.headers[param.name];
+ if (typeof this.params.headers[param.name] !== 'undefined')
+ headers[key] = headerValue;
+ }
+ }
+
+ // if there's a body, need to set the accepts header via requestContentType
+ if (body && (this.type === "POST" || this.type === "PUT" || this.type === "PATCH" || this.type === "DELETE")) {
+ if (this.opts.requestContentType)
+ consumes = this.opts.requestContentType;
+ } else {
+ // if any form params, content type must be set
+ if (definedFormParams.length > 0) {
+ if (definedFileParams.length > 0)
+ consumes = "multipart/form-data";
+ else
+ consumes = "application/x-www-form-urlencoded";
+ }
+ else if (this.type === "DELETE")
+ body = "{}";
+ else if (this.type != "DELETE")
+ accepts = null;
+ }
+
+ if (consumes && this.operation.consumes) {
+ if (this.operation.consumes.indexOf(consumes) === -1) {
+ log("server doesn't consume " + consumes + ", try " + JSON.stringify(this.operation.consumes));
+ consumes = this.operation.consumes[0];
+ }
+ }
+
+ if (this.opts.responseContentType) {
+ accepts = this.opts.responseContentType;
+ } else {
+ accepts = "application/json";
+ }
+ if (accepts && this.operation.produces) {
+ if (this.operation.produces.indexOf(accepts) === -1) {
+ log("server can't produce " + accepts);
+ accepts = this.operation.produces[0];
+ }
+ }
+
+ if ((consumes && body !== "") || (consumes === "application/x-www-form-urlencoded"))
+ headers["Content-Type"] = consumes;
+ if (accepts)
+ headers["Accept"] = accepts;
+ return headers;
+ }
+
+ SwaggerRequest.prototype.asCurl = function () {
+ var results = [];
+ if (this.headers) {
+ var key;
+ for (key in this.headers) {
+ results.push("--header \"" + key + ": " + this.headers[v] + "\"");
+ }
+ }
+ return "curl " + (results.join(" ")) + " " + this.url;
+ };
+
+ /**
+ * SwaggerHttp is a wrapper for executing requests
+ */
+ var SwaggerHttp = function () { };
+
+ SwaggerHttp.prototype.execute = function (obj) {
+ if (obj && (typeof obj.useJQuery === 'boolean'))
+ this.useJQuery = obj.useJQuery;
+ else
+ this.useJQuery = this.isIE8();
+
+ if (this.useJQuery)
+ return new JQueryHttpClient().execute(obj);
+ else
+ return new ShredHttpClient().execute(obj);
+ }
+
+ SwaggerHttp.prototype.isIE8 = function () {
+ var detectedIE = false;
+ if (typeof navigator !== 'undefined' && navigator.userAgent) {
+ nav = navigator.userAgent.toLowerCase();
+ if (nav.indexOf('msie') !== -1) {
+ var version = parseInt(nav.split('msie')[1]);
+ if (version <= 8) {
+ detectedIE = true;
+ }
+ }
+ }
+ return detectedIE;
+ };
+
+ /*
+ * JQueryHttpClient lets a browser take advantage of JQuery's cross-browser magic.
+ * NOTE: when jQuery is available it will export both '$' and 'jQuery' to the global space.
+ * Since we are using closures here we need to alias it for internal use.
+ */
+ var JQueryHttpClient = function (options) {
+ "use strict";
+ if (!jQuery) {
+ var jQuery = window.jQuery;
+ }
+ }
+
+ JQueryHttpClient.prototype.execute = function (obj) {
+ var cb = obj.on;
+ var request = obj;
+
+ obj.type = obj.method;
+ obj.cache = false;
+
+ obj.beforeSend = function (xhr) {
+ var key, results;
+ if (obj.headers) {
+ results = [];
+ var key;
+ for (key in obj.headers) {
+ if (key.toLowerCase() === "content-type") {
+ results.push(obj.contentType = obj.headers[key]);
+ } else if (key.toLowerCase() === "accept") {
+ results.push(obj.accepts = obj.headers[key]);
+ } else {
+ results.push(xhr.setRequestHeader(key, obj.headers[key]));
+ }
+ }
+ return results;
+ }
+ };
+
+ obj.data = obj.body;
+ obj.complete = function (response, textStatus, opts) {
+ var headers = {},
+ headerArray = response.getAllResponseHeaders().split("\n");
+
+ for (var i = 0; i < headerArray.length; i++) {
+ var toSplit = headerArray[i].trim();
+ if (toSplit.length === 0)
+ continue;
+ var separator = toSplit.indexOf(":");
+ if (separator === -1) {
+ // Name but no value in the header
+ headers[toSplit] = null;
+ continue;
+ }
+ var name = toSplit.substring(0, separator).trim(),
+ value = toSplit.substring(separator + 1).trim();
+ headers[name] = value;
+ }
+
+ var out = {
+ url: request.url,
+ method: request.method,
+ status: response.status,
+ data: response.responseText,
+ headers: headers
+ };
+
+ var contentType = (headers["content-type"] || headers["Content-Type"] || null)
+
+ if (contentType != null) {
+ if (contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) {
+ if (response.responseText && response.responseText !== "")
+ out.obj = JSON.parse(response.responseText);
+ else
+ out.obj = {}
+ }
+ }
+
+ if (response.status >= 200 && response.status < 300)
+ cb.response(out);
+ else if (response.status === 0 || (response.status >= 400 && response.status < 599))
+ cb.error(out);
+ else
+ return cb.response(out);
+ };
+
+ jQuery.support.cors = true;
+ return jQuery.ajax(obj);
+ }
+
+ /*
+ * ShredHttpClient is a light-weight, node or browser HTTP client
+ */
+ var ShredHttpClient = function (options) {
+ this.options = (options || {});
+ this.isInitialized = false;
+
+ var identity, toString;
+
+ if (typeof window !== 'undefined') {
+ this.Shred = require("./shred");
+ this.content = require("./shred/content");
+ }
+ else
+ this.Shred = require("shred");
+ this.shred = new this.Shred();
+ }
+
+ ShredHttpClient.prototype.initShred = function () {
+ this.isInitialized = true;
+ this.registerProcessors(this.shred);
+ }
+
+ ShredHttpClient.prototype.registerProcessors = function (shred) {
+ var identity = function (x) {
+ return x;
+ };
+ var toString = function (x) {
+ return x.toString();
+ };
+
+ if (typeof window !== 'undefined') {
+ this.content.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
+ parser: identity,
+ stringify: toString
+ });
+ } else {
+ this.Shred.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
+ parser: identity,
+ stringify: toString
+ });
+ }
+ }
+
+ ShredHttpClient.prototype.execute = function (obj) {
+ if (!this.isInitialized)
+ this.initShred();
+
+ var cb = obj.on, res;
+
+ var transform = function (response) {
+ var out = {
+ headers: response._headers,
+ url: response.request.url,
+ method: response.request.method,
+ status: response.status,
+ data: response.content.data
+ };
+
+ var contentType = (response._headers["content-type"] || response._headers["Content-Type"] || null)
+
+ if (contentType != null) {
+ if (contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) {
+ if (response.content.data && response.content.data !== "")
+ out.obj = JSON.parse(response.content.data);
+ else
+ out.obj = {}
+ }
+ }
+ return out;
+ };
+
+ // Transform an error into a usable response-like object
+ var transformError = function (error) {
+ var out = {
+ // Default to a status of 0 - The client will treat this as a generic permissions sort of error
+ status: 0,
+ data: error.message || error
+ };
+
+ if (error.code) {
+ out.obj = error;
+
+ if (error.code === 'ENOTFOUND' || error.code === 'ECONNREFUSED') {
+ // We can tell the client that this should be treated as a missing resource and not as a permissions thing
+ out.status = 404;
+ }
+ }
+
+ return out;
+ };
+
+ var res = {
+ error: function (response) {
+ if (obj)
+ return cb.error(transform(response));
+ },
+ // Catch the Shred error raised when the request errors as it is made (i.e. No Response is coming)
+ request_error: function (err) {
+ if (obj)
+ return cb.error(transformError(err));
+ },
+ redirect: function (response) {
+ if (obj)
+ return cb.redirect(transform(response));
+ },
+ 307: function (response) {
+ if (obj)
+ return cb.redirect(transform(response));
+ },
+ response: function (response) {
+ if (obj)
+ return cb.response(transform(response));
+ }
+ };
+ if (obj) {
+ obj.on = res;
+ }
+ return this.shred.request(obj);
+ };
+
+ /**
+ * SwaggerAuthorizations applys the correct authorization to an operation being executed
+ */
+ var SwaggerAuthorizations = function () {
+ this.authz = {};
+ };
+
+ SwaggerAuthorizations.prototype.add = function (name, auth) {
+ this.authz[name] = auth;
+ return auth;
+ };
+
+ SwaggerAuthorizations.prototype.remove = function (name) {
+ return delete this.authz[name];
+ };
+
+ SwaggerAuthorizations.prototype.apply = function (obj, authorizations) {
+ var status = null;
+ var key, value, result;
+
+ // if the "authorizations" key is undefined, or has an empty array, add all keys
+ if (typeof authorizations === 'undefined' || Object.keys(authorizations).length == 0) {
+ for (key in this.authz) {
+ value = this.authz[key];
+ result = value.apply(obj, authorizations);
+ if (result === true)
+ status = true;
+ }
+ }
+ else {
+ for (name in authorizations) {
+ for (key in this.authz) {
+ if (key == name) {
+ value = this.authz[key];
+ result = value.apply(obj, authorizations);
+ if (result === true)
+ status = true;
+ }
+ }
+ }
+ }
+
+ return status;
+ };
+
+ /**
+ * ApiKeyAuthorization allows a query param or header to be injected
+ */
+ var ApiKeyAuthorization = function (name, value, type, delimiter) {
+ this.name = name;
+ this.value = value;
+ this.type = type;
+ this.delimiter = delimiter;
+ };
+
+ ApiKeyAuthorization.prototype.apply = function (obj, authorizations) {
+ if (this.type === "query") {
+ if (obj.url.indexOf('?') > 0)
+ obj.url = obj.url + "&" + this.name + "=" + this.value;
+ else
+ obj.url = obj.url + "?" + this.name + "=" + this.value;
+ return true;
+ } else if (this.type === "header") {
+ if (typeof obj.headers[this.name] !== 'undefined') {
+ if (typeof this.delimiter !== 'undefined')
+ obj.headers[this.name] = obj.headers[this.name] + this.delimiter + this.value;
+ }
+ else
+ obj.headers[this.name] = this.value;
+ return true;
+ }
+ };
+
+ var CookieAuthorization = function (cookie) {
+ this.cookie = cookie;
+ }
+
+ CookieAuthorization.prototype.apply = function (obj, authorizations) {
+ obj.cookieJar = obj.cookieJar || CookieJar();
+ obj.cookieJar.setCookie(this.cookie);
+ return true;
+ }
+
+ /**
+ * Password Authorization is a basic auth implementation
+ */
+ var PasswordAuthorization = function (name, username, password) {
+ this.name = name;
+ this.username = username;
+ this.password = password;
+ this._btoa = null;
+ if (typeof window !== 'undefined')
+ this._btoa = btoa;
+ else
+ this._btoa = require("btoa");
+ };
+
+ PasswordAuthorization.prototype.apply = function (obj, authorizations) {
+ var base64encoder = this._btoa;
+ obj.headers["Authorization"] = "Basic " + base64encoder(this.username + ":" + this.password);
+ return true;
+ };
+
+ var e = (typeof window !== 'undefined' ? window : exports);
+
+ var sampleModels = {};
+ var cookies = {};
+
+ e.SampleModels = sampleModels;
+ e.SwaggerHttp = SwaggerHttp;
+ e.SwaggerRequest = SwaggerRequest;
+ e.authorizations = new SwaggerAuthorizations();
+ e.ApiKeyAuthorization = ApiKeyAuthorization;
+ e.PasswordAuthorization = PasswordAuthorization;
+ e.CookieAuthorization = CookieAuthorization;
+ e.JQueryHttpClient = JQueryHttpClient;
+ e.ShredHttpClient = ShredHttpClient;
+ e.SwaggerOperation = SwaggerOperation;
+ e.SwaggerModel = SwaggerModel;
+ e.SwaggerModelProperty = SwaggerModelProperty;
+ e.SwaggerResource = SwaggerResource;
+ e.SwaggerApi = SwaggerApi;
+ e.log = log;
+
+})();
profiles/killbill/src/main/webapp/lib/swagger-client.js 1382(+1382 -0)
diff --git a/profiles/killbill/src/main/webapp/lib/swagger-client.js b/profiles/killbill/src/main/webapp/lib/swagger-client.js
new file mode 100644
index 0000000..6bb8031
--- /dev/null
+++ b/profiles/killbill/src/main/webapp/lib/swagger-client.js
@@ -0,0 +1,1382 @@
+// swagger-client.js
+// version 2.1.0
+
+/**
+ * SwaggerAuthorizations applys the correct authorization to an operation being executed
+ */
+var SwaggerAuthorizations = function() {
+ this.authz = {};
+};
+
+SwaggerAuthorizations.prototype.add = function(name, auth) {
+ this.authz[name] = auth;
+ return auth;
+};
+
+SwaggerAuthorizations.prototype.remove = function(name) {
+ return delete this.authz[name];
+};
+
+SwaggerAuthorizations.prototype.apply = function(obj, authorizations) {
+ var status = null;
+ var key;
+
+ // if the "authorizations" key is undefined, or has an empty array, add all keys
+ if(typeof authorizations === 'undefined' || Object.keys(authorizations).length == 0) {
+ for (key in this.authz) {
+ value = this.authz[key];
+ result = value.apply(obj, authorizations);
+ if (result === true)
+ status = true;
+ }
+ }
+ else {
+ for(name in authorizations) {
+ for (key in this.authz) {
+ if(key == name) {
+ value = this.authz[key];
+ result = value.apply(obj, authorizations);
+ if (result === true)
+ status = true;
+ }
+ }
+ }
+ }
+
+ return status;
+};
+
+/**
+ * ApiKeyAuthorization allows a query param or header to be injected
+ */
+var ApiKeyAuthorization = function(name, value, type) {
+ this.name = name;
+ this.value = value;
+ this.type = type;
+};
+
+ApiKeyAuthorization.prototype.apply = function(obj, authorizations) {
+ if (this.type === "query") {
+ if (obj.url.indexOf('?') > 0)
+ obj.url = obj.url + "&" + this.name + "=" + this.value;
+ else
+ obj.url = obj.url + "?" + this.name + "=" + this.value;
+ return true;
+ } else if (this.type === "header") {
+ obj.headers[this.name] = this.value;
+ return true;
+ }
+};
+
+var CookieAuthorization = function(cookie) {
+ this.cookie = cookie;
+}
+
+CookieAuthorization.prototype.apply = function(obj, authorizations) {
+ obj.cookieJar = obj.cookieJar || CookieJar();
+ obj.cookieJar.setCookie(this.cookie);
+ return true;
+}
+
+/**
+ * Password Authorization is a basic auth implementation
+ */
+var PasswordAuthorization = function(name, username, password) {
+ this.name = name;
+ this.username = username;
+ this.password = password;
+ this._btoa = null;
+ if (typeof window !== 'undefined')
+ this._btoa = btoa;
+ else
+ this._btoa = require("btoa");
+};
+
+PasswordAuthorization.prototype.apply = function(obj, authorizations) {
+ var base64encoder = this._btoa;
+ obj.headers["Authorization"] = "Basic " + base64encoder(this.username + ":" + this.password);
+ return true;
+};var __bind = function(fn, me){
+ return function(){
+ return fn.apply(me, arguments);
+ };
+};
+
+fail = function(message) {
+ log(message);
+}
+
+log = function(){
+ log.history = log.history || [];
+ log.history.push(arguments);
+ if(this.console){
+ console.log( Array.prototype.slice.call(arguments)[0] );
+ }
+};
+
+if (!Array.prototype.indexOf) {
+ Array.prototype.indexOf = function(obj, start) {
+ for (var i = (start || 0), j = this.length; i < j; i++) {
+ if (this[i] === obj) { return i; }
+ }
+ return -1;
+ }
+}
+
+if (!('filter' in Array.prototype)) {
+ Array.prototype.filter= function(filter, that /*opt*/) {
+ var other= [], v;
+ for (var i=0, n= this.length; i<n; i++)
+ if (i in this && filter.call(that, v= this[i], i, this))
+ other.push(v);
+ return other;
+ };
+}
+
+if (!('map' in Array.prototype)) {
+ Array.prototype.map= function(mapper, that /*opt*/) {
+ var other= new Array(this.length);
+ for (var i= 0, n= this.length; i<n; i++)
+ if (i in this)
+ other[i]= mapper.call(that, this[i], i, this);
+ return other;
+ };
+}
+
+Object.keys = Object.keys || (function () {
+ var hasOwnProperty = Object.prototype.hasOwnProperty,
+ hasDontEnumBug = !{toString:null}.propertyIsEnumerable("toString"),
+ DontEnums = [
+ 'toString',
+ 'toLocaleString',
+ 'valueOf',
+ 'hasOwnProperty',
+ 'isPrototypeOf',
+ 'propertyIsEnumerable',
+ 'constructor'
+ ],
+ DontEnumsLength = DontEnums.length;
+
+ return function (o) {
+ if (typeof o != "object" && typeof o != "function" || o === null)
+ throw new TypeError("Object.keys called on a non-object");
+
+ var result = [];
+ for (var name in o) {
+ if (hasOwnProperty.call(o, name))
+ result.push(name);
+ }
+
+ if (hasDontEnumBug) {
+ for (var i = 0; i < DontEnumsLength; i++) {
+ if (hasOwnProperty.call(o, DontEnums[i]))
+ result.push(DontEnums[i]);
+ }
+ }
+
+ return result;
+ };
+})();
+var SwaggerClient = function(url, options) {
+ this.isBuilt = false;
+ this.url = null;
+ this.debug = false;
+ this.basePath = null;
+ this.authorizations = null;
+ this.authorizationScheme = null;
+ this.isValid = false;
+ this.info = null;
+ this.useJQuery = false;
+ this.models = models;
+
+ options = (options||{});
+ if (url)
+ if (url.url) options = url;
+ else this.url = url;
+ else options = url;
+
+ if (options.url != null)
+ this.url = options.url;
+
+ if (options.success != null)
+ this.success = options.success;
+
+ if (typeof options.useJQuery === 'boolean')
+ this.useJQuery = options.useJQuery;
+
+ this.failure = options.failure != null ? options.failure : function() {};
+ this.progress = options.progress != null ? options.progress : function() {};
+ this.spec = options.spec;
+
+ if (options.success != null)
+ this.build();
+}
+
+SwaggerClient.prototype.build = function() {
+ var self = this;
+ this.progress('fetching resource list: ' + this.url);
+ var obj = {
+ useJQuery: this.useJQuery,
+ url: this.url,
+ method: "get",
+ headers: {
+ accept: "application/json, */*"
+ },
+ on: {
+ error: function(response) {
+ if (self.url.substring(0, 4) !== 'http')
+ return self.fail('Please specify the protocol for ' + self.url);
+ else if (response.status === 0)
+ return self.fail('Can\'t read from server. It may not have the appropriate access-control-origin settings.');
+ else if (response.status === 404)
+ return self.fail('Can\'t read swagger JSON from ' + self.url);
+ else
+ return self.fail(response.status + ' : ' + response.statusText + ' ' + self.url);
+ },
+ response: function(resp) {
+ var responseObj = resp.obj || JSON.parse(resp.data);
+ self.swaggerVersion = responseObj.swaggerVersion;
+
+ if(responseObj.swagger && responseObj.swagger === 2.0) {
+ self.swaggerVersion = responseObj.swagger;
+ self.buildFromSpec(responseObj);
+ self.isValid = true;
+ }
+ else {
+ self.isValid = false;
+ self.failure();
+ }
+ }
+ }
+ };
+ if(this.spec) {
+ var self = this;
+ setTimeout(function() {
+ self.buildFromSpec(self.spec);
+ }, 10);
+ }
+ else {
+ var e = (typeof window !== 'undefined' ? window : exports);
+ var status = e.authorizations.apply(obj);
+ new SwaggerHttp().execute(obj);
+ }
+
+ return this;
+};
+
+SwaggerClient.prototype.buildFromSpec = function(response) {
+ if(this.isBuilt)
+ return this;
+ this.info = response.info || {};
+ this.title = response.title || '';
+ this.host = response.host || '';
+ this.schemes = response.schemes || [ 'http' ];
+ this.basePath = response.basePath || '';
+ this.apis = {};
+ this.apisArray = [];
+ this.consumes = response.consumes;
+ this.produces = response.produces;
+ this.authSchemes = response.authorizations;
+
+ if(typeof this.host === 'undefined' || this.host === '') {
+ var location = this.parseUri(this.url);
+ this.host = location.host;
+ }
+
+ this.definitions = response.definitions;
+ var key;
+ for(key in this.definitions) {
+ var model = new Model(key, this.definitions[key]);
+ if(model) {
+ models[key] = model;
+ }
+ }
+
+ // get paths, create functions for each operationId
+ var path;
+ var operations = [];
+ for(path in response.paths) {
+ var httpMethod;
+ for(httpMethod in response.paths[path]) {
+ var operation = response.paths[path][httpMethod];
+ var tags = operation.tags;
+ if(typeof tags === 'undefined') {
+ operation.tags = [ 'default' ];
+ tags = operation.tags;
+ }
+ var operationId = this.idFromOp(path, httpMethod, operation);
+ var operationObject = new Operation (
+ this,
+ operationId,
+ httpMethod,
+ path,
+ operation,
+ this.definitions
+ );
+ // bind this operation's execute command to the api
+ if(tags.length > 0) {
+ var i;
+ for(i = 0; i < tags.length; i++) {
+ var tag = this.tagFromLabel(tags[i]);
+ var operationGroup = this[tag];
+ if(typeof operationGroup === 'undefined') {
+ this[tag] = [];
+ operationGroup = this[tag];
+ operationGroup.label = tag;
+ operationGroup.apis = [];
+ this[tag].help = this.help.bind(operationGroup);
+ this.apisArray.push(new OperationGroup(tag, operationObject));
+ }
+ operationGroup[operationId] = operationObject.execute.bind(operationObject);
+ operationGroup[operationId].help = operationObject.help.bind(operationObject);
+ operationGroup.apis.push(operationObject);
+
+ // legacy UI feature
+ var j;
+ var api = null;
+ for(j = 0; j < this.apisArray.length; j++) {
+ if(this.apisArray[j].tag === tag) {
+ api = this.apisArray[j];
+ }
+ }
+ if(api) {
+ api.operationsArray.push(operationObject);
+ }
+ }
+ }
+ else {
+ log('no group to bind to');
+ }
+ }
+ }
+ this.isBuilt = true;
+ if (this.success)
+ this.success();
+ return this;
+}
+
+SwaggerClient.prototype.parseUri = function(uri) {
+ var urlParseRE = /^(((([^:\/#\?]+:)?(?:(\/\/)((?:(([^:@\/#\?]+)(?:\:([^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?:\:([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/;
+ var parts = urlParseRE.exec(uri);
+ return {
+ scheme: parts[4].replace(':',''),
+ host: parts[11],
+ path: parts[15]
+ };
+}
+
+SwaggerClient.prototype.help = function() {
+ var i;
+ log('operations for the "' + this.label + '" tag');
+ for(i = 0; i < this.apis.length; i++) {
+ var api = this.apis[i];
+ log(' * ' + api.nickname + ': ' + api.operation.summary);
+ }
+}
+
+SwaggerClient.prototype.tagFromLabel = function(label) {
+ return label;
+}
+
+SwaggerClient.prototype.idFromOp = function(path, httpMethod, op) {
+ if(typeof op.operationId !== 'undefined') {
+ return (op.operationId);
+ }
+ else {
+ return path.substring(1).replace(/\//g, "_").replace(/\{/g, "").replace(/\}/g, "") + "_" + httpMethod;
+ }
+}
+
+SwaggerClient.prototype.fail = function(message) {
+ this.failure(message);
+ throw message;
+};
+
+var OperationGroup = function(tag, operation) {
+ this.tag = tag;
+ this.path = tag;
+ this.name = tag;
+ this.operation = operation;
+ this.operationsArray = [];
+
+ this.description = operation.description || "";
+}
+
+var Operation = function(parent, operationId, httpMethod, path, args, definitions) {
+ var errors = [];
+ this.operation = args;
+ this.deprecated = args.deprecated;
+ this.consumes = args.consumes;
+ this.produces = args.produces;
+ this.parent = parent;
+ this.host = parent.host;
+ this.schemes = parent.schemes;
+ this.basePath = parent.basePath;
+ this.nickname = (operationId||errors.push('Operations must have a nickname.'));
+ this.method = (httpMethod||errors.push('Operation ' + operationId + ' is missing method.'));
+ this.path = (path||errors.push('Operation ' + nickname + ' is missing path.'));
+ this.parameters = args != null ? (args.parameters||[]) : {};
+ this.summary = args.summary || '';
+ this.responses = (args.responses||{});
+ this.type = null;
+ this.security = args.security;
+ this.description = args.description;
+
+ var i;
+ for(i = 0; i < this.parameters.length; i++) {
+ var param = this.parameters[i];
+ type = this.getType(param);
+
+ param.signature = this.getSignature(type, models);
+ param.sampleJSON = this.getSampleJSON(type, models);
+ param.responseClassSignature = param.signature;
+ }
+
+ var response;
+ var model;
+ var responses = this.responses;
+
+ if(responses['200']) {
+ response = responses['200'];
+ defaultResponseCode = '200';
+ }
+ else if(responses['201']) {
+ response = responses['201'];
+ defaultResponseCode = '201';
+ }
+ else if(responses['202']) {
+ response = responses['202'];
+ defaultResponseCode = '202';
+ }
+ else if(responses['203']) {
+ response = responses['203'];
+ defaultResponseCode = '203';
+ }
+ else if(responses['204']) {
+ response = responses['204'];
+ defaultResponseCode = '204';
+ }
+ else if(responses['205']) {
+ response = responses['205'];
+ defaultResponseCode = '205';
+ }
+ else if(responses['206']) {
+ response = responses['206'];
+ defaultResponseCode = '206';
+ }
+ else if(responses['default']) {
+ response = responses['default'];
+ defaultResponseCode = 'default';
+ }
+
+ if(response && response.schema) {
+ var resolvedModel = this.resolveModel(response.schema, definitions);
+ if(resolvedModel) {
+ this.type = resolvedModel.name;
+ this.responseSampleJSON = JSON.stringify(resolvedModel.getSampleValue(), null, 2);
+ this.responseClassSignature = resolvedModel.getMockSignature();
+ delete responses[defaultResponseCode];
+ }
+ else {
+ this.type = response.schema.type;
+ }
+ }
+
+ if (errors.length > 0)
+ this.resource.api.fail(errors);
+
+ return this;
+}
+
+OperationGroup.prototype.sort = function(sorter) {
+
+}
+
+Operation.prototype.getType = function (param) {
+ var type = param.type;
+ var format = param.format;
+ var isArray = false;
+ var str;
+ if(type === 'integer' && format === 'int32')
+ str = 'integer';
+ else if(type === 'integer' && format === 'int64')
+ str = 'long';
+ else if(type === 'string' && format === 'date-time')
+ str = 'date-time';
+ else if(type === 'string' && format === 'date')
+ str = 'date';
+ else if(type === 'number' && format === 'float')
+ str = 'float';
+ else if(type === 'number' && format === 'double')
+ str = 'double';
+ else if(type === 'boolean')
+ str = 'boolean';
+ else if(type === 'string')
+ str = 'string';
+ else if(type === 'array') {
+ isArray = true;
+ if(param.items)
+ str = this.getType(param.items);
+ }
+ if(param['$ref'])
+ str = param['$ref'];
+
+ var schema = param.schema;
+ if(schema) {
+ var ref = schema['$ref'];
+ if(ref) {
+ ref = simpleRef(ref);
+ if(isArray)
+ return [ ref ];
+ else
+ return ref;
+ }
+ else
+ return this.getType(schema);
+ }
+ if(isArray)
+ return [ str ];
+ else
+ return str;
+}
+
+Operation.prototype.resolveModel = function (schema, definitions) {
+ if(typeof schema['$ref'] !== 'undefined') {
+ var ref = schema['$ref'];
+ if(ref.indexOf('#/definitions/') == 0)
+ ref = ref.substring('#/definitions/'.length);
+ if(definitions[ref])
+ return new Model(ref, definitions[ref]);
+ }
+ if(schema.type === 'array')
+ return new ArrayModel(schema);
+ else
+ return null;
+}
+
+Operation.prototype.help = function() {
+ log(this.nickname + ': ' + this.operation.summary);
+ for(var i = 0; i < this.parameters.length; i++) {
+ var param = this.parameters[i];
+ log(' * ' + param.name + ': ' + param.description);
+ }
+}
+
+Operation.prototype.getSignature = function(type, models) {
+ var isPrimitive, listType;
+
+ if(type instanceof Array) {
+ listType = true;
+ type = type[0];
+ }
+
+ if(type === 'string')
+ isPrimitive = true
+ else
+ isPrimitive = ((listType != null) && models[listType]) || (models[type] != null) ? false : true;
+ if (isPrimitive) {
+ return type;
+ } else {
+ if (listType != null) {
+ return models[type].getMockSignature();
+ } else {
+ return models[type].getMockSignature();
+ }
+ }
+};
+
+Operation.prototype.getSampleJSON = function(type, models) {
+ var isPrimitive, listType, sampleJson;
+
+ listType = (type instanceof Array);
+ isPrimitive = (models[type] != null) ? false : true;
+ sampleJson = isPrimitive ? void 0 : models[type].createJSONSample();
+
+ if (sampleJson) {
+ sampleJson = listType ? [sampleJson] : sampleJson;
+ if(typeof sampleJson == 'string')
+ return sampleJson;
+ else if(typeof sampleJson === 'object') {
+ var t = sampleJson;
+ if(sampleJson instanceof Array && sampleJson.length > 0) {
+ t = sampleJson[0];
+ }
+ if(t.nodeName) {
+ var xmlString = new XMLSerializer().serializeToString(t);
+ return this.formatXml(xmlString);
+ }
+ else
+ return JSON.stringify(sampleJson, null, 2);
+ }
+ else
+ return sampleJson;
+ }
+};
+
+// legacy support
+Operation.prototype["do"] = function(args, opts, callback, error, parent) {
+ return this.execute(args, opts, callback, error, parent);
+}
+
+Operation.prototype.execute = function(arg1, arg2, arg3, arg4, parent) {
+ var args = (arg1||{});
+ var opts = {}, success, error;
+ if(typeof arg2 === 'object') {
+ opts = arg2;
+ success = arg3;
+ error = arg4;
+ }
+ if(typeof arg2 === 'function') {
+ success = arg2;
+ error = arg3;
+ }
+
+ var formParams = {};
+ var headers = {};
+ var requestUrl = this.path;
+
+ success = (success||log)
+ error = (error||log)
+
+ var requiredParams = [];
+ var missingParams = [];
+ // check required params
+ for(var i = 0; i < this.parameters.length; i++) {
+ var param = this.parameters[i];
+ if(param.required === true) {
+ requiredParams.push(param.name);
+ if(typeof args[param.name] === 'undefined')
+ missingParams = param.name;
+ }
+ }
+
+ if(missingParams.length > 0) {
+ var message = 'missing required params: ' + missingParams;
+ fail(message);
+ return;
+ }
+
+ // set content type negotiation
+ var consumes = this.consumes || this.parent.consumes || [ 'application/json' ];
+ var produces = this.produces || this.parent.produces || [ 'application/json' ];
+
+ headers = this.setContentTypes(args, opts);
+
+ // grab params from the args, build the querystring along the way
+ var querystring = "";
+ for(var i = 0; i < this.parameters.length; i++) {
+ var param = this.parameters[i];
+ if(typeof args[param.name] !== 'undefined') {
+ if(param.in === 'path') {
+ var reg = new RegExp('\{' + param.name + '[^\}]*\}', 'gi');
+ requestUrl = requestUrl.replace(reg, this.encodePathParam(args[param.name]));
+ }
+ else if (param.in === 'query') {
+ if(querystring === '')
+ querystring += '?';
+ else
+ querystring += '&';
+ if(typeof param.collectionFormat !== 'undefined') {
+ var qp = args[param.name];
+ if(Array.isArray(qp))
+ querystring += this.encodeCollection(param.collectionFormat, param.name, qp);
+ else
+ querystring += this.encodeQueryParam(param.name) + '=' + this.encodeQueryParam(args[param.name]);
+ }
+ else
+ querystring += this.encodeQueryParam(param.name) + '=' + this.encodeQueryParam(args[param.name]);
+ }
+ else if (param.in === 'header')
+ headers[param.name] = args[param.name];
+ else if (param.in === 'form')
+ formParams[param.name] = args[param.name];
+ }
+ }
+ var scheme = this.schemes[0];
+ var url = scheme + '://' + this.host + this.basePath + requestUrl + querystring;
+
+ var obj = {
+ url: url,
+ method: this.method,
+ body: args.body,
+ useJQuery: this.useJQuery,
+ headers: headers,
+ on: {
+ response: function(response) {
+ return success(response, parent);
+ },
+ error: function(response) {
+ return error(response, parent);
+ }
+ }
+ };
+ var status = e.authorizations.apply(obj, this.operation.security);
+ new SwaggerHttp().execute(obj);
+}
+
+Operation.prototype.setContentTypes = function(args, opts) {
+ // default type
+ var accepts = 'application/json';
+ var consumes = 'application/json';
+
+ var allDefinedParams = this.parameters;
+ var definedFormParams = [];
+ var definedFileParams = [];
+ var body = args.body;
+ var headers = {};
+
+ // get params from the operation and set them in definedFileParams, definedFormParams, headers
+ var i;
+ for(i = 0; i < allDefinedParams.length; i++) {
+ var param = allDefinedParams[i];
+ if(param.in === 'form')
+ definedFormParams.push(param);
+ else if(param.in === 'file')
+ definedFileParams.push(param);
+ else if(param.in === 'header' && this.headers) {
+ var key = param.name;
+ var headerValue = this.headers[param.name];
+ if(typeof this.headers[param.name] !== 'undefined')
+ headers[key] = headerValue;
+ }
+ }
+
+ // if there's a body, need to set the accepts header via requestContentType
+ if (body && (this.type === 'post' || this.type === 'put' || this.type === 'patch' || this.type === 'delete')) {
+ if (opts.requestContentType)
+ consumes = opts.requestContentType;
+ } else {
+ // if any form params, content type must be set
+ if(definedFormParams.length > 0) {
+ if(definedFileParams.length > 0)
+ consumes = 'multipart/form-data';
+ else
+ consumes = 'application/x-www-form-urlencoded';
+ }
+ else if (this.type == 'DELETE')
+ body = '{}';
+ else if (this.type != 'DELETE')
+ accepts = null;
+ }
+
+ if (consumes && this.consumes) {
+ if (this.consumes.indexOf(consumes) === -1) {
+ log('server doesn\'t consume ' + consumes + ', try ' + JSON.stringify(this.consumes));
+ consumes = this.operation.consumes[0];
+ }
+ }
+
+ if (opts.responseContentType) {
+ accepts = opts.responseContentType;
+ } else {
+ accepts = 'application/json';
+ }
+ if (accepts && this.produces) {
+ if (this.produces.indexOf(accepts) === -1) {
+ log('server can\'t produce ' + accepts);
+ accepts = this.produces[0];
+ }
+ }
+
+ if ((consumes && body !== '') || (consumes === 'application/x-www-form-urlencoded'))
+ headers['Content-Type'] = consumes;
+ if (accepts)
+ headers['Accept'] = accepts;
+ return headers;
+}
+
+Operation.prototype.encodeCollection = function(type, name, value) {
+ var encoded = '';
+ var i;
+ if(type === 'jaxrs') {
+ for(i = 0; i < value.length; i++) {
+ if(i > 0) encoded += '&'
+ encoded += this.encodeQueryParam(name) + '=' + this.encodeQueryParam(value[i]);
+ }
+ }
+ return encoded;
+}
+
+Operation.prototype.encodeQueryParam = function(arg) {
+ return escape(arg);
+}
+
+Operation.prototype.encodePathParam = function(pathParam) {
+ var encParts, part, parts, _i, _len;
+ pathParam = pathParam.toString();
+ if (pathParam.indexOf('/') === -1) {
+ return encodeURIComponent(pathParam);
+ } else {
+ parts = pathParam.split('/');
+ encParts = [];
+ for (_i = 0, _len = parts.length; _i < _len; _i++) {
+ part = parts[_i];
+ encParts.push(encodeURIComponent(part));
+ }
+ return encParts.join('/');
+ }
+};
+
+Operation.prototype.encodePathParam = function(pathParam) {
+ var encParts, part, parts, _i, _len;
+ pathParam = pathParam.toString();
+ if (pathParam.indexOf('/') === -1) {
+ return encodeURIComponent(pathParam);
+ } else {
+ parts = pathParam.split('/');
+ encParts = [];
+ for (_i = 0, _len = parts.length; _i < _len; _i++) {
+ part = parts[_i];
+ encParts.push(encodeURIComponent(part));
+ }
+ return encParts.join('/');
+ }
+};
+
+var ArrayModel = function(definition) {
+ this.name = "name";
+ this.definition = definition || {};
+ this.properties = [];
+ this.type;
+ this.ref;
+
+ var requiredFields = definition.enum || [];
+ var items = definition.items;
+ if(items) {
+ var type = items.type;
+ if(items.type) {
+ this.type = typeFromJsonSchema(type.type, type.format);
+ }
+ else {
+ this.ref = items['$ref'];
+ }
+ }
+}
+
+ArrayModel.prototype.createJSONSample = function(modelsToIgnore) {
+ var result;
+ var modelsToIgnore = (modelsToIgnore||[])
+ if(this.type) {
+ result = type;
+ }
+ else if (this.ref) {
+ var name = simpleRef(this.ref);
+ result = models[name].createJSONSample();
+ }
+ return [ result ];
+};
+
+ArrayModel.prototype.getSampleValue = function() {
+ var result;
+ var modelsToIgnore = (modelsToIgnore||[])
+ if(this.type) {
+ result = type;
+ }
+ else if (this.ref) {
+ var name = simpleRef(this.ref);
+ result = models[name].getSampleValue();
+ }
+ return [ result ];
+}
+
+ArrayModel.prototype.getMockSignature = function(modelsToIgnore) {
+ var propertiesStr = [];
+
+ if(this.ref) {
+ return models[simpleRef(this.ref)].getMockSignature();
+ }
+};
+
+
+var PrimitiveModel = function(definition) {
+ this.name = "name";
+ this.definition = definition || {};
+ this.properties = [];
+ this.type;
+
+ var requiredFields = definition.enum || [];
+ this.type = typeFromJsonSchema(definition.type, definition.format);
+}
+
+PrimitiveModel.prototype.createJSONSample = function(modelsToIgnore) {
+ var result = this.type;
+ return result;
+};
+
+PrimitiveModel.prototype.getSampleValue = function() {
+ var result = this.type;
+ return null;
+}
+
+PrimitiveModel.prototype.getMockSignature = function(modelsToIgnore) {
+ var propertiesStr = [];
+ var i;
+ for (i = 0; i < this.properties.length; i++) {
+ var prop = this.properties[i];
+ propertiesStr.push(prop.toString());
+ }
+
+ var strong = '<span class="strong">';
+ var stronger = '<span class="stronger">';
+ var strongClose = '</span>';
+ var classOpen = strong + this.name + ' {' + strongClose;
+ var classClose = strong + '}' + strongClose;
+ var returnVal = classOpen + '<div>' + propertiesStr.join(',</div><div>') + '</div>' + classClose;
+ if (!modelsToIgnore)
+ modelsToIgnore = [];
+
+ modelsToIgnore.push(this.name);
+ var i;
+ for (i = 0; i < this.properties.length; i++) {
+ var prop = this.properties[i];
+ var ref = prop['$ref'];
+ var model = models[ref];
+ if (model && modelsToIgnore.indexOf(ref) === -1) {
+ returnVal = returnVal + ('<br>' + model.getMockSignature(modelsToIgnore));
+ }
+ }
+ return returnVal;
+};
+
+var Model = function(name, definition) {
+ this.name = name;
+ this.definition = definition || {};
+ this.properties = [];
+ var requiredFields = definition.enum || [];
+
+ var key;
+ var props = definition.properties;
+ if(props) {
+ for(key in props) {
+ var required = false;
+ var property = props[key];
+ if(requiredFields.indexOf(key) >= 0)
+ required = true;
+ this.properties.push(new Property(key, property, required));
+ }
+ }
+}
+
+Model.prototype.createJSONSample = function(modelsToIgnore) {
+ var result = {};
+ var modelsToIgnore = (modelsToIgnore||[])
+ modelsToIgnore.push(this.name);
+ for (var i = 0; i < this.properties.length; i++) {
+ prop = this.properties[i];
+ result[prop.name] = prop.getSampleValue(modelsToIgnore);
+ }
+ modelsToIgnore.pop(this.name);
+ return result;
+};
+
+Model.prototype.getSampleValue = function() {
+ var i;
+ var obj = {};
+ for(i = 0; i < this.properties.length; i++ ) {
+ var property = this.properties[i];
+ obj[property.name] = property.sampleValue();
+ }
+ return obj;
+}
+
+Model.prototype.getMockSignature = function(modelsToIgnore) {
+ var propertiesStr = [];
+ var i;
+ for (i = 0; i < this.properties.length; i++) {
+ var prop = this.properties[i];
+ propertiesStr.push(prop.toString());
+ }
+
+ var strong = '<span class="strong">';
+ var stronger = '<span class="stronger">';
+ var strongClose = '</span>';
+ var classOpen = strong + this.name + ' {' + strongClose;
+ var classClose = strong + '}' + strongClose;
+ var returnVal = classOpen + '<div>' + propertiesStr.join(',</div><div>') + '</div>' + classClose;
+ if (!modelsToIgnore)
+ modelsToIgnore = [];
+
+ modelsToIgnore.push(this.name);
+ var i;
+ for (i = 0; i < this.properties.length; i++) {
+ var prop = this.properties[i];
+ var ref = prop['$ref'];
+ var model = models[ref];
+ if (model && modelsToIgnore.indexOf(ref) === -1) {
+ returnVal = returnVal + ('<br>' + model.getMockSignature(modelsToIgnore));
+ }
+ }
+ return returnVal;
+};
+
+var Property = function(name, obj, required) {
+ this.schema = obj;
+ this.required = required;
+ if(obj['$ref']) {
+ var refType = obj['$ref'];
+ refType = refType.indexOf('#/definitions') === -1 ? refType : refType.substring('#/definitions').length;
+ this['$ref'] = refType;
+ }
+ else if (obj.type === 'array') {
+ if(obj.items['$ref'])
+ this['$ref'] = obj.items['$ref'];
+ else
+ obj = obj.items;
+ }
+ this.name = name;
+ this.obj = obj;
+ this.optional = true;
+ this.example = obj.example || null;
+}
+
+Property.prototype.getSampleValue = function () {
+ return this.sampleValue(false);
+}
+
+Property.prototype.isArray = function () {
+ var schema = this.schema;
+ if(schema.type === 'array')
+ return true;
+ else
+ return false;
+}
+
+Property.prototype.sampleValue = function(isArray, ignoredModels) {
+ isArray = (isArray || this.isArray());
+ ignoredModels = (ignoredModels || {})
+ var type = getStringSignature(this.obj);
+ var output;
+
+ if(this['$ref']) {
+ var refModel = models[this['$ref']];
+ if(refModel && typeof ignoredModels[refModel] === 'undefined') {
+ output = refModel.getSampleValue(ignoredModels);
+ }
+ else
+ type = refModel;
+ }
+ else if(this.example)
+ output = this.example;
+ else if(type === 'date-time') {
+ output = new Date().toISOString();
+ }
+ else if(type === 'string') {
+ output = 'string';
+ }
+ else if(type === 'integer') {
+ output = 0;
+ }
+ else if(type === 'long') {
+ output = 0;
+ }
+ else if(type === 'float') {
+ output = 0.0;
+ }
+ else if(type === 'double') {
+ output = 0.0;
+ }
+ else if(type === 'boolean') {
+ output = true;
+ }
+ else
+ output = {};
+ if(isArray) return [output];
+ else return output;
+}
+
+getStringSignature = function(obj) {
+ var str = '';
+ if(obj.type === 'array') {
+ obj = (obj.items || obj['$ref'] || {});
+ str += 'Array[';
+ }
+ if(obj.type === 'integer' && obj.format === 'int32')
+ str += 'integer';
+ else if(obj.type === 'integer' && obj.format === 'int64')
+ str += 'long';
+ else if(obj.type === 'string' && obj.format === 'date-time')
+ str += 'date-time';
+ else if(obj.type === 'string' && obj.format === 'date')
+ str += 'date';
+ else if(obj.type === 'number' && obj.format === 'float')
+ str += 'float';
+ else if(obj.type === 'number' && obj.format === 'double')
+ str += 'double';
+ else if(obj.type === 'boolean')
+ str += 'boolean';
+ else
+ str += obj.type || obj['$ref'];
+ if(obj.type === 'array')
+ str += ']';
+ return str;
+}
+
+simpleRef = function(name) {
+ if(name.indexOf("#/definitions/") === 0)
+ return name.substring('#/definitions/'.length)
+ else
+ return name;
+}
+
+Property.prototype.toString = function() {
+ var str = getStringSignature(this.obj);
+ if(str !== '')
+ str = this.name + ' : ' + str;
+ else
+ str = this.name + ' : ' + JSON.stringify(this.obj);
+ if(!this.required)
+ str += ' (optional)';
+ return str;
+}
+
+typeFromJsonSchema = function(type, format) {
+ var str;
+ if(type === 'integer' && format === 'int32')
+ str = 'integer';
+ else if(type === 'integer' && format === 'int64')
+ str = 'long';
+ else if(type === 'string' && format === 'date-time')
+ str = 'date-time';
+ else if(type === 'string' && format === 'date')
+ str = 'date';
+ else if(type === 'number' && format === 'float')
+ str = 'float';
+ else if(type === 'number' && format === 'double')
+ str = 'double';
+ else if(type === 'boolean')
+ str = 'boolean';
+ else if(type === 'string')
+ str = 'string';
+
+ return str;
+}
+
+var e = (typeof window !== 'undefined' ? window : exports);
+
+var sampleModels = {};
+var cookies = {};
+var models = {};
+
+e.authorizations = new SwaggerAuthorizations();
+e.ApiKeyAuthorization = ApiKeyAuthorization;
+e.PasswordAuthorization = PasswordAuthorization;
+e.CookieAuthorization = CookieAuthorization;
+e.SwaggerClient = SwaggerClient;/**
+ * SwaggerHttp is a wrapper for executing requests
+ */
+var SwaggerHttp = function() {};
+
+SwaggerHttp.prototype.execute = function(obj) {
+ if(obj && (typeof obj.useJQuery === 'boolean'))
+ this.useJQuery = obj.useJQuery;
+ else
+ this.useJQuery = this.isIE8();
+
+ if(this.useJQuery)
+ return new JQueryHttpClient().execute(obj);
+ else
+ return new ShredHttpClient().execute(obj);
+}
+
+SwaggerHttp.prototype.isIE8 = function() {
+ var detectedIE = false;
+ if (typeof navigator !== 'undefined' && navigator.userAgent) {
+ nav = navigator.userAgent.toLowerCase();
+ if (nav.indexOf('msie') !== -1) {
+ var version = parseInt(nav.split('msie')[1]);
+ if (version <= 8) {
+ detectedIE = true;
+ }
+ }
+ }
+ return detectedIE;
+};
+
+/*
+ * JQueryHttpClient lets a browser take advantage of JQuery's cross-browser magic.
+ * NOTE: when jQuery is available it will export both '$' and 'jQuery' to the global space.
+ * Since we are using closures here we need to alias it for internal use.
+ */
+var JQueryHttpClient = function(options) {
+ "use strict";
+ if(!jQuery){
+ var jQuery = window.jQuery;
+ }
+}
+
+JQueryHttpClient.prototype.execute = function(obj) {
+ var cb = obj.on;
+ var request = obj;
+
+ obj.type = obj.method;
+ obj.cache = false;
+
+ obj.beforeSend = function(xhr) {
+ var key, results;
+ if (obj.headers) {
+ results = [];
+ var key;
+ for (key in obj.headers) {
+ if (key.toLowerCase() === "content-type") {
+ results.push(obj.contentType = obj.headers[key]);
+ } else if (key.toLowerCase() === "accept") {
+ results.push(obj.accepts = obj.headers[key]);
+ } else {
+ results.push(xhr.setRequestHeader(key, obj.headers[key]));
+ }
+ }
+ return results;
+ }
+ };
+
+ obj.data = obj.body;
+ obj.complete = function(response, textStatus, opts) {
+ var headers = {},
+ headerArray = response.getAllResponseHeaders().split("\n");
+
+ for(var i = 0; i < headerArray.length; i++) {
+ var toSplit = headerArray[i].trim();
+ if(toSplit.length === 0)
+ continue;
+ var separator = toSplit.indexOf(":");
+ if(separator === -1) {
+ // Name but no value in the header
+ headers[toSplit] = null;
+ continue;
+ }
+ var name = toSplit.substring(0, separator).trim(),
+ value = toSplit.substring(separator + 1).trim();
+ headers[name] = value;
+ }
+
+ var out = {
+ url: request.url,
+ method: request.method,
+ status: response.status,
+ data: response.responseText,
+ headers: headers
+ };
+
+ var contentType = (headers["content-type"]||headers["Content-Type"]||null)
+
+ if(contentType != null) {
+ if(contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) {
+ if(response.responseText && response.responseText !== "")
+ out.obj = JSON.parse(response.responseText);
+ else
+ out.obj = {}
+ }
+ }
+
+ if(response.status >= 200 && response.status < 300)
+ cb.response(out);
+ else if(response.status === 0 || (response.status >= 400 && response.status < 599))
+ cb.error(out);
+ else
+ return cb.response(out);
+ };
+
+ jQuery.support.cors = true;
+ return jQuery.ajax(obj);
+}
+
+/*
+ * ShredHttpClient is a light-weight, node or browser HTTP client
+ */
+var ShredHttpClient = function(options) {
+ this.options = (options||{});
+ this.isInitialized = false;
+
+ var identity, toString;
+
+ if (typeof window !== 'undefined') {
+ this.Shred = require("./shred");
+ this.content = require("./shred/content");
+ }
+ else
+ this.Shred = require("shred");
+ this.shred = new this.Shred();
+}
+
+ShredHttpClient.prototype.initShred = function () {
+ this.isInitialized = true;
+ this.registerProcessors(this.shred);
+}
+
+ShredHttpClient.prototype.registerProcessors = function(shred) {
+ var identity = function(x) {
+ return x;
+ };
+ var toString = function(x) {
+ return x.toString();
+ };
+
+ if (typeof window !== 'undefined') {
+ this.content.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
+ parser: identity,
+ stringify: toString
+ });
+ } else {
+ this.Shred.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
+ parser: identity,
+ stringify: toString
+ });
+ }
+}
+
+ShredHttpClient.prototype.execute = function(obj) {
+ if(!this.isInitialized)
+ this.initShred();
+
+ var cb = obj.on, res;
+
+ var transform = function(response) {
+ var out = {
+ headers: response._headers,
+ url: response.request.url,
+ method: response.request.method,
+ status: response.status,
+ data: response.content.data
+ };
+
+ var contentType = (response._headers["content-type"]||response._headers["Content-Type"]||null)
+
+ if(contentType != null) {
+ if(contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) {
+ if(response.content.data && response.content.data !== "")
+ try{
+ out.obj = JSON.parse(response.content.data);
+ }
+ catch (e) {
+ // unable to parse
+ }
+ else
+ out.obj = {}
+ }
+ }
+ return out;
+ };
+
+ res = {
+ error: function(response) {
+ if (obj)
+ return cb.error(transform(response));
+ },
+ redirect: function(response) {
+ if (obj)
+ return cb.redirect(transform(response));
+ },
+ 307: function(response) {
+ if (obj)
+ return cb.redirect(transform(response));
+ },
+ response: function(response) {
+ if (obj)
+ return cb.response(transform(response));
+ }
+ };
+ if (obj) {
+ obj.on = res;
+ }
+ return this.shred.request(obj);
+};
\ No newline at end of file
diff --git a/profiles/killbill/src/main/webapp/lib/swagger-oauth.js b/profiles/killbill/src/main/webapp/lib/swagger-oauth.js
new file mode 100644
index 0000000..8bb17fb
--- /dev/null
+++ b/profiles/killbill/src/main/webapp/lib/swagger-oauth.js
@@ -0,0 +1,211 @@
+var appName;
+var popupMask;
+var popupDialog;
+var clientId;
+var realm;
+
+function handleLogin() {
+ var scopes = [];
+
+ if(window.swaggerUi.api.authSchemes
+ && window.swaggerUi.api.authSchemes.oauth2
+ && window.swaggerUi.api.authSchemes.oauth2.scopes) {
+ scopes = window.swaggerUi.api.authSchemes.oauth2.scopes;
+ }
+
+ if(window.swaggerUi.api
+ && window.swaggerUi.api.info) {
+ appName = window.swaggerUi.api.info.title;
+ }
+
+ if(popupDialog.length > 0)
+ popupDialog = popupDialog.last();
+ else {
+ popupDialog = $(
+ [
+ '<div class="api-popup-dialog">',
+ '<div class="api-popup-title">Select OAuth2.0 Scopes</div>',
+ '<div class="api-popup-content">',
+ '<p>Scopes are used to grant an application different levels of access to data on behalf of the end user. Each API may declare one or more scopes.',
+ '<a href="#">Learn how to use</a>',
+ '</p>',
+ '<p><strong>' + appName + '</strong> API requires the following scopes. Select which ones you want to grant to Swagger UI.</p>',
+ '<ul class="api-popup-scopes">',
+ '</ul>',
+ '<p class="error-msg"></p>',
+ '<div class="api-popup-actions"><button class="api-popup-authbtn api-button green" type="button">Authorize</button><button class="api-popup-cancel api-button gray" type="button">Cancel</button></div>',
+ '</div>',
+ '</div>'].join(''));
+ $(document.body).append(popupDialog);
+
+ popup = popupDialog.find('ul.api-popup-scopes').empty();
+ for (i = 0; i < scopes.length; i ++) {
+ scope = scopes[i];
+ str = '<li><input type="checkbox" id="scope_' + i + '" scope="' + scope.scope + '"/>' + '<label for="scope_' + i + '">' + scope.scope;
+ if (scope.description) {
+ str += '<br/><span class="api-scope-desc">' + scope.description + '</span>';
+ }
+ str += '</label></li>';
+ popup.append(str);
+ }
+ }
+
+ var $win = $(window),
+ dw = $win.width(),
+ dh = $win.height(),
+ st = $win.scrollTop(),
+ dlgWd = popupDialog.outerWidth(),
+ dlgHt = popupDialog.outerHeight(),
+ top = (dh -dlgHt)/2 + st,
+ left = (dw - dlgWd)/2;
+
+ popupDialog.css({
+ top: (top < 0? 0 : top) + 'px',
+ left: (left < 0? 0 : left) + 'px'
+ });
+
+ popupDialog.find('button.api-popup-cancel').click(function() {
+ popupMask.hide();
+ popupDialog.hide();
+ });
+ popupDialog.find('button.api-popup-authbtn').click(function() {
+ popupMask.hide();
+ popupDialog.hide();
+
+ var authSchemes = window.swaggerUi.api.authSchemes;
+ var host = window.location;
+ var pathname = location.pathname.substring(0, location.pathname.lastIndexOf("/"));
+ var redirectUrl = host.protocol + '//' + host.host + pathname + "/o2c.html";
+ var url = null;
+
+ for (var key in authSchemes) {
+ if (authSchemes.hasOwnProperty(key)) {
+ var o = authSchemes[key].grantTypes;
+ for(var t in o) {
+ if(o.hasOwnProperty(t) && t === 'implicit') {
+ var dets = o[t];
+ url = dets.loginEndpoint.url + "?response_type=token";
+ window.swaggerUi.tokenName = dets.tokenName;
+ }
+ }
+ }
+ }
+ var scopes = []
+ var o = $('.api-popup-scopes').find('input:checked');
+
+ for(k =0; k < o.length; k++) {
+ scopes.push($(o[k]).attr("scope"));
+ }
+
+ window.enabledScopes=scopes;
+
+ url += '&redirect_uri=' + encodeURIComponent(redirectUrl);
+ url += '&realm=' + encodeURIComponent(realm);
+ url += '&client_id=' + encodeURIComponent(clientId);
+ url += '&scope=' + encodeURIComponent(scopes);
+
+ window.open(url);
+ });
+
+ popupMask.show();
+ popupDialog.show();
+ return;
+}
+
+
+function handleLogout() {
+ for(key in window.authorizations.authz){
+ window.authorizations.remove(key)
+ }
+ window.enabledScopes = null;
+ $('.api-ic.ic-on').addClass('ic-off');
+ $('.api-ic.ic-on').removeClass('ic-on');
+
+ // set the info box
+ $('.api-ic.ic-warning').addClass('ic-error');
+ $('.api-ic.ic-warning').removeClass('ic-warning');
+}
+
+function initOAuth(opts) {
+ var o = (opts||{});
+ var errors = [];
+
+ appName = (o.appName||errors.push("missing appName"));
+ popupMask = (o.popupMask||$('#api-common-mask'));
+ popupDialog = (o.popupDialog||$('.api-popup-dialog'));
+ clientId = (o.clientId||errors.push("missing client id"));
+ realm = (o.realm||errors.push("missing realm"));
+
+ if(errors.length > 0){
+ log("auth unable initialize oauth: " + errors);
+ return;
+ }
+
+ $('pre code').each(function(i, e) {hljs.highlightBlock(e)});
+ $('.api-ic').click(function(s) {
+ if($(s.target).hasClass('ic-off'))
+ handleLogin();
+ else {
+ handleLogout();
+ }
+ false;
+ });
+}
+
+function onOAuthComplete(token) {
+ if(token) {
+ if(token.error) {
+ var checkbox = $('input[type=checkbox],.secured')
+ checkbox.each(function(pos){
+ checkbox[pos].checked = false;
+ });
+ alert(token.error);
+ }
+ else {
+ var b = token[window.swaggerUi.tokenName];
+ if(b){
+ // if all roles are satisfied
+ var o = null;
+ $.each($('.auth #api_information_panel'), function(k, v) {
+ var children = v;
+ if(children && children.childNodes) {
+ var requiredScopes = [];
+ $.each((children.childNodes), function (k1, v1){
+ var inner = v1.innerHTML;
+ if(inner)
+ requiredScopes.push(inner);
+ });
+ var diff = [];
+ for(var i=0; i < requiredScopes.length; i++) {
+ var s = requiredScopes[i];
+ if(window.enabledScopes && window.enabledScopes.indexOf(s) == -1) {
+ diff.push(s);
+ }
+ }
+ if(diff.length > 0){
+ o = v.parentNode;
+ $(o.parentNode).find('.api-ic.ic-on').addClass('ic-off');
+ $(o.parentNode).find('.api-ic.ic-on').removeClass('ic-on');
+
+ // sorry, not all scopes are satisfied
+ $(o).find('.api-ic').addClass('ic-warning');
+ $(o).find('.api-ic').removeClass('ic-error');
+ }
+ else {
+ o = v.parentNode;
+ $(o.parentNode).find('.api-ic.ic-off').addClass('ic-on');
+ $(o.parentNode).find('.api-ic.ic-off').removeClass('ic-off');
+
+ // all scopes are satisfied
+ $(o).find('.api-ic').addClass('ic-info');
+ $(o).find('.api-ic').removeClass('ic-warning');
+ $(o).find('.api-ic').removeClass('ic-error');
+ }
+ }
+ });
+
+ window.authorizations.add("oauth2", new ApiKeyAuthorization("Authorization", "Bearer " + b, "header"));
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/profiles/killbill/src/main/webapp/lib/swagger-ui.min.js b/profiles/killbill/src/main/webapp/lib/swagger-ui.min.js
new file mode 100644
index 0000000..0d60523
--- /dev/null
+++ b/profiles/killbill/src/main/webapp/lib/swagger-ui.min.js
@@ -0,0 +1 @@
+$(function(){$.fn.vAlign=function(){return this.each(function(c){var a=$(this).height();var d=$(this).parent().height();var b=(d-a)/2;$(this).css("margin-top",b)})};$.fn.stretchFormtasticInputWidthToParent=function(){return this.each(function(b){var d=$(this).closest("form").innerWidth();var c=parseInt($(this).closest("form").css("padding-left"),10)+parseInt($(this).closest("form").css("padding-right"),10);var a=parseInt($(this).css("padding-left"),10)+parseInt($(this).css("padding-right"),10);$(this).css("width",d-c-a)})};$("form.formtastic li.string input, form.formtastic textarea").stretchFormtasticInputWidthToParent();$("ul.downplayed li div.content p").vAlign();$("form.sandbox").submit(function(){var a=true;$(this).find("input.required").each(function(){$(this).removeClass("error");if($(this).val()==""){$(this).addClass("error");$(this).wiggle();a=false}});return a})});function clippyCopiedCallback(b){$("#api_key_copied").fadeIn().delay(1000).fadeOut()}log=function(){log.history=log.history||[];log.history.push(arguments);if(this.console){console.log(Array.prototype.slice.call(arguments)[0])}};if(Function.prototype.bind&&console&&typeof console.log=="object"){["log","info","warn","error","assert","dir","clear","profile","profileEnd"].forEach(function(a){console[a]=this.bind(console[a],console)},Function.prototype.call)}var Docs={shebang:function(){var b=$.param.fragment().split("/");b.shift();switch(b.length){case 1:var d="resource_"+b[0];Docs.expandEndpointListForResource(b[0]);$("#"+d).slideto({highlight:false});break;case 2:Docs.expandEndpointListForResource(b[0]);$("#"+d).slideto({highlight:false});var c=b.join("_");var a=c+"_content";Docs.expandOperation($("#"+a));$("#"+c).slideto({highlight:false});break}},toggleEndpointListForResource:function(b){var a=$("li#resource_"+Docs.escapeResourceName(b)+" ul.endpoints");if(a.is(":visible")){Docs.collapseEndpointListForResource(b)}else{Docs.expandEndpointListForResource(b)}},expandEndpointListForResource:function(b){var b=Docs.escapeResourceName(b);if(b==""){$(".resource ul.endpoints").slideDown();return}$("li#resource_"+b).addClass("active");var a=$("li#resource_"+b+" ul.endpoints");a.slideDown()},collapseEndpointListForResource:function(b){var b=Docs.escapeResourceName(b);$("li#resource_"+b).removeClass("active");var a=$("li#resource_"+b+" ul.endpoints");a.slideUp()},expandOperationsForResource:function(a){Docs.expandEndpointListForResource(a);if(a==""){$(".resource ul.endpoints li.operation div.content").slideDown();return}$("li#resource_"+Docs.escapeResourceName(a)+" li.operation div.content").each(function(){Docs.expandOperation($(this))})},collapseOperationsForResource:function(a){Docs.expandEndpointListForResource(a);$("li#resource_"+Docs.escapeResourceName(a)+" li.operation div.content").each(function(){Docs.collapseOperation($(this))})},escapeResourceName:function(a){return a.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g,"\\$&")},expandOperation:function(a){a.slideDown()},collapseOperation:function(a){a.slideUp()}};(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.content_type=b(function(g,l,f,k,j){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);j=j||{};var i="",c,h="function",m=this;function e(r,q){var o="",p;o+="\n ";p=f.each.call(r,r.produces,{hash:{},inverse:m.noop,fn:m.program(2,d,q),data:q});if(p||p===0){o+=p}o+="\n";return o}function d(r,q){var o="",p;o+='\n <option value="';p=(typeof r===h?r.apply(r):r);if(p||p===0){o+=p}o+='">';p=(typeof r===h?r.apply(r):r);if(p||p===0){o+=p}o+="</option>\n ";return o}function n(p,o){return'\n <option value="application/json">application/json</option>\n'}i+='<label for="contentType"></label>\n<select name="contentType">\n';c=f["if"].call(l,l.produces,{hash:{},inverse:m.program(4,n,j),fn:m.program(1,e,j),data:j});if(c||c===0){i+=c}i+="\n</select>\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.main=b(function(h,n,g,m,l){this.compilerInfo=[4,">= 1.0.0"];g=this.merge(g,h.helpers);l=l||{};var j="",c,s,i="function",k=this.escapeExpression,q=this;function f(x,w){var t="",v,u;t+='\n <div class="info_title">'+k(((v=((v=x.info),v==null||v===false?v:v.title)),typeof v===i?v.apply(x):v))+'</div>\n <div class="info_description">';u=((v=((v=x.info),v==null||v===false?v:v.description)),typeof v===i?v.apply(x):v);if(u||u===0){t+=u}t+="</div>\n ";u=g["if"].call(x,((v=x.info),v==null||v===false?v:v.termsOfServiceUrl),{hash:{},inverse:q.noop,fn:q.program(2,d,w),data:w});if(u||u===0){t+=u}t+="\n ";u=g["if"].call(x,((v=x.info),v==null||v===false?v:v.contact),{hash:{},inverse:q.noop,fn:q.program(4,r,w),data:w});if(u||u===0){t+=u}t+="\n ";u=g["if"].call(x,((v=x.info),v==null||v===false?v:v.license),{hash:{},inverse:q.noop,fn:q.program(6,p,w),data:w});if(u||u===0){t+=u}t+="\n ";return t}function d(w,v){var t="",u;t+='<div class="info_tos"><a href="'+k(((u=((u=w.info),u==null||u===false?u:u.termsOfServiceUrl)),typeof u===i?u.apply(w):u))+'">Terms of service</a></div>';return t}function r(w,v){var t="",u;t+="<div class='info_contact'><a href=\"mailto:"+k(((u=((u=((u=w.info),u==null||u===false?u:u.contact)),u==null||u===false?u:u.name)),typeof u===i?u.apply(w):u))+'">Contact the developer</a></div>';return t}function p(w,v){var t="",u;t+="<div class='info_license'><a href='"+k(((u=((u=((u=w.info),u==null||u===false?u:u.license)),u==null||u===false?u:u.url)),typeof u===i?u.apply(w):u))+"'>"+k(((u=((u=((u=w.info),u==null||u===false?u:u.license)),u==null||u===false?u:u.name)),typeof u===i?u.apply(w):u))+"</a></div>";return t}function o(w,v){var t="",u;t+='\n , <span style="font-variant: small-caps">api version</span>: '+k(((u=((u=w.info),u==null||u===false?u:u.version)),typeof u===i?u.apply(w):u))+"\n ";return t}function e(w,v){var t="",u;t+='\n <span style="float:right"><a href="http://online.swagger.io/validator/debug?url=';if(u=g.url){u=u.call(w,{hash:{},data:v})}else{u=w.url;u=typeof u===i?u.apply(w):u}t+=k(u)+'"><img id="validator" src="http://online.swagger.io/validator?url=';if(u=g.url){u=u.call(w,{hash:{},data:v})}else{u=w.url;u=typeof u===i?u.apply(w):u}t+=k(u)+'"></a>\n </span>\n ';return t}j+="<div class='info' id='api_info'>\n ";c=g["if"].call(n,n.info,{hash:{},inverse:q.noop,fn:q.program(1,f,l),data:l});if(c||c===0){j+=c}j+="\n</div>\n<div class='container' id='resources_container'>\n <ul id='resources'>\n </ul>\n\n <div class=\"footer\">\n <br>\n <br>\n <h4 style=\"color: #999\">[ <span style=\"font-variant: small-caps\">base url</span>: ";if(c=g.basePath){c=c.call(n,{hash:{},data:l})}else{c=n.basePath;c=typeof c===i?c.apply(n):c}j+=k(c)+"\n ";s=g["if"].call(n,((c=n.info),c==null||c===false?c:c.version),{hash:{},inverse:q.noop,fn:q.program(8,o,l),data:l});if(s||s===0){j+=s}j+="]\n ";s=g["if"].call(n,n.validatorUrl,{hash:{},inverse:q.noop,fn:q.program(10,e,l),data:l});if(s||s===0){j+=s}j+="\n </h4>\n </div>\n</div>\n";return j})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.operation=b(function(g,s,q,m,y){this.compilerInfo=[4,">= 1.0.0"];q=this.merge(q,g.helpers);y=y||{};var r="",i,f,e="function",d=this.escapeExpression,p=this,c=q.blockHelperMissing;function o(C,B){var z="",A;z+="\n <h4>Implementation Notes</h4>\n <p>";if(A=q.description){A=A.call(C,{hash:{},data:B})}else{A=C.description;A=typeof A===e?A.apply(C):A}if(A||A===0){z+=A}z+="</p>\n ";return z}function n(A,z){return'\n <div class="auth">\n <span class="api-ic ic-error"></span>'}function l(C,B){var z="",A;z+='\n <div id="api_information_panel" style="top: 526px; left: 776px; display: none;">\n ';A=q.each.call(C,C,{hash:{},inverse:p.noop,fn:p.program(6,k,B),data:B});if(A||A===0){z+=A}z+="\n </div>\n ";return z}function k(D,C){var z="",B,A;z+="\n <div title='";A=((B=D.description),typeof B===e?B.apply(D):B);if(A||A===0){z+=A}z+="'>"+d(((B=D.scope),typeof B===e?B.apply(D):B))+"</div>\n ";return z}function h(A,z){return"</div>"}function x(A,z){return'\n <div class=\'access\'>\n <span class="api-ic ic-off" title="click to authenticate"></span>\n </div>\n '}function w(A,z){return'\n <h4>Response Class</h4>\n <p><span class="model-signature" /></p>\n <br/>\n <div class="response-content-type" />\n '}function v(A,z){return'\n <h4>Parameters</h4>\n <table class=\'fullwidth\'>\n <thead>\n <tr>\n <th style="width: 100px; max-width: 100px">Parameter</th>\n <th style="width: 310px; max-width: 310px">Value</th>\n <th style="width: 200px; max-width: 200px">Description</th>\n <th style="width: 100px; max-width: 100px">Parameter Type</th>\n <th style="width: 220px; max-width: 230px">Data Type</th>\n </tr>\n </thead>\n <tbody class="operation-params">\n\n </tbody>\n </table>\n '}function u(A,z){return"\n <div style='margin:0;padding:0;display:inline'></div>\n <h4>Response Messages</h4>\n <table class='fullwidth'>\n <thead>\n <tr>\n <th>HTTP Status Code</th>\n <th>Reason</th>\n <th>Response Model</th>\n </tr>\n </thead>\n <tbody class=\"operation-status\">\n \n </tbody>\n </table>\n "}function t(A,z){return"\n "}function j(A,z){return"\n <div class='sandbox_header'>\n <input class='submit' name='commit' type='button' value='Try it out!' />\n <a href='#' class='response_hider' style='display:none'>Hide Response</a>\n <span class='response_throbber' style='display:none'></span>\n </div>\n "}r+="\n <ul class='operations' >\n <li class='";if(i=q.method){i=i.call(s,{hash:{},data:y})}else{i=s.method;i=typeof i===e?i.apply(s):i}r+=d(i)+" operation' id='";if(i=q.parentId){i=i.call(s,{hash:{},data:y})}else{i=s.parentId;i=typeof i===e?i.apply(s):i}r+=d(i)+"_";if(i=q.nickname){i=i.call(s,{hash:{},data:y})}else{i=s.nickname;i=typeof i===e?i.apply(s):i}r+=d(i)+"'>\n <div class='heading'>\n <h3>\n <span class='http_method'>\n <a href='#!/";if(i=q.parentId){i=i.call(s,{hash:{},data:y})}else{i=s.parentId;i=typeof i===e?i.apply(s):i}r+=d(i)+"/";if(i=q.nickname){i=i.call(s,{hash:{},data:y})}else{i=s.nickname;i=typeof i===e?i.apply(s):i}r+=d(i)+'\' class="toggleOperation">';if(i=q.method){i=i.call(s,{hash:{},data:y})}else{i=s.method;i=typeof i===e?i.apply(s):i}r+=d(i)+"</a>\n </span>\n <span class='path'>\n <a href='#!/";if(i=q.parentId){i=i.call(s,{hash:{},data:y})}else{i=s.parentId;i=typeof i===e?i.apply(s):i}r+=d(i)+"/";if(i=q.nickname){i=i.call(s,{hash:{},data:y})}else{i=s.nickname;i=typeof i===e?i.apply(s):i}r+=d(i)+'\' class="toggleOperation">';if(i=q.path){i=i.call(s,{hash:{},data:y})}else{i=s.path;i=typeof i===e?i.apply(s):i}r+=d(i)+"</a>\n </span>\n </h3>\n <ul class='options'>\n <li>\n <a href='#!/";if(i=q.parentId){i=i.call(s,{hash:{},data:y})}else{i=s.parentId;i=typeof i===e?i.apply(s):i}r+=d(i)+"/";if(i=q.nickname){i=i.call(s,{hash:{},data:y})}else{i=s.nickname;i=typeof i===e?i.apply(s):i}r+=d(i)+'\' class="toggleOperation">';if(i=q.summary){i=i.call(s,{hash:{},data:y})}else{i=s.summary;i=typeof i===e?i.apply(s):i}if(i||i===0){r+=i}r+="</a>\n </li>\n </ul>\n </div>\n <div class='content' id='";if(i=q.parentId){i=i.call(s,{hash:{},data:y})}else{i=s.parentId;i=typeof i===e?i.apply(s):i}r+=d(i)+"_";if(i=q.nickname){i=i.call(s,{hash:{},data:y})}else{i=s.nickname;i=typeof i===e?i.apply(s):i}r+=d(i)+"_content' style='display:none'>\n ";i=q["if"].call(s,s.description,{hash:{},inverse:p.noop,fn:p.program(1,o,y),data:y});if(i||i===0){r+=i}r+="\n ";f={hash:{},inverse:p.noop,fn:p.program(3,n,y),data:y};if(i=q.oauth){i=i.call(s,f)}else{i=s.oauth;i=typeof i===e?i.apply(s):i}if(!q.oauth){i=c.call(s,i,f)}if(i||i===0){r+=i}r+="\n ";i=q.each.call(s,s.oauth,{hash:{},inverse:p.noop,fn:p.program(5,l,y),data:y});if(i||i===0){r+=i}r+="\n ";f={hash:{},inverse:p.noop,fn:p.program(8,h,y),data:y};if(i=q.oauth){i=i.call(s,f)}else{i=s.oauth;i=typeof i===e?i.apply(s):i}if(!q.oauth){i=c.call(s,i,f)}if(i||i===0){r+=i}r+="\n ";f={hash:{},inverse:p.noop,fn:p.program(10,x,y),data:y};if(i=q.oauth){i=i.call(s,f)}else{i=s.oauth;i=typeof i===e?i.apply(s):i}if(!q.oauth){i=c.call(s,i,f)}if(i||i===0){r+=i}r+="\n ";i=q["if"].call(s,s.type,{hash:{},inverse:p.noop,fn:p.program(12,w,y),data:y});if(i||i===0){r+=i}r+="\n <form accept-charset='UTF-8' class='sandbox'>\n <div style='margin:0;padding:0;display:inline'></div>\n ";i=q["if"].call(s,s.parameters,{hash:{},inverse:p.noop,fn:p.program(14,v,y),data:y});if(i||i===0){r+=i}r+="\n ";i=q["if"].call(s,s.responseMessages,{hash:{},inverse:p.noop,fn:p.program(16,u,y),data:y});if(i||i===0){r+=i}r+="\n ";i=q["if"].call(s,s.isReadOnly,{hash:{},inverse:p.program(20,j,y),fn:p.program(18,t,y),data:y});if(i||i===0){r+=i}r+="\n </form>\n <div class='response' style='display:none'>\n <h4>Request URL</h4>\n <div class='block request_url'></div>\n <h4>Response Body</h4>\n <div class='block response_body'></div>\n <h4>Response Code</h4>\n <div class='block response_code'></div>\n <h4>Response Headers</h4>\n <div class='block response_headers'></div>\n </div>\n </div>\n </li>\n </ul>\n";return r})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param=b(function(f,q,o,j,t){this.compilerInfo=[4,">= 1.0.0"];o=this.merge(o,f.helpers);t=t||{};var p="",g,d="function",c=this.escapeExpression,n=this;function m(y,x){var v="",w;v+="\n ";w=o["if"].call(y,y.isFile,{hash:{},inverse:n.program(4,k,x),fn:n.program(2,l,x),data:x});if(w||w===0){v+=w}v+="\n ";return v}function l(y,x){var v="",w;v+='\n <input type="file" name=\'';if(w=o.name){w=w.call(y,{hash:{},data:x})}else{w=y.name;w=typeof w===d?w.apply(y):w}v+=c(w)+'\'/>\n <div class="parameter-content-type" />\n ';return v}function k(y,x){var v="",w;v+="\n ";w=o["if"].call(y,y["default"],{hash:{},inverse:n.program(7,h,x),fn:n.program(5,i,x),data:x});if(w||w===0){v+=w}v+="\n ";return v}function i(y,x){var v="",w;v+="\n <textarea class='body-textarea' name='";if(w=o.name){w=w.call(y,{hash:{},data:x})}else{w=y.name;w=typeof w===d?w.apply(y):w}v+=c(w)+"'>";if(w=o["default"]){w=w.call(y,{hash:{},data:x})}else{w=y["default"];w=typeof w===d?w.apply(y):w}v+=c(w)+"</textarea>\n ";return v}function h(y,x){var v="",w;v+="\n <textarea class='body-textarea' name='";if(w=o.name){w=w.call(y,{hash:{},data:x})}else{w=y.name;w=typeof w===d?w.apply(y):w}v+=c(w)+'\'></textarea>\n <br />\n <div class="parameter-content-type" />\n ';return v}function e(y,x){var v="",w;v+="\n ";w=o["if"].call(y,y.isFile,{hash:{},inverse:n.program(10,u,x),fn:n.program(2,l,x),data:x});if(w||w===0){v+=w}v+="\n ";return v}function u(y,x){var v="",w;v+="\n ";w=o["if"].call(y,y["default"],{hash:{},inverse:n.program(13,r,x),fn:n.program(11,s,x),data:x});if(w||w===0){v+=w}v+="\n ";return v}function s(y,x){var v="",w;v+="\n <input class='parameter' minlength='0' name='";if(w=o.name){w=w.call(y,{hash:{},data:x})}else{w=y.name;w=typeof w===d?w.apply(y):w}v+=c(w)+"' placeholder='' type='text' value='";if(w=o["default"]){w=w.call(y,{hash:{},data:x})}else{w=y["default"];w=typeof w===d?w.apply(y):w}v+=c(w)+"'/>\n ";return v}function r(y,x){var v="",w;v+="\n <input class='parameter' minlength='0' name='";if(w=o.name){w=w.call(y,{hash:{},data:x})}else{w=y.name;w=typeof w===d?w.apply(y):w}v+=c(w)+"' placeholder='' type='text' value=''/>\n ";return v}p+="<td class='code'>";if(g=o.name){g=g.call(q,{hash:{},data:t})}else{g=q.name;g=typeof g===d?g.apply(q):g}p+=c(g)+"</td>\n<td>\n\n ";g=o["if"].call(q,q.isBody,{hash:{},inverse:n.program(9,e,t),fn:n.program(1,m,t),data:t});if(g||g===0){p+=g}p+="\n\n</td>\n<td>";if(g=o.description){g=g.call(q,{hash:{},data:t})}else{g=q.description;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+="</td>\n<td>";if(g=o.paramType){g=g.call(q,{hash:{},data:t})}else{g=q.paramType;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+='</td>\n<td>\n <span class="model-signature"></span>\n</td>\n';return p})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_list=b(function(h,t,r,m,y){this.compilerInfo=[4,">= 1.0.0"];r=this.merge(r,h.helpers);y=y||{};var s="",j,g,e,p=this,q=r.helperMissing,d="function",c=this.escapeExpression;function o(A,z){return" multiple='multiple'"}function n(A,z){return"\n "}function l(C,B){var z="",A;z+="\n ";A=r["if"].call(C,C.defaultValue,{hash:{},inverse:p.program(8,i,B),fn:p.program(6,k,B),data:B});if(A||A===0){z+=A}z+="\n ";return z}function k(A,z){return"\n "}function i(E,D){var z="",C,B,A;z+="\n ";A={hash:{},inverse:p.program(11,x,D),fn:p.program(9,f,D),data:D};B=((C=r.isArray||E.isArray),C?C.call(E,E,A):q.call(E,"isArray",E,A));if(B||B===0){z+=B}z+="\n ";return z}function f(A,z){return"\n "}function x(A,z){return"\n <option selected=\"\" value=''></option>\n "}function w(C,B){var z="",A;z+="\n ";A=r["if"].call(C,C.isDefault,{hash:{},inverse:p.program(16,u,B),fn:p.program(14,v,B),data:B});if(A||A===0){z+=A}z+="\n ";return z}function v(C,B){var z="",A;z+='\n <option selected="" value=\'';if(A=r.value){A=A.call(C,{hash:{},data:B})}else{A=C.value;A=typeof A===d?A.apply(C):A}z+=c(A)+"'>";if(A=r.value){A=A.call(C,{hash:{},data:B})}else{A=C.value;A=typeof A===d?A.apply(C):A}z+=c(A)+" (default)</option>\n ";return z}function u(C,B){var z="",A;z+="\n <option value='";if(A=r.value){A=A.call(C,{hash:{},data:B})}else{A=C.value;A=typeof A===d?A.apply(C):A}z+=c(A)+"'>";if(A=r.value){A=A.call(C,{hash:{},data:B})}else{A=C.value;A=typeof A===d?A.apply(C):A}z+=c(A)+"</option>\n ";return z}s+="<td class='code'>";if(j=r.name){j=j.call(t,{hash:{},data:y})}else{j=t.name;j=typeof j===d?j.apply(t):j}s+=c(j)+"</td>\n<td>\n <select ";e={hash:{},inverse:p.noop,fn:p.program(1,o,y),data:y};g=((j=r.isArray||t.isArray),j?j.call(t,t,e):q.call(t,"isArray",t,e));if(g||g===0){s+=g}s+=" class='parameter' name='";if(g=r.name){g=g.call(t,{hash:{},data:y})}else{g=t.name;g=typeof g===d?g.apply(t):g}s+=c(g)+"'>\n ";g=r["if"].call(t,t.required,{hash:{},inverse:p.program(5,l,y),fn:p.program(3,n,y),data:y});if(g||g===0){s+=g}s+="\n ";g=r.each.call(t,((j=t.allowableValues),j==null||j===false?j:j.descriptiveValues),{hash:{},inverse:p.noop,fn:p.program(13,w,y),data:y});if(g||g===0){s+=g}s+="\n </select>\n</td>\n<td>";if(g=r.description){g=g.call(t,{hash:{},data:y})}else{g=t.description;g=typeof g===d?g.apply(t):g}if(g||g===0){s+=g}s+="</td>\n<td>";if(g=r.paramType){g=g.call(t,{hash:{},data:y})}else{g=t.paramType;g=typeof g===d?g.apply(t):g}if(g||g===0){s+=g}s+='</td>\n<td><span class="model-signature"></span></td>';return s})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly=b(function(g,m,f,l,k){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);k=k||{};var i="",d,h="function",j=this.escapeExpression,o=this;function e(t,s){var q="",r;q+="\n <textarea class='body-textarea' readonly='readonly' name='";if(r=f.name){r=r.call(t,{hash:{},data:s})}else{r=t.name;r=typeof r===h?r.apply(t):r}q+=j(r)+"'>";if(r=f.defaultValue){r=r.call(t,{hash:{},data:s})}else{r=t.defaultValue;r=typeof r===h?r.apply(t):r}q+=j(r)+"</textarea>\n ";return q}function c(t,s){var q="",r;q+="\n ";r=f["if"].call(t,t.defaultValue,{hash:{},inverse:o.program(6,n,s),fn:o.program(4,p,s),data:s});if(r||r===0){q+=r}q+="\n ";return q}function p(t,s){var q="",r;q+="\n ";if(r=f.defaultValue){r=r.call(t,{hash:{},data:s})}else{r=t.defaultValue;r=typeof r===h?r.apply(t):r}q+=j(r)+"\n ";return q}function n(r,q){return"\n (empty)\n "}i+="<td class='code'>";if(d=f.name){d=d.call(m,{hash:{},data:k})}else{d=m.name;d=typeof d===h?d.apply(m):d}i+=j(d)+"</td>\n<td>\n ";d=f["if"].call(m,m.isBody,{hash:{},inverse:o.program(3,c,k),fn:o.program(1,e,k),data:k});if(d||d===0){i+=d}i+="\n</td>\n<td>";if(d=f.description){d=d.call(m,{hash:{},data:k})}else{d=m.description;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+="</td>\n<td>";if(d=f.paramType){d=d.call(m,{hash:{},data:k})}else{d=m.paramType;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+='</td>\n<td><span class="model-signature"></span></td>\n';return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly_required=b(function(g,m,f,l,k){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);k=k||{};var i="",d,h="function",j=this.escapeExpression,o=this;function e(t,s){var q="",r;q+="\n <textarea class='body-textarea' readonly='readonly' placeholder='(required)' name='";if(r=f.name){r=r.call(t,{hash:{},data:s})}else{r=t.name;r=typeof r===h?r.apply(t):r}q+=j(r)+"'>";if(r=f.defaultValue){r=r.call(t,{hash:{},data:s})}else{r=t.defaultValue;r=typeof r===h?r.apply(t):r}q+=j(r)+"</textarea>\n ";return q}function c(t,s){var q="",r;q+="\n ";r=f["if"].call(t,t.defaultValue,{hash:{},inverse:o.program(6,n,s),fn:o.program(4,p,s),data:s});if(r||r===0){q+=r}q+="\n ";return q}function p(t,s){var q="",r;q+="\n ";if(r=f.defaultValue){r=r.call(t,{hash:{},data:s})}else{r=t.defaultValue;r=typeof r===h?r.apply(t):r}q+=j(r)+"\n ";return q}function n(r,q){return"\n (empty)\n "}i+="<td class='code required'>";if(d=f.name){d=d.call(m,{hash:{},data:k})}else{d=m.name;d=typeof d===h?d.apply(m):d}i+=j(d)+"</td>\n<td>\n ";d=f["if"].call(m,m.isBody,{hash:{},inverse:o.program(3,c,k),fn:o.program(1,e,k),data:k});if(d||d===0){i+=d}i+="\n</td>\n<td>";if(d=f.description){d=d.call(m,{hash:{},data:k})}else{d=m.description;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+="</td>\n<td>";if(d=f.paramType){d=d.call(m,{hash:{},data:k})}else{d=m.paramType;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+='</td>\n<td><span class="model-signature"></span></td>\n';return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_required=b(function(f,q,o,j,u){this.compilerInfo=[4,">= 1.0.0"];o=this.merge(o,f.helpers);u=u||{};var p="",g,d="function",c=this.escapeExpression,n=this;function m(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.isFile,{hash:{},inverse:n.program(4,k,y),fn:n.program(2,l,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function l(z,y){var w="",x;w+='\n <input type="file" name=\'';if(x=o.name){x=x.call(z,{hash:{},data:y})}else{x=z.name;x=typeof x===d?x.apply(z):x}w+=c(x)+"'/>\n ";return w}function k(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.defaultValue,{hash:{},inverse:n.program(7,h,y),fn:n.program(5,i,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function i(z,y){var w="",x;w+="\n <textarea class='body-textarea' placeholder='(required)' name='";if(x=o.name){x=x.call(z,{hash:{},data:y})}else{x=z.name;x=typeof x===d?x.apply(z):x}w+=c(x)+"'>";if(x=o.defaultValue){x=x.call(z,{hash:{},data:y})}else{x=z.defaultValue;x=typeof x===d?x.apply(z):x}w+=c(x)+"</textarea>\n ";return w}function h(z,y){var w="",x;w+="\n <textarea class='body-textarea' placeholder='(required)' name='";if(x=o.name){x=x.call(z,{hash:{},data:y})}else{x=z.name;x=typeof x===d?x.apply(z):x}w+=c(x)+'\'></textarea>\n <br />\n <div class="parameter-content-type" />\n ';return w}function e(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.isFile,{hash:{},inverse:n.program(12,t,y),fn:n.program(10,v,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function v(z,y){var w="",x;w+="\n <input class='parameter' class='required' type='file' name='";if(x=o.name){x=x.call(z,{hash:{},data:y})}else{x=z.name;x=typeof x===d?x.apply(z):x}w+=c(x)+"'/>\n ";return w}function t(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.defaultValue,{hash:{},inverse:n.program(15,r,y),fn:n.program(13,s,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function s(z,y){var w="",x;w+="\n <input class='parameter required' minlength='1' name='";if(x=o.name){x=x.call(z,{hash:{},data:y})}else{x=z.name;x=typeof x===d?x.apply(z):x}w+=c(x)+"' placeholder='(required)' type='text' value='";if(x=o.defaultValue){x=x.call(z,{hash:{},data:y})}else{x=z.defaultValue;x=typeof x===d?x.apply(z):x}w+=c(x)+"'/>\n ";return w}function r(z,y){var w="",x;w+="\n <input class='parameter required' minlength='1' name='";if(x=o.name){x=x.call(z,{hash:{},data:y})}else{x=z.name;x=typeof x===d?x.apply(z):x}w+=c(x)+"' placeholder='(required)' type='text' value=''/>\n ";return w}p+="<td class='code required'>";if(g=o.name){g=g.call(q,{hash:{},data:u})}else{g=q.name;g=typeof g===d?g.apply(q):g}p+=c(g)+"</td>\n<td>\n ";g=o["if"].call(q,q.isBody,{hash:{},inverse:n.program(9,e,u),fn:n.program(1,m,u),data:u});if(g||g===0){p+=g}p+="\n</td>\n<td>\n <strong>";if(g=o.description){g=g.call(q,{hash:{},data:u})}else{g=q.description;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+="</strong>\n</td>\n<td>";if(g=o.paramType){g=g.call(q,{hash:{},data:u})}else{g=q.paramType;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+='</td>\n<td><span class="model-signature"></span></td>\n';return p})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.parameter_content_type=b(function(g,l,f,k,j){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);j=j||{};var i="",c,h="function",m=this;function e(r,q){var o="",p;o+="\n ";p=f.each.call(r,r.consumes,{hash:{},inverse:m.noop,fn:m.program(2,d,q),data:q});if(p||p===0){o+=p}o+="\n";return o}function d(r,q){var o="",p;o+='\n <option value="';p=(typeof r===h?r.apply(r):r);if(p||p===0){o+=p}o+='">';p=(typeof r===h?r.apply(r):r);if(p||p===0){o+=p}o+="</option>\n ";return o}function n(p,o){return'\n <option value="application/json">application/json</option>\n'}i+='<label for="parameterContentType"></label>\n<select name="parameterContentType">\n';c=f["if"].call(l,l.consumes,{hash:{},inverse:m.program(4,n,j),fn:m.program(1,e,j),data:j});if(c||c===0){i+=c}i+="\n</select>\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.resource=b(function(g,m,f,l,k){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);k=k||{};var i="",d,p,h="function",j=this.escapeExpression,o=this,n=f.blockHelperMissing;function e(r,q){return" : "}function c(t,s){var q="",r;q+="<li>\n <a href='";if(r=f.url){r=r.call(t,{hash:{},data:s})}else{r=t.url;r=typeof r===h?r.apply(t):r}q+=j(r)+"'>Raw</a>\n </li>";return q}i+="<div class='heading'>\n <h2>\n <a href='#!/";if(d=f.id){d=d.call(m,{hash:{},data:k})}else{d=m.id;d=typeof d===h?d.apply(m):d}i+=j(d)+'\' class="toggleEndpointList" data-id="';if(d=f.id){d=d.call(m,{hash:{},data:k})}else{d=m.id;d=typeof d===h?d.apply(m):d}i+=j(d)+'">';if(d=f.name){d=d.call(m,{hash:{},data:k})}else{d=m.name;d=typeof d===h?d.apply(m):d}i+=j(d)+"</a> ";p={hash:{},inverse:o.noop,fn:o.program(1,e,k),data:k};if(d=f.summary){d=d.call(m,p)}else{d=m.summary;d=typeof d===h?d.apply(m):d}if(!f.summary){d=n.call(m,d,p)}if(d||d===0){i+=d}if(d=f.summary){d=d.call(m,{hash:{},data:k})}else{d=m.summary;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+="\n </h2>\n <ul class='options'>\n <li>\n <a href='#!/";if(d=f.id){d=d.call(m,{hash:{},data:k})}else{d=m.id;d=typeof d===h?d.apply(m):d}i+=j(d)+"' id='endpointListTogger_";if(d=f.id){d=d.call(m,{hash:{},data:k})}else{d=m.id;d=typeof d===h?d.apply(m):d}i+=j(d)+'\' class="toggleEndpointList" data-id="';if(d=f.id){d=d.call(m,{hash:{},data:k})}else{d=m.id;d=typeof d===h?d.apply(m):d}i+=j(d)+'">Show/Hide</a>\n </li>\n <li>\n <a href=\'#\' class="collapseResource" data-id="';if(d=f.id){d=d.call(m,{hash:{},data:k})}else{d=m.id;d=typeof d===h?d.apply(m):d}i+=j(d)+'">\n List Operations\n </a>\n </li>\n <li>\n <a href=\'#\' class="expandResource" data-id=';if(d=f.id){d=d.call(m,{hash:{},data:k})}else{d=m.id;d=typeof d===h?d.apply(m):d}i+=j(d)+">\n Expand Operations\n </a>\n </li>\n ";p={hash:{},inverse:o.noop,fn:o.program(3,c,k),data:k};if(d=f.url){d=d.call(m,p)}else{d=m.url;d=typeof d===h?d.apply(m):d}if(!f.url){d=n.call(m,d,p)}if(d||d===0){i+=d}i+="\n </ul>\n</div>\n<ul class='endpoints' id='";if(d=f.id){d=d.call(m,{hash:{},data:k})}else{d=m.id;d=typeof d===h?d.apply(m):d}i+=j(d)+"_endpoint_list' style='display:none'>\n\n</ul>\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.response_content_type=b(function(g,l,f,k,j){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);j=j||{};var i="",c,h="function",m=this;function e(r,q){var o="",p;o+="\n ";p=f.each.call(r,r.produces,{hash:{},inverse:m.noop,fn:m.program(2,d,q),data:q});if(p||p===0){o+=p}o+="\n";return o}function d(r,q){var o="",p;o+='\n <option value="';p=(typeof r===h?r.apply(r):r);if(p||p===0){o+=p}o+='">';p=(typeof r===h?r.apply(r):r);if(p||p===0){o+=p}o+="</option>\n ";return o}function n(p,o){return'\n <option value="application/json">application/json</option>\n'}i+='<label for="responseContentType"></label>\n<select name="responseContentType">\n';c=f["if"].call(l,l.produces,{hash:{},inverse:m.program(4,n,j),fn:m.program(1,e,j),data:j});if(c||c===0){i+=c}i+="\n</select>\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.signature=b(function(e,k,d,j,i){this.compilerInfo=[4,">= 1.0.0"];d=this.merge(d,e.helpers);i=i||{};var g="",c,f="function",h=this.escapeExpression;g+='<div>\n<ul class="signature-nav">\n <li><a class="description-link" href="#">Model</a></li>\n <li><a class="snippet-link" href="#">Model Schema</a></li>\n</ul>\n<div>\n\n<div class="signature-container">\n <div class="description">\n ';if(c=d.signature){c=c.call(k,{hash:{},data:i})}else{c=k.signature;c=typeof c===f?c.apply(k):c}if(c||c===0){g+=c}g+='\n </div>\n\n <div class="snippet">\n <pre><code>';if(c=d.sampleJSON){c=c.call(k,{hash:{},data:i})}else{c=k.sampleJSON;c=typeof c===f?c.apply(k):c}g+=h(c)+'</code></pre>\n <small class="notice"></small>\n </div>\n</div>\n\n';return g})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.status_code=b(function(e,k,d,j,i){this.compilerInfo=[4,">= 1.0.0"];d=this.merge(d,e.helpers);i=i||{};var g="",c,f="function",h=this.escapeExpression;g+="<td width='15%' class='code'>";if(c=d.code){c=c.call(k,{hash:{},data:i})}else{c=k.code;c=typeof c===f?c.apply(k):c}g+=h(c)+"</td>\n<td>";if(c=d.message){c=c.call(k,{hash:{},data:i})}else{c=k.message;c=typeof c===f?c.apply(k):c}if(c||c===0){g+=c}g+="</td>\n<td width='50%'><span class=\"model-signature\" /></td>";return g})})();(function(){var j,r,u,o,l,k,n,m,i,p,s,q,h,c,g,f,e,d,b,a,x,w,t={}.hasOwnProperty,v=function(B,z){for(var y in z){if(t.call(z,y)){B[y]=z[y]}}function A(){this.constructor=B}A.prototype=z.prototype;B.prototype=new A();B.__super__=z.prototype;return B};s=(function(z){v(y,z);function y(){q=y.__super__.constructor.apply(this,arguments);return q}y.prototype.dom_id="swagger_ui";y.prototype.options=null;y.prototype.api=null;y.prototype.headerView=null;y.prototype.mainView=null;y.prototype.initialize=function(A){var B=this;if(A==null){A={}}if(A.dom_id!=null){this.dom_id=A.dom_id;delete A.dom_id}if($("#"+this.dom_id)==null){$("body").append('<div id="'+this.dom_id+'"></div>')}this.options=A;this.options.success=function(){return B.render()};this.options.progress=function(C){return B.showMessage(C)};this.options.failure=function(C){if(B.api&&B.api.isValid===false){log("not a valid 2.0 spec, loading legacy client");B.api=new SwaggerApi(B.options);return B.api.build()}else{return B.onLoadFailure(C)}};this.headerView=new r({el:$("#header")});return this.headerView.on("update-swagger-ui",function(C){return B.updateSwaggerUi(C)})};y.prototype.updateSwaggerUi=function(A){this.options.url=A.url;return this.load()};y.prototype.load=function(){var B,A;if((A=this.mainView)!=null){A.clear()}B=this.options.url;if(B.indexOf("http")!==0){B=this.buildUrl(window.location.href.toString(),B)}this.options.url=B;this.headerView.update(B);this.api=new SwaggerClient(this.options);return this.api.build()};y.prototype.render=function(){var A=this;this.showMessage("Finished Loading Resource Information. Rendering Swagger UI...");this.mainView=new u({model:this.api,el:$("#"+this.dom_id),swaggerOptions:this.options}).render();this.showMessage();switch(this.options.docExpansion){case"full":Docs.expandOperationsForResource("");break;case"list":Docs.collapseOperationsForResource("")}if(this.options.onComplete){this.options.onComplete(this.api,this)}return setTimeout(function(){return Docs.shebang()},400)};y.prototype.buildUrl=function(C,A){var B,D;log("base is "+C);if(A.indexOf("/")===0){D=C.split("/");C=D[0]+"//"+D[2];return C+A}else{B=C.length;if(C.indexOf("?")>-1){B=Math.min(B,C.indexOf("?"))}if(C.indexOf("#")>-1){B=Math.min(B,C.indexOf("#"))}C=C.substring(0,B);if(C.indexOf("/",C.length-1)!==-1){return C+A}return C+"/"+A}};y.prototype.showMessage=function(A){if(A==null){A=""}$("#message-bar").removeClass("message-fail");$("#message-bar").addClass("message-success");return $("#message-bar").html(A)};y.prototype.onLoadFailure=function(A){var B;if(A==null){A=""}$("#message-bar").removeClass("message-success");$("#message-bar").addClass("message-fail");B=$("#message-bar").html(A);if(this.options.onFailure!=null){this.options.onFailure(A)}return B};return y})(Backbone.Router);window.SwaggerUi=s;r=(function(z){v(y,z);function y(){h=y.__super__.constructor.apply(this,arguments);return h}y.prototype.events={"click #show-pet-store-icon":"showPetStore","click #show-wordnik-dev-icon":"showWordnikDev","click #explore":"showCustom","keyup #input_baseUrl":"showCustomOnKeyup","keyup #input_apiKey":"showCustomOnKeyup"};y.prototype.initialize=function(){};y.prototype.showPetStore=function(A){return this.trigger("update-swagger-ui",{url:"http://petstore.swagger.wordnik.com/api/api-docs"})};y.prototype.showWordnikDev=function(A){return this.trigger("update-swagger-ui",{url:"http://api.wordnik.com/v4/resources.json"})};y.prototype.showCustomOnKeyup=function(A){if(A.keyCode===13){return this.showCustom()}};y.prototype.showCustom=function(A){if(A!=null){A.preventDefault()}return this.trigger("update-swagger-ui",{url:$("#input_baseUrl").val(),apiKey:$("#input_apiKey").val()})};y.prototype.update=function(B,C,A){if(A==null){A=false}$("#input_baseUrl").val(B);if(A){return this.trigger("update-swagger-ui",{url:B})}};return y})(Backbone.View);u=(function(y){var z;v(A,y);function A(){g=A.__super__.constructor.apply(this,arguments);return g}z={alpha:function(C,B){return C.path.localeCompare(B.path)},method:function(C,B){return C.method.localeCompare(B.method)}};A.prototype.initialize=function(B){var C,I,J,E,D,G,H,F;if(B==null){B={}}if(B.swaggerOptions.sorter){E=B.swaggerOptions.sorter;J=z[E];if(this.model.apisArray){F=this.model.apisArray;for(G=0,H=F.length;G<H;G++){I=F[G];I.operationsArray.sort(J)}if(E==="alpha"){this.model.apisArray.sort(J)}}}if(this.model.info&&this.model.info.license&&typeof this.model.info.license==="string"){C=this.model.info.license;D=this.model.info.licenseUrl;this.model.info.license={};this.model.info.license.name=C;this.model.info.license.url=D}if(!this.model.info){this.model.info={}}if(!this.model.info.version){this.model.info.version=this.model.apiVersion}if(this.model.url.indexOf("http://localhost")===-1&&this.model.swaggerVersion===2){return this.model.validatorUrl=this.model.url}};A.prototype.render=function(){var C,H,E,F,D,B,G;$(this.el).html(Handlebars.templates.main(this.model));F={};C=0;G=this.model.apisArray;for(D=0,B=G.length;D<B;D++){E=G[D];H=E.name;while(typeof F[H]!=="undefined"){H=H+"_"+C;C+=1}E.id=H;F[H]=E;this.addResource(E)}return this};A.prototype.addResource=function(C){var B;C.id=C.id.replace(/\s/g,"_");B=new n({model:C,tagName:"li",id:"resource_"+C.id,className:"resource",swaggerOptions:this.options.swaggerOptions});return $("#resources").append(B.render().el)};A.prototype.clear=function(){return $(this.el).html("")};return A})(Backbone.View);n=(function(z){v(y,z);function y(){f=y.__super__.constructor.apply(this,arguments);return f}y.prototype.initialize=function(){if(""===this.model.description){return this.model.description=null}};y.prototype.render=function(){var B,G,D,C,E,A,F;$(this.el).html(Handlebars.templates.resource(this.model));D={};if(this.model.description){this.model.summary=this.model.description}F=this.model.operationsArray;for(E=0,A=F.length;E<A;E++){C=F[E];B=0;G=C.nickname;while(typeof D[G]!=="undefined"){G=G+"_"+B;B+=1}D[G]=C;C.nickname=G;C.parentId=this.model.id;this.addOperation(C)}$(".toggleEndpointList",this.el).click(this.callDocs.bind(this,"toggleEndpointListForResource"));$(".collapseResource",this.el).click(this.callDocs.bind(this,"collapseOperationsForResource"));$(".expandResource",this.el).click(this.callDocs.bind(this,"expandOperationsForResource"));return this};y.prototype.addOperation=function(A){var B;A.number=this.number;B=new o({model:A,tagName:"li",className:"endpoint",swaggerOptions:this.options.swaggerOptions});$(".endpoints",$(this.el)).append(B.render().el);return this.number++};y.prototype.callDocs=function(B,A){A.preventDefault();return Docs[B](A.currentTarget.getAttribute("data-id"))};return y})(Backbone.View);o=(function(z){v(y,z);function y(){e=y.__super__.constructor.apply(this,arguments);return e}y.prototype.invocationUrl=null;y.prototype.events={"submit .sandbox":"submitOperation","click .submit":"submitOperation","click .response_hider":"hideResponse","click .toggleOperation":"toggleOperationContent","mouseenter .api-ic":"mouseEnter","mouseout .api-ic":"mouseExit"};y.prototype.initialize=function(){};y.prototype.mouseEnter=function(F){var D,E,I,B,A,J,G,C,K,H;D=$(F.currentTarget.parentNode).find("#api_information_panel");K=F.pageX;H=F.pageY;J=$(window).scrollLeft();G=$(window).scrollTop();B=J+$(window).width();A=G+$(window).height();C=D.width();E=D.height();if(K+C>B){K=B-C}if(K<J){K=J}if(H+E>A){H=A-E}if(H<G){H=G}I={};I.top=H;I.left=K;D.css(I);return $(F.currentTarget.parentNode).find("#api_information_panel").show()};y.prototype.mouseExit=function(A){return $(A.currentTarget.parentNode).find("#api_information_panel").hide()};y.prototype.render=function(){var D,U,V,T,R,K,J,Q,L,P,W,O,M,I,N,S,H,G,F,C,Y,ab,Z,X,E,B,A,ac,aa;V=true;if(!V){this.model.isReadOnly=true}this.model.description=this.model.description||this.model.notes;if(this.model.description){this.model.description=this.model.description.replace(/(?:\r\n|\r|\n)/g,"<br />")}this.model.oauth=null;if(this.model.authorizations){E=this.model.authorizations;for(T in E){N=E[T];if(T==="oauth2"){if(this.model.oauth===null){this.model.oauth={}}if(this.model.oauth.scopes===void 0){this.model.oauth.scopes=[]}for(H=0,Y=N.length;H<Y;H++){R=N[H];this.model.oauth.scopes.push(R)}}}}if(typeof this.model.responses!=="undefined"){this.model.responseMessages=[];B=this.model.responses;for(D in B){S=B[D];P=null;W=this.model.responses[D].schema;if(W&&W["$ref"]){P=W["$ref"];if(P.indexOf("#/definitions/")===0){P=P.substring("#/definitions/".length)}}this.model.responseMessages.push({code:D,message:S.description,responseModel:P})}}if(typeof this.model.responseMessages==="undefined"){this.model.responseMessages=[]}$(this.el).html(Handlebars.templates.operation(this.model));if(this.model.responseClassSignature&&this.model.responseClassSignature!=="string"){O={sampleJSON:this.model.responseSampleJSON,isParam:false,signature:this.model.responseClassSignature};L=new i({model:O,tagName:"div"});$(".model-signature",$(this.el)).append(L.render().el)}else{this.model.responseClassSignature="string";$(".model-signature",$(this.el)).html(this.model.type)}U={isParam:false};U.consumes=this.model.consumes;U.produces=this.model.produces;A=this.model.parameters;for(G=0,ab=A.length;G<ab;G++){K=A[G];I=K.type||K.dataType;if(typeof I==="undefined"){P=K.schema;if(P&&P["$ref"]){J=P["$ref"];if(J.indexOf("#/definitions/")===0){I=J.substring("#/definitions/".length)}else{I=J}}}if(I&&I.toLowerCase()==="file"){if(!U.consumes){U.consumes="multipart/form-data"}}K.type=I}Q=new m({model:U});$(".response-content-type",$(this.el)).append(Q.render().el);ac=this.model.parameters;for(F=0,Z=ac.length;F<Z;F++){K=ac[F];this.addParameter(K,U.consumes)}aa=this.model.responseMessages;for(C=0,X=aa.length;C<X;C++){M=aa[C];this.addStatusCode(M)}return this};y.prototype.addParameter=function(C,A){var B;C.consumes=A;B=new k({model:C,tagName:"tr",readOnly:this.model.isReadOnly});return $(".operation-params",$(this.el)).append(B.render().el)};y.prototype.addStatusCode=function(B){var A;A=new p({model:B,tagName:"tr"});return $(".operation-status",$(this.el)).append(A.render().el)};y.prototype.submitOperation=function(O){var Q,G,N,D,I,A,J,M,L,K,P,F,C,H,E,B;if(O!=null){O.preventDefault()}G=$(".sandbox",$(this.el));Q=true;G.find("input.required").each(function(){var R=this;$(this).removeClass("error");if(jQuery.trim($(this).val())===""){$(this).addClass("error");$(this).wiggle({callback:function(){return $(R).focus()}});return Q=false}});if(Q){D={};A={parent:this};N=false;H=G.find("input");for(M=0,P=H.length;M<P;M++){I=H[M];if((I.value!=null)&&jQuery.trim(I.value).length>0){D[I.name]=I.value}if(I.type==="file"){N=true}}E=G.find("textarea");for(L=0,F=E.length;L<F;L++){I=E[L];if((I.value!=null)&&jQuery.trim(I.value).length>0){D.body=I.value}}B=G.find("select");for(K=0,C=B.length;K<C;K++){I=B[K];J=this.getSelectedValue(I);if((J!=null)&&jQuery.trim(J).length>0){D[I.name]=J}}A.responseContentType=$("div select[name=responseContentType]",$(this.el)).val();A.requestContentType=$("div select[name=parameterContentType]",$(this.el)).val();$(".response_throbber",$(this.el)).show();if(N){return this.handleFileUpload(D,G)}else{return this.model["do"](D,A,this.showCompleteStatus,this.showErrorStatus,this)}}};y.prototype.success=function(A,B){return B.showCompleteStatus(A)};y.prototype.handleFileUpload=function(R,I){var M,H,C,N,L,K,P,J,G,F,D,Q,U,T,S,E,B,A,V,O=this;E=I.serializeArray();for(J=0,Q=E.length;J<Q;J++){N=E[J];if((N.value!=null)&&jQuery.trim(N.value).length>0){R[N.name]=N.value}}M=new FormData();P=0;B=this.model.parameters;for(G=0,U=B.length;G<U;G++){K=B[G];if(K.paramType==="form"){if(K.type.toLowerCase()!=="file"&&R[K.name]!==void 0){M.append(K.name,R[K.name])}}}C={};A=this.model.parameters;for(F=0,T=A.length;F<T;F++){K=A[F];if(K.paramType==="header"){C[K.name]=R[K.name]}}V=I.find('input[type~="file"]');for(D=0,S=V.length;D<S;D++){H=V[D];if(typeof H.files[0]!=="undefined"){M.append($(H).attr("name"),H.files[0]);P+=1}}this.invocationUrl=this.model.supportHeaderParams()?(C=this.model.getHeaderParams(R),this.model.urlify(R,false)):this.model.urlify(R,true);$(".request_url",$(this.el)).html("<pre></pre>");$(".request_url pre",$(this.el)).text(this.invocationUrl);L={type:this.model.method,url:this.invocationUrl,headers:C,data:M,dataType:"json",contentType:false,processData:false,error:function(X,Y,W){return O.showErrorStatus(O.wrap(X),O)},success:function(W){return O.showResponse(W,O)},complete:function(W){return O.showCompleteStatus(O.wrap(W),O)}};if(window.authorizations){window.authorizations.apply(L)}if(P===0){L.data.append("fake","true")}jQuery.ajax(L);return false};y.prototype.wrap=function(E){var C,F,H,B,G,D,A;H={};F=E.getAllResponseHeaders().split("\r");for(D=0,A=F.length;D<A;D++){B=F[D];C=B.split(":");if(C[0]!==void 0&&C[1]!==void 0){H[C[0].trim()]=C[1].trim()}}G={};G.content={};G.content.data=E.responseText;G.headers=H;G.request={};G.request.url=this.invocationUrl;G.status=E.status;return G};y.prototype.getSelectedValue=function(A){var D,C,F,B,E;if(!A.multiple){return A.value}else{C=[];E=A.options;for(F=0,B=E.length;F<B;F++){D=E[F];if(D.selected){C.push(D.value)}}if(C.length>0){return C.join(",")}else{return null}}};y.prototype.hideResponse=function(A){if(A!=null){A.preventDefault()}$(".response",$(this.el)).slideUp();return $(".response_hider",$(this.el)).fadeOut()};y.prototype.showResponse=function(A){var B;B=JSON.stringify(A,null,"\t").replace(/\n/g,"<br>");return $(".response_body",$(this.el)).html(escape(B))};y.prototype.showErrorStatus=function(B,A){return A.showStatus(B)};y.prototype.showCompleteStatus=function(B,A){return A.showStatus(B)};y.prototype.formatXml=function(H){var D,G,B,I,N,J,C,A,L,M,F,E,K;A=/(>)(<)(\/*)/g;M=/[ ]*(.*)[ ]+\n/g;D=/(<.+>)(.+\n)/g;H=H.replace(A,"$1\n$2$3").replace(M,"$1\n").replace(D,"$1\n$2");C=0;G="";N=H.split("\n");B=0;I="other";L={"single->single":0,"single->closing":-1,"single->opening":0,"single->other":0,"closing->single":0,"closing->closing":-1,"closing->opening":0,"closing->other":0,"opening->single":1,"opening->closing":0,"opening->opening":1,"opening->other":1,"other->single":0,"other->closing":-1,"other->opening":0,"other->other":0};F=function(T){var P,O,R,V,S,Q,U;Q={single:Boolean(T.match(/<.+\/>/)),closing:Boolean(T.match(/<\/.+>/)),opening:Boolean(T.match(/<[^!?].*>/))};S=((function(){var W;W=[];for(R in Q){U=Q[R];if(U){W.push(R)}}return W})())[0];S=S===void 0?"other":S;P=I+"->"+S;I=S;V="";B+=L[P];V=((function(){var X,Y,W;W=[];for(O=X=0,Y=B;0<=Y?X<Y:X>Y;O=0<=Y?++X:--X){W.push(" ")}return W})()).join("");if(P==="opening->closing"){return G=G.substr(0,G.length-1)+T+"\n"}else{return G+=V+T+"\n"}};for(E=0,K=N.length;E<K;E++){J=N[E];F(J)}return G};y.prototype.showStatus=function(F){var C,J,L,I,D,M,A,E,H,G,B;if(F.content===void 0){J=F.data;B=F.url}else{J=F.content.data;B=F.request.url}D=F.headers;L=D&&D["Content-Type"]?D["Content-Type"].split(";")[0].trim():null;if(!J){C=$("<code />").text("no content");E=$('<pre class="json" />').append(C)}else{if(L==="application/json"||/\+json$/.test(L)){M=null;try{M=JSON.stringify(JSON.parse(J),null," ")}catch(K){I=K;M="can't parse JSON. Raw result:\n\n"+J}C=$("<code />").text(M);E=$('<pre class="json" />').append(C)}else{if(L==="application/xml"||/\+xml$/.test(L)){C=$("<code />").text(this.formatXml(J));E=$('<pre class="xml" />').append(C)}else{if(L==="text/html"){C=$("<code />").html(_.escape(J));E=$('<pre class="xml" />').append(C)}else{if(/^image\//.test(L)){E=$("<img>").attr("src",B)}else{C=$("<code />").text(J);E=$('<pre class="json" />').append(C)}}}}}H=E;$(".request_url",$(this.el)).html("<pre></pre>");$(".request_url pre",$(this.el)).text(B);$(".response_code",$(this.el)).html("<pre>"+F.status+"</pre>");$(".response_body",$(this.el)).html(H);$(".response_headers",$(this.el)).html("<pre>"+_.escape(JSON.stringify(F.headers,null," ")).replace(/\n/g,"<br>")+"</pre>");$(".response",$(this.el)).slideDown();$(".response_hider",$(this.el)).show();$(".response_throbber",$(this.el)).hide();G=$(".response_body",$(this.el))[0];A=this.options.swaggerOptions;if(A.highlightSizeThreshold&&F.data.length>A.highlightSizeThreshold){return G}else{return hljs.highlightBlock(G)}};y.prototype.toggleOperationContent=function(){var A;A=$("#"+Docs.escapeResourceName(this.model.parentId)+"_"+this.model.nickname+"_content");if(A.is(":visible")){return Docs.collapseOperation(A)}else{return Docs.expandOperation(A)}};return y})(Backbone.View);p=(function(z){v(y,z);function y(){d=y.__super__.constructor.apply(this,arguments);return d}y.prototype.initialize=function(){};y.prototype.render=function(){var B,A,C;C=this.template();$(this.el).html(C(this.model));if(swaggerUi.api.models.hasOwnProperty(this.model.responseModel)){B={sampleJSON:JSON.stringify(swaggerUi.api.models[this.model.responseModel].createJSONSample(),null,2),isParam:false,signature:swaggerUi.api.models[this.model.responseModel].getMockSignature()};A=new i({model:B,tagName:"div"});$(".model-signature",this.$el).append(A.render().el)}else{$(".model-signature",this.$el).html("")}return this};y.prototype.template=function(){return Handlebars.templates.status_code};return y})(Backbone.View);k=(function(z){v(y,z);function y(){b=y.__super__.constructor.apply(this,arguments);return b}y.prototype.initialize=function(){return Handlebars.registerHelper("isArray",function(B,A){if(B.type.toLowerCase()==="array"||B.allowMultiple){return A.fn(this)}else{return A.inverse(this)}})};y.prototype.render=function(){var A,B,E,C,F,D,I,J,H,G;G=this.model.type||this.model.dataType;if(typeof G==="undefined"){D=this.model.schema;if(D&&D["$ref"]){C=D["$ref"];if(C.indexOf("#/definitions/")===0){G=C.substring("#/definitions/".length)}else{G=C}}}this.model.type=G;this.model.paramType=this.model["in"]||this.model.paramType;if(this.model.paramType==="body"){this.model.isBody=true}if(G&&G.toLowerCase()==="file"){this.model.isFile=true}this.model["default"]=this.model["default"]||this.model.defaultValue;H=this.template();$(this.el).html(H(this.model));I={sampleJSON:this.model.sampleJSON,isParam:true,signature:this.model.signature};if(this.model.sampleJSON){J=new i({model:I,tagName:"div"});$(".model-signature",$(this.el)).append(J.render().el)}else{$(".model-signature",$(this.el)).html(this.model.signature)}B=false;if(this.model.isBody){B=true}A={isParam:B};A.consumes=this.model.consumes;if(B){E=new l({model:A});$(".parameter-content-type",$(this.el)).append(E.render().el)}else{F=new m({model:A});$(".response-content-type",$(this.el)).append(F.render().el)}return this};y.prototype.template=function(){if(this.model.isList){return Handlebars.templates.param_list}else{if(this.options.readOnly){if(this.model.required){return Handlebars.templates.param_readonly_required}else{return Handlebars.templates.param_readonly}}else{if(this.model.required){return Handlebars.templates.param_required}else{return Handlebars.templates.param}}}};return y})(Backbone.View);i=(function(z){v(y,z);function y(){a=y.__super__.constructor.apply(this,arguments);return a}y.prototype.events={"click a.description-link":"switchToDescription","click a.snippet-link":"switchToSnippet","mousedown .snippet":"snippetToTextArea"};y.prototype.initialize=function(){};y.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));this.switchToSnippet();this.isParam=this.model.isParam;if(this.isParam){$(".notice",$(this.el)).text("Click to set as parameter value")}return this};y.prototype.template=function(){return Handlebars.templates.signature};y.prototype.switchToDescription=function(A){if(A!=null){A.preventDefault()}$(".snippet",$(this.el)).hide();$(".description",$(this.el)).show();$(".description-link",$(this.el)).addClass("selected");return $(".snippet-link",$(this.el)).removeClass("selected")};y.prototype.switchToSnippet=function(A){if(A!=null){A.preventDefault()}$(".description",$(this.el)).hide();$(".snippet",$(this.el)).show();$(".snippet-link",$(this.el)).addClass("selected");return $(".description-link",$(this.el)).removeClass("selected")};y.prototype.snippetToTextArea=function(A){var B;if(this.isParam){if(A!=null){A.preventDefault()}B=$("textarea",$(this.el.parentNode.parentNode.parentNode));if($.trim(B.val())===""){return B.val(this.model.sampleJSON)}}};return y})(Backbone.View);j=(function(y){v(z,y);function z(){x=z.__super__.constructor.apply(this,arguments);return x}z.prototype.initialize=function(){};z.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));$("label[for=contentType]",$(this.el)).text("Response Content Type");return this};z.prototype.template=function(){return Handlebars.templates.content_type};return z})(Backbone.View);m=(function(y){v(z,y);function z(){w=z.__super__.constructor.apply(this,arguments);return w}z.prototype.initialize=function(){};z.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));$("label[for=responseContentType]",$(this.el)).text("Response Content Type");return this};z.prototype.template=function(){return Handlebars.templates.response_content_type};return z})(Backbone.View);l=(function(z){v(y,z);function y(){c=y.__super__.constructor.apply(this,arguments);return c}y.prototype.initialize=function(){};y.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));$("label[for=parameterContentType]",$(this.el)).text("Parameter content type:");return this};y.prototype.template=function(){return Handlebars.templates.parameter_content_type};return y})(Backbone.View)}).call(this);
\ No newline at end of file
diff --git a/profiles/killbill/src/main/webapp/lib/underscore-min.js b/profiles/killbill/src/main/webapp/lib/underscore-min.js
new file mode 100644
index 0000000..5a0cb3b
--- /dev/null
+++ b/profiles/killbill/src/main/webapp/lib/underscore-min.js
@@ -0,0 +1,32 @@
+// Underscore.js 1.3.3
+// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
+// Underscore is freely distributable under the MIT license.
+// Portions of Underscore are inspired or borrowed from Prototype,
+// Oliver Steele's Functional, and John Resig's Micro-Templating.
+// For all details and documentation:
+// http://documentcloud.github.com/underscore
+(function(){function r(a,c,d){if(a===c)return 0!==a||1/a==1/c;if(null==a||null==c)return a===c;a._chain&&(a=a._wrapped);c._chain&&(c=c._wrapped);if(a.isEqual&&b.isFunction(a.isEqual))return a.isEqual(c);if(c.isEqual&&b.isFunction(c.isEqual))return c.isEqual(a);var e=l.call(a);if(e!=l.call(c))return!1;switch(e){case "[object String]":return a==""+c;case "[object Number]":return a!=+a?c!=+c:0==a?1/a==1/c:a==+c;case "[object Date]":case "[object Boolean]":return+a==+c;case "[object RegExp]":return a.source==
+c.source&&a.global==c.global&&a.multiline==c.multiline&&a.ignoreCase==c.ignoreCase}if("object"!=typeof a||"object"!=typeof c)return!1;for(var f=d.length;f--;)if(d[f]==a)return!0;d.push(a);var f=0,g=!0;if("[object Array]"==e){if(f=a.length,g=f==c.length)for(;f--&&(g=f in a==f in c&&r(a[f],c[f],d)););}else{if("constructor"in a!="constructor"in c||a.constructor!=c.constructor)return!1;for(var h in a)if(b.has(a,h)&&(f++,!(g=b.has(c,h)&&r(a[h],c[h],d))))break;if(g){for(h in c)if(b.has(c,h)&&!f--)break;
+g=!f}}d.pop();return g}var s=this,I=s._,o={},k=Array.prototype,p=Object.prototype,i=k.slice,J=k.unshift,l=p.toString,K=p.hasOwnProperty,y=k.forEach,z=k.map,A=k.reduce,B=k.reduceRight,C=k.filter,D=k.every,E=k.some,q=k.indexOf,F=k.lastIndexOf,p=Array.isArray,L=Object.keys,t=Function.prototype.bind,b=function(a){return new m(a)};"undefined"!==typeof exports?("undefined"!==typeof module&&module.exports&&(exports=module.exports=b),exports._=b):s._=b;b.VERSION="1.3.3";var j=b.each=b.forEach=function(a,
+c,d){if(a!=null)if(y&&a.forEach===y)a.forEach(c,d);else if(a.length===+a.length)for(var e=0,f=a.length;e<f;e++){if(e in a&&c.call(d,a[e],e,a)===o)break}else for(e in a)if(b.has(a,e)&&c.call(d,a[e],e,a)===o)break};b.map=b.collect=function(a,c,b){var e=[];if(a==null)return e;if(z&&a.map===z)return a.map(c,b);j(a,function(a,g,h){e[e.length]=c.call(b,a,g,h)});if(a.length===+a.length)e.length=a.length;return e};b.reduce=b.foldl=b.inject=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(A&&
+a.reduce===A){e&&(c=b.bind(c,e));return f?a.reduce(c,d):a.reduce(c)}j(a,function(a,b,i){if(f)d=c.call(e,d,a,b,i);else{d=a;f=true}});if(!f)throw new TypeError("Reduce of empty array with no initial value");return d};b.reduceRight=b.foldr=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(B&&a.reduceRight===B){e&&(c=b.bind(c,e));return f?a.reduceRight(c,d):a.reduceRight(c)}var g=b.toArray(a).reverse();e&&!f&&(c=b.bind(c,e));return f?b.reduce(g,c,d,e):b.reduce(g,c)};b.find=b.detect=function(a,
+c,b){var e;G(a,function(a,g,h){if(c.call(b,a,g,h)){e=a;return true}});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(C&&a.filter===C)return a.filter(c,b);j(a,function(a,g,h){c.call(b,a,g,h)&&(e[e.length]=a)});return e};b.reject=function(a,c,b){var e=[];if(a==null)return e;j(a,function(a,g,h){c.call(b,a,g,h)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=true;if(a==null)return e;if(D&&a.every===D)return a.every(c,b);j(a,function(a,g,h){if(!(e=e&&c.call(b,
+a,g,h)))return o});return!!e};var G=b.some=b.any=function(a,c,d){c||(c=b.identity);var e=false;if(a==null)return e;if(E&&a.some===E)return a.some(c,d);j(a,function(a,b,h){if(e||(e=c.call(d,a,b,h)))return o});return!!e};b.include=b.contains=function(a,c){var b=false;if(a==null)return b;if(q&&a.indexOf===q)return a.indexOf(c)!=-1;return b=G(a,function(a){return a===c})};b.invoke=function(a,c){var d=i.call(arguments,2);return b.map(a,function(a){return(b.isFunction(c)?c||a:a[c]).apply(a,d)})};b.pluck=
+function(a,c){return b.map(a,function(a){return a[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a)&&a[0]===+a[0])return Math.max.apply(Math,a);if(!c&&b.isEmpty(a))return-Infinity;var e={computed:-Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a)&&a[0]===+a[0])return Math.min.apply(Math,a);if(!c&&b.isEmpty(a))return Infinity;var e={computed:Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b<e.computed&&
+(e={value:a,computed:b})});return e.value};b.shuffle=function(a){var b=[],d;j(a,function(a,f){d=Math.floor(Math.random()*(f+1));b[f]=b[d];b[d]=a});return b};b.sortBy=function(a,c,d){var e=b.isFunction(c)?c:function(a){return a[c]};return b.pluck(b.map(a,function(a,b,c){return{value:a,criteria:e.call(d,a,b,c)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;return c===void 0?1:d===void 0?-1:c<d?-1:c>d?1:0}),"value")};b.groupBy=function(a,c){var d={},e=b.isFunction(c)?c:function(a){return a[c]};
+j(a,function(a,b){var c=e(a,b);(d[c]||(d[c]=[])).push(a)});return d};b.sortedIndex=function(a,c,d){d||(d=b.identity);for(var e=0,f=a.length;e<f;){var g=e+f>>1;d(a[g])<d(c)?e=g+1:f=g}return e};b.toArray=function(a){return!a?[]:b.isArray(a)||b.isArguments(a)?i.call(a):a.toArray&&b.isFunction(a.toArray)?a.toArray():b.values(a)};b.size=function(a){return b.isArray(a)?a.length:b.keys(a).length};b.first=b.head=b.take=function(a,b,d){return b!=null&&!d?i.call(a,0,b):a[0]};b.initial=function(a,b,d){return i.call(a,
+0,a.length-(b==null||d?1:b))};b.last=function(a,b,d){return b!=null&&!d?i.call(a,Math.max(a.length-b,0)):a[a.length-1]};b.rest=b.tail=function(a,b,d){return i.call(a,b==null||d?1:b)};b.compact=function(a){return b.filter(a,function(a){return!!a})};b.flatten=function(a,c){return b.reduce(a,function(a,e){if(b.isArray(e))return a.concat(c?e:b.flatten(e));a[a.length]=e;return a},[])};b.without=function(a){return b.difference(a,i.call(arguments,1))};b.uniq=b.unique=function(a,c,d){var d=d?b.map(a,d):a,
+e=[];a.length<3&&(c=true);b.reduce(d,function(d,g,h){if(c?b.last(d)!==g||!d.length:!b.include(d,g)){d.push(g);e.push(a[h])}return d},[]);return e};b.union=function(){return b.uniq(b.flatten(arguments,true))};b.intersection=b.intersect=function(a){var c=i.call(arguments,1);return b.filter(b.uniq(a),function(a){return b.every(c,function(c){return b.indexOf(c,a)>=0})})};b.difference=function(a){var c=b.flatten(i.call(arguments,1),true);return b.filter(a,function(a){return!b.include(c,a)})};b.zip=function(){for(var a=
+i.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),e=0;e<c;e++)d[e]=b.pluck(a,""+e);return d};b.indexOf=function(a,c,d){if(a==null)return-1;var e;if(d){d=b.sortedIndex(a,c);return a[d]===c?d:-1}if(q&&a.indexOf===q)return a.indexOf(c);d=0;for(e=a.length;d<e;d++)if(d in a&&a[d]===c)return d;return-1};b.lastIndexOf=function(a,b){if(a==null)return-1;if(F&&a.lastIndexOf===F)return a.lastIndexOf(b);for(var d=a.length;d--;)if(d in a&&a[d]===b)return d;return-1};b.range=function(a,b,d){if(arguments.length<=
+1){b=a||0;a=0}for(var d=arguments[2]||1,e=Math.max(Math.ceil((b-a)/d),0),f=0,g=Array(e);f<e;){g[f++]=a;a=a+d}return g};var H=function(){};b.bind=function(a,c){var d,e;if(a.bind===t&&t)return t.apply(a,i.call(arguments,1));if(!b.isFunction(a))throw new TypeError;e=i.call(arguments,2);return d=function(){if(!(this instanceof d))return a.apply(c,e.concat(i.call(arguments)));H.prototype=a.prototype;var b=new H,g=a.apply(b,e.concat(i.call(arguments)));return Object(g)===g?g:b}};b.bindAll=function(a){var c=
+i.call(arguments,1);c.length==0&&(c=b.functions(a));j(c,function(c){a[c]=b.bind(a[c],a)});return a};b.memoize=function(a,c){var d={};c||(c=b.identity);return function(){var e=c.apply(this,arguments);return b.has(d,e)?d[e]:d[e]=a.apply(this,arguments)}};b.delay=function(a,b){var d=i.call(arguments,2);return setTimeout(function(){return a.apply(null,d)},b)};b.defer=function(a){return b.delay.apply(b,[a,1].concat(i.call(arguments,1)))};b.throttle=function(a,c){var d,e,f,g,h,i,j=b.debounce(function(){h=
+g=false},c);return function(){d=this;e=arguments;f||(f=setTimeout(function(){f=null;h&&a.apply(d,e);j()},c));g?h=true:i=a.apply(d,e);j();g=true;return i}};b.debounce=function(a,b,d){var e;return function(){var f=this,g=arguments;d&&!e&&a.apply(f,g);clearTimeout(e);e=setTimeout(function(){e=null;d||a.apply(f,g)},b)}};b.once=function(a){var b=false,d;return function(){if(b)return d;b=true;return d=a.apply(this,arguments)}};b.wrap=function(a,b){return function(){var d=[a].concat(i.call(arguments,0));
+return b.apply(this,d)}};b.compose=function(){var a=arguments;return function(){for(var b=arguments,d=a.length-1;d>=0;d--)b=[a[d].apply(this,b)];return b[0]}};b.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}};b.keys=L||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var c=[],d;for(d in a)b.has(a,d)&&(c[c.length]=d);return c};b.values=function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&
+c.push(d);return c.sort()};b.extend=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]=b[d]});return a};b.pick=function(a){var c={};j(b.flatten(i.call(arguments,1)),function(b){b in a&&(c[b]=a[b])});return c};b.defaults=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return!b.isObject(a)?a:b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};b.isEqual=function(a,b){return r(a,b,[])};b.isEmpty=
+function(a){if(a==null)return true;if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(b.has(a,c))return false;return true};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=p||function(a){return l.call(a)=="[object Array]"};b.isObject=function(a){return a===Object(a)};b.isArguments=function(a){return l.call(a)=="[object Arguments]"};b.isArguments(arguments)||(b.isArguments=function(a){return!(!a||!b.has(a,"callee"))});b.isFunction=function(a){return l.call(a)=="[object Function]"};
+b.isString=function(a){return l.call(a)=="[object String]"};b.isNumber=function(a){return l.call(a)=="[object Number]"};b.isFinite=function(a){return b.isNumber(a)&&isFinite(a)};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===true||a===false||l.call(a)=="[object Boolean]"};b.isDate=function(a){return l.call(a)=="[object Date]"};b.isRegExp=function(a){return l.call(a)=="[object RegExp]"};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.has=function(a,
+b){return K.call(a,b)};b.noConflict=function(){s._=I;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e<a;e++)b.call(d,e)};b.escape=function(a){return(""+a).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")};b.result=function(a,c){if(a==null)return null;var d=a[c];return b.isFunction(d)?d.call(a):d};b.mixin=function(a){j(b.functions(a),function(c){M(c,b[c]=a[c])})};var N=0;b.uniqueId=
+function(a){var b=N++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var u=/.^/,n={"\\":"\\","'":"'",r:"\r",n:"\n",t:"\t",u2028:"\u2028",u2029:"\u2029"},v;for(v in n)n[n[v]]=v;var O=/\\|'|\r|\n|\t|\u2028|\u2029/g,P=/\\(\\|'|r|n|t|u2028|u2029)/g,w=function(a){return a.replace(P,function(a,b){return n[b]})};b.template=function(a,c,d){d=b.defaults(d||{},b.templateSettings);a="__p+='"+a.replace(O,function(a){return"\\"+n[a]}).replace(d.escape||
+u,function(a,b){return"'+\n_.escape("+w(b)+")+\n'"}).replace(d.interpolate||u,function(a,b){return"'+\n("+w(b)+")+\n'"}).replace(d.evaluate||u,function(a,b){return"';\n"+w(b)+"\n;__p+='"})+"';\n";d.variable||(a="with(obj||{}){\n"+a+"}\n");var a="var __p='';var print=function(){__p+=Array.prototype.join.call(arguments, '')};\n"+a+"return __p;\n",e=new Function(d.variable||"obj","_",a);if(c)return e(c,b);c=function(a){return e.call(this,a,b)};c.source="function("+(d.variable||"obj")+"){\n"+a+"}";return c};
+b.chain=function(a){return b(a).chain()};var m=function(a){this._wrapped=a};b.prototype=m.prototype;var x=function(a,c){return c?b(a).chain():a},M=function(a,c){m.prototype[a]=function(){var a=i.call(arguments);J.call(a,this._wrapped);return x(c.apply(b,a),this._chain)}};b.mixin(b);j("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=k[a];m.prototype[a]=function(){var d=this._wrapped;b.apply(d,arguments);var e=d.length;(a=="shift"||a=="splice")&&e===0&&delete d[0];return x(d,
+this._chain)}});j(["concat","join","slice"],function(a){var b=k[a];m.prototype[a]=function(){return x(b.apply(this._wrapped,arguments),this._chain)}});m.prototype.chain=function(){this._chain=true;return this};m.prototype.value=function(){return this._wrapped}}).call(this);
profiles/killpay/pom.xml 2(+1 -1)
diff --git a/profiles/killpay/pom.xml b/profiles/killpay/pom.xml
index b5f55dd..b8e940b 100644
--- a/profiles/killpay/pom.xml
+++ b/profiles/killpay/pom.xml
@@ -20,7 +20,7 @@
<parent>
<artifactId>killbill-profiles</artifactId>
<groupId>org.kill-bill.billing</groupId>
- <version>0.11.13-SNAPSHOT</version>
+ <version>0.11.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-profiles-killpay</artifactId>
profiles/killpay/src/main/webapp/api.html 147(+147 -0)
diff --git a/profiles/killpay/src/main/webapp/api.html b/profiles/killpay/src/main/webapp/api.html
new file mode 100644
index 0000000..0ce3e81
--- /dev/null
+++ b/profiles/killpay/src/main/webapp/api.html
@@ -0,0 +1,147 @@
+<!--
+ ~ Copyright 2010-2013 Ning, Inc.
+ ~
+ ~ Ning licenses this file to you under the Apache License, version 2.0
+ ~ (the "License"); you may not use this file except in compliance with the
+ ~ License. You may obtain a copy of the License at:
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ ~ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ ~ License for the specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Kill Bill APIs</title>
+ <link href='//fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'/>
+ <link href='//fonts.googleapis.com/css?family=Roboto:400,700' rel='stylesheet' type='text/css'/>
+ <link href='css/reset.css' media='screen' rel='stylesheet' type='text/css'/>
+ <link href='css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
+ <link href='css/reset.css' media='print' rel='stylesheet' type='text/css'/>
+ <link href='css/screen.css' media='print' rel='stylesheet' type='text/css'/>
+ <link href='css/killbill-swagger.css' media='screen' rel='stylesheet' type='text/css'/>
+ <link href='css/killbill-swagger.css' media='print' rel='stylesheet' type='text/css'/>
+ <script type="text/javascript" src="lib/shred.bundle.js"></script>
+ <script src='lib/jquery-1.8.0.min.js' type='text/javascript'></script>
+ <script src='lib/jquery.slideto.min.js' type='text/javascript'></script>
+ <script src='lib/jquery.wiggle.min.js' type='text/javascript'></script>
+ <script src='lib/jquery.ba-bbq.min.js' type='text/javascript'></script>
+ <script src='lib/handlebars-1.0.0.js' type='text/javascript'></script>
+ <script src='lib/underscore-min.js' type='text/javascript'></script>
+ <script src='lib/backbone-min.js' type='text/javascript'></script>
+ <script src='lib/swagger.js' type='text/javascript'></script>
+ <script src='lib/swagger-client.js' type='text/javascript'></script>
+ <script src='lib/swagger-ui.min.js' type='text/javascript'></script>
+ <script src='lib/highlight.7.3.pack.js' type='text/javascript'></script>
+
+ <!-- enabling this will enable oauth2 implicit scope support -->
+ <script src='lib/swagger-oauth.js' type='text/javascript'></script>
+ <script type="text/javascript">
+ $(function () {
+ var url = window.location.search.match(/url=([^&]+)/);
+ if (url && url.length > 1) {
+ url = url[1];
+ } else {
+ url = "http://127.0.0.1:8080/api-docs";
+ }
+ window.swaggerUi = new SwaggerUi({
+ url: url,
+ dom_id: "swagger-ui-container",
+ supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
+ onComplete: function(swaggerApi, swaggerUi){
+ log("Loaded SwaggerUI");
+ if(typeof initOAuth == "function") {
+ /*
+ initOAuth({
+ clientId: "your-client-id",
+ realm: "your-realms",
+ appName: "your-app-name"
+ });
+ */
+ }
+ $('pre code').each(function(i, e) {
+ hljs.highlightBlock(e)
+ });
+ },
+ onFailure: function(data) {
+ log("Unable to Load SwaggerUI");
+ },
+ docExpansion: "none",
+ sorter : "alpha"
+ });
+
+ function addApiKeyAuthorization() {
+ var key = $('#input_apiKey')[0].value;
+ log("key: " + key);
+ if(key && key.trim() != "") {
+ log("added key " + key);
+ window.authorizations.add("api_key", new ApiKeyAuthorization("api_key", key, "query"));
+ }
+ }
+
+ $('#input_apiKey').change(function() {
+ addApiKeyAuthorization();
+ });
+
+ // if you have an apiKey you would like to pre-populate on the page for demonstration purposes...
+ /*
+ var apiKey = "myApiKeyXXXX123456789";
+ $('#input_apiKey').val(apiKey);
+ addApiKeyAuthorization();
+ */
+
+ $.each(["#input_kb_apiKey", "#input_kb_apiSecret", "#input_kb_username", "#input_kb_password"], function(idx, selector_id) {
+ $(selector_id).change(function() {
+ setHeaders();
+ });
+ });
+
+ function setHeader(header, value) {
+ if (value && value.trim() != "") {
+ log("Setting header " + header + " to " + value);
+ window.authorizations.remove(header);
+ window.authorizations.add(header, new ApiKeyAuthorization(header, value, "header"));
+ }
+ }
+
+ function setHeaders() {
+ setHeader("X-Killbill-ApiKey", $("#input_kb_apiKey")[0].value || "bob");
+ setHeader("X-Killbill-ApiSecret", $("#input_kb_apiSecret")[0].value || "lazar");
+ setHeader("Authorization", "Basic " + btoa(($("#input_kb_username")[0].value || "admin") + ":" + ($("#input_kb_password")[0].value || "password")));
+ }
+
+ setHeaders();
+
+ window.swaggerUi.load();
+ });
+ </script>
+</head>
+
+<body class="swagger-section">
+<div id='header'>
+ <div class="swagger-ui-wrap">
+ <div id="kb-logo-container">
+ <a href="http://kill-bill.org">
+ <img id="kb-logo" title="Kill Bill" border="0" alt="Kill Bill" src="../images/killbill_logo.png">
+ </a>
+ </div>
+ <form id='api_selector'>
+ <div class='input'><input placeholder="http://127.0.0.1:8080/api-docs" id="input_baseUrl" name="baseUrl" type="text" size="38"/></div>
+ <div class='input'><input placeholder="api_key" id="input_kb_apiKey" name="apiKey" type="text" size="8"/></div>
+ <div class='input'><input placeholder="api_secret" id="input_kb_apiSecret" name="apiSecret" type="text" size="8"/></div>
+ <div class='input'><input placeholder="username" id="input_kb_username" name="username" type="text" size="8"/></div>
+ <div class='input'><input placeholder="password" id="input_kb_password" name="password" type="text" size="8"/></div>
+ <div class='input'><a id="explore" href="#">Explore</a></div>
+ </form>
+ </div>
+</div>
+
+<div id="message-bar" class="swagger-ui-wrap"> </div>
+<div id="swagger-ui-container" class="swagger-ui-wrap"></div>
+</body>
+</html>
diff --git a/profiles/killpay/src/main/webapp/css/killbill-swagger.css b/profiles/killpay/src/main/webapp/css/killbill-swagger.css
new file mode 100644
index 0000000..ded906d
--- /dev/null
+++ b/profiles/killpay/src/main/webapp/css/killbill-swagger.css
@@ -0,0 +1,50 @@
+#api_info {
+ display: none;
+}
+
+/*
+#header {
+ display: none;
+}
+
+.footer {
+ display: none;
+}
+*/
+
+#kb-logo-container {
+ max-width: 175px;
+ margin-left: -220px;
+ margin-top: -10px;
+ float: left;
+}
+
+img#kb-logo {
+ max-width: 100%;
+ height: auto;
+ width: auto\9; /* ie8 */
+}
+
+.swagger-section .swagger-ui-wrap {
+ height: 24px;
+}
+
+.swagger-section .swagger-ui-wrap {
+ font-family: "Roboto Light";
+}
+
+.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 {
+ font-family: "Roboto Light";
+}
+
+.swagger-section #header {
+ background-color: transparent;
+}
+
+.swagger-section #header form#api_selector {
+ float: left;
+}
+
+.swagger-section #header form#api_selector .input a#explore {
+ background-color: #e44c3a;
+}
\ No newline at end of file
profiles/killpay/src/main/webapp/css/reset.css 125(+125 -0)
diff --git a/profiles/killpay/src/main/webapp/css/reset.css b/profiles/killpay/src/main/webapp/css/reset.css
new file mode 100644
index 0000000..b2b0789
--- /dev/null
+++ b/profiles/killpay/src/main/webapp/css/reset.css
@@ -0,0 +1,125 @@
+/* http://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 */
+html,
+body,
+div,
+span,
+applet,
+object,
+iframe,
+h1,
+h2,
+h3,
+h4,
+h5,
+h6,
+p,
+blockquote,
+pre,
+a,
+abbr,
+acronym,
+address,
+big,
+cite,
+code,
+del,
+dfn,
+em,
+img,
+ins,
+kbd,
+q,
+s,
+samp,
+small,
+strike,
+strong,
+sub,
+sup,
+tt,
+var,
+b,
+u,
+i,
+center,
+dl,
+dt,
+dd,
+ol,
+ul,
+li,
+fieldset,
+form,
+label,
+legend,
+table,
+caption,
+tbody,
+tfoot,
+thead,
+tr,
+th,
+td,
+article,
+aside,
+canvas,
+details,
+embed,
+figure,
+figcaption,
+footer,
+header,
+hgroup,
+menu,
+nav,
+output,
+ruby,
+section,
+summary,
+time,
+mark,
+audio,
+video {
+ margin: 0;
+ padding: 0;
+ border: 0;
+ font-size: 100%;
+ font: inherit;
+ vertical-align: baseline;
+}
+/* HTML5 display-role reset for older browsers */
+article,
+aside,
+details,
+figcaption,
+figure,
+footer,
+header,
+hgroup,
+menu,
+nav,
+section {
+ display: block;
+}
+body {
+ line-height: 1;
+}
+ol,
+ul {
+ list-style: none;
+}
+blockquote,
+q {
+ quotes: none;
+}
+blockquote:before,
+blockquote:after,
+q:before,
+q:after {
+ content: '';
+ content: none;
+}
+table {
+ border-collapse: collapse;
+ border-spacing: 0;
+}
profiles/killpay/src/main/webapp/css/screen.css 1224(+1224 -0)
diff --git a/profiles/killpay/src/main/webapp/css/screen.css b/profiles/killpay/src/main/webapp/css/screen.css
new file mode 100644
index 0000000..478b998
--- /dev/null
+++ b/profiles/killpay/src/main/webapp/css/screen.css
@@ -0,0 +1,1224 @@
+/* Original style from softwaremaniacs.org (c) Ivan Sagalaev <Maniac@SoftwareManiacs.Org> */
+.swagger-section pre code {
+ display: block;
+ padding: 0.5em;
+ background: #F0F0F0;
+}
+.swagger-section pre code,
+.swagger-section pre .subst,
+.swagger-section pre .tag .title,
+.swagger-section pre .lisp .title,
+.swagger-section pre .clojure .built_in,
+.swagger-section pre .nginx .title {
+ color: black;
+}
+.swagger-section pre .string,
+.swagger-section pre .title,
+.swagger-section pre .constant,
+.swagger-section pre .parent,
+.swagger-section pre .tag .value,
+.swagger-section pre .rules .value,
+.swagger-section pre .rules .value .number,
+.swagger-section pre .preprocessor,
+.swagger-section pre .ruby .symbol,
+.swagger-section pre .ruby .symbol .string,
+.swagger-section pre .aggregate,
+.swagger-section pre .template_tag,
+.swagger-section pre .django .variable,
+.swagger-section pre .smalltalk .class,
+.swagger-section pre .addition,
+.swagger-section pre .flow,
+.swagger-section pre .stream,
+.swagger-section pre .bash .variable,
+.swagger-section pre .apache .tag,
+.swagger-section pre .apache .cbracket,
+.swagger-section pre .tex .command,
+.swagger-section pre .tex .special,
+.swagger-section pre .erlang_repl .function_or_atom,
+.swagger-section pre .markdown .header {
+ color: #800;
+}
+.swagger-section pre .comment,
+.swagger-section pre .annotation,
+.swagger-section pre .template_comment,
+.swagger-section pre .diff .header,
+.swagger-section pre .chunk,
+.swagger-section pre .markdown .blockquote {
+ color: #888;
+}
+.swagger-section pre .number,
+.swagger-section pre .date,
+.swagger-section pre .regexp,
+.swagger-section pre .literal,
+.swagger-section pre .smalltalk .symbol,
+.swagger-section pre .smalltalk .char,
+.swagger-section pre .go .constant,
+.swagger-section pre .change,
+.swagger-section pre .markdown .bullet,
+.swagger-section pre .markdown .link_url {
+ color: #080;
+}
+.swagger-section pre .label,
+.swagger-section pre .javadoc,
+.swagger-section pre .ruby .string,
+.swagger-section pre .decorator,
+.swagger-section pre .filter .argument,
+.swagger-section pre .localvars,
+.swagger-section pre .array,
+.swagger-section pre .attr_selector,
+.swagger-section pre .important,
+.swagger-section pre .pseudo,
+.swagger-section pre .pi,
+.swagger-section pre .doctype,
+.swagger-section pre .deletion,
+.swagger-section pre .envvar,
+.swagger-section pre .shebang,
+.swagger-section pre .apache .sqbracket,
+.swagger-section pre .nginx .built_in,
+.swagger-section pre .tex .formula,
+.swagger-section pre .erlang_repl .reserved,
+.swagger-section pre .prompt,
+.swagger-section pre .markdown .link_label,
+.swagger-section pre .vhdl .attribute,
+.swagger-section pre .clojure .attribute,
+.swagger-section pre .coffeescript .property {
+ color: #8888ff;
+}
+.swagger-section pre .keyword,
+.swagger-section pre .id,
+.swagger-section pre .phpdoc,
+.swagger-section pre .title,
+.swagger-section pre .built_in,
+.swagger-section pre .aggregate,
+.swagger-section pre .css .tag,
+.swagger-section pre .javadoctag,
+.swagger-section pre .phpdoc,
+.swagger-section pre .yardoctag,
+.swagger-section pre .smalltalk .class,
+.swagger-section pre .winutils,
+.swagger-section pre .bash .variable,
+.swagger-section pre .apache .tag,
+.swagger-section pre .go .typename,
+.swagger-section pre .tex .command,
+.swagger-section pre .markdown .strong,
+.swagger-section pre .request,
+.swagger-section pre .status {
+ font-weight: bold;
+}
+.swagger-section pre .markdown .emphasis {
+ font-style: italic;
+}
+.swagger-section pre .nginx .built_in {
+ font-weight: normal;
+}
+.swagger-section pre .coffeescript .javascript,
+.swagger-section pre .javascript .xml,
+.swagger-section pre .tex .formula,
+.swagger-section pre .xml .javascript,
+.swagger-section pre .xml .vbscript,
+.swagger-section pre .xml .css,
+.swagger-section pre .xml .cdata {
+ opacity: 0.5;
+}
+.swagger-section .swagger-ui-wrap {
+ line-height: 1;
+ font-family: "Droid Sans", sans-serif;
+ max-width: 960px;
+ margin-left: auto;
+ margin-right: auto;
+}
+.swagger-section .swagger-ui-wrap b,
+.swagger-section .swagger-ui-wrap strong {
+ font-family: "Droid Sans", sans-serif;
+ font-weight: bold;
+}
+.swagger-section .swagger-ui-wrap q,
+.swagger-section .swagger-ui-wrap blockquote {
+ quotes: none;
+}
+.swagger-section .swagger-ui-wrap p {
+ line-height: 1.4em;
+ padding: 0 0 10px;
+ color: #333333;
+}
+.swagger-section .swagger-ui-wrap q:before,
+.swagger-section .swagger-ui-wrap q:after,
+.swagger-section .swagger-ui-wrap blockquote:before,
+.swagger-section .swagger-ui-wrap blockquote:after {
+ content: none;
+}
+.swagger-section .swagger-ui-wrap .heading_with_menu h1,
+.swagger-section .swagger-ui-wrap .heading_with_menu h2,
+.swagger-section .swagger-ui-wrap .heading_with_menu h3,
+.swagger-section .swagger-ui-wrap .heading_with_menu h4,
+.swagger-section .swagger-ui-wrap .heading_with_menu h5,
+.swagger-section .swagger-ui-wrap .heading_with_menu h6 {
+ display: block;
+ clear: none;
+ float: left;
+ -moz-box-sizing: border-box;
+ -webkit-box-sizing: border-box;
+ -ms-box-sizing: border-box;
+ box-sizing: border-box;
+ width: 60%;
+}
+.swagger-section .swagger-ui-wrap table {
+ border-collapse: collapse;
+ border-spacing: 0;
+}
+.swagger-section .swagger-ui-wrap table thead tr th {
+ padding: 5px;
+ font-size: 0.9em;
+ color: #666666;
+ border-bottom: 1px solid #999999;
+}
+.swagger-section .swagger-ui-wrap table tbody tr:last-child td {
+ border-bottom: none;
+}
+.swagger-section .swagger-ui-wrap table tbody tr.offset {
+ background-color: #f0f0f0;
+}
+.swagger-section .swagger-ui-wrap table tbody tr td {
+ padding: 6px;
+ font-size: 0.9em;
+ border-bottom: 1px solid #cccccc;
+ vertical-align: top;
+ line-height: 1.3em;
+}
+.swagger-section .swagger-ui-wrap ol {
+ margin: 0px 0 10px;
+ padding: 0 0 0 18px;
+ list-style-type: decimal;
+}
+.swagger-section .swagger-ui-wrap ol li {
+ padding: 5px 0px;
+ font-size: 0.9em;
+ color: #333333;
+}
+.swagger-section .swagger-ui-wrap ol,
+.swagger-section .swagger-ui-wrap ul {
+ list-style: none;
+}
+.swagger-section .swagger-ui-wrap h1 a,
+.swagger-section .swagger-ui-wrap h2 a,
+.swagger-section .swagger-ui-wrap h3 a,
+.swagger-section .swagger-ui-wrap h4 a,
+.swagger-section .swagger-ui-wrap h5 a,
+.swagger-section .swagger-ui-wrap h6 a {
+ text-decoration: none;
+}
+.swagger-section .swagger-ui-wrap h1 a:hover,
+.swagger-section .swagger-ui-wrap h2 a:hover,
+.swagger-section .swagger-ui-wrap h3 a:hover,
+.swagger-section .swagger-ui-wrap h4 a:hover,
+.swagger-section .swagger-ui-wrap h5 a:hover,
+.swagger-section .swagger-ui-wrap h6 a:hover {
+ text-decoration: underline;
+}
+.swagger-section .swagger-ui-wrap h1 span.divider,
+.swagger-section .swagger-ui-wrap h2 span.divider,
+.swagger-section .swagger-ui-wrap h3 span.divider,
+.swagger-section .swagger-ui-wrap h4 span.divider,
+.swagger-section .swagger-ui-wrap h5 span.divider,
+.swagger-section .swagger-ui-wrap h6 span.divider {
+ color: #aaaaaa;
+}
+.swagger-section .swagger-ui-wrap a {
+ color: #547f00;
+}
+.swagger-section .swagger-ui-wrap a img {
+ border: none;
+}
+.swagger-section .swagger-ui-wrap article,
+.swagger-section .swagger-ui-wrap aside,
+.swagger-section .swagger-ui-wrap details,
+.swagger-section .swagger-ui-wrap figcaption,
+.swagger-section .swagger-ui-wrap figure,
+.swagger-section .swagger-ui-wrap footer,
+.swagger-section .swagger-ui-wrap header,
+.swagger-section .swagger-ui-wrap hgroup,
+.swagger-section .swagger-ui-wrap menu,
+.swagger-section .swagger-ui-wrap nav,
+.swagger-section .swagger-ui-wrap section,
+.swagger-section .swagger-ui-wrap summary {
+ display: block;
+}
+.swagger-section .swagger-ui-wrap pre {
+ font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
+ background-color: #fcf6db;
+ border: 1px solid #e5e0c6;
+ padding: 10px;
+}
+.swagger-section .swagger-ui-wrap pre code {
+ line-height: 1.6em;
+ background: none;
+}
+.swagger-section .swagger-ui-wrap .content > .content-type > div > label {
+ clear: both;
+ display: block;
+ color: #0F6AB4;
+ font-size: 1.1em;
+ margin: 0;
+ padding: 15px 0 5px;
+}
+.swagger-section .swagger-ui-wrap .content pre {
+ font-size: 12px;
+ margin-top: 5px;
+ padding: 5px;
+}
+.swagger-section .swagger-ui-wrap .icon-btn {
+ cursor: pointer;
+}
+.swagger-section .swagger-ui-wrap .info_title {
+ padding-bottom: 10px;
+ font-weight: bold;
+ font-size: 25px;
+}
+.swagger-section .swagger-ui-wrap p.big,
+.swagger-section .swagger-ui-wrap div.big p {
+ font-size: 1em;
+ margin-bottom: 10px;
+}
+.swagger-section .swagger-ui-wrap form.fullwidth ol li.string input,
+.swagger-section .swagger-ui-wrap form.fullwidth ol li.url input,
+.swagger-section .swagger-ui-wrap form.fullwidth ol li.text textarea,
+.swagger-section .swagger-ui-wrap form.fullwidth ol li.numeric input {
+ width: 500px !important;
+}
+.swagger-section .swagger-ui-wrap .info_license {
+ padding-bottom: 5px;
+}
+.swagger-section .swagger-ui-wrap .info_tos {
+ padding-bottom: 5px;
+}
+.swagger-section .swagger-ui-wrap .message-fail {
+ color: #cc0000;
+}
+.swagger-section .swagger-ui-wrap .info_contact {
+ padding-bottom: 5px;
+}
+.swagger-section .swagger-ui-wrap .info_description {
+ padding-bottom: 10px;
+ font-size: 15px;
+}
+.swagger-section .swagger-ui-wrap .markdown ol li,
+.swagger-section .swagger-ui-wrap .markdown ul li {
+ padding: 3px 0px;
+ line-height: 1.4em;
+ color: #333333;
+}
+.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.string input,
+.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.url input,
+.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.numeric input {
+ display: block;
+ padding: 4px;
+ width: auto;
+ clear: both;
+}
+.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.string input.title,
+.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.url input.title,
+.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.numeric input.title {
+ font-size: 1.3em;
+}
+.swagger-section .swagger-ui-wrap table.fullwidth {
+ width: 100%;
+}
+.swagger-section .swagger-ui-wrap .model-signature {
+ font-family: "Droid Sans", sans-serif;
+ font-size: 1em;
+ line-height: 1.5em;
+}
+.swagger-section .swagger-ui-wrap .model-signature .signature-nav a {
+ text-decoration: none;
+ color: #AAA;
+}
+.swagger-section .swagger-ui-wrap .model-signature .signature-nav a:hover {
+ text-decoration: underline;
+ color: black;
+}
+.swagger-section .swagger-ui-wrap .model-signature .signature-nav .selected {
+ color: black;
+ text-decoration: none;
+}
+.swagger-section .swagger-ui-wrap .model-signature .propType {
+ color: #5555aa;
+}
+.swagger-section .swagger-ui-wrap .model-signature pre:hover {
+ background-color: #ffffdd;
+}
+.swagger-section .swagger-ui-wrap .model-signature pre {
+ font-size: .85em;
+ line-height: 1.2em;
+ overflow: auto;
+ max-height: 200px;
+ cursor: pointer;
+}
+.swagger-section .swagger-ui-wrap .model-signature ul.signature-nav {
+ display: block;
+ margin: 0;
+ padding: 0;
+}
+.swagger-section .swagger-ui-wrap .model-signature ul.signature-nav li:last-child {
+ padding-right: 0;
+ border-right: none;
+}
+.swagger-section .swagger-ui-wrap .model-signature ul.signature-nav li {
+ float: left;
+ margin: 0 5px 5px 0;
+ padding: 2px 5px 2px 0;
+ border-right: 1px solid #ddd;
+}
+.swagger-section .swagger-ui-wrap .model-signature .propOpt {
+ color: #555;
+}
+.swagger-section .swagger-ui-wrap .model-signature .snippet small {
+ font-size: 0.75em;
+}
+.swagger-section .swagger-ui-wrap .model-signature .propOptKey {
+ font-style: italic;
+}
+.swagger-section .swagger-ui-wrap .model-signature .description .strong {
+ font-weight: bold;
+ color: #000;
+ font-size: .9em;
+}
+.swagger-section .swagger-ui-wrap .model-signature .description div {
+ font-size: 0.9em;
+ line-height: 1.5em;
+ margin-left: 1em;
+}
+.swagger-section .swagger-ui-wrap .model-signature .description .stronger {
+ font-weight: bold;
+ color: #000;
+}
+.swagger-section .swagger-ui-wrap .model-signature .propName {
+ font-weight: bold;
+}
+.swagger-section .swagger-ui-wrap .model-signature .signature-container {
+ clear: both;
+}
+.swagger-section .swagger-ui-wrap .body-textarea {
+ width: 300px;
+ height: 100px;
+ border: 1px solid #aaa;
+}
+.swagger-section .swagger-ui-wrap .markdown p code,
+.swagger-section .swagger-ui-wrap .markdown li code {
+ font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
+ background-color: #f0f0f0;
+ color: black;
+ padding: 1px 3px;
+}
+.swagger-section .swagger-ui-wrap .required {
+ font-weight: bold;
+}
+.swagger-section .swagger-ui-wrap input.parameter {
+ width: 300px;
+ border: 1px solid #aaa;
+}
+.swagger-section .swagger-ui-wrap h1 {
+ color: black;
+ font-size: 1.5em;
+ line-height: 1.3em;
+ padding: 10px 0 10px 0;
+ font-family: "Droid Sans", sans-serif;
+ font-weight: bold;
+}
+.swagger-section .swagger-ui-wrap .heading_with_menu {
+ float: none;
+ clear: both;
+ overflow: hidden;
+ display: block;
+}
+.swagger-section .swagger-ui-wrap .heading_with_menu ul {
+ display: block;
+ clear: none;
+ float: right;
+ -moz-box-sizing: border-box;
+ -webkit-box-sizing: border-box;
+ -ms-box-sizing: border-box;
+ box-sizing: border-box;
+ margin-top: 10px;
+}
+.swagger-section .swagger-ui-wrap h2 {
+ color: black;
+ font-size: 1.3em;
+ padding: 10px 0 10px 0;
+}
+.swagger-section .swagger-ui-wrap h2 a {
+ color: black;
+}
+.swagger-section .swagger-ui-wrap h2 span.sub {
+ font-size: 0.7em;
+ color: #999999;
+ font-style: italic;
+}
+.swagger-section .swagger-ui-wrap h2 span.sub a {
+ color: #777777;
+}
+.swagger-section .swagger-ui-wrap span.weak {
+ color: #666666;
+}
+.swagger-section .swagger-ui-wrap .message-success {
+ color: #89BF04;
+}
+.swagger-section .swagger-ui-wrap caption,
+.swagger-section .swagger-ui-wrap th,
+.swagger-section .swagger-ui-wrap td {
+ text-align: left;
+ font-weight: normal;
+ vertical-align: middle;
+}
+.swagger-section .swagger-ui-wrap .code {
+ font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
+}
+.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.text textarea {
+ font-family: "Droid Sans", sans-serif;
+ height: 250px;
+ padding: 4px;
+ display: block;
+ clear: both;
+}
+.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.select select {
+ display: block;
+ clear: both;
+}
+.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.boolean {
+ float: none;
+ clear: both;
+ overflow: hidden;
+ display: block;
+}
+.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.boolean label {
+ display: block;
+ float: left;
+ clear: none;
+ margin: 0;
+ padding: 0;
+}
+.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.boolean input {
+ display: block;
+ float: left;
+ clear: none;
+ margin: 0 5px 0 0;
+}
+.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.required label {
+ color: black;
+}
+.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li label {
+ display: block;
+ clear: both;
+ width: auto;
+ padding: 0 0 3px;
+ color: #666666;
+}
+.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li label abbr {
+ padding-left: 3px;
+ color: #888888;
+}
+.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li p.inline-hints {
+ margin-left: 0;
+ font-style: italic;
+ font-size: 0.9em;
+ margin: 0;
+}
+.swagger-section .swagger-ui-wrap form.formtastic fieldset.buttons {
+ margin: 0;
+ padding: 0;
+}
+.swagger-section .swagger-ui-wrap span.blank,
+.swagger-section .swagger-ui-wrap span.empty {
+ color: #888888;
+ font-style: italic;
+}
+.swagger-section .swagger-ui-wrap .markdown h3 {
+ color: #547f00;
+}
+.swagger-section .swagger-ui-wrap .markdown h4 {
+ color: #666666;
+}
+.swagger-section .swagger-ui-wrap .markdown pre {
+ font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
+ background-color: #fcf6db;
+ border: 1px solid #e5e0c6;
+ padding: 10px;
+ margin: 0 0 10px 0;
+}
+.swagger-section .swagger-ui-wrap .markdown pre code {
+ line-height: 1.6em;
+}
+.swagger-section .swagger-ui-wrap div.gist {
+ margin: 20px 0 25px 0 !important;
+}
+.swagger-section .swagger-ui-wrap ul#resources {
+ font-family: "Droid Sans", sans-serif;
+ font-size: 0.9em;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource {
+ border-bottom: 1px solid #dddddd;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource:hover div.heading h2 a,
+.swagger-section .swagger-ui-wrap ul#resources li.resource.active div.heading h2 a {
+ color: black;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource:hover div.heading ul.options li a,
+.swagger-section .swagger-ui-wrap ul#resources li.resource.active div.heading ul.options li a {
+ color: #555555;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource:last-child {
+ border-bottom: none;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading {
+ border: 1px solid transparent;
+ float: none;
+ clear: both;
+ overflow: hidden;
+ display: block;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options {
+ overflow: hidden;
+ padding: 0;
+ display: block;
+ clear: none;
+ float: right;
+ margin: 14px 10px 0 0;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li {
+ float: left;
+ clear: none;
+ margin: 0;
+ padding: 2px 10px;
+ border-right: 1px solid #dddddd;
+ color: #666666;
+ font-size: 0.9em;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li a {
+ color: #aaaaaa;
+ text-decoration: none;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li a:hover {
+ text-decoration: underline;
+ color: black;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li a:hover,
+.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li a:active,
+.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li a.active {
+ text-decoration: underline;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li:first-child,
+.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li.first {
+ padding-left: 0;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li:last-child,
+.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li.last {
+ padding-right: 0;
+ border-right: none;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options:first-child,
+.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options.first {
+ padding-left: 0;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 {
+ color: #999999;
+ padding-left: 0;
+ display: block;
+ clear: none;
+ float: left;
+ font-family: "Droid Sans", sans-serif;
+ font-weight: bold;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 a {
+ color: #999999;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 a:hover {
+ color: black;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation {
+ float: none;
+ clear: both;
+ overflow: hidden;
+ display: block;
+ margin: 0 0 10px;
+ padding: 0;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading {
+ float: none;
+ clear: both;
+ overflow: hidden;
+ display: block;
+ margin: 0;
+ padding: 0;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 {
+ display: block;
+ clear: none;
+ float: left;
+ width: auto;
+ margin: 0;
+ padding: 0;
+ line-height: 1.1em;
+ color: black;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 span.path {
+ padding-left: 10px;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 span.path a {
+ color: black;
+ text-decoration: none;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 span.path a:hover {
+ text-decoration: underline;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 span.http_method a {
+ text-transform: uppercase;
+ text-decoration: none;
+ color: white;
+ display: inline-block;
+ width: 50px;
+ font-size: 0.7em;
+ text-align: center;
+ padding: 7px 0 4px;
+ -moz-border-radius: 2px;
+ -webkit-border-radius: 2px;
+ -o-border-radius: 2px;
+ -ms-border-radius: 2px;
+ -khtml-border-radius: 2px;
+ border-radius: 2px;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 span {
+ margin: 0;
+ padding: 0;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading ul.options {
+ overflow: hidden;
+ padding: 0;
+ display: block;
+ clear: none;
+ float: right;
+ margin: 6px 10px 0 0;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading ul.options li {
+ float: left;
+ clear: none;
+ margin: 0;
+ padding: 2px 10px;
+ font-size: 0.9em;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading ul.options li a {
+ text-decoration: none;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading ul.options li.access {
+ color: black;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content {
+ border-top: none;
+ padding: 10px;
+ -moz-border-radius-bottomleft: 6px;
+ -webkit-border-bottom-left-radius: 6px;
+ -o-border-bottom-left-radius: 6px;
+ -ms-border-bottom-left-radius: 6px;
+ -khtml-border-bottom-left-radius: 6px;
+ border-bottom-left-radius: 6px;
+ -moz-border-radius-bottomright: 6px;
+ -webkit-border-bottom-right-radius: 6px;
+ -o-border-bottom-right-radius: 6px;
+ -ms-border-bottom-right-radius: 6px;
+ -khtml-border-bottom-right-radius: 6px;
+ border-bottom-right-radius: 6px;
+ margin: 0 0 20px;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content h4 {
+ font-size: 1.1em;
+ margin: 0;
+ padding: 15px 0 5px;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header {
+ float: none;
+ clear: both;
+ overflow: hidden;
+ display: block;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header a {
+ padding: 4px 0 0 10px;
+ display: inline-block;
+ font-size: 0.9em;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header input.submit {
+ display: block;
+ clear: none;
+ float: left;
+ padding: 6px 8px;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header span.response_throbber {
+ background-image: url('../images/throbber.gif');
+ width: 128px;
+ height: 16px;
+ display: block;
+ clear: none;
+ float: right;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content form input[type='text'].error {
+ outline: 2px solid black;
+ outline-color: #cc0000;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.response div.block pre {
+ font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
+ padding: 10px;
+ font-size: 0.9em;
+ max-height: 400px;
+ overflow-y: auto;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading {
+ background-color: #f9f2e9;
+ border: 1px solid #f0e0ca;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading h3 span.http_method a {
+ background-color: #c5862b;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li {
+ border-right: 1px solid #dddddd;
+ border-right-color: #f0e0ca;
+ color: #c5862b;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li a {
+ color: #c5862b;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content {
+ background-color: #faf5ee;
+ border: 1px solid #f0e0ca;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content h4 {
+ color: #c5862b;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content div.sandbox_header a {
+ color: #dcb67f;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.heading {
+ background-color: #fcffcd;
+ border: 1px solid black;
+ border-color: #ffd20f;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.heading h3 span.http_method a {
+ text-transform: uppercase;
+ background-color: #ffd20f;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.heading ul.options li {
+ border-right: 1px solid #dddddd;
+ border-right-color: #ffd20f;
+ color: #ffd20f;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.heading ul.options li a {
+ color: #ffd20f;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.content {
+ background-color: #fcffcd;
+ border: 1px solid black;
+ border-color: #ffd20f;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.content h4 {
+ color: #ffd20f;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.content div.sandbox_header a {
+ color: #6fc992;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading {
+ background-color: #f5e8e8;
+ border: 1px solid #e8c6c7;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading h3 span.http_method a {
+ text-transform: uppercase;
+ background-color: #a41e22;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li {
+ border-right: 1px solid #dddddd;
+ border-right-color: #e8c6c7;
+ color: #a41e22;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li a {
+ color: #a41e22;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content {
+ background-color: #f7eded;
+ border: 1px solid #e8c6c7;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content h4 {
+ color: #a41e22;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content div.sandbox_header a {
+ color: #c8787a;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading {
+ background-color: #e7f6ec;
+ border: 1px solid #c3e8d1;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading h3 span.http_method a {
+ background-color: #10a54a;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li {
+ border-right: 1px solid #dddddd;
+ border-right-color: #c3e8d1;
+ color: #10a54a;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li a {
+ color: #10a54a;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content {
+ background-color: #ebf7f0;
+ border: 1px solid #c3e8d1;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content h4 {
+ color: #10a54a;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content div.sandbox_header a {
+ color: #6fc992;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading {
+ background-color: #FCE9E3;
+ border: 1px solid #F5D5C3;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading h3 span.http_method a {
+ background-color: #D38042;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading ul.options li {
+ border-right: 1px solid #dddddd;
+ border-right-color: #f0cecb;
+ color: #D38042;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading ul.options li a {
+ color: #D38042;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.content {
+ background-color: #faf0ef;
+ border: 1px solid #f0cecb;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.content h4 {
+ color: #D38042;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.content div.sandbox_header a {
+ color: #dcb67f;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading {
+ background-color: #e7f0f7;
+ border: 1px solid #c3d9ec;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading h3 span.http_method a {
+ background-color: #0f6ab4;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li {
+ border-right: 1px solid #dddddd;
+ border-right-color: #c3d9ec;
+ color: #0f6ab4;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li a {
+ color: #0f6ab4;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content {
+ background-color: #ebf3f9;
+ border: 1px solid #c3d9ec;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content h4 {
+ color: #0f6ab4;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content div.sandbox_header a {
+ color: #6fa5d2;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.options div.heading {
+ background-color: #e7f0f7;
+ border: 1px solid #c3d9ec;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.options div.heading h3 span.http_method a {
+ background-color: #0f6ab4;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.options div.heading ul.options li {
+ border-right: 1px solid #dddddd;
+ border-right-color: #c3d9ec;
+ color: #0f6ab4;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.options div.heading ul.options li a {
+ color: #0f6ab4;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.options div.content {
+ background-color: #ebf3f9;
+ border: 1px solid #c3d9ec;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.options div.content h4 {
+ color: #0f6ab4;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.options div.content div.sandbox_header a {
+ color: #6fa5d2;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.content,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.content,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content {
+ border-top: none;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li:last-child,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li:last-child,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.heading ul.options li:last-child,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li:last-child,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading ul.options li:last-child,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li:last-child,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li.last,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li.last,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.heading ul.options li.last,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li.last,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading ul.options li.last,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li.last {
+ padding-right: 0;
+ border-right: none;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations ul.options li a:hover,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations ul.options li a:active,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations ul.options li a.active {
+ text-decoration: underline;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations ul.options li:first-child,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations ul.options li.first {
+ padding-left: 0;
+}
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations:first-child,
+.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations.first {
+ padding-left: 0;
+}
+.swagger-section .swagger-ui-wrap p#colophon {
+ margin: 0 15px 40px 15px;
+ padding: 10px 0;
+ font-size: 0.8em;
+ border-top: 1px solid #dddddd;
+ font-family: "Droid Sans", sans-serif;
+ color: #999999;
+ font-style: italic;
+}
+.swagger-section .swagger-ui-wrap p#colophon a {
+ text-decoration: none;
+ color: #547f00;
+}
+.swagger-section .swagger-ui-wrap h3 {
+ color: black;
+ font-size: 1.1em;
+ padding: 10px 0 10px 0;
+}
+.swagger-section .swagger-ui-wrap .markdown ol,
+.swagger-section .swagger-ui-wrap .markdown ul {
+ font-family: "Droid Sans", sans-serif;
+ margin: 5px 0 10px;
+ padding: 0 0 0 18px;
+ list-style-type: disc;
+}
+.swagger-section .swagger-ui-wrap form.form_box {
+ background-color: #ebf3f9;
+ border: 1px solid #c3d9ec;
+ padding: 10px;
+}
+.swagger-section .swagger-ui-wrap form.form_box label {
+ color: #0f6ab4 !important;
+}
+.swagger-section .swagger-ui-wrap form.form_box input[type=submit] {
+ display: block;
+ padding: 10px;
+}
+.swagger-section .swagger-ui-wrap form.form_box p.weak {
+ font-size: 0.8em;
+}
+.swagger-section .swagger-ui-wrap form.form_box p {
+ font-size: 0.9em;
+ padding: 0 0 15px;
+ color: #7e7b6d;
+}
+.swagger-section .swagger-ui-wrap form.form_box p a {
+ color: #646257;
+}
+.swagger-section .swagger-ui-wrap form.form_box p strong {
+ color: black;
+}
+.swagger-section .title {
+ font-style: bold;
+}
+.swagger-section .secondary_form {
+ display: none;
+}
+.swagger-section .main_image {
+ display: block;
+ margin-left: auto;
+ margin-right: auto;
+}
+.swagger-section .oauth_body {
+ margin-left: 100px;
+ margin-right: 100px;
+}
+.swagger-section .oauth_submit {
+ text-align: center;
+}
+.swagger-section .api-popup-dialog {
+ z-index: 10000;
+ position: absolute;
+ width: 500px;
+ background: #FFF;
+ padding: 20px;
+ border: 1px solid #ccc;
+ border-radius: 5px;
+ display: none;
+ font-size: 13px;
+ color: #777;
+}
+.swagger-section .api-popup-dialog .api-popup-title {
+ font-size: 24px;
+ padding: 10px 0;
+}
+.swagger-section .api-popup-dialog .api-popup-title {
+ font-size: 24px;
+ padding: 10px 0;
+}
+.swagger-section .api-popup-dialog p.error-msg {
+ padding-left: 5px;
+ padding-bottom: 5px;
+}
+.swagger-section .api-popup-dialog button.api-popup-authbtn {
+ height: 30px;
+}
+.swagger-section .api-popup-dialog button.api-popup-cancel {
+ height: 30px;
+}
+.swagger-section .api-popup-scopes {
+ padding: 10px 20px;
+}
+.swagger-section .api-popup-scopes li {
+ padding: 5px 0;
+ line-height: 20px;
+}
+.swagger-section .api-popup-scopes .api-scope-desc {
+ padding-left: 20px;
+ font-style: italic;
+}
+.swagger-section .api-popup-scopes li input {
+ position: relative;
+ top: 2px;
+}
+.swagger-section .api-popup-actions {
+ padding-top: 10px;
+}
+.swagger-section .access {
+ float: right;
+}
+.swagger-section .auth {
+ float: right;
+}
+.swagger-section #api_information_panel {
+ position: absolute;
+ background: #FFF;
+ border: 1px solid #ccc;
+ border-radius: 5px;
+ display: none;
+ font-size: 13px;
+ max-width: 300px;
+ line-height: 30px;
+ color: black;
+ padding: 5px;
+}
+.swagger-section #api_information_panel p .api-msg-enabled {
+ color: green;
+}
+.swagger-section #api_information_panel p .api-msg-disabled {
+ color: red;
+}
+.swagger-section .api-ic {
+ height: 18px;
+ vertical-align: middle;
+ display: inline-block;
+ background: url(../images/explorer_icons.png) no-repeat;
+}
+.swagger-section .ic-info {
+ background-position: 0 0;
+ width: 18px;
+ margin-top: -7px;
+ margin-left: 4px;
+}
+.swagger-section .ic-warning {
+ background-position: -60px 0;
+ width: 18px;
+ margin-top: -7px;
+ margin-left: 4px;
+}
+.swagger-section .ic-error {
+ background-position: -30px 0;
+ width: 18px;
+ margin-top: -7px;
+ margin-left: 4px;
+}
+.swagger-section .ic-off {
+ background-position: -90px 0;
+ width: 58px;
+ margin-top: -4px;
+ cursor: pointer;
+}
+.swagger-section .ic-on {
+ background-position: -160px 0;
+ width: 58px;
+ margin-top: -4px;
+ cursor: pointer;
+}
+.swagger-section #header {
+ background-color: #89bf04;
+ padding: 14px;
+}
+.swagger-section #header a#logo {
+ font-size: 1.5em;
+ font-weight: bold;
+ text-decoration: none;
+ background: transparent url(../images/logo_small.png) no-repeat left center;
+ padding: 20px 0 20px 40px;
+ color: white;
+}
+.swagger-section #header form#api_selector {
+ display: block;
+ clear: none;
+ float: right;
+}
+.swagger-section #header form#api_selector .input {
+ display: block;
+ clear: none;
+ float: left;
+ margin: 0 10px 0 0;
+}
+.swagger-section #header form#api_selector .input input#input_apiKey {
+ width: 200px;
+}
+.swagger-section #header form#api_selector .input input#input_baseUrl {
+ width: 400px;
+}
+.swagger-section #header form#api_selector .input a#explore {
+ display: block;
+ text-decoration: none;
+ font-weight: bold;
+ padding: 6px 8px;
+ font-size: 0.9em;
+ color: white;
+ background-color: #547f00;
+ -moz-border-radius: 4px;
+ -webkit-border-radius: 4px;
+ -o-border-radius: 4px;
+ -ms-border-radius: 4px;
+ -khtml-border-radius: 4px;
+ border-radius: 4px;
+}
+.swagger-section #header form#api_selector .input a#explore:hover {
+ background-color: #547f00;
+}
+.swagger-section #header form#api_selector .input input {
+ font-size: 0.9em;
+ padding: 3px;
+ margin: 0;
+}
+.swagger-section #content_message {
+ margin: 10px 15px;
+ font-style: italic;
+ color: #999999;
+}
+.swagger-section #message-bar {
+ min-height: 30px;
+ text-align: center;
+ padding-top: 10px;
+}
diff --git a/profiles/killpay/src/main/webapp/images/killbill_logo.png b/profiles/killpay/src/main/webapp/images/killbill_logo.png
new file mode 100644
index 0000000..feb37eb
Binary files /dev/null and b/profiles/killpay/src/main/webapp/images/killbill_logo.png differ
diff --git a/profiles/killpay/src/main/webapp/index.html b/profiles/killpay/src/main/webapp/index.html
index e6f4b1f..f9b6e11 100644
--- a/profiles/killpay/src/main/webapp/index.html
+++ b/profiles/killpay/src/main/webapp/index.html
@@ -24,11 +24,9 @@
<!--[if lt IE 9]>
<script src=javascripts/html5.js" type="text/javascript"></script>
<![endif]-->
- <script src="javascripts/jquery.min.js"></script>
- <script src="javascripts/bootstrap.min.js"></script>
- <link rel=stylesheet type="text/css" href="stylesheets/bootstrap.min.css">
- <link rel=stylesheet type="text/css" href="stylesheets/killbill.css">
+ <link rel=stylesheet type="text/css" href="css/bootstrap.min.css">
+ <link rel=stylesheet type="text/css" href="css/killbill-bootstrap.css">
</head>
<body data-spy="scroll" data-target=".bs-docs-sidebar">
@@ -47,14 +45,15 @@
<div class="container">
<div class="jumbotron">
<h1>Kill Bill</h1>
- <h2>The Open-Source payment Platform</h2>
- <img src="img/KillBillLogo400x400.png" style="height: 200px; margin-bottom: 20px;" />
+ <h2>The Open-Source Billing Platform</h2>
+ <img src="images/KillBillLogo400x400.png" style="height: 200px; margin-bottom: 20px;" />
</div>
<div class="marketing">
<h1>Congratulations!</h1>
<p class="lead">Kill Pay is up and running.</p>
<ul class="inline">
+ <li><a class="btn btn-primary btn-large" href="/api.html">APIs</a></li>
<li><a class="btn btn-primary btn-large" href="/1.0/metrics?pretty=true">Metrics</a></li>
<li><a class="btn btn-primary btn-large" href="/1.0/threads">Threads</a></li>
</ul>
diff --git a/profiles/killpay/src/main/webapp/lib/backbone-min.js b/profiles/killpay/src/main/webapp/lib/backbone-min.js
new file mode 100644
index 0000000..c1c0d4f
--- /dev/null
+++ b/profiles/killpay/src/main/webapp/lib/backbone-min.js
@@ -0,0 +1,38 @@
+// Backbone.js 0.9.2
+
+// (c) 2010-2012 Jeremy Ashkenas, DocumentCloud Inc.
+// Backbone may be freely distributed under the MIT license.
+// For all details and documentation:
+// http://backbonejs.org
+(function(){var l=this,y=l.Backbone,z=Array.prototype.slice,A=Array.prototype.splice,g;g="undefined"!==typeof exports?exports:l.Backbone={};g.VERSION="0.9.2";var f=l._;!f&&"undefined"!==typeof require&&(f=require("underscore"));var i=l.jQuery||l.Zepto||l.ender;g.setDomLibrary=function(a){i=a};g.noConflict=function(){l.Backbone=y;return this};g.emulateHTTP=!1;g.emulateJSON=!1;var p=/\s+/,k=g.Events={on:function(a,b,c){var d,e,f,g,j;if(!b)return this;a=a.split(p);for(d=this._callbacks||(this._callbacks=
+{});e=a.shift();)f=(j=d[e])?j.tail:{},f.next=g={},f.context=c,f.callback=b,d[e]={tail:g,next:j?j.next:f};return this},off:function(a,b,c){var d,e,h,g,j,q;if(e=this._callbacks){if(!a&&!b&&!c)return delete this._callbacks,this;for(a=a?a.split(p):f.keys(e);d=a.shift();)if(h=e[d],delete e[d],h&&(b||c))for(g=h.tail;(h=h.next)!==g;)if(j=h.callback,q=h.context,b&&j!==b||c&&q!==c)this.on(d,j,q);return this}},trigger:function(a){var b,c,d,e,f,g;if(!(d=this._callbacks))return this;f=d.all;a=a.split(p);for(g=
+z.call(arguments,1);b=a.shift();){if(c=d[b])for(e=c.tail;(c=c.next)!==e;)c.callback.apply(c.context||this,g);if(c=f){e=c.tail;for(b=[b].concat(g);(c=c.next)!==e;)c.callback.apply(c.context||this,b)}}return this}};k.bind=k.on;k.unbind=k.off;var o=g.Model=function(a,b){var c;a||(a={});b&&b.parse&&(a=this.parse(a));if(c=n(this,"defaults"))a=f.extend({},c,a);b&&b.collection&&(this.collection=b.collection);this.attributes={};this._escapedAttributes={};this.cid=f.uniqueId("c");this.changed={};this._silent=
+{};this._pending={};this.set(a,{silent:!0});this.changed={};this._silent={};this._pending={};this._previousAttributes=f.clone(this.attributes);this.initialize.apply(this,arguments)};f.extend(o.prototype,k,{changed:null,_silent:null,_pending:null,idAttribute:"id",initialize:function(){},toJSON:function(){return f.clone(this.attributes)},get:function(a){return this.attributes[a]},escape:function(a){var b;if(b=this._escapedAttributes[a])return b;b=this.get(a);return this._escapedAttributes[a]=f.escape(null==
+b?"":""+b)},has:function(a){return null!=this.get(a)},set:function(a,b,c){var d,e;f.isObject(a)||null==a?(d=a,c=b):(d={},d[a]=b);c||(c={});if(!d)return this;d instanceof o&&(d=d.attributes);if(c.unset)for(e in d)d[e]=void 0;if(!this._validate(d,c))return!1;this.idAttribute in d&&(this.id=d[this.idAttribute]);var b=c.changes={},h=this.attributes,g=this._escapedAttributes,j=this._previousAttributes||{};for(e in d){a=d[e];if(!f.isEqual(h[e],a)||c.unset&&f.has(h,e))delete g[e],(c.silent?this._silent:
+b)[e]=!0;c.unset?delete h[e]:h[e]=a;!f.isEqual(j[e],a)||f.has(h,e)!=f.has(j,e)?(this.changed[e]=a,c.silent||(this._pending[e]=!0)):(delete this.changed[e],delete this._pending[e])}c.silent||this.change(c);return this},unset:function(a,b){(b||(b={})).unset=!0;return this.set(a,null,b)},clear:function(a){(a||(a={})).unset=!0;return this.set(f.clone(this.attributes),a)},fetch:function(a){var a=a?f.clone(a):{},b=this,c=a.success;a.success=function(d,e,f){if(!b.set(b.parse(d,f),a))return!1;c&&c(b,d)};
+a.error=g.wrapError(a.error,b,a);return(this.sync||g.sync).call(this,"read",this,a)},save:function(a,b,c){var d,e;f.isObject(a)||null==a?(d=a,c=b):(d={},d[a]=b);c=c?f.clone(c):{};if(c.wait){if(!this._validate(d,c))return!1;e=f.clone(this.attributes)}a=f.extend({},c,{silent:!0});if(d&&!this.set(d,c.wait?a:c))return!1;var h=this,i=c.success;c.success=function(a,b,e){b=h.parse(a,e);if(c.wait){delete c.wait;b=f.extend(d||{},b)}if(!h.set(b,c))return false;i?i(h,a):h.trigger("sync",h,a,c)};c.error=g.wrapError(c.error,
+h,c);b=this.isNew()?"create":"update";b=(this.sync||g.sync).call(this,b,this,c);c.wait&&this.set(e,a);return b},destroy:function(a){var a=a?f.clone(a):{},b=this,c=a.success,d=function(){b.trigger("destroy",b,b.collection,a)};if(this.isNew())return d(),!1;a.success=function(e){a.wait&&d();c?c(b,e):b.trigger("sync",b,e,a)};a.error=g.wrapError(a.error,b,a);var e=(this.sync||g.sync).call(this,"delete",this,a);a.wait||d();return e},url:function(){var a=n(this,"urlRoot")||n(this.collection,"url")||t();
+return this.isNew()?a:a+("/"==a.charAt(a.length-1)?"":"/")+encodeURIComponent(this.id)},parse:function(a){return a},clone:function(){return new this.constructor(this.attributes)},isNew:function(){return null==this.id},change:function(a){a||(a={});var b=this._changing;this._changing=!0;for(var c in this._silent)this._pending[c]=!0;var d=f.extend({},a.changes,this._silent);this._silent={};for(c in d)this.trigger("change:"+c,this,this.get(c),a);if(b)return this;for(;!f.isEmpty(this._pending);){this._pending=
+{};this.trigger("change",this,a);for(c in this.changed)!this._pending[c]&&!this._silent[c]&&delete this.changed[c];this._previousAttributes=f.clone(this.attributes)}this._changing=!1;return this},hasChanged:function(a){return!arguments.length?!f.isEmpty(this.changed):f.has(this.changed,a)},changedAttributes:function(a){if(!a)return this.hasChanged()?f.clone(this.changed):!1;var b,c=!1,d=this._previousAttributes,e;for(e in a)if(!f.isEqual(d[e],b=a[e]))(c||(c={}))[e]=b;return c},previous:function(a){return!arguments.length||
+!this._previousAttributes?null:this._previousAttributes[a]},previousAttributes:function(){return f.clone(this._previousAttributes)},isValid:function(){return!this.validate(this.attributes)},_validate:function(a,b){if(b.silent||!this.validate)return!0;var a=f.extend({},this.attributes,a),c=this.validate(a,b);if(!c)return!0;b&&b.error?b.error(this,c,b):this.trigger("error",this,c,b);return!1}});var r=g.Collection=function(a,b){b||(b={});b.model&&(this.model=b.model);b.comparator&&(this.comparator=b.comparator);
+this._reset();this.initialize.apply(this,arguments);a&&this.reset(a,{silent:!0,parse:b.parse})};f.extend(r.prototype,k,{model:o,initialize:function(){},toJSON:function(a){return this.map(function(b){return b.toJSON(a)})},add:function(a,b){var c,d,e,g,i,j={},k={},l=[];b||(b={});a=f.isArray(a)?a.slice():[a];c=0;for(d=a.length;c<d;c++){if(!(e=a[c]=this._prepareModel(a[c],b)))throw Error("Can't add an invalid model to a collection");g=e.cid;i=e.id;j[g]||this._byCid[g]||null!=i&&(k[i]||this._byId[i])?
+l.push(c):j[g]=k[i]=e}for(c=l.length;c--;)a.splice(l[c],1);c=0;for(d=a.length;c<d;c++)(e=a[c]).on("all",this._onModelEvent,this),this._byCid[e.cid]=e,null!=e.id&&(this._byId[e.id]=e);this.length+=d;A.apply(this.models,[null!=b.at?b.at:this.models.length,0].concat(a));this.comparator&&this.sort({silent:!0});if(b.silent)return this;c=0;for(d=this.models.length;c<d;c++)if(j[(e=this.models[c]).cid])b.index=c,e.trigger("add",e,this,b);return this},remove:function(a,b){var c,d,e,g;b||(b={});a=f.isArray(a)?
+a.slice():[a];c=0;for(d=a.length;c<d;c++)if(g=this.getByCid(a[c])||this.get(a[c]))delete this._byId[g.id],delete this._byCid[g.cid],e=this.indexOf(g),this.models.splice(e,1),this.length--,b.silent||(b.index=e,g.trigger("remove",g,this,b)),this._removeReference(g);return this},push:function(a,b){a=this._prepareModel(a,b);this.add(a,b);return a},pop:function(a){var b=this.at(this.length-1);this.remove(b,a);return b},unshift:function(a,b){a=this._prepareModel(a,b);this.add(a,f.extend({at:0},b));return a},
+shift:function(a){var b=this.at(0);this.remove(b,a);return b},get:function(a){return null==a?void 0:this._byId[null!=a.id?a.id:a]},getByCid:function(a){return a&&this._byCid[a.cid||a]},at:function(a){return this.models[a]},where:function(a){return f.isEmpty(a)?[]:this.filter(function(b){for(var c in a)if(a[c]!==b.get(c))return!1;return!0})},sort:function(a){a||(a={});if(!this.comparator)throw Error("Cannot sort a set without a comparator");var b=f.bind(this.comparator,this);1==this.comparator.length?
+this.models=this.sortBy(b):this.models.sort(b);a.silent||this.trigger("reset",this,a);return this},pluck:function(a){return f.map(this.models,function(b){return b.get(a)})},reset:function(a,b){a||(a=[]);b||(b={});for(var c=0,d=this.models.length;c<d;c++)this._removeReference(this.models[c]);this._reset();this.add(a,f.extend({silent:!0},b));b.silent||this.trigger("reset",this,b);return this},fetch:function(a){a=a?f.clone(a):{};void 0===a.parse&&(a.parse=!0);var b=this,c=a.success;a.success=function(d,
+e,f){b[a.add?"add":"reset"](b.parse(d,f),a);c&&c(b,d)};a.error=g.wrapError(a.error,b,a);return(this.sync||g.sync).call(this,"read",this,a)},create:function(a,b){var c=this,b=b?f.clone(b):{},a=this._prepareModel(a,b);if(!a)return!1;b.wait||c.add(a,b);var d=b.success;b.success=function(e,f){b.wait&&c.add(e,b);d?d(e,f):e.trigger("sync",a,f,b)};a.save(null,b);return a},parse:function(a){return a},chain:function(){return f(this.models).chain()},_reset:function(){this.length=0;this.models=[];this._byId=
+{};this._byCid={}},_prepareModel:function(a,b){b||(b={});a instanceof o?a.collection||(a.collection=this):(b.collection=this,a=new this.model(a,b),a._validate(a.attributes,b)||(a=!1));return a},_removeReference:function(a){this==a.collection&&delete a.collection;a.off("all",this._onModelEvent,this)},_onModelEvent:function(a,b,c,d){("add"==a||"remove"==a)&&c!=this||("destroy"==a&&this.remove(b,d),b&&a==="change:"+b.idAttribute&&(delete this._byId[b.previous(b.idAttribute)],this._byId[b.id]=b),this.trigger.apply(this,
+arguments))}});f.each("forEach,each,map,reduce,reduceRight,find,detect,filter,select,reject,every,all,some,any,include,contains,invoke,max,min,sortBy,sortedIndex,toArray,size,first,initial,rest,last,without,indexOf,shuffle,lastIndexOf,isEmpty,groupBy".split(","),function(a){r.prototype[a]=function(){return f[a].apply(f,[this.models].concat(f.toArray(arguments)))}});var u=g.Router=function(a){a||(a={});a.routes&&(this.routes=a.routes);this._bindRoutes();this.initialize.apply(this,arguments)},B=/:\w+/g,
+C=/\*\w+/g,D=/[-[\]{}()+?.,\\^$|#\s]/g;f.extend(u.prototype,k,{initialize:function(){},route:function(a,b,c){g.history||(g.history=new m);f.isRegExp(a)||(a=this._routeToRegExp(a));c||(c=this[b]);g.history.route(a,f.bind(function(d){d=this._extractParameters(a,d);c&&c.apply(this,d);this.trigger.apply(this,["route:"+b].concat(d));g.history.trigger("route",this,b,d)},this));return this},navigate:function(a,b){g.history.navigate(a,b)},_bindRoutes:function(){if(this.routes){var a=[],b;for(b in this.routes)a.unshift([b,
+this.routes[b]]);b=0;for(var c=a.length;b<c;b++)this.route(a[b][0],a[b][1],this[a[b][1]])}},_routeToRegExp:function(a){a=a.replace(D,"\\$&").replace(B,"([^/]+)").replace(C,"(.*?)");return RegExp("^"+a+"$")},_extractParameters:function(a,b){return a.exec(b).slice(1)}});var m=g.History=function(){this.handlers=[];f.bindAll(this,"checkUrl")},s=/^[#\/]/,E=/msie [\w.]+/;m.started=!1;f.extend(m.prototype,k,{interval:50,getHash:function(a){return(a=(a?a.location:window.location).href.match(/#(.*)$/))?a[1]:
+""},getFragment:function(a,b){if(null==a)if(this._hasPushState||b){var a=window.location.pathname,c=window.location.search;c&&(a+=c)}else a=this.getHash();a.indexOf(this.options.root)||(a=a.substr(this.options.root.length));return a.replace(s,"")},start:function(a){if(m.started)throw Error("Backbone.history has already been started");m.started=!0;this.options=f.extend({},{root:"/"},this.options,a);this._wantsHashChange=!1!==this.options.hashChange;this._wantsPushState=!!this.options.pushState;this._hasPushState=
+!(!this.options.pushState||!window.history||!window.history.pushState);var a=this.getFragment(),b=document.documentMode;if(b=E.exec(navigator.userAgent.toLowerCase())&&(!b||7>=b))this.iframe=i('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo("body")[0].contentWindow,this.navigate(a);this._hasPushState?i(window).bind("popstate",this.checkUrl):this._wantsHashChange&&"onhashchange"in window&&!b?i(window).bind("hashchange",this.checkUrl):this._wantsHashChange&&(this._checkUrlInterval=setInterval(this.checkUrl,
+this.interval));this.fragment=a;a=window.location;b=a.pathname==this.options.root;if(this._wantsHashChange&&this._wantsPushState&&!this._hasPushState&&!b)return this.fragment=this.getFragment(null,!0),window.location.replace(this.options.root+"#"+this.fragment),!0;this._wantsPushState&&this._hasPushState&&b&&a.hash&&(this.fragment=this.getHash().replace(s,""),window.history.replaceState({},document.title,a.protocol+"//"+a.host+this.options.root+this.fragment));if(!this.options.silent)return this.loadUrl()},
+stop:function(){i(window).unbind("popstate",this.checkUrl).unbind("hashchange",this.checkUrl);clearInterval(this._checkUrlInterval);m.started=!1},route:function(a,b){this.handlers.unshift({route:a,callback:b})},checkUrl:function(){var a=this.getFragment();a==this.fragment&&this.iframe&&(a=this.getFragment(this.getHash(this.iframe)));if(a==this.fragment)return!1;this.iframe&&this.navigate(a);this.loadUrl()||this.loadUrl(this.getHash())},loadUrl:function(a){var b=this.fragment=this.getFragment(a);return f.any(this.handlers,
+function(a){if(a.route.test(b))return a.callback(b),!0})},navigate:function(a,b){if(!m.started)return!1;if(!b||!0===b)b={trigger:b};var c=(a||"").replace(s,"");this.fragment!=c&&(this._hasPushState?(0!=c.indexOf(this.options.root)&&(c=this.options.root+c),this.fragment=c,window.history[b.replace?"replaceState":"pushState"]({},document.title,c)):this._wantsHashChange?(this.fragment=c,this._updateHash(window.location,c,b.replace),this.iframe&&c!=this.getFragment(this.getHash(this.iframe))&&(b.replace||
+this.iframe.document.open().close(),this._updateHash(this.iframe.location,c,b.replace))):window.location.assign(this.options.root+a),b.trigger&&this.loadUrl(a))},_updateHash:function(a,b,c){c?a.replace(a.toString().replace(/(javascript:|#).*$/,"")+"#"+b):a.hash=b}});var v=g.View=function(a){this.cid=f.uniqueId("view");this._configure(a||{});this._ensureElement();this.initialize.apply(this,arguments);this.delegateEvents()},F=/^(\S+)\s*(.*)$/,w="model,collection,el,id,attributes,className,tagName".split(",");
+f.extend(v.prototype,k,{tagName:"div",$:function(a){return this.$el.find(a)},initialize:function(){},render:function(){return this},remove:function(){this.$el.remove();return this},make:function(a,b,c){a=document.createElement(a);b&&i(a).attr(b);c&&i(a).html(c);return a},setElement:function(a,b){this.$el&&this.undelegateEvents();this.$el=a instanceof i?a:i(a);this.el=this.$el[0];!1!==b&&this.delegateEvents();return this},delegateEvents:function(a){if(a||(a=n(this,"events"))){this.undelegateEvents();
+for(var b in a){var c=a[b];f.isFunction(c)||(c=this[a[b]]);if(!c)throw Error('Method "'+a[b]+'" does not exist');var d=b.match(F),e=d[1],d=d[2],c=f.bind(c,this),e=e+(".delegateEvents"+this.cid);""===d?this.$el.bind(e,c):this.$el.delegate(d,e,c)}}},undelegateEvents:function(){this.$el.unbind(".delegateEvents"+this.cid)},_configure:function(a){this.options&&(a=f.extend({},this.options,a));for(var b=0,c=w.length;b<c;b++){var d=w[b];a[d]&&(this[d]=a[d])}this.options=a},_ensureElement:function(){if(this.el)this.setElement(this.el,
+!1);else{var a=n(this,"attributes")||{};this.id&&(a.id=this.id);this.className&&(a["class"]=this.className);this.setElement(this.make(this.tagName,a),!1)}}});o.extend=r.extend=u.extend=v.extend=function(a,b){var c=G(this,a,b);c.extend=this.extend;return c};var H={create:"POST",update:"PUT","delete":"DELETE",read:"GET"};g.sync=function(a,b,c){var d=H[a];c||(c={});var e={type:d,dataType:"json"};c.url||(e.url=n(b,"url")||t());if(!c.data&&b&&("create"==a||"update"==a))e.contentType="application/json",
+e.data=JSON.stringify(b.toJSON());g.emulateJSON&&(e.contentType="application/x-www-form-urlencoded",e.data=e.data?{model:e.data}:{});if(g.emulateHTTP&&("PUT"===d||"DELETE"===d))g.emulateJSON&&(e.data._method=d),e.type="POST",e.beforeSend=function(a){a.setRequestHeader("X-HTTP-Method-Override",d)};"GET"!==e.type&&!g.emulateJSON&&(e.processData=!1);return i.ajax(f.extend(e,c))};g.wrapError=function(a,b,c){return function(d,e){e=d===b?e:d;a?a(b,e,c):b.trigger("error",b,e,c)}};var x=function(){},G=function(a,
+b,c){var d;d=b&&b.hasOwnProperty("constructor")?b.constructor:function(){a.apply(this,arguments)};f.extend(d,a);x.prototype=a.prototype;d.prototype=new x;b&&f.extend(d.prototype,b);c&&f.extend(d,c);d.prototype.constructor=d;d.__super__=a.prototype;return d},n=function(a,b){return!a||!a[b]?null:f.isFunction(a[b])?a[b]():a[b]},t=function(){throw Error('A "url" property or function must be specified');}}).call(this);
profiles/killpay/src/main/webapp/lib/handlebars-1.0.0.js 2278(+2278 -0)
diff --git a/profiles/killpay/src/main/webapp/lib/handlebars-1.0.0.js b/profiles/killpay/src/main/webapp/lib/handlebars-1.0.0.js
new file mode 100644
index 0000000..c70f09d
--- /dev/null
+++ b/profiles/killpay/src/main/webapp/lib/handlebars-1.0.0.js
@@ -0,0 +1,2278 @@
+/*
+
+Copyright (C) 2011 by Yehuda Katz
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+*/
+
+// lib/handlebars/browser-prefix.js
+var Handlebars = {};
+
+(function(Handlebars, undefined) {
+;
+// lib/handlebars/base.js
+
+Handlebars.VERSION = "1.0.0";
+Handlebars.COMPILER_REVISION = 4;
+
+Handlebars.REVISION_CHANGES = {
+ 1: '<= 1.0.rc.2', // 1.0.rc.2 is actually rev2 but doesn't report it
+ 2: '== 1.0.0-rc.3',
+ 3: '== 1.0.0-rc.4',
+ 4: '>= 1.0.0'
+};
+
+Handlebars.helpers = {};
+Handlebars.partials = {};
+
+var toString = Object.prototype.toString,
+ functionType = '[object Function]',
+ objectType = '[object Object]';
+
+Handlebars.registerHelper = function(name, fn, inverse) {
+ if (toString.call(name) === objectType) {
+ if (inverse || fn) { throw new Handlebars.Exception('Arg not supported with multiple helpers'); }
+ Handlebars.Utils.extend(this.helpers, name);
+ } else {
+ if (inverse) { fn.not = inverse; }
+ this.helpers[name] = fn;
+ }
+};
+
+Handlebars.registerPartial = function(name, str) {
+ if (toString.call(name) === objectType) {
+ Handlebars.Utils.extend(this.partials, name);
+ } else {
+ this.partials[name] = str;
+ }
+};
+
+Handlebars.registerHelper('helperMissing', function(arg) {
+ if(arguments.length === 2) {
+ return undefined;
+ } else {
+ throw new Error("Missing helper: '" + arg + "'");
+ }
+});
+
+Handlebars.registerHelper('blockHelperMissing', function(context, options) {
+ var inverse = options.inverse || function() {}, fn = options.fn;
+
+ var type = toString.call(context);
+
+ if(type === functionType) { context = context.call(this); }
+
+ if(context === true) {
+ return fn(this);
+ } else if(context === false || context == null) {
+ return inverse(this);
+ } else if(type === "[object Array]") {
+ if(context.length > 0) {
+ return Handlebars.helpers.each(context, options);
+ } else {
+ return inverse(this);
+ }
+ } else {
+ return fn(context);
+ }
+});
+
+Handlebars.K = function() {};
+
+Handlebars.createFrame = Object.create || function(object) {
+ Handlebars.K.prototype = object;
+ var obj = new Handlebars.K();
+ Handlebars.K.prototype = null;
+ return obj;
+};
+
+Handlebars.logger = {
+ DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3, level: 3,
+
+ methodMap: {0: 'debug', 1: 'info', 2: 'warn', 3: 'error'},
+
+ // can be overridden in the host environment
+ log: function(level, obj) {
+ if (Handlebars.logger.level <= level) {
+ var method = Handlebars.logger.methodMap[level];
+ if (typeof console !== 'undefined' && console[method]) {
+ console[method].call(console, obj);
+ }
+ }
+ }
+};
+
+Handlebars.log = function(level, obj) { Handlebars.logger.log(level, obj); };
+
+Handlebars.registerHelper('each', function(context, options) {
+ var fn = options.fn, inverse = options.inverse;
+ var i = 0, ret = "", data;
+
+ var type = toString.call(context);
+ if(type === functionType) { context = context.call(this); }
+
+ if (options.data) {
+ data = Handlebars.createFrame(options.data);
+ }
+
+ if(context && typeof context === 'object') {
+ if(context instanceof Array){
+ for(var j = context.length; i<j; i++) {
+ if (data) { data.index = i; }
+ ret = ret + fn(context[i], { data: data });
+ }
+ } else {
+ for(var key in context) {
+ if(context.hasOwnProperty(key)) {
+ if(data) { data.key = key; }
+ ret = ret + fn(context[key], {data: data});
+ i++;
+ }
+ }
+ }
+ }
+
+ if(i === 0){
+ ret = inverse(this);
+ }
+
+ return ret;
+});
+
+Handlebars.registerHelper('if', function(conditional, options) {
+ var type = toString.call(conditional);
+ if(type === functionType) { conditional = conditional.call(this); }
+
+ if(!conditional || Handlebars.Utils.isEmpty(conditional)) {
+ return options.inverse(this);
+ } else {
+ return options.fn(this);
+ }
+});
+
+Handlebars.registerHelper('unless', function(conditional, options) {
+ return Handlebars.helpers['if'].call(this, conditional, {fn: options.inverse, inverse: options.fn});
+});
+
+Handlebars.registerHelper('with', function(context, options) {
+ var type = toString.call(context);
+ if(type === functionType) { context = context.call(this); }
+
+ if (!Handlebars.Utils.isEmpty(context)) return options.fn(context);
+});
+
+Handlebars.registerHelper('log', function(context, options) {
+ var level = options.data && options.data.level != null ? parseInt(options.data.level, 10) : 1;
+ Handlebars.log(level, context);
+});
+;
+// lib/handlebars/compiler/parser.js
+/* Jison generated parser */
+var handlebars = (function(){
+var parser = {trace: function trace() { },
+yy: {},
+symbols_: {"error":2,"root":3,"program":4,"EOF":5,"simpleInverse":6,"statements":7,"statement":8,"openInverse":9,"closeBlock":10,"openBlock":11,"mustache":12,"partial":13,"CONTENT":14,"COMMENT":15,"OPEN_BLOCK":16,"inMustache":17,"CLOSE":18,"OPEN_INVERSE":19,"OPEN_ENDBLOCK":20,"path":21,"OPEN":22,"OPEN_UNESCAPED":23,"CLOSE_UNESCAPED":24,"OPEN_PARTIAL":25,"partialName":26,"params":27,"hash":28,"dataName":29,"param":30,"STRING":31,"INTEGER":32,"BOOLEAN":33,"hashSegments":34,"hashSegment":35,"ID":36,"EQUALS":37,"DATA":38,"pathSegments":39,"SEP":40,"$accept":0,"$end":1},
+terminals_: {2:"error",5:"EOF",14:"CONTENT",15:"COMMENT",16:"OPEN_BLOCK",18:"CLOSE",19:"OPEN_INVERSE",20:"OPEN_ENDBLOCK",22:"OPEN",23:"OPEN_UNESCAPED",24:"CLOSE_UNESCAPED",25:"OPEN_PARTIAL",31:"STRING",32:"INTEGER",33:"BOOLEAN",36:"ID",37:"EQUALS",38:"DATA",40:"SEP"},
+productions_: [0,[3,2],[4,2],[4,3],[4,2],[4,1],[4,1],[4,0],[7,1],[7,2],[8,3],[8,3],[8,1],[8,1],[8,1],[8,1],[11,3],[9,3],[10,3],[12,3],[12,3],[13,3],[13,4],[6,2],[17,3],[17,2],[17,2],[17,1],[17,1],[27,2],[27,1],[30,1],[30,1],[30,1],[30,1],[30,1],[28,1],[34,2],[34,1],[35,3],[35,3],[35,3],[35,3],[35,3],[26,1],[26,1],[26,1],[29,2],[21,1],[39,3],[39,1]],
+performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$) {
+
+var $0 = $$.length - 1;
+switch (yystate) {
+case 1: return $$[$0-1];
+break;
+case 2: this.$ = new yy.ProgramNode([], $$[$0]);
+break;
+case 3: this.$ = new yy.ProgramNode($$[$0-2], $$[$0]);
+break;
+case 4: this.$ = new yy.ProgramNode($$[$0-1], []);
+break;
+case 5: this.$ = new yy.ProgramNode($$[$0]);
+break;
+case 6: this.$ = new yy.ProgramNode([], []);
+break;
+case 7: this.$ = new yy.ProgramNode([]);
+break;
+case 8: this.$ = [$$[$0]];
+break;
+case 9: $$[$0-1].push($$[$0]); this.$ = $$[$0-1];
+break;
+case 10: this.$ = new yy.BlockNode($$[$0-2], $$[$0-1].inverse, $$[$0-1], $$[$0]);
+break;
+case 11: this.$ = new yy.BlockNode($$[$0-2], $$[$0-1], $$[$0-1].inverse, $$[$0]);
+break;
+case 12: this.$ = $$[$0];
+break;
+case 13: this.$ = $$[$0];
+break;
+case 14: this.$ = new yy.ContentNode($$[$0]);
+break;
+case 15: this.$ = new yy.CommentNode($$[$0]);
+break;
+case 16: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]);
+break;
+case 17: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]);
+break;
+case 18: this.$ = $$[$0-1];
+break;
+case 19:
+ // Parsing out the '&' escape token at this level saves ~500 bytes after min due to the removal of one parser node.
+ this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1], $$[$0-2][2] === '&');
+
+break;
+case 20: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1], true);
+break;
+case 21: this.$ = new yy.PartialNode($$[$0-1]);
+break;
+case 22: this.$ = new yy.PartialNode($$[$0-2], $$[$0-1]);
+break;
+case 23:
+break;
+case 24: this.$ = [[$$[$0-2]].concat($$[$0-1]), $$[$0]];
+break;
+case 25: this.$ = [[$$[$0-1]].concat($$[$0]), null];
+break;
+case 26: this.$ = [[$$[$0-1]], $$[$0]];
+break;
+case 27: this.$ = [[$$[$0]], null];
+break;
+case 28: this.$ = [[$$[$0]], null];
+break;
+case 29: $$[$0-1].push($$[$0]); this.$ = $$[$0-1];
+break;
+case 30: this.$ = [$$[$0]];
+break;
+case 31: this.$ = $$[$0];
+break;
+case 32: this.$ = new yy.StringNode($$[$0]);
+break;
+case 33: this.$ = new yy.IntegerNode($$[$0]);
+break;
+case 34: this.$ = new yy.BooleanNode($$[$0]);
+break;
+case 35: this.$ = $$[$0];
+break;
+case 36: this.$ = new yy.HashNode($$[$0]);
+break;
+case 37: $$[$0-1].push($$[$0]); this.$ = $$[$0-1];
+break;
+case 38: this.$ = [$$[$0]];
+break;
+case 39: this.$ = [$$[$0-2], $$[$0]];
+break;
+case 40: this.$ = [$$[$0-2], new yy.StringNode($$[$0])];
+break;
+case 41: this.$ = [$$[$0-2], new yy.IntegerNode($$[$0])];
+break;
+case 42: this.$ = [$$[$0-2], new yy.BooleanNode($$[$0])];
+break;
+case 43: this.$ = [$$[$0-2], $$[$0]];
+break;
+case 44: this.$ = new yy.PartialNameNode($$[$0]);
+break;
+case 45: this.$ = new yy.PartialNameNode(new yy.StringNode($$[$0]));
+break;
+case 46: this.$ = new yy.PartialNameNode(new yy.IntegerNode($$[$0]));
+break;
+case 47: this.$ = new yy.DataNode($$[$0]);
+break;
+case 48: this.$ = new yy.IdNode($$[$0]);
+break;
+case 49: $$[$0-2].push({part: $$[$0], separator: $$[$0-1]}); this.$ = $$[$0-2];
+break;
+case 50: this.$ = [{part: $$[$0]}];
+break;
+}
+},
+table: [{3:1,4:2,5:[2,7],6:3,7:4,8:6,9:7,11:8,12:9,13:10,14:[1,11],15:[1,12],16:[1,13],19:[1,5],22:[1,14],23:[1,15],25:[1,16]},{1:[3]},{5:[1,17]},{5:[2,6],7:18,8:6,9:7,11:8,12:9,13:10,14:[1,11],15:[1,12],16:[1,13],19:[1,19],20:[2,6],22:[1,14],23:[1,15],25:[1,16]},{5:[2,5],6:20,8:21,9:7,11:8,12:9,13:10,14:[1,11],15:[1,12],16:[1,13],19:[1,5],20:[2,5],22:[1,14],23:[1,15],25:[1,16]},{17:23,18:[1,22],21:24,29:25,36:[1,28],38:[1,27],39:26},{5:[2,8],14:[2,8],15:[2,8],16:[2,8],19:[2,8],20:[2,8],22:[2,8],23:[2,8],25:[2,8]},{4:29,6:3,7:4,8:6,9:7,11:8,12:9,13:10,14:[1,11],15:[1,12],16:[1,13],19:[1,5],20:[2,7],22:[1,14],23:[1,15],25:[1,16]},{4:30,6:3,7:4,8:6,9:7,11:8,12:9,13:10,14:[1,11],15:[1,12],16:[1,13],19:[1,5],20:[2,7],22:[1,14],23:[1,15],25:[1,16]},{5:[2,12],14:[2,12],15:[2,12],16:[2,12],19:[2,12],20:[2,12],22:[2,12],23:[2,12],25:[2,12]},{5:[2,13],14:[2,13],15:[2,13],16:[2,13],19:[2,13],20:[2,13],22:[2,13],23:[2,13],25:[2,13]},{5:[2,14],14:[2,14],15:[2,14],16:[2,14],19:[2,14],20:[2,14],22:[2,14],23:[2,14],25:[2,14]},{5:[2,15],14:[2,15],15:[2,15],16:[2,15],19:[2,15],20:[2,15],22:[2,15],23:[2,15],25:[2,15]},{17:31,21:24,29:25,36:[1,28],38:[1,27],39:26},{17:32,21:24,29:25,36:[1,28],38:[1,27],39:26},{17:33,21:24,29:25,36:[1,28],38:[1,27],39:26},{21:35,26:34,31:[1,36],32:[1,37],36:[1,28],39:26},{1:[2,1]},{5:[2,2],8:21,9:7,11:8,12:9,13:10,14:[1,11],15:[1,12],16:[1,13],19:[1,19],20:[2,2],22:[1,14],23:[1,15],25:[1,16]},{17:23,21:24,29:25,36:[1,28],38:[1,27],39:26},{5:[2,4],7:38,8:6,9:7,11:8,12:9,13:10,14:[1,11],15:[1,12],16:[1,13],19:[1,19],20:[2,4],22:[1,14],23:[1,15],25:[1,16]},{5:[2,9],14:[2,9],15:[2,9],16:[2,9],19:[2,9],20:[2,9],22:[2,9],23:[2,9],25:[2,9]},{5:[2,23],14:[2,23],15:[2,23],16:[2,23],19:[2,23],20:[2,23],22:[2,23],23:[2,23],25:[2,23]},{18:[1,39]},{18:[2,27],21:44,24:[2,27],27:40,28:41,29:48,30:42,31:[1,45],32:[1,46],33:[1,47],34:43,35:49,36:[1,50],38:[1,27],39:26},{18:[2,28],24:[2,28]},{18:[2,48],24:[2,48],31:[2,48],32:[2,48],33:[2,48],36:[2,48],38:[2,48],40:[1,51]},{21:52,36:[1,28],39:26},{18:[2,50],24:[2,50],31:[2,50],32:[2,50],33:[2,50],36:[2,50],38:[2,50],40:[2,50]},{10:53,20:[1,54]},{10:55,20:[1,54]},{18:[1,56]},{18:[1,57]},{24:[1,58]},{18:[1,59],21:60,36:[1,28],39:26},{18:[2,44],36:[2,44]},{18:[2,45],36:[2,45]},{18:[2,46],36:[2,46]},{5:[2,3],8:21,9:7,11:8,12:9,13:10,14:[1,11],15:[1,12],16:[1,13],19:[1,19],20:[2,3],22:[1,14],23:[1,15],25:[1,16]},{14:[2,17],15:[2,17],16:[2,17],19:[2,17],20:[2,17],22:[2,17],23:[2,17],25:[2,17]},{18:[2,25],21:44,24:[2,25],28:61,29:48,30:62,31:[1,45],32:[1,46],33:[1,47],34:43,35:49,36:[1,50],38:[1,27],39:26},{18:[2,26],24:[2,26]},{18:[2,30],24:[2,30],31:[2,30],32:[2,30],33:[2,30],36:[2,30],38:[2,30]},{18:[2,36],24:[2,36],35:63,36:[1,64]},{18:[2,31],24:[2,31],31:[2,31],32:[2,31],33:[2,31],36:[2,31],38:[2,31]},{18:[2,32],24:[2,32],31:[2,32],32:[2,32],33:[2,32],36:[2,32],38:[2,32]},{18:[2,33],24:[2,33],31:[2,33],32:[2,33],33:[2,33],36:[2,33],38:[2,33]},{18:[2,34],24:[2,34],31:[2,34],32:[2,34],33:[2,34],36:[2,34],38:[2,34]},{18:[2,35],24:[2,35],31:[2,35],32:[2,35],33:[2,35],36:[2,35],38:[2,35]},{18:[2,38],24:[2,38],36:[2,38]},{18:[2,50],24:[2,50],31:[2,50],32:[2,50],33:[2,50],36:[2,50],37:[1,65],38:[2,50],40:[2,50]},{36:[1,66]},{18:[2,47],24:[2,47],31:[2,47],32:[2,47],33:[2,47],36:[2,47],38:[2,47]},{5:[2,10],14:[2,10],15:[2,10],16:[2,10],19:[2,10],20:[2,10],22:[2,10],23:[2,10],25:[2,10]},{21:67,36:[1,28],39:26},{5:[2,11],14:[2,11],15:[2,11],16:[2,11],19:[2,11],20:[2,11],22:[2,11],23:[2,11],25:[2,11]},{14:[2,16],15:[2,16],16:[2,16],19:[2,16],20:[2,16],22:[2,16],23:[2,16],25:[2,16]},{5:[2,19],14:[2,19],15:[2,19],16:[2,19],19:[2,19],20:[2,19],22:[2,19],23:[2,19],25:[2,19]},{5:[2,20],14:[2,20],15:[2,20],16:[2,20],19:[2,20],20:[2,20],22:[2,20],23:[2,20],25:[2,20]},{5:[2,21],14:[2,21],15:[2,21],16:[2,21],19:[2,21],20:[2,21],22:[2,21],23:[2,21],25:[2,21]},{18:[1,68]},{18:[2,24],24:[2,24]},{18:[2,29],24:[2,29],31:[2,29],32:[2,29],33:[2,29],36:[2,29],38:[2,29]},{18:[2,37],24:[2,37],36:[2,37]},{37:[1,65]},{21:69,29:73,31:[1,70],32:[1,71],33:[1,72],36:[1,28],38:[1,27],39:26},{18:[2,49],24:[2,49],31:[2,49],32:[2,49],33:[2,49],36:[2,49],38:[2,49],40:[2,49]},{18:[1,74]},{5:[2,22],14:[2,22],15:[2,22],16:[2,22],19:[2,22],20:[2,22],22:[2,22],23:[2,22],25:[2,22]},{18:[2,39],24:[2,39],36:[2,39]},{18:[2,40],24:[2,40],36:[2,40]},{18:[2,41],24:[2,41],36:[2,41]},{18:[2,42],24:[2,42],36:[2,42]},{18:[2,43],24:[2,43],36:[2,43]},{5:[2,18],14:[2,18],15:[2,18],16:[2,18],19:[2,18],20:[2,18],22:[2,18],23:[2,18],25:[2,18]}],
+defaultActions: {17:[2,1]},
+parseError: function parseError(str, hash) {
+ throw new Error(str);
+},
+parse: function parse(input) {
+ var self = this, stack = [0], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1;
+ this.lexer.setInput(input);
+ this.lexer.yy = this.yy;
+ this.yy.lexer = this.lexer;
+ this.yy.parser = this;
+ if (typeof this.lexer.yylloc == "undefined")
+ this.lexer.yylloc = {};
+ var yyloc = this.lexer.yylloc;
+ lstack.push(yyloc);
+ var ranges = this.lexer.options && this.lexer.options.ranges;
+ if (typeof this.yy.parseError === "function")
+ this.parseError = this.yy.parseError;
+ function popStack(n) {
+ stack.length = stack.length - 2 * n;
+ vstack.length = vstack.length - n;
+ lstack.length = lstack.length - n;
+ }
+ function lex() {
+ var token;
+ token = self.lexer.lex() || 1;
+ if (typeof token !== "number") {
+ token = self.symbols_[token] || token;
+ }
+ return token;
+ }
+ var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
+ while (true) {
+ state = stack[stack.length - 1];
+ if (this.defaultActions[state]) {
+ action = this.defaultActions[state];
+ } else {
+ if (symbol === null || typeof symbol == "undefined") {
+ symbol = lex();
+ }
+ action = table[state] && table[state][symbol];
+ }
+ if (typeof action === "undefined" || !action.length || !action[0]) {
+ var errStr = "";
+ if (!recovering) {
+ expected = [];
+ for (p in table[state])
+ if (this.terminals_[p] && p > 2) {
+ expected.push("'" + this.terminals_[p] + "'");
+ }
+ if (this.lexer.showPosition) {
+ errStr = "Parse error on line " + (yylineno + 1) + ":\n" + this.lexer.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
+ } else {
+ errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == 1?"end of input":"'" + (this.terminals_[symbol] || symbol) + "'");
+ }
+ this.parseError(errStr, {text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected});
+ }
+ }
+ if (action[0] instanceof Array && action.length > 1) {
+ throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
+ }
+ switch (action[0]) {
+ case 1:
+ stack.push(symbol);
+ vstack.push(this.lexer.yytext);
+ lstack.push(this.lexer.yylloc);
+ stack.push(action[1]);
+ symbol = null;
+ if (!preErrorSymbol) {
+ yyleng = this.lexer.yyleng;
+ yytext = this.lexer.yytext;
+ yylineno = this.lexer.yylineno;
+ yyloc = this.lexer.yylloc;
+ if (recovering > 0)
+ recovering--;
+ } else {
+ symbol = preErrorSymbol;
+ preErrorSymbol = null;
+ }
+ break;
+ case 2:
+ len = this.productions_[action[1]][1];
+ yyval.$ = vstack[vstack.length - len];
+ yyval._$ = {first_line: lstack[lstack.length - (len || 1)].first_line, last_line: lstack[lstack.length - 1].last_line, first_column: lstack[lstack.length - (len || 1)].first_column, last_column: lstack[lstack.length - 1].last_column};
+ if (ranges) {
+ yyval._$.range = [lstack[lstack.length - (len || 1)].range[0], lstack[lstack.length - 1].range[1]];
+ }
+ r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack);
+ if (typeof r !== "undefined") {
+ return r;
+ }
+ if (len) {
+ stack = stack.slice(0, -1 * len * 2);
+ vstack = vstack.slice(0, -1 * len);
+ lstack = lstack.slice(0, -1 * len);
+ }
+ stack.push(this.productions_[action[1]][0]);
+ vstack.push(yyval.$);
+ lstack.push(yyval._$);
+ newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
+ stack.push(newState);
+ break;
+ case 3:
+ return true;
+ }
+ }
+ return true;
+}
+};
+/* Jison generated lexer */
+var lexer = (function(){
+var lexer = ({EOF:1,
+parseError:function parseError(str, hash) {
+ if (this.yy.parser) {
+ this.yy.parser.parseError(str, hash);
+ } else {
+ throw new Error(str);
+ }
+ },
+setInput:function (input) {
+ this._input = input;
+ this._more = this._less = this.done = false;
+ this.yylineno = this.yyleng = 0;
+ this.yytext = this.matched = this.match = '';
+ this.conditionStack = ['INITIAL'];
+ this.yylloc = {first_line:1,first_column:0,last_line:1,last_column:0};
+ if (this.options.ranges) this.yylloc.range = [0,0];
+ this.offset = 0;
+ return this;
+ },
+input:function () {
+ var ch = this._input[0];
+ this.yytext += ch;
+ this.yyleng++;
+ this.offset++;
+ this.match += ch;
+ this.matched += ch;
+ var lines = ch.match(/(?:\r\n?|\n).*/g);
+ if (lines) {
+ this.yylineno++;
+ this.yylloc.last_line++;
+ } else {
+ this.yylloc.last_column++;
+ }
+ if (this.options.ranges) this.yylloc.range[1]++;
+
+ this._input = this._input.slice(1);
+ return ch;
+ },
+unput:function (ch) {
+ var len = ch.length;
+ var lines = ch.split(/(?:\r\n?|\n)/g);
+
+ this._input = ch + this._input;
+ this.yytext = this.yytext.substr(0, this.yytext.length-len-1);
+ //this.yyleng -= len;
+ this.offset -= len;
+ var oldLines = this.match.split(/(?:\r\n?|\n)/g);
+ this.match = this.match.substr(0, this.match.length-1);
+ this.matched = this.matched.substr(0, this.matched.length-1);
+
+ if (lines.length-1) this.yylineno -= lines.length-1;
+ var r = this.yylloc.range;
+
+ this.yylloc = {first_line: this.yylloc.first_line,
+ last_line: this.yylineno+1,
+ first_column: this.yylloc.first_column,
+ last_column: lines ?
+ (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length:
+ this.yylloc.first_column - len
+ };
+
+ if (this.options.ranges) {
+ this.yylloc.range = [r[0], r[0] + this.yyleng - len];
+ }
+ return this;
+ },
+more:function () {
+ this._more = true;
+ return this;
+ },
+less:function (n) {
+ this.unput(this.match.slice(n));
+ },
+pastInput:function () {
+ var past = this.matched.substr(0, this.matched.length - this.match.length);
+ return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, "");
+ },
+upcomingInput:function () {
+ var next = this.match;
+ if (next.length < 20) {
+ next += this._input.substr(0, 20-next.length);
+ }
+ return (next.substr(0,20)+(next.length > 20 ? '...':'')).replace(/\n/g, "");
+ },
+showPosition:function () {
+ var pre = this.pastInput();
+ var c = new Array(pre.length + 1).join("-");
+ return pre + this.upcomingInput() + "\n" + c+"^";
+ },
+next:function () {
+ if (this.done) {
+ return this.EOF;
+ }
+ if (!this._input) this.done = true;
+
+ var token,
+ match,
+ tempMatch,
+ index,
+ col,
+ lines;
+ if (!this._more) {
+ this.yytext = '';
+ this.match = '';
+ }
+ var rules = this._currentRules();
+ for (var i=0;i < rules.length; i++) {
+ tempMatch = this._input.match(this.rules[rules[i]]);
+ if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
+ match = tempMatch;
+ index = i;
+ if (!this.options.flex) break;
+ }
+ }
+ if (match) {
+ lines = match[0].match(/(?:\r\n?|\n).*/g);
+ if (lines) this.yylineno += lines.length;
+ this.yylloc = {first_line: this.yylloc.last_line,
+ last_line: this.yylineno+1,
+ first_column: this.yylloc.last_column,
+ last_column: lines ? lines[lines.length-1].length-lines[lines.length-1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length};
+ this.yytext += match[0];
+ this.match += match[0];
+ this.matches = match;
+ this.yyleng = this.yytext.length;
+ if (this.options.ranges) {
+ this.yylloc.range = [this.offset, this.offset += this.yyleng];
+ }
+ this._more = false;
+ this._input = this._input.slice(match[0].length);
+ this.matched += match[0];
+ token = this.performAction.call(this, this.yy, this, rules[index],this.conditionStack[this.conditionStack.length-1]);
+ if (this.done && this._input) this.done = false;
+ if (token) return token;
+ else return;
+ }
+ if (this._input === "") {
+ return this.EOF;
+ } else {
+ return this.parseError('Lexical error on line '+(this.yylineno+1)+'. Unrecognized text.\n'+this.showPosition(),
+ {text: "", token: null, line: this.yylineno});
+ }
+ },
+lex:function lex() {
+ var r = this.next();
+ if (typeof r !== 'undefined') {
+ return r;
+ } else {
+ return this.lex();
+ }
+ },
+begin:function begin(condition) {
+ this.conditionStack.push(condition);
+ },
+popState:function popState() {
+ return this.conditionStack.pop();
+ },
+_currentRules:function _currentRules() {
+ return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules;
+ },
+topState:function () {
+ return this.conditionStack[this.conditionStack.length-2];
+ },
+pushState:function begin(condition) {
+ this.begin(condition);
+ }});
+lexer.options = {};
+lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) {
+
+var YYSTATE=YY_START
+switch($avoiding_name_collisions) {
+case 0: yy_.yytext = "\\"; return 14;
+break;
+case 1:
+ if(yy_.yytext.slice(-1) !== "\\") this.begin("mu");
+ if(yy_.yytext.slice(-1) === "\\") yy_.yytext = yy_.yytext.substr(0,yy_.yyleng-1), this.begin("emu");
+ if(yy_.yytext) return 14;
+
+break;
+case 2: return 14;
+break;
+case 3:
+ if(yy_.yytext.slice(-1) !== "\\") this.popState();
+ if(yy_.yytext.slice(-1) === "\\") yy_.yytext = yy_.yytext.substr(0,yy_.yyleng-1);
+ return 14;
+
+break;
+case 4: yy_.yytext = yy_.yytext.substr(0, yy_.yyleng-4); this.popState(); return 15;
+break;
+case 5: return 25;
+break;
+case 6: return 16;
+break;
+case 7: return 20;
+break;
+case 8: return 19;
+break;
+case 9: return 19;
+break;
+case 10: return 23;
+break;
+case 11: return 22;
+break;
+case 12: this.popState(); this.begin('com');
+break;
+case 13: yy_.yytext = yy_.yytext.substr(3,yy_.yyleng-5); this.popState(); return 15;
+break;
+case 14: return 22;
+break;
+case 15: return 37;
+break;
+case 16: return 36;
+break;
+case 17: return 36;
+break;
+case 18: return 40;
+break;
+case 19: /*ignore whitespace*/
+break;
+case 20: this.popState(); return 24;
+break;
+case 21: this.popState(); return 18;
+break;
+case 22: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\"/g,'"'); return 31;
+break;
+case 23: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\'/g,"'"); return 31;
+break;
+case 24: return 38;
+break;
+case 25: return 33;
+break;
+case 26: return 33;
+break;
+case 27: return 32;
+break;
+case 28: return 36;
+break;
+case 29: yy_.yytext = yy_.yytext.substr(1, yy_.yyleng-2); return 36;
+break;
+case 30: return 'INVALID';
+break;
+case 31: return 5;
+break;
+}
+};
+lexer.rules = [/^(?:\\\\(?=(\{\{)))/,/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|$)))/,/^(?:[\s\S]*?--\}\})/,/^(?:\{\{>)/,/^(?:\{\{#)/,/^(?:\{\{\/)/,/^(?:\{\{\^)/,/^(?:\{\{\s*else\b)/,/^(?:\{\{\{)/,/^(?:\{\{&)/,/^(?:\{\{!--)/,/^(?:\{\{![\s\S]*?\}\})/,/^(?:\{\{)/,/^(?:=)/,/^(?:\.(?=[}\/ ]))/,/^(?:\.\.)/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}\}\})/,/^(?:\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@)/,/^(?:true(?=[}\s]))/,/^(?:false(?=[}\s]))/,/^(?:-?[0-9]+(?=[}\s]))/,/^(?:[^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=[=}\s\/.]))/,/^(?:\[[^\]]*\])/,/^(?:.)/,/^(?:$)/];
+lexer.conditions = {"mu":{"rules":[5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31],"inclusive":false},"emu":{"rules":[3],"inclusive":false},"com":{"rules":[4],"inclusive":false},"INITIAL":{"rules":[0,1,2,31],"inclusive":true}};
+return lexer;})()
+parser.lexer = lexer;
+function Parser () { this.yy = {}; }Parser.prototype = parser;parser.Parser = Parser;
+return new Parser;
+})();;
+// lib/handlebars/compiler/base.js
+
+Handlebars.Parser = handlebars;
+
+Handlebars.parse = function(input) {
+
+ // Just return if an already-compile AST was passed in.
+ if(input.constructor === Handlebars.AST.ProgramNode) { return input; }
+
+ Handlebars.Parser.yy = Handlebars.AST;
+ return Handlebars.Parser.parse(input);
+};
+;
+// lib/handlebars/compiler/ast.js
+Handlebars.AST = {};
+
+Handlebars.AST.ProgramNode = function(statements, inverse) {
+ this.type = "program";
+ this.statements = statements;
+ if(inverse) { this.inverse = new Handlebars.AST.ProgramNode(inverse); }
+};
+
+Handlebars.AST.MustacheNode = function(rawParams, hash, unescaped) {
+ this.type = "mustache";
+ this.escaped = !unescaped;
+ this.hash = hash;
+
+ var id = this.id = rawParams[0];
+ var params = this.params = rawParams.slice(1);
+
+ // a mustache is an eligible helper if:
+ // * its id is simple (a single part, not `this` or `..`)
+ var eligibleHelper = this.eligibleHelper = id.isSimple;
+
+ // a mustache is definitely a helper if:
+ // * it is an eligible helper, and
+ // * it has at least one parameter or hash segment
+ this.isHelper = eligibleHelper && (params.length || hash);
+
+ // if a mustache is an eligible helper but not a definite
+ // helper, it is ambiguous, and will be resolved in a later
+ // pass or at runtime.
+};
+
+Handlebars.AST.PartialNode = function(partialName, context) {
+ this.type = "partial";
+ this.partialName = partialName;
+ this.context = context;
+};
+
+Handlebars.AST.BlockNode = function(mustache, program, inverse, close) {
+ var verifyMatch = function(open, close) {
+ if(open.original !== close.original) {
+ throw new Handlebars.Exception(open.original + " doesn't match " + close.original);
+ }
+ };
+
+ verifyMatch(mustache.id, close);
+ this.type = "block";
+ this.mustache = mustache;
+ this.program = program;
+ this.inverse = inverse;
+
+ if (this.inverse && !this.program) {
+ this.isInverse = true;
+ }
+};
+
+Handlebars.AST.ContentNode = function(string) {
+ this.type = "content";
+ this.string = string;
+};
+
+Handlebars.AST.HashNode = function(pairs) {
+ this.type = "hash";
+ this.pairs = pairs;
+};
+
+Handlebars.AST.IdNode = function(parts) {
+ this.type = "ID";
+
+ var original = "",
+ dig = [],
+ depth = 0;
+
+ for(var i=0,l=parts.length; i<l; i++) {
+ var part = parts[i].part;
+ original += (parts[i].separator || '') + part;
+
+ if (part === ".." || part === "." || part === "this") {
+ if (dig.length > 0) { throw new Handlebars.Exception("Invalid path: " + original); }
+ else if (part === "..") { depth++; }
+ else { this.isScoped = true; }
+ }
+ else { dig.push(part); }
+ }
+
+ this.original = original;
+ this.parts = dig;
+ this.string = dig.join('.');
+ this.depth = depth;
+
+ // an ID is simple if it only has one part, and that part is not
+ // `..` or `this`.
+ this.isSimple = parts.length === 1 && !this.isScoped && depth === 0;
+
+ this.stringModeValue = this.string;
+};
+
+Handlebars.AST.PartialNameNode = function(name) {
+ this.type = "PARTIAL_NAME";
+ this.name = name.original;
+};
+
+Handlebars.AST.DataNode = function(id) {
+ this.type = "DATA";
+ this.id = id;
+};
+
+Handlebars.AST.StringNode = function(string) {
+ this.type = "STRING";
+ this.original =
+ this.string =
+ this.stringModeValue = string;
+};
+
+Handlebars.AST.IntegerNode = function(integer) {
+ this.type = "INTEGER";
+ this.original =
+ this.integer = integer;
+ this.stringModeValue = Number(integer);
+};
+
+Handlebars.AST.BooleanNode = function(bool) {
+ this.type = "BOOLEAN";
+ this.bool = bool;
+ this.stringModeValue = bool === "true";
+};
+
+Handlebars.AST.CommentNode = function(comment) {
+ this.type = "comment";
+ this.comment = comment;
+};
+;
+// lib/handlebars/utils.js
+
+var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack'];
+
+Handlebars.Exception = function(message) {
+ var tmp = Error.prototype.constructor.apply(this, arguments);
+
+ // Unfortunately errors are not enumerable in Chrome (at least), so `for prop in tmp` doesn't work.
+ for (var idx = 0; idx < errorProps.length; idx++) {
+ this[errorProps[idx]] = tmp[errorProps[idx]];
+ }
+};
+Handlebars.Exception.prototype = new Error();
+
+// Build out our basic SafeString type
+Handlebars.SafeString = function(string) {
+ this.string = string;
+};
+Handlebars.SafeString.prototype.toString = function() {
+ return this.string.toString();
+};
+
+var escape = {
+ "&": "&",
+ "<": "<",
+ ">": ">",
+ '"': """,
+ "'": "'",
+ "`": "`"
+};
+
+var badChars = /[&<>"'`]/g;
+var possible = /[&<>"'`]/;
+
+var escapeChar = function(chr) {
+ return escape[chr] || "&";
+};
+
+Handlebars.Utils = {
+ extend: function(obj, value) {
+ for(var key in value) {
+ if(value.hasOwnProperty(key)) {
+ obj[key] = value[key];
+ }
+ }
+ },
+
+ escapeExpression: function(string) {
+ // don't escape SafeStrings, since they're already safe
+ if (string instanceof Handlebars.SafeString) {
+ return string.toString();
+ } else if (string == null || string === false) {
+ return "";
+ }
+
+ // Force a string conversion as this will be done by the append regardless and
+ // the regex test will do this transparently behind the scenes, causing issues if
+ // an object's to string has escaped characters in it.
+ string = string.toString();
+
+ if(!possible.test(string)) { return string; }
+ return string.replace(badChars, escapeChar);
+ },
+
+ isEmpty: function(value) {
+ if (!value && value !== 0) {
+ return true;
+ } else if(toString.call(value) === "[object Array]" && value.length === 0) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+};
+;
+// lib/handlebars/compiler/compiler.js
+
+/*jshint eqnull:true*/
+var Compiler = Handlebars.Compiler = function() {};
+var JavaScriptCompiler = Handlebars.JavaScriptCompiler = function() {};
+
+// the foundHelper register will disambiguate helper lookup from finding a
+// function in a context. This is necessary for mustache compatibility, which
+// requires that context functions in blocks are evaluated by blockHelperMissing,
+// and then proceed as if the resulting value was provided to blockHelperMissing.
+
+Compiler.prototype = {
+ compiler: Compiler,
+
+ disassemble: function() {
+ var opcodes = this.opcodes, opcode, out = [], params, param;
+
+ for (var i=0, l=opcodes.length; i<l; i++) {
+ opcode = opcodes[i];
+
+ if (opcode.opcode === 'DECLARE') {
+ out.push("DECLARE " + opcode.name + "=" + opcode.value);
+ } else {
+ params = [];
+ for (var j=0; j<opcode.args.length; j++) {
+ param = opcode.args[j];
+ if (typeof param === "string") {
+ param = "\"" + param.replace("\n", "\\n") + "\"";
+ }
+ params.push(param);
+ }
+ out.push(opcode.opcode + " " + params.join(" "));
+ }
+ }
+
+ return out.join("\n");
+ },
+ equals: function(other) {
+ var len = this.opcodes.length;
+ if (other.opcodes.length !== len) {
+ return false;
+ }
+
+ for (var i = 0; i < len; i++) {
+ var opcode = this.opcodes[i],
+ otherOpcode = other.opcodes[i];
+ if (opcode.opcode !== otherOpcode.opcode || opcode.args.length !== otherOpcode.args.length) {
+ return false;
+ }
+ for (var j = 0; j < opcode.args.length; j++) {
+ if (opcode.args[j] !== otherOpcode.args[j]) {
+ return false;
+ }
+ }
+ }
+
+ len = this.children.length;
+ if (other.children.length !== len) {
+ return false;
+ }
+ for (i = 0; i < len; i++) {
+ if (!this.children[i].equals(other.children[i])) {
+ return false;
+ }
+ }
+
+ return true;
+ },
+
+ guid: 0,
+
+ compile: function(program, options) {
+ this.children = [];
+ this.depths = {list: []};
+ this.options = options;
+
+ // These changes will propagate to the other compiler components
+ var knownHelpers = this.options.knownHelpers;
+ this.options.knownHelpers = {
+ 'helperMissing': true,
+ 'blockHelperMissing': true,
+ 'each': true,
+ 'if': true,
+ 'unless': true,
+ 'with': true,
+ 'log': true
+ };
+ if (knownHelpers) {
+ for (var name in knownHelpers) {
+ this.options.knownHelpers[name] = knownHelpers[name];
+ }
+ }
+
+ return this.program(program);
+ },
+
+ accept: function(node) {
+ return this[node.type](node);
+ },
+
+ program: function(program) {
+ var statements = program.statements, statement;
+ this.opcodes = [];
+
+ for(var i=0, l=statements.length; i<l; i++) {
+ statement = statements[i];
+ this[statement.type](statement);
+ }
+ this.isSimple = l === 1;
+
+ this.depths.list = this.depths.list.sort(function(a, b) {
+ return a - b;
+ });
+
+ return this;
+ },
+
+ compileProgram: function(program) {
+ var result = new this.compiler().compile(program, this.options);
+ var guid = this.guid++, depth;
+
+ this.usePartial = this.usePartial || result.usePartial;
+
+ this.children[guid] = result;
+
+ for(var i=0, l=result.depths.list.length; i<l; i++) {
+ depth = result.depths.list[i];
+
+ if(depth < 2) { continue; }
+ else { this.addDepth(depth - 1); }
+ }
+
+ return guid;
+ },
+
+ block: function(block) {
+ var mustache = block.mustache,
+ program = block.program,
+ inverse = block.inverse;
+
+ if (program) {
+ program = this.compileProgram(program);
+ }
+
+ if (inverse) {
+ inverse = this.compileProgram(inverse);
+ }
+
+ var type = this.classifyMustache(mustache);
+
+ if (type === "helper") {
+ this.helperMustache(mustache, program, inverse);
+ } else if (type === "simple") {
+ this.simpleMustache(mustache);
+
+ // now that the simple mustache is resolved, we need to
+ // evaluate it by executing `blockHelperMissing`
+ this.opcode('pushProgram', program);
+ this.opcode('pushProgram', inverse);
+ this.opcode('emptyHash');
+ this.opcode('blockValue');
+ } else {
+ this.ambiguousMustache(mustache, program, inverse);
+
+ // now that the simple mustache is resolved, we need to
+ // evaluate it by executing `blockHelperMissing`
+ this.opcode('pushProgram', program);
+ this.opcode('pushProgram', inverse);
+ this.opcode('emptyHash');
+ this.opcode('ambiguousBlockValue');
+ }
+
+ this.opcode('append');
+ },
+
+ hash: function(hash) {
+ var pairs = hash.pairs, pair, val;
+
+ this.opcode('pushHash');
+
+ for(var i=0, l=pairs.length; i<l; i++) {
+ pair = pairs[i];
+ val = pair[1];
+
+ if (this.options.stringParams) {
+ if(val.depth) {
+ this.addDepth(val.depth);
+ }
+ this.opcode('getContext', val.depth || 0);
+ this.opcode('pushStringParam', val.stringModeValue, val.type);
+ } else {
+ this.accept(val);
+ }
+
+ this.opcode('assignToHash', pair[0]);
+ }
+ this.opcode('popHash');
+ },
+
+ partial: function(partial) {
+ var partialName = partial.partialName;
+ this.usePartial = true;
+
+ if(partial.context) {
+ this.ID(partial.context);
+ } else {
+ this.opcode('push', 'depth0');
+ }
+
+ this.opcode('invokePartial', partialName.name);
+ this.opcode('append');
+ },
+
+ content: function(content) {
+ this.opcode('appendContent', content.string);
+ },
+
+ mustache: function(mustache) {
+ var options = this.options;
+ var type = this.classifyMustache(mustache);
+
+ if (type === "simple") {
+ this.simpleMustache(mustache);
+ } else if (type === "helper") {
+ this.helperMustache(mustache);
+ } else {
+ this.ambiguousMustache(mustache);
+ }
+
+ if(mustache.escaped && !options.noEscape) {
+ this.opcode('appendEscaped');
+ } else {
+ this.opcode('append');
+ }
+ },
+
+ ambiguousMustache: function(mustache, program, inverse) {
+ var id = mustache.id,
+ name = id.parts[0],
+ isBlock = program != null || inverse != null;
+
+ this.opcode('getContext', id.depth);
+
+ this.opcode('pushProgram', program);
+ this.opcode('pushProgram', inverse);
+
+ this.opcode('invokeAmbiguous', name, isBlock);
+ },
+
+ simpleMustache: function(mustache) {
+ var id = mustache.id;
+
+ if (id.type === 'DATA') {
+ this.DATA(id);
+ } else if (id.parts.length) {
+ this.ID(id);
+ } else {
+ // Simplified ID for `this`
+ this.addDepth(id.depth);
+ this.opcode('getContext', id.depth);
+ this.opcode('pushContext');
+ }
+
+ this.opcode('resolvePossibleLambda');
+ },
+
+ helperMustache: function(mustache, program, inverse) {
+ var params = this.setupFullMustacheParams(mustache, program, inverse),
+ name = mustache.id.parts[0];
+
+ if (this.options.knownHelpers[name]) {
+ this.opcode('invokeKnownHelper', params.length, name);
+ } else if (this.options.knownHelpersOnly) {
+ throw new Error("You specified knownHelpersOnly, but used the unknown helper " + name);
+ } else {
+ this.opcode('invokeHelper', params.length, name);
+ }
+ },
+
+ ID: function(id) {
+ this.addDepth(id.depth);
+ this.opcode('getContext', id.depth);
+
+ var name = id.parts[0];
+ if (!name) {
+ this.opcode('pushContext');
+ } else {
+ this.opcode('lookupOnContext', id.parts[0]);
+ }
+
+ for(var i=1, l=id.parts.length; i<l; i++) {
+ this.opcode('lookup', id.parts[i]);
+ }
+ },
+
+ DATA: function(data) {
+ this.options.data = true;
+ if (data.id.isScoped || data.id.depth) {
+ throw new Handlebars.Exception('Scoped data references are not supported: ' + data.original);
+ }
+
+ this.opcode('lookupData');
+ var parts = data.id.parts;
+ for(var i=0, l=parts.length; i<l; i++) {
+ this.opcode('lookup', parts[i]);
+ }
+ },
+
+ STRING: function(string) {
+ this.opcode('pushString', string.string);
+ },
+
+ INTEGER: function(integer) {
+ this.opcode('pushLiteral', integer.integer);
+ },
+
+ BOOLEAN: function(bool) {
+ this.opcode('pushLiteral', bool.bool);
+ },
+
+ comment: function() {},
+
+ // HELPERS
+ opcode: function(name) {
+ this.opcodes.push({ opcode: name, args: [].slice.call(arguments, 1) });
+ },
+
+ declare: function(name, value) {
+ this.opcodes.push({ opcode: 'DECLARE', name: name, value: value });
+ },
+
+ addDepth: function(depth) {
+ if(isNaN(depth)) { throw new Error("EWOT"); }
+ if(depth === 0) { return; }
+
+ if(!this.depths[depth]) {
+ this.depths[depth] = true;
+ this.depths.list.push(depth);
+ }
+ },
+
+ classifyMustache: function(mustache) {
+ var isHelper = mustache.isHelper;
+ var isEligible = mustache.eligibleHelper;
+ var options = this.options;
+
+ // if ambiguous, we can possibly resolve the ambiguity now
+ if (isEligible && !isHelper) {
+ var name = mustache.id.parts[0];
+
+ if (options.knownHelpers[name]) {
+ isHelper = true;
+ } else if (options.knownHelpersOnly) {
+ isEligible = false;
+ }
+ }
+
+ if (isHelper) { return "helper"; }
+ else if (isEligible) { return "ambiguous"; }
+ else { return "simple"; }
+ },
+
+ pushParams: function(params) {
+ var i = params.length, param;
+
+ while(i--) {
+ param = params[i];
+
+ if(this.options.stringParams) {
+ if(param.depth) {
+ this.addDepth(param.depth);
+ }
+
+ this.opcode('getContext', param.depth || 0);
+ this.opcode('pushStringParam', param.stringModeValue, param.type);
+ } else {
+ this[param.type](param);
+ }
+ }
+ },
+
+ setupMustacheParams: function(mustache) {
+ var params = mustache.params;
+ this.pushParams(params);
+
+ if(mustache.hash) {
+ this.hash(mustache.hash);
+ } else {
+ this.opcode('emptyHash');
+ }
+
+ return params;
+ },
+
+ // this will replace setupMustacheParams when we're done
+ setupFullMustacheParams: function(mustache, program, inverse) {
+ var params = mustache.params;
+ this.pushParams(params);
+
+ this.opcode('pushProgram', program);
+ this.opcode('pushProgram', inverse);
+
+ if(mustache.hash) {
+ this.hash(mustache.hash);
+ } else {
+ this.opcode('emptyHash');
+ }
+
+ return params;
+ }
+};
+
+var Literal = function(value) {
+ this.value = value;
+};
+
+JavaScriptCompiler.prototype = {
+ // PUBLIC API: You can override these methods in a subclass to provide
+ // alternative compiled forms for name lookup and buffering semantics
+ nameLookup: function(parent, name /* , type*/) {
+ if (/^[0-9]+$/.test(name)) {
+ return parent + "[" + name + "]";
+ } else if (JavaScriptCompiler.isValidJavaScriptVariableName(name)) {
+ return parent + "." + name;
+ }
+ else {
+ return parent + "['" + name + "']";
+ }
+ },
+
+ appendToBuffer: function(string) {
+ if (this.environment.isSimple) {
+ return "return " + string + ";";
+ } else {
+ return {
+ appendToBuffer: true,
+ content: string,
+ toString: function() { return "buffer += " + string + ";"; }
+ };
+ }
+ },
+
+ initializeBuffer: function() {
+ return this.quotedString("");
+ },
+
+ namespace: "Handlebars",
+ // END PUBLIC API
+
+ compile: function(environment, options, context, asObject) {
+ this.environment = environment;
+ this.options = options || {};
+
+ Handlebars.log(Handlebars.logger.DEBUG, this.environment.disassemble() + "\n\n");
+
+ this.name = this.environment.name;
+ this.isChild = !!context;
+ this.context = context || {
+ programs: [],
+ environments: [],
+ aliases: { }
+ };
+
+ this.preamble();
+
+ this.stackSlot = 0;
+ this.stackVars = [];
+ this.registers = { list: [] };
+ this.compileStack = [];
+ this.inlineStack = [];
+
+ this.compileChildren(environment, options);
+
+ var opcodes = environment.opcodes, opcode;
+
+ this.i = 0;
+
+ for(l=opcodes.length; this.i<l; this.i++) {
+ opcode = opcodes[this.i];
+
+ if(opcode.opcode === 'DECLARE') {
+ this[opcode.name] = opcode.value;
+ } else {
+ this[opcode.opcode].apply(this, opcode.args);
+ }
+ }
+
+ return this.createFunctionContext(asObject);
+ },
+
+ nextOpcode: function() {
+ var opcodes = this.environment.opcodes;
+ return opcodes[this.i + 1];
+ },
+
+ eat: function() {
+ this.i = this.i + 1;
+ },
+
+ preamble: function() {
+ var out = [];
+
+ if (!this.isChild) {
+ var namespace = this.namespace;
+
+ var copies = "helpers = this.merge(helpers, " + namespace + ".helpers);";
+ if (this.environment.usePartial) { copies = copies + " partials = this.merge(partials, " + namespace + ".partials);"; }
+ if (this.options.data) { copies = copies + " data = data || {};"; }
+ out.push(copies);
+ } else {
+ out.push('');
+ }
+
+ if (!this.environment.isSimple) {
+ out.push(", buffer = " + this.initializeBuffer());
+ } else {
+ out.push("");
+ }
+
+ // track the last context pushed into place to allow skipping the
+ // getContext opcode when it would be a noop
+ this.lastContext = 0;
+ this.source = out;
+ },
+
+ createFunctionContext: function(asObject) {
+ var locals = this.stackVars.concat(this.registers.list);
+
+ if(locals.length > 0) {
+ this.source[1] = this.source[1] + ", " + locals.join(", ");
+ }
+
+ // Generate minimizer alias mappings
+ if (!this.isChild) {
+ for (var alias in this.context.aliases) {
+ if (this.context.aliases.hasOwnProperty(alias)) {
+ this.source[1] = this.source[1] + ', ' + alias + '=' + this.context.aliases[alias];
+ }
+ }
+ }
+
+ if (this.source[1]) {
+ this.source[1] = "var " + this.source[1].substring(2) + ";";
+ }
+
+ // Merge children
+ if (!this.isChild) {
+ this.source[1] += '\n' + this.context.programs.join('\n') + '\n';
+ }
+
+ if (!this.environment.isSimple) {
+ this.source.push("return buffer;");
+ }
+
+ var params = this.isChild ? ["depth0", "data"] : ["Handlebars", "depth0", "helpers", "partials", "data"];
+
+ for(var i=0, l=this.environment.depths.list.length; i<l; i++) {
+ params.push("depth" + this.environment.depths.list[i]);
+ }
+
+ // Perform a second pass over the output to merge content when possible
+ var source = this.mergeSource();
+
+ if (!this.isChild) {
+ var revision = Handlebars.COMPILER_REVISION,
+ versions = Handlebars.REVISION_CHANGES[revision];
+ source = "this.compilerInfo = ["+revision+",'"+versions+"'];\n"+source;
+ }
+
+ if (asObject) {
+ params.push(source);
+
+ return Function.apply(this, params);
+ } else {
+ var functionSource = 'function ' + (this.name || '') + '(' + params.join(',') + ') {\n ' + source + '}';
+ Handlebars.log(Handlebars.logger.DEBUG, functionSource + "\n\n");
+ return functionSource;
+ }
+ },
+ mergeSource: function() {
+ // WARN: We are not handling the case where buffer is still populated as the source should
+ // not have buffer append operations as their final action.
+ var source = '',
+ buffer;
+ for (var i = 0, len = this.source.length; i < len; i++) {
+ var line = this.source[i];
+ if (line.appendToBuffer) {
+ if (buffer) {
+ buffer = buffer + '\n + ' + line.content;
+ } else {
+ buffer = line.content;
+ }
+ } else {
+ if (buffer) {
+ source += 'buffer += ' + buffer + ';\n ';
+ buffer = undefined;
+ }
+ source += line + '\n ';
+ }
+ }
+ return source;
+ },
+
+ // [blockValue]
+ //
+ // On stack, before: hash, inverse, program, value
+ // On stack, after: return value of blockHelperMissing
+ //
+ // The purpose of this opcode is to take a block of the form
+ // `{{#foo}}...{{/foo}}`, resolve the value of `foo`, and
+ // replace it on the stack with the result of properly
+ // invoking blockHelperMissing.
+ blockValue: function() {
+ this.context.aliases.blockHelperMissing = 'helpers.blockHelperMissing';
+
+ var params = ["depth0"];
+ this.setupParams(0, params);
+
+ this.replaceStack(function(current) {
+ params.splice(1, 0, current);
+ return "blockHelperMissing.call(" + params.join(", ") + ")";
+ });
+ },
+
+ // [ambiguousBlockValue]
+ //
+ // On stack, before: hash, inverse, program, value
+ // Compiler value, before: lastHelper=value of last found helper, if any
+ // On stack, after, if no lastHelper: same as [blockValue]
+ // On stack, after, if lastHelper: value
+ ambiguousBlockValue: function() {
+ this.context.aliases.blockHelperMissing = 'helpers.blockHelperMissing';
+
+ var params = ["depth0"];
+ this.setupParams(0, params);
+
+ var current = this.topStack();
+ params.splice(1, 0, current);
+
+ // Use the options value generated from the invocation
+ params[params.length-1] = 'options';
+
+ this.source.push("if (!" + this.lastHelper + ") { " + current + " = blockHelperMissing.call(" + params.join(", ") + "); }");
+ },
+
+ // [appendContent]
+ //
+ // On stack, before: ...
+ // On stack, after: ...
+ //
+ // Appends the string value of `content` to the current buffer
+ appendContent: function(content) {
+ this.source.push(this.appendToBuffer(this.quotedString(content)));
+ },
+
+ // [append]
+ //
+ // On stack, before: value, ...
+ // On stack, after: ...
+ //
+ // Coerces `value` to a String and appends it to the current buffer.
+ //
+ // If `value` is truthy, or 0, it is coerced into a string and appended
+ // Otherwise, the empty string is appended
+ append: function() {
+ // Force anything that is inlined onto the stack so we don't have duplication
+ // when we examine local
+ this.flushInline();
+ var local = this.popStack();
+ this.source.push("if(" + local + " || " + local + " === 0) { " + this.appendToBuffer(local) + " }");
+ if (this.environment.isSimple) {
+ this.source.push("else { " + this.appendToBuffer("''") + " }");
+ }
+ },
+
+ // [appendEscaped]
+ //
+ // On stack, before: value, ...
+ // On stack, after: ...
+ //
+ // Escape `value` and append it to the buffer
+ appendEscaped: function() {
+ this.context.aliases.escapeExpression = 'this.escapeExpression';
+
+ this.source.push(this.appendToBuffer("escapeExpression(" + this.popStack() + ")"));
+ },
+
+ // [getContext]
+ //
+ // On stack, before: ...
+ // On stack, after: ...
+ // Compiler value, after: lastContext=depth
+ //
+ // Set the value of the `lastContext` compiler value to the depth
+ getContext: function(depth) {
+ if(this.lastContext !== depth) {
+ this.lastContext = depth;
+ }
+ },
+
+ // [lookupOnContext]
+ //
+ // On stack, before: ...
+ // On stack, after: currentContext[name], ...
+ //
+ // Looks up the value of `name` on the current context and pushes
+ // it onto the stack.
+ lookupOnContext: function(name) {
+ this.push(this.nameLookup('depth' + this.lastContext, name, 'context'));
+ },
+
+ // [pushContext]
+ //
+ // On stack, before: ...
+ // On stack, after: currentContext, ...
+ //
+ // Pushes the value of the current context onto the stack.
+ pushContext: function() {
+ this.pushStackLiteral('depth' + this.lastContext);
+ },
+
+ // [resolvePossibleLambda]
+ //
+ // On stack, before: value, ...
+ // On stack, after: resolved value, ...
+ //
+ // If the `value` is a lambda, replace it on the stack by
+ // the return value of the lambda
+ resolvePossibleLambda: function() {
+ this.context.aliases.functionType = '"function"';
+
+ this.replaceStack(function(current) {
+ return "typeof " + current + " === functionType ? " + current + ".apply(depth0) : " + current;
+ });
+ },
+
+ // [lookup]
+ //
+ // On stack, before: value, ...
+ // On stack, after: value[name], ...
+ //
+ // Replace the value on the stack with the result of looking
+ // up `name` on `value`
+ lookup: function(name) {
+ this.replaceStack(function(current) {
+ return current + " == null || " + current + " === false ? " + current + " : " + this.nameLookup(current, name, 'context');
+ });
+ },
+
+ // [lookupData]
+ //
+ // On stack, before: ...
+ // On stack, after: data[id], ...
+ //
+ // Push the result of looking up `id` on the current data
+ lookupData: function(id) {
+ this.push('data');
+ },
+
+ // [pushStringParam]
+ //
+ // On stack, before: ...
+ // On stack, after: string, currentContext, ...
+ //
+ // This opcode is designed for use in string mode, which
+ // provides the string value of a parameter along with its
+ // depth rather than resolving it immediately.
+ pushStringParam: function(string, type) {
+ this.pushStackLiteral('depth' + this.lastContext);
+
+ this.pushString(type);
+
+ if (typeof string === 'string') {
+ this.pushString(string);
+ } else {
+ this.pushStackLiteral(string);
+ }
+ },
+
+ emptyHash: function() {
+ this.pushStackLiteral('{}');
+
+ if (this.options.stringParams) {
+ this.register('hashTypes', '{}');
+ this.register('hashContexts', '{}');
+ }
+ },
+ pushHash: function() {
+ this.hash = {values: [], types: [], contexts: []};
+ },
+ popHash: function() {
+ var hash = this.hash;
+ this.hash = undefined;
+
+ if (this.options.stringParams) {
+ this.register('hashContexts', '{' + hash.contexts.join(',') + '}');
+ this.register('hashTypes', '{' + hash.types.join(',') + '}');
+ }
+ this.push('{\n ' + hash.values.join(',\n ') + '\n }');
+ },
+
+ // [pushString]
+ //
+ // On stack, before: ...
+ // On stack, after: quotedString(string), ...
+ //
+ // Push a quoted version of `string` onto the stack
+ pushString: function(string) {
+ this.pushStackLiteral(this.quotedString(string));
+ },
+
+ // [push]
+ //
+ // On stack, before: ...
+ // On stack, after: expr, ...
+ //
+ // Push an expression onto the stack
+ push: function(expr) {
+ this.inlineStack.push(expr);
+ return expr;
+ },
+
+ // [pushLiteral]
+ //
+ // On stack, before: ...
+ // On stack, after: value, ...
+ //
+ // Pushes a value onto the stack. This operation prevents
+ // the compiler from creating a temporary variable to hold
+ // it.
+ pushLiteral: function(value) {
+ this.pushStackLiteral(value);
+ },
+
+ // [pushProgram]
+ //
+ // On stack, before: ...
+ // On stack, after: program(guid), ...
+ //
+ // Push a program expression onto the stack. This takes
+ // a compile-time guid and converts it into a runtime-accessible
+ // expression.
+ pushProgram: function(guid) {
+ if (guid != null) {
+ this.pushStackLiteral(this.programExpression(guid));
+ } else {
+ this.pushStackLiteral(null);
+ }
+ },
+
+ // [invokeHelper]
+ //
+ // On stack, before: hash, inverse, program, params..., ...
+ // On stack, after: result of helper invocation
+ //
+ // Pops off the helper's parameters, invokes the helper,
+ // and pushes the helper's return value onto the stack.
+ //
+ // If the helper is not found, `helperMissing` is called.
+ invokeHelper: function(paramSize, name) {
+ this.context.aliases.helperMissing = 'helpers.helperMissing';
+
+ var helper = this.lastHelper = this.setupHelper(paramSize, name, true);
+ var nonHelper = this.nameLookup('depth' + this.lastContext, name, 'context');
+
+ this.push(helper.name + ' || ' + nonHelper);
+ this.replaceStack(function(name) {
+ return name + ' ? ' + name + '.call(' +
+ helper.callParams + ") " + ": helperMissing.call(" +
+ helper.helperMissingParams + ")";
+ });
+ },
+
+ // [invokeKnownHelper]
+ //
+ // On stack, before: hash, inverse, program, params..., ...
+ // On stack, after: result of helper invocation
+ //
+ // This operation is used when the helper is known to exist,
+ // so a `helperMissing` fallback is not required.
+ invokeKnownHelper: function(paramSize, name) {
+ var helper = this.setupHelper(paramSize, name);
+ this.push(helper.name + ".call(" + helper.callParams + ")");
+ },
+
+ // [invokeAmbiguous]
+ //
+ // On stack, before: hash, inverse, program, params..., ...
+ // On stack, after: result of disambiguation
+ //
+ // This operation is used when an expression like `{{foo}}`
+ // is provided, but we don't know at compile-time whether it
+ // is a helper or a path.
+ //
+ // This operation emits more code than the other options,
+ // and can be avoided by passing the `knownHelpers` and
+ // `knownHelpersOnly` flags at compile-time.
+ invokeAmbiguous: function(name, helperCall) {
+ this.context.aliases.functionType = '"function"';
+
+ this.pushStackLiteral('{}'); // Hash value
+ var helper = this.setupHelper(0, name, helperCall);
+
+ var helperName = this.lastHelper = this.nameLookup('helpers', name, 'helper');
+
+ var nonHelper = this.nameLookup('depth' + this.lastContext, name, 'context');
+ var nextStack = this.nextStack();
+
+ this.source.push('if (' + nextStack + ' = ' + helperName + ') { ' + nextStack + ' = ' + nextStack + '.call(' + helper.callParams + '); }');
+ this.source.push('else { ' + nextStack + ' = ' + nonHelper + '; ' + nextStack + ' = typeof ' + nextStack + ' === functionType ? ' + nextStack + '.apply(depth0) : ' + nextStack + '; }');
+ },
+
+ // [invokePartial]
+ //
+ // On stack, before: context, ...
+ // On stack after: result of partial invocation
+ //
+ // This operation pops off a context, invokes a partial with that context,
+ // and pushes the result of the invocation back.
+ invokePartial: function(name) {
+ var params = [this.nameLookup('partials', name, 'partial'), "'" + name + "'", this.popStack(), "helpers", "partials"];
+
+ if (this.options.data) {
+ params.push("data");
+ }
+
+ this.context.aliases.self = "this";
+ this.push("self.invokePartial(" + params.join(", ") + ")");
+ },
+
+ // [assignToHash]
+ //
+ // On stack, before: value, hash, ...
+ // On stack, after: hash, ...
+ //
+ // Pops a value and hash off the stack, assigns `hash[key] = value`
+ // and pushes the hash back onto the stack.
+ assignToHash: function(key) {
+ var value = this.popStack(),
+ context,
+ type;
+
+ if (this.options.stringParams) {
+ type = this.popStack();
+ context = this.popStack();
+ }
+
+ var hash = this.hash;
+ if (context) {
+ hash.contexts.push("'" + key + "': " + context);
+ }
+ if (type) {
+ hash.types.push("'" + key + "': " + type);
+ }
+ hash.values.push("'" + key + "': (" + value + ")");
+ },
+
+ // HELPERS
+
+ compiler: JavaScriptCompiler,
+
+ compileChildren: function(environment, options) {
+ var children = environment.children, child, compiler;
+
+ for(var i=0, l=children.length; i<l; i++) {
+ child = children[i];
+ compiler = new this.compiler();
+
+ var index = this.matchExistingProgram(child);
+
+ if (index == null) {
+ this.context.programs.push(''); // Placeholder to prevent name conflicts for nested children
+ index = this.context.programs.length;
+ child.index = index;
+ child.name = 'program' + index;
+ this.context.programs[index] = compiler.compile(child, options, this.context);
+ this.context.environments[index] = child;
+ } else {
+ child.index = index;
+ child.name = 'program' + index;
+ }
+ }
+ },
+ matchExistingProgram: function(child) {
+ for (var i = 0, len = this.context.environments.length; i < len; i++) {
+ var environment = this.context.environments[i];
+ if (environment && environment.equals(child)) {
+ return i;
+ }
+ }
+ },
+
+ programExpression: function(guid) {
+ this.context.aliases.self = "this";
+
+ if(guid == null) {
+ return "self.noop";
+ }
+
+ var child = this.environment.children[guid],
+ depths = child.depths.list, depth;
+
+ var programParams = [child.index, child.name, "data"];
+
+ for(var i=0, l = depths.length; i<l; i++) {
+ depth = depths[i];
+
+ if(depth === 1) { programParams.push("depth0"); }
+ else { programParams.push("depth" + (depth - 1)); }
+ }
+
+ return (depths.length === 0 ? "self.program(" : "self.programWithDepth(") + programParams.join(", ") + ")";
+ },
+
+ register: function(name, val) {
+ this.useRegister(name);
+ this.source.push(name + " = " + val + ";");
+ },
+
+ useRegister: function(name) {
+ if(!this.registers[name]) {
+ this.registers[name] = true;
+ this.registers.list.push(name);
+ }
+ },
+
+ pushStackLiteral: function(item) {
+ return this.push(new Literal(item));
+ },
+
+ pushStack: function(item) {
+ this.flushInline();
+
+ var stack = this.incrStack();
+ if (item) {
+ this.source.push(stack + " = " + item + ";");
+ }
+ this.compileStack.push(stack);
+ return stack;
+ },
+
+ replaceStack: function(callback) {
+ var prefix = '',
+ inline = this.isInline(),
+ stack;
+
+ // If we are currently inline then we want to merge the inline statement into the
+ // replacement statement via ','
+ if (inline) {
+ var top = this.popStack(true);
+
+ if (top instanceof Literal) {
+ // Literals do not need to be inlined
+ stack = top.value;
+ } else {
+ // Get or create the current stack name for use by the inline
+ var name = this.stackSlot ? this.topStackName() : this.incrStack();
+
+ prefix = '(' + this.push(name) + ' = ' + top + '),';
+ stack = this.topStack();
+ }
+ } else {
+ stack = this.topStack();
+ }
+
+ var item = callback.call(this, stack);
+
+ if (inline) {
+ if (this.inlineStack.length || this.compileStack.length) {
+ this.popStack();
+ }
+ this.push('(' + prefix + item + ')');
+ } else {
+ // Prevent modification of the context depth variable. Through replaceStack
+ if (!/^stack/.test(stack)) {
+ stack = this.nextStack();
+ }
+
+ this.source.push(stack + " = (" + prefix + item + ");");
+ }
+ return stack;
+ },
+
+ nextStack: function() {
+ return this.pushStack();
+ },
+
+ incrStack: function() {
+ this.stackSlot++;
+ if(this.stackSlot > this.stackVars.length) { this.stackVars.push("stack" + this.stackSlot); }
+ return this.topStackName();
+ },
+ topStackName: function() {
+ return "stack" + this.stackSlot;
+ },
+ flushInline: function() {
+ var inlineStack = this.inlineStack;
+ if (inlineStack.length) {
+ this.inlineStack = [];
+ for (var i = 0, len = inlineStack.length; i < len; i++) {
+ var entry = inlineStack[i];
+ if (entry instanceof Literal) {
+ this.compileStack.push(entry);
+ } else {
+ this.pushStack(entry);
+ }
+ }
+ }
+ },
+ isInline: function() {
+ return this.inlineStack.length;
+ },
+
+ popStack: function(wrapped) {
+ var inline = this.isInline(),
+ item = (inline ? this.inlineStack : this.compileStack).pop();
+
+ if (!wrapped && (item instanceof Literal)) {
+ return item.value;
+ } else {
+ if (!inline) {
+ this.stackSlot--;
+ }
+ return item;
+ }
+ },
+
+ topStack: function(wrapped) {
+ var stack = (this.isInline() ? this.inlineStack : this.compileStack),
+ item = stack[stack.length - 1];
+
+ if (!wrapped && (item instanceof Literal)) {
+ return item.value;
+ } else {
+ return item;
+ }
+ },
+
+ quotedString: function(str) {
+ return '"' + str
+ .replace(/\\/g, '\\\\')
+ .replace(/"/g, '\\"')
+ .replace(/\n/g, '\\n')
+ .replace(/\r/g, '\\r')
+ .replace(/\u2028/g, '\\u2028') // Per Ecma-262 7.3 + 7.8.4
+ .replace(/\u2029/g, '\\u2029') + '"';
+ },
+
+ setupHelper: function(paramSize, name, missingParams) {
+ var params = [];
+ this.setupParams(paramSize, params, missingParams);
+ var foundHelper = this.nameLookup('helpers', name, 'helper');
+
+ return {
+ params: params,
+ name: foundHelper,
+ callParams: ["depth0"].concat(params).join(", "),
+ helperMissingParams: missingParams && ["depth0", this.quotedString(name)].concat(params).join(", ")
+ };
+ },
+
+ // the params and contexts arguments are passed in arrays
+ // to fill in
+ setupParams: function(paramSize, params, useRegister) {
+ var options = [], contexts = [], types = [], param, inverse, program;
+
+ options.push("hash:" + this.popStack());
+
+ inverse = this.popStack();
+ program = this.popStack();
+
+ // Avoid setting fn and inverse if neither are set. This allows
+ // helpers to do a check for `if (options.fn)`
+ if (program || inverse) {
+ if (!program) {
+ this.context.aliases.self = "this";
+ program = "self.noop";
+ }
+
+ if (!inverse) {
+ this.context.aliases.self = "this";
+ inverse = "self.noop";
+ }
+
+ options.push("inverse:" + inverse);
+ options.push("fn:" + program);
+ }
+
+ for(var i=0; i<paramSize; i++) {
+ param = this.popStack();
+ params.push(param);
+
+ if(this.options.stringParams) {
+ types.push(this.popStack());
+ contexts.push(this.popStack());
+ }
+ }
+
+ if (this.options.stringParams) {
+ options.push("contexts:[" + contexts.join(",") + "]");
+ options.push("types:[" + types.join(",") + "]");
+ options.push("hashContexts:hashContexts");
+ options.push("hashTypes:hashTypes");
+ }
+
+ if(this.options.data) {
+ options.push("data:data");
+ }
+
+ options = "{" + options.join(",") + "}";
+ if (useRegister) {
+ this.register('options', options);
+ params.push('options');
+ } else {
+ params.push(options);
+ }
+ return params.join(", ");
+ }
+};
+
+var reservedWords = (
+ "break else new var" +
+ " case finally return void" +
+ " catch for switch while" +
+ " continue function this with" +
+ " default if throw" +
+ " delete in try" +
+ " do instanceof typeof" +
+ " abstract enum int short" +
+ " boolean export interface static" +
+ " byte extends long super" +
+ " char final native synchronized" +
+ " class float package throws" +
+ " const goto private transient" +
+ " debugger implements protected volatile" +
+ " double import public let yield"
+).split(" ");
+
+var compilerWords = JavaScriptCompiler.RESERVED_WORDS = {};
+
+for(var i=0, l=reservedWords.length; i<l; i++) {
+ compilerWords[reservedWords[i]] = true;
+}
+
+JavaScriptCompiler.isValidJavaScriptVariableName = function(name) {
+ if(!JavaScriptCompiler.RESERVED_WORDS[name] && /^[a-zA-Z_$][0-9a-zA-Z_$]+$/.test(name)) {
+ return true;
+ }
+ return false;
+};
+
+Handlebars.precompile = function(input, options) {
+ if (input == null || (typeof input !== 'string' && input.constructor !== Handlebars.AST.ProgramNode)) {
+ throw new Handlebars.Exception("You must pass a string or Handlebars AST to Handlebars.precompile. You passed " + input);
+ }
+
+ options = options || {};
+ if (!('data' in options)) {
+ options.data = true;
+ }
+ var ast = Handlebars.parse(input);
+ var environment = new Compiler().compile(ast, options);
+ return new JavaScriptCompiler().compile(environment, options);
+};
+
+Handlebars.compile = function(input, options) {
+ if (input == null || (typeof input !== 'string' && input.constructor !== Handlebars.AST.ProgramNode)) {
+ throw new Handlebars.Exception("You must pass a string or Handlebars AST to Handlebars.compile. You passed " + input);
+ }
+
+ options = options || {};
+ if (!('data' in options)) {
+ options.data = true;
+ }
+ var compiled;
+ function compile() {
+ var ast = Handlebars.parse(input);
+ var environment = new Compiler().compile(ast, options);
+ var templateSpec = new JavaScriptCompiler().compile(environment, options, undefined, true);
+ return Handlebars.template(templateSpec);
+ }
+
+ // Template is only compiled on first use and cached after that point.
+ return function(context, options) {
+ if (!compiled) {
+ compiled = compile();
+ }
+ return compiled.call(this, context, options);
+ };
+};
+
+;
+// lib/handlebars/runtime.js
+
+Handlebars.VM = {
+ template: function(templateSpec) {
+ // Just add water
+ var container = {
+ escapeExpression: Handlebars.Utils.escapeExpression,
+ invokePartial: Handlebars.VM.invokePartial,
+ programs: [],
+ program: function(i, fn, data) {
+ var programWrapper = this.programs[i];
+ if(data) {
+ programWrapper = Handlebars.VM.program(i, fn, data);
+ } else if (!programWrapper) {
+ programWrapper = this.programs[i] = Handlebars.VM.program(i, fn);
+ }
+ return programWrapper;
+ },
+ merge: function(param, common) {
+ var ret = param || common;
+
+ if (param && common) {
+ ret = {};
+ Handlebars.Utils.extend(ret, common);
+ Handlebars.Utils.extend(ret, param);
+ }
+ return ret;
+ },
+ programWithDepth: Handlebars.VM.programWithDepth,
+ noop: Handlebars.VM.noop,
+ compilerInfo: null
+ };
+
+ return function(context, options) {
+ options = options || {};
+ var result = templateSpec.call(container, Handlebars, context, options.helpers, options.partials, options.data);
+
+ var compilerInfo = container.compilerInfo || [],
+ compilerRevision = compilerInfo[0] || 1,
+ currentRevision = Handlebars.COMPILER_REVISION;
+
+ if (compilerRevision !== currentRevision) {
+ if (compilerRevision < currentRevision) {
+ var runtimeVersions = Handlebars.REVISION_CHANGES[currentRevision],
+ compilerVersions = Handlebars.REVISION_CHANGES[compilerRevision];
+ throw "Template was precompiled with an older version of Handlebars than the current runtime. "+
+ "Please update your precompiler to a newer version ("+runtimeVersions+") or downgrade your runtime to an older version ("+compilerVersions+").";
+ } else {
+ // Use the embedded version info since the runtime doesn't know about this revision yet
+ throw "Template was precompiled with a newer version of Handlebars than the current runtime. "+
+ "Please update your runtime to a newer version ("+compilerInfo[1]+").";
+ }
+ }
+
+ return result;
+ };
+ },
+
+ programWithDepth: function(i, fn, data /*, $depth */) {
+ var args = Array.prototype.slice.call(arguments, 3);
+
+ var program = function(context, options) {
+ options = options || {};
+
+ return fn.apply(this, [context, options.data || data].concat(args));
+ };
+ program.program = i;
+ program.depth = args.length;
+ return program;
+ },
+ program: function(i, fn, data) {
+ var program = function(context, options) {
+ options = options || {};
+
+ return fn(context, options.data || data);
+ };
+ program.program = i;
+ program.depth = 0;
+ return program;
+ },
+ noop: function() { return ""; },
+ invokePartial: function(partial, name, context, helpers, partials, data) {
+ var options = { helpers: helpers, partials: partials, data: data };
+
+ if(partial === undefined) {
+ throw new Handlebars.Exception("The partial " + name + " could not be found");
+ } else if(partial instanceof Function) {
+ return partial(context, options);
+ } else if (!Handlebars.compile) {
+ throw new Handlebars.Exception("The partial " + name + " could not be compiled when running in runtime-only mode");
+ } else {
+ partials[name] = Handlebars.compile(partial, {data: data !== undefined});
+ return partials[name](context, options);
+ }
+ }
+};
+
+Handlebars.template = Handlebars.VM.template;
+;
+// lib/handlebars/browser-suffix.js
+})(Handlebars);
+;
diff --git a/profiles/killpay/src/main/webapp/lib/highlight.7.3.pack.js b/profiles/killpay/src/main/webapp/lib/highlight.7.3.pack.js
new file mode 100644
index 0000000..9a95a75
--- /dev/null
+++ b/profiles/killpay/src/main/webapp/lib/highlight.7.3.pack.js
@@ -0,0 +1 @@
+var hljs=new function(){function l(o){return o.replace(/&/gm,"&").replace(/</gm,"<").replace(/>/gm,">")}function b(p){for(var o=p.firstChild;o;o=o.nextSibling){if(o.nodeName=="CODE"){return o}if(!(o.nodeType==3&&o.nodeValue.match(/\s+/))){break}}}function h(p,o){return Array.prototype.map.call(p.childNodes,function(q){if(q.nodeType==3){return o?q.nodeValue.replace(/\n/g,""):q.nodeValue}if(q.nodeName=="BR"){return"\n"}return h(q,o)}).join("")}function a(q){var p=(q.className+" "+q.parentNode.className).split(/\s+/);p=p.map(function(r){return r.replace(/^language-/,"")});for(var o=0;o<p.length;o++){if(e[p[o]]||p[o]=="no-highlight"){return p[o]}}}function c(q){var o=[];(function p(r,s){for(var t=r.firstChild;t;t=t.nextSibling){if(t.nodeType==3){s+=t.nodeValue.length}else{if(t.nodeName=="BR"){s+=1}else{if(t.nodeType==1){o.push({event:"start",offset:s,node:t});s=p(t,s);o.push({event:"stop",offset:s,node:t})}}}}return s})(q,0);return o}function j(x,v,w){var p=0;var y="";var r=[];function t(){if(x.length&&v.length){if(x[0].offset!=v[0].offset){return(x[0].offset<v[0].offset)?x:v}else{return v[0].event=="start"?x:v}}else{return x.length?x:v}}function s(A){function z(B){return" "+B.nodeName+'="'+l(B.value)+'"'}return"<"+A.nodeName+Array.prototype.map.call(A.attributes,z).join("")+">"}while(x.length||v.length){var u=t().splice(0,1)[0];y+=l(w.substr(p,u.offset-p));p=u.offset;if(u.event=="start"){y+=s(u.node);r.push(u.node)}else{if(u.event=="stop"){var o,q=r.length;do{q--;o=r[q];y+=("</"+o.nodeName.toLowerCase()+">")}while(o!=u.node);r.splice(q,1);while(q<r.length){y+=s(r[q]);q++}}}}return y+l(w.substr(p))}function f(q){function o(s,r){return RegExp(s,"m"+(q.cI?"i":"")+(r?"g":""))}function p(y,w){if(y.compiled){return}y.compiled=true;var s=[];if(y.k){var r={};function z(A,t){t.split(" ").forEach(function(B){var C=B.split("|");r[C[0]]=[A,C[1]?Number(C[1]):1];s.push(C[0])})}y.lR=o(y.l||hljs.IR,true);if(typeof y.k=="string"){z("keyword",y.k)}else{for(var x in y.k){if(!y.k.hasOwnProperty(x)){continue}z(x,y.k[x])}}y.k=r}if(w){if(y.bWK){y.b="\\b("+s.join("|")+")\\s"}y.bR=o(y.b?y.b:"\\B|\\b");if(!y.e&&!y.eW){y.e="\\B|\\b"}if(y.e){y.eR=o(y.e)}y.tE=y.e||"";if(y.eW&&w.tE){y.tE+=(y.e?"|":"")+w.tE}}if(y.i){y.iR=o(y.i)}if(y.r===undefined){y.r=1}if(!y.c){y.c=[]}for(var v=0;v<y.c.length;v++){if(y.c[v]=="self"){y.c[v]=y}p(y.c[v],y)}if(y.starts){p(y.starts,w)}var u=[];for(var v=0;v<y.c.length;v++){u.push(y.c[v].b)}if(y.tE){u.push(y.tE)}if(y.i){u.push(y.i)}y.t=u.length?o(u.join("|"),true):{exec:function(t){return null}}}p(q)}function d(D,E){function o(r,M){for(var L=0;L<M.c.length;L++){var K=M.c[L].bR.exec(r);if(K&&K.index==0){return M.c[L]}}}function s(K,r){if(K.e&&K.eR.test(r)){return K}if(K.eW){return s(K.parent,r)}}function t(r,K){return K.i&&K.iR.test(r)}function y(L,r){var K=F.cI?r[0].toLowerCase():r[0];return L.k.hasOwnProperty(K)&&L.k[K]}function G(){var K=l(w);if(!A.k){return K}var r="";var N=0;A.lR.lastIndex=0;var L=A.lR.exec(K);while(L){r+=K.substr(N,L.index-N);var M=y(A,L);if(M){v+=M[1];r+='<span class="'+M[0]+'">'+L[0]+"</span>"}else{r+=L[0]}N=A.lR.lastIndex;L=A.lR.exec(K)}return r+K.substr(N)}function z(){if(A.sL&&!e[A.sL]){return l(w)}var r=A.sL?d(A.sL,w):g(w);if(A.r>0){v+=r.keyword_count;B+=r.r}return'<span class="'+r.language+'">'+r.value+"</span>"}function J(){return A.sL!==undefined?z():G()}function I(L,r){var K=L.cN?'<span class="'+L.cN+'">':"";if(L.rB){x+=K;w=""}else{if(L.eB){x+=l(r)+K;w=""}else{x+=K;w=r}}A=Object.create(L,{parent:{value:A}});B+=L.r}function C(K,r){w+=K;if(r===undefined){x+=J();return 0}var L=o(r,A);if(L){x+=J();I(L,r);return L.rB?0:r.length}var M=s(A,r);if(M){if(!(M.rE||M.eE)){w+=r}x+=J();do{if(A.cN){x+="</span>"}A=A.parent}while(A!=M.parent);if(M.eE){x+=l(r)}w="";if(M.starts){I(M.starts,"")}return M.rE?0:r.length}if(t(r,A)){throw"Illegal"}w+=r;return r.length||1}var F=e[D];f(F);var A=F;var w="";var B=0;var v=0;var x="";try{var u,q,p=0;while(true){A.t.lastIndex=p;u=A.t.exec(E);if(!u){break}q=C(E.substr(p,u.index-p),u[0]);p=u.index+q}C(E.substr(p));return{r:B,keyword_count:v,value:x,language:D}}catch(H){if(H=="Illegal"){return{r:0,keyword_count:0,value:l(E)}}else{throw H}}}function g(s){var o={keyword_count:0,r:0,value:l(s)};var q=o;for(var p in e){if(!e.hasOwnProperty(p)){continue}var r=d(p,s);r.language=p;if(r.keyword_count+r.r>q.keyword_count+q.r){q=r}if(r.keyword_count+r.r>o.keyword_count+o.r){q=o;o=r}}if(q.language){o.second_best=q}return o}function i(q,p,o){if(p){q=q.replace(/^((<[^>]+>|\t)+)/gm,function(r,v,u,t){return v.replace(/\t/g,p)})}if(o){q=q.replace(/\n/g,"<br>")}return q}function m(r,u,p){var v=h(r,p);var t=a(r);if(t=="no-highlight"){return}var w=t?d(t,v):g(v);t=w.language;var o=c(r);if(o.length){var q=document.createElement("pre");q.innerHTML=w.value;w.value=j(o,c(q),v)}w.value=i(w.value,u,p);var s=r.className;if(!s.match("(\\s|^)(language-)?"+t+"(\\s|$)")){s=s?(s+" "+t):t}r.innerHTML=w.value;r.className=s;r.result={language:t,kw:w.keyword_count,re:w.r};if(w.second_best){r.second_best={language:w.second_best.language,kw:w.second_best.keyword_count,re:w.second_best.r}}}function n(){if(n.called){return}n.called=true;Array.prototype.map.call(document.getElementsByTagName("pre"),b).filter(Boolean).forEach(function(o){m(o,hljs.tabReplace)})}function k(){window.addEventListener("DOMContentLoaded",n,false);window.addEventListener("load",n,false)}var e={};this.LANGUAGES=e;this.highlight=d;this.highlightAuto=g;this.fixMarkup=i;this.highlightBlock=m;this.initHighlighting=n;this.initHighlightingOnLoad=k;this.IR="[a-zA-Z][a-zA-Z0-9_]*";this.UIR="[a-zA-Z_][a-zA-Z0-9_]*";this.NR="\\b\\d+(\\.\\d+)?";this.CNR="(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)";this.BNR="\\b(0b[01]+)";this.RSR="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|\\.|-|-=|/|/=|:|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~";this.BE={b:"\\\\[\\s\\S]",r:0};this.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[this.BE],r:0};this.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[this.BE],r:0};this.CLCM={cN:"comment",b:"//",e:"$"};this.CBLCLM={cN:"comment",b:"/\\*",e:"\\*/"};this.HCM={cN:"comment",b:"#",e:"$"};this.NM={cN:"number",b:this.NR,r:0};this.CNM={cN:"number",b:this.CNR,r:0};this.BNM={cN:"number",b:this.BNR,r:0};this.inherit=function(q,r){var o={};for(var p in q){o[p]=q[p]}if(r){for(var p in r){o[p]=r[p]}}return o}}();hljs.LANGUAGES.xml=function(a){var c="[A-Za-z0-9\\._:-]+";var b={eW:true,c:[{cN:"attribute",b:c,r:0},{b:'="',rB:true,e:'"',c:[{cN:"value",b:'"',eW:true}]},{b:"='",rB:true,e:"'",c:[{cN:"value",b:"'",eW:true}]},{b:"=",c:[{cN:"value",b:"[^\\s/>]+"}]}]};return{cI:true,c:[{cN:"pi",b:"<\\?",e:"\\?>",r:10},{cN:"doctype",b:"<!DOCTYPE",e:">",r:10,c:[{b:"\\[",e:"\\]"}]},{cN:"comment",b:"<!--",e:"-->",r:10},{cN:"cdata",b:"<\\!\\[CDATA\\[",e:"\\]\\]>",r:10},{cN:"tag",b:"<style(?=\\s|>|$)",e:">",k:{title:"style"},c:[b],starts:{e:"</style>",rE:true,sL:"css"}},{cN:"tag",b:"<script(?=\\s|>|$)",e:">",k:{title:"script"},c:[b],starts:{e:"<\/script>",rE:true,sL:"javascript"}},{b:"<%",e:"%>",sL:"vbscript"},{cN:"tag",b:"</?",e:"/?>",c:[{cN:"title",b:"[^ />]+"},b]}]}}(hljs);hljs.LANGUAGES.json=function(a){var e={literal:"true false null"};var d=[a.QSM,a.CNM];var c={cN:"value",e:",",eW:true,eE:true,c:d,k:e};var b={b:"{",e:"}",c:[{cN:"attribute",b:'\\s*"',e:'"\\s*:\\s*',eB:true,eE:true,c:[a.BE],i:"\\n",starts:c}],i:"\\S"};var f={b:"\\[",e:"\\]",c:[a.inherit(c,{cN:null})],i:"\\S"};d.splice(d.length,0,b,f);return{c:d,k:e,i:"\\S"}}(hljs);
\ No newline at end of file
diff --git a/profiles/killpay/src/main/webapp/lib/jquery.ba-bbq.min.js b/profiles/killpay/src/main/webapp/lib/jquery.ba-bbq.min.js
new file mode 100644
index 0000000..bcbf248
--- /dev/null
+++ b/profiles/killpay/src/main/webapp/lib/jquery.ba-bbq.min.js
@@ -0,0 +1,18 @@
+/*
+ * jQuery BBQ: Back Button & Query Library - v1.2.1 - 2/17/2010
+ * http://benalman.com/projects/jquery-bbq-plugin/
+ *
+ * Copyright (c) 2010 "Cowboy" Ben Alman
+ * Dual licensed under the MIT and GPL licenses.
+ * http://benalman.com/about/license/
+ */
+(function($,p){var i,m=Array.prototype.slice,r=decodeURIComponent,a=$.param,c,l,v,b=$.bbq=$.bbq||{},q,u,j,e=$.event.special,d="hashchange",A="querystring",D="fragment",y="elemUrlAttr",g="location",k="href",t="src",x=/^.*\?|#.*$/g,w=/^.*\#/,h,C={};function E(F){return typeof F==="string"}function B(G){var F=m.call(arguments,1);return function(){return G.apply(this,F.concat(m.call(arguments)))}}function n(F){return F.replace(/^[^#]*#?(.*)$/,"$1")}function o(F){return F.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")}function f(H,M,F,I,G){var O,L,K,N,J;if(I!==i){K=F.match(H?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);J=K[3]||"";if(G===2&&E(I)){L=I.replace(H?w:x,"")}else{N=l(K[2]);I=E(I)?l[H?D:A](I):I;L=G===2?I:G===1?$.extend({},I,N):$.extend({},N,I);L=a(L);if(H){L=L.replace(h,r)}}O=K[1]+(H?"#":L||!K[1]?"?":"")+L+J}else{O=M(F!==i?F:p[g][k])}return O}a[A]=B(f,0,o);a[D]=c=B(f,1,n);c.noEscape=function(G){G=G||"";var F=$.map(G.split(""),encodeURIComponent);h=new RegExp(F.join("|"),"g")};c.noEscape(",/");$.deparam=l=function(I,F){var H={},G={"true":!0,"false":!1,"null":null};$.each(I.replace(/\+/g," ").split("&"),function(L,Q){var K=Q.split("="),P=r(K[0]),J,O=H,M=0,R=P.split("]["),N=R.length-1;if(/\[/.test(R[0])&&/\]$/.test(R[N])){R[N]=R[N].replace(/\]$/,"");R=R.shift().split("[").concat(R);N=R.length-1}else{N=0}if(K.length===2){J=r(K[1]);if(F){J=J&&!isNaN(J)?+J:J==="undefined"?i:G[J]!==i?G[J]:J}if(N){for(;M<=N;M++){P=R[M]===""?O.length:R[M];O=O[P]=M<N?O[P]||(R[M+1]&&isNaN(R[M+1])?{}:[]):J}}else{if($.isArray(H[P])){H[P].push(J)}else{if(H[P]!==i){H[P]=[H[P],J]}else{H[P]=J}}}}else{if(P){H[P]=F?i:""}}});return H};function z(H,F,G){if(F===i||typeof F==="boolean"){G=F;F=a[H?D:A]()}else{F=E(F)?F.replace(H?w:x,""):F}return l(F,G)}l[A]=B(z,0);l[D]=v=B(z,1);$[y]||($[y]=function(F){return $.extend(C,F)})({a:k,base:k,iframe:t,img:t,input:t,form:"action",link:k,script:t});j=$[y];function s(I,G,H,F){if(!E(H)&&typeof H!=="object"){F=H;H=G;G=i}return this.each(function(){var L=$(this),J=G||j()[(this.nodeName||"").toLowerCase()]||"",K=J&&L.attr(J)||"";L.attr(J,a[I](K,H,F))})}$.fn[A]=B(s,A);$.fn[D]=B(s,D);b.pushState=q=function(I,F){if(E(I)&&/^#/.test(I)&&F===i){F=2}var H=I!==i,G=c(p[g][k],H?I:{},H?F:2);p[g][k]=G+(/#/.test(G)?"":"#")};b.getState=u=function(F,G){return F===i||typeof F==="boolean"?v(F):v(G)[F]};b.removeState=function(F){var G={};if(F!==i){G=u();$.each($.isArray(F)?F:arguments,function(I,H){delete G[H]})}q(G,2)};e[d]=$.extend(e[d],{add:function(F){var H;function G(J){var I=J[D]=c();J.getState=function(K,L){return K===i||typeof K==="boolean"?l(I,K):l(I,L)[K]};H.apply(this,arguments)}if($.isFunction(F)){H=F;return G}else{H=F.handler;F.handler=G}}})})(jQuery,this);
+/*
+ * jQuery hashchange event - v1.2 - 2/11/2010
+ * http://benalman.com/projects/jquery-hashchange-plugin/
+ *
+ * Copyright (c) 2010 "Cowboy" Ben Alman
+ * Dual licensed under the MIT and GPL licenses.
+ * http://benalman.com/about/license/
+ */
+(function($,i,b){var j,k=$.event.special,c="location",d="hashchange",l="href",f=$.browser,g=document.documentMode,h=f.msie&&(g===b||g<8),e="on"+d in i&&!h;function a(m){m=m||i[c][l];return m.replace(/^[^#]*#?(.*)$/,"$1")}$[d+"Delay"]=100;k[d]=$.extend(k[d],{setup:function(){if(e){return false}$(j.start)},teardown:function(){if(e){return false}$(j.stop)}});j=(function(){var m={},r,n,o,q;function p(){o=q=function(s){return s};if(h){n=$('<iframe src="javascript:0"/>').hide().insertAfter("body")[0].contentWindow;q=function(){return a(n.document[c][l])};o=function(u,s){if(u!==s){var t=n.document;t.open().close();t[c].hash="#"+u}};o(a())}}m.start=function(){if(r){return}var t=a();o||p();(function s(){var v=a(),u=q(t);if(v!==t){o(t=v,u);$(i).trigger(d)}else{if(u!==t){i[c][l]=i[c][l].replace(/#.*/,"")+"#"+u}}r=setTimeout(s,$[d+"Delay"])})()};m.stop=function(){if(!n){r&&clearTimeout(r);r=0}};return m})()})(jQuery,this);
\ No newline at end of file
diff --git a/profiles/killpay/src/main/webapp/lib/jquery.slideto.min.js b/profiles/killpay/src/main/webapp/lib/jquery.slideto.min.js
new file mode 100644
index 0000000..ba32cff
--- /dev/null
+++ b/profiles/killpay/src/main/webapp/lib/jquery.slideto.min.js
@@ -0,0 +1 @@
+(function(b){b.fn.slideto=function(a){a=b.extend({slide_duration:"slow",highlight_duration:3E3,highlight:true,highlight_color:"#FFFF99"},a);return this.each(function(){obj=b(this);b("body").animate({scrollTop:obj.offset().top},a.slide_duration,function(){a.highlight&&b.ui.version&&obj.effect("highlight",{color:a.highlight_color},a.highlight_duration)})})}})(jQuery);
diff --git a/profiles/killpay/src/main/webapp/lib/jquery.wiggle.min.js b/profiles/killpay/src/main/webapp/lib/jquery.wiggle.min.js
new file mode 100644
index 0000000..2adb0d6
--- /dev/null
+++ b/profiles/killpay/src/main/webapp/lib/jquery.wiggle.min.js
@@ -0,0 +1,8 @@
+/*
+jQuery Wiggle
+Author: WonderGroup, Jordan Thomas
+URL: http://labs.wondergroup.com/demos/mini-ui/index.html
+License: MIT (http://en.wikipedia.org/wiki/MIT_License)
+*/
+jQuery.fn.wiggle=function(o){var d={speed:50,wiggles:3,travel:5,callback:null};var o=jQuery.extend(d,o);return this.each(function(){var cache=this;var wrap=jQuery(this).wrap('<div class="wiggle-wrap"></div>').css("position","relative");var calls=0;for(i=1;i<=o.wiggles;i++){jQuery(this).animate({left:"-="+o.travel},o.speed).animate({left:"+="+o.travel*2},o.speed*2).animate({left:"-="+o.travel},o.speed,function(){calls++;if(jQuery(cache).parent().hasClass('wiggle-wrap')){jQuery(cache).parent().replaceWith(cache);}
+if(calls==o.wiggles&&jQuery.isFunction(o.callback)){o.callback();}});}});};
\ No newline at end of file
diff --git a/profiles/killpay/src/main/webapp/lib/jquery-1.8.0.min.js b/profiles/killpay/src/main/webapp/lib/jquery-1.8.0.min.js
new file mode 100644
index 0000000..f121291
--- /dev/null
+++ b/profiles/killpay/src/main/webapp/lib/jquery-1.8.0.min.js
@@ -0,0 +1,2 @@
+/*! jQuery v@1.8.0 jquery.com | jquery.org/license */
+(function(a,b){function G(a){var b=F[a]={};return p.each(a.split(s),function(a,c){b[c]=!0}),b}function J(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(I,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:+d+""===d?+d:H.test(d)?p.parseJSON(d):d}catch(f){}p.data(a,c,d)}else d=b}return d}function K(a){var b;for(b in a){if(b==="data"&&p.isEmptyObject(a[b]))continue;if(b!=="toJSON")return!1}return!0}function ba(){return!1}function bb(){return!0}function bh(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function bi(a,b){do a=a[b];while(a&&a.nodeType!==1);return a}function bj(a,b,c){b=b||0;if(p.isFunction(b))return p.grep(a,function(a,d){var e=!!b.call(a,d,a);return e===c});if(b.nodeType)return p.grep(a,function(a,d){return a===b===c});if(typeof b=="string"){var d=p.grep(a,function(a){return a.nodeType===1});if(be.test(b))return p.filter(b,d,!c);b=p.filter(b,d)}return p.grep(a,function(a,d){return p.inArray(a,b)>=0===c})}function bk(a){var b=bl.split("|"),c=a.createDocumentFragment();if(c.createElement)while(b.length)c.createElement(b.pop());return c}function bC(a,b){return a.getElementsByTagName(b)[0]||a.appendChild(a.ownerDocument.createElement(b))}function bD(a,b){if(b.nodeType!==1||!p.hasData(a))return;var c,d,e,f=p._data(a),g=p._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;d<e;d++)p.event.add(b,c,h[c][d])}g.data&&(g.data=p.extend({},g.data))}function bE(a,b){var c;if(b.nodeType!==1)return;b.clearAttributes&&b.clearAttributes(),b.mergeAttributes&&b.mergeAttributes(a),c=b.nodeName.toLowerCase(),c==="object"?(b.parentNode&&(b.outerHTML=a.outerHTML),p.support.html5Clone&&a.innerHTML&&!p.trim(b.innerHTML)&&(b.innerHTML=a.innerHTML)):c==="input"&&bv.test(a.type)?(b.defaultChecked=b.checked=a.checked,b.value!==a.value&&(b.value=a.value)):c==="option"?b.selected=a.defaultSelected:c==="input"||c==="textarea"?b.defaultValue=a.defaultValue:c==="script"&&b.text!==a.text&&(b.text=a.text),b.removeAttribute(p.expando)}function bF(a){return typeof a.getElementsByTagName!="undefined"?a.getElementsByTagName("*"):typeof a.querySelectorAll!="undefined"?a.querySelectorAll("*"):[]}function bG(a){bv.test(a.type)&&(a.defaultChecked=a.checked)}function bX(a,b){if(b in a)return b;var c=b.charAt(0).toUpperCase()+b.slice(1),d=b,e=bV.length;while(e--){b=bV[e]+c;if(b in a)return b}return d}function bY(a,b){return a=b||a,p.css(a,"display")==="none"||!p.contains(a.ownerDocument,a)}function bZ(a,b){var c,d,e=[],f=0,g=a.length;for(;f<g;f++){c=a[f];if(!c.style)continue;e[f]=p._data(c,"olddisplay"),b?(!e[f]&&c.style.display==="none"&&(c.style.display=""),c.style.display===""&&bY(c)&&(e[f]=p._data(c,"olddisplay",cb(c.nodeName)))):(d=bH(c,"display"),!e[f]&&d!=="none"&&p._data(c,"olddisplay",d))}for(f=0;f<g;f++){c=a[f];if(!c.style)continue;if(!b||c.style.display==="none"||c.style.display==="")c.style.display=b?e[f]||"":"none"}return a}function b$(a,b,c){var d=bO.exec(b);return d?Math.max(0,d[1]-(c||0))+(d[2]||"px"):b}function b_(a,b,c,d){var e=c===(d?"border":"content")?4:b==="width"?1:0,f=0;for(;e<4;e+=2)c==="margin"&&(f+=p.css(a,c+bU[e],!0)),d?(c==="content"&&(f-=parseFloat(bH(a,"padding"+bU[e]))||0),c!=="margin"&&(f-=parseFloat(bH(a,"border"+bU[e]+"Width"))||0)):(f+=parseFloat(bH(a,"padding"+bU[e]))||0,c!=="padding"&&(f+=parseFloat(bH(a,"border"+bU[e]+"Width"))||0));return f}function ca(a,b,c){var d=b==="width"?a.offsetWidth:a.offsetHeight,e=!0,f=p.support.boxSizing&&p.css(a,"boxSizing")==="border-box";if(d<=0){d=bH(a,b);if(d<0||d==null)d=a.style[b];if(bP.test(d))return d;e=f&&(p.support.boxSizingReliable||d===a.style[b]),d=parseFloat(d)||0}return d+b_(a,b,c||(f?"border":"content"),e)+"px"}function cb(a){if(bR[a])return bR[a];var b=p("<"+a+">").appendTo(e.body),c=b.css("display");b.remove();if(c==="none"||c===""){bI=e.body.appendChild(bI||p.extend(e.createElement("iframe"),{frameBorder:0,width:0,height:0}));if(!bJ||!bI.createElement)bJ=(bI.contentWindow||bI.contentDocument).document,bJ.write("<!doctype html><html><body>"),bJ.close();b=bJ.body.appendChild(bJ.createElement(a)),c=bH(b,"display"),e.body.removeChild(bI)}return bR[a]=c,c}function ch(a,b,c,d){var e;if(p.isArray(b))p.each(b,function(b,e){c||cd.test(a)?d(a,e):ch(a+"["+(typeof e=="object"?b:"")+"]",e,c,d)});else if(!c&&p.type(b)==="object")for(e in b)ch(a+"["+e+"]",b[e],c,d);else d(a,b)}function cy(a){return function(b,c){typeof b!="string"&&(c=b,b="*");var d,e,f,g=b.toLowerCase().split(s),h=0,i=g.length;if(p.isFunction(c))for(;h<i;h++)d=g[h],f=/^\+/.test(d),f&&(d=d.substr(1)||"*"),e=a[d]=a[d]||[],e[f?"unshift":"push"](c)}}function cz(a,c,d,e,f,g){f=f||c.dataTypes[0],g=g||{},g[f]=!0;var h,i=a[f],j=0,k=i?i.length:0,l=a===cu;for(;j<k&&(l||!h);j++)h=i[j](c,d,e),typeof h=="string"&&(!l||g[h]?h=b:(c.dataTypes.unshift(h),h=cz(a,c,d,e,h,g)));return(l||!h)&&!g["*"]&&(h=cz(a,c,d,e,"*",g)),h}function cA(a,c){var d,e,f=p.ajaxSettings.flatOptions||{};for(d in c)c[d]!==b&&((f[d]?a:e||(e={}))[d]=c[d]);e&&p.extend(!0,a,e)}function cB(a,c,d){var e,f,g,h,i=a.contents,j=a.dataTypes,k=a.responseFields;for(f in k)f in d&&(c[k[f]]=d[f]);while(j[0]==="*")j.shift(),e===b&&(e=a.mimeType||c.getResponseHeader("content-type"));if(e)for(f in i)if(i[f]&&i[f].test(e)){j.unshift(f);break}if(j[0]in d)g=j[0];else{for(f in d){if(!j[0]||a.converters[f+" "+j[0]]){g=f;break}h||(h=f)}g=g||h}if(g)return g!==j[0]&&j.unshift(g),d[g]}function cC(a,b){var c,d,e,f,g=a.dataTypes.slice(),h=g[0],i={},j=0;a.dataFilter&&(b=a.dataFilter(b,a.dataType));if(g[1])for(c in a.converters)i[c.toLowerCase()]=a.converters[c];for(;e=g[++j];)if(e!=="*"){if(h!=="*"&&h!==e){c=i[h+" "+e]||i["* "+e];if(!c)for(d in i){f=d.split(" ");if(f[1]===e){c=i[h+" "+f[0]]||i["* "+f[0]];if(c){c===!0?c=i[d]:i[d]!==!0&&(e=f[0],g.splice(j--,0,e));break}}}if(c!==!0)if(c&&a["throws"])b=c(b);else try{b=c(b)}catch(k){return{state:"parsererror",error:c?k:"No conversion from "+h+" to "+e}}}h=e}return{state:"success",data:b}}function cK(){try{return new a.XMLHttpRequest}catch(b){}}function cL(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function cT(){return setTimeout(function(){cM=b},0),cM=p.now()}function cU(a,b){p.each(b,function(b,c){var d=(cS[b]||[]).concat(cS["*"]),e=0,f=d.length;for(;e<f;e++)if(d[e].call(a,b,c))return})}function cV(a,b,c){var d,e=0,f=0,g=cR.length,h=p.Deferred().always(function(){delete i.elem}),i=function(){var b=cM||cT(),c=Math.max(0,j.startTime+j.duration-b),d=1-(c/j.duration||0),e=0,f=j.tweens.length;for(;e<f;e++)j.tweens[e].run(d);return h.notifyWith(a,[j,d,c]),d<1&&f?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:p.extend({},b),opts:p.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:cM||cT(),duration:c.duration,tweens:[],createTween:function(b,c,d){var e=p.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(e),e},stop:function(b){var c=0,d=b?j.tweens.length:0;for(;c<d;c++)j.tweens[c].run(1);return b?h.resolveWith(a,[j,b]):h.rejectWith(a,[j,b]),this}}),k=j.props;cW(k,j.opts.specialEasing);for(;e<g;e++){d=cR[e].call(j,a,k,j.opts);if(d)return d}return cU(j,k),p.isFunction(j.opts.start)&&j.opts.start.call(a,j),p.fx.timer(p.extend(i,{anim:j,queue:j.opts.queue,elem:a})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}function cW(a,b){var c,d,e,f,g;for(c in a){d=p.camelCase(c),e=b[d],f=a[c],p.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=p.cssHooks[d];if(g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}}function cX(a,b,c){var d,e,f,g,h,i,j,k,l=this,m=a.style,n={},o=[],q=a.nodeType&&bY(a);c.queue||(j=p._queueHooks(a,"fx"),j.unqueued==null&&(j.unqueued=0,k=j.empty.fire,j.empty.fire=function(){j.unqueued||k()}),j.unqueued++,l.always(function(){l.always(function(){j.unqueued--,p.queue(a,"fx").length||j.empty.fire()})})),a.nodeType===1&&("height"in b||"width"in b)&&(c.overflow=[m.overflow,m.overflowX,m.overflowY],p.css(a,"display")==="inline"&&p.css(a,"float")==="none"&&(!p.support.inlineBlockNeedsLayout||cb(a.nodeName)==="inline"?m.display="inline-block":m.zoom=1)),c.overflow&&(m.overflow="hidden",p.support.shrinkWrapBlocks||l.done(function(){m.overflow=c.overflow[0],m.overflowX=c.overflow[1],m.overflowY=c.overflow[2]}));for(d in b){f=b[d];if(cO.exec(f)){delete b[d];if(f===(q?"hide":"show"))continue;o.push(d)}}g=o.length;if(g){h=p._data(a,"fxshow")||p._data(a,"fxshow",{}),q?p(a).show():l.done(function(){p(a).hide()}),l.done(function(){var b;p.removeData(a,"fxshow",!0);for(b in n)p.style(a,b,n[b])});for(d=0;d<g;d++)e=o[d],i=l.createTween(e,q?h[e]:0),n[e]=h[e]||p.style(a,e),e in h||(h[e]=i.start,q&&(i.end=i.start,i.start=e==="width"||e==="height"?1:0))}}function cY(a,b,c,d,e){return new cY.prototype.init(a,b,c,d,e)}function cZ(a,b){var c,d={height:a},e=0;for(;e<4;e+=2-b)c=bU[e],d["margin"+c]=d["padding"+c]=a;return b&&(d.opacity=d.width=a),d}function c_(a){return p.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}var c,d,e=a.document,f=a.location,g=a.navigator,h=a.jQuery,i=a.$,j=Array.prototype.push,k=Array.prototype.slice,l=Array.prototype.indexOf,m=Object.prototype.toString,n=Object.prototype.hasOwnProperty,o=String.prototype.trim,p=function(a,b){return new p.fn.init(a,b,c)},q=/[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source,r=/\S/,s=/\s+/,t=r.test(" ")?/^[\s\xA0]+|[\s\xA0]+$/g:/^\s+|\s+$/g,u=/^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,v=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,w=/^[\],:{}\s]*$/,x=/(?:^|:|,)(?:\s*\[)+/g,y=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,z=/"[^"\\\r\n]*"|true|false|null|-?(?:\d\d*\.|)\d+(?:[eE][\-+]?\d+|)/g,A=/^-ms-/,B=/-([\da-z])/gi,C=function(a,b){return(b+"").toUpperCase()},D=function(){e.addEventListener?(e.removeEventListener("DOMContentLoaded",D,!1),p.ready()):e.readyState==="complete"&&(e.detachEvent("onreadystatechange",D),p.ready())},E={};p.fn=p.prototype={constructor:p,init:function(a,c,d){var f,g,h,i;if(!a)return this;if(a.nodeType)return this.context=this[0]=a,this.length=1,this;if(typeof a=="string"){a.charAt(0)==="<"&&a.charAt(a.length-1)===">"&&a.length>=3?f=[null,a,null]:f=u.exec(a);if(f&&(f[1]||!c)){if(f[1])return c=c instanceof p?c[0]:c,i=c&&c.nodeType?c.ownerDocument||c:e,a=p.parseHTML(f[1],i,!0),v.test(f[1])&&p.isPlainObject(c)&&this.attr.call(a,c,!0),p.merge(this,a);g=e.getElementById(f[2]);if(g&&g.parentNode){if(g.id!==f[2])return d.find(a);this.length=1,this[0]=g}return this.context=e,this.selector=a,this}return!c||c.jquery?(c||d).find(a):this.constructor(c).find(a)}return p.isFunction(a)?d.ready(a):(a.selector!==b&&(this.selector=a.selector,this.context=a.context),p.makeArray(a,this))},selector:"",jquery:"1.8.0",length:0,size:function(){return this.length},toArray:function(){return k.call(this)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=p.merge(this.constructor(),a);return d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")"),d},each:function(a,b){return p.each(this,a,b)},ready:function(a){return p.ready.promise().done(a),this},eq:function(a){return a=+a,a===-1?this.slice(a):this.slice(a,a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(k.apply(this,arguments),"slice",k.call(arguments).join(","))},map:function(a){return this.pushStack(p.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:j,sort:[].sort,splice:[].splice},p.fn.init.prototype=p.fn,p.extend=p.fn.extend=function(){var a,c,d,e,f,g,h=arguments[0]||{},i=1,j=arguments.length,k=!1;typeof h=="boolean"&&(k=h,h=arguments[1]||{},i=2),typeof h!="object"&&!p.isFunction(h)&&(h={}),j===i&&(h=this,--i);for(;i<j;i++)if((a=arguments[i])!=null)for(c in a){d=h[c],e=a[c];if(h===e)continue;k&&e&&(p.isPlainObject(e)||(f=p.isArray(e)))?(f?(f=!1,g=d&&p.isArray(d)?d:[]):g=d&&p.isPlainObject(d)?d:{},h[c]=p.extend(k,g,e)):e!==b&&(h[c]=e)}return h},p.extend({noConflict:function(b){return a.$===p&&(a.$=i),b&&a.jQuery===p&&(a.jQuery=h),p},isReady:!1,readyWait:1,holdReady:function(a){a?p.readyWait++:p.ready(!0)},ready:function(a){if(a===!0?--p.readyWait:p.isReady)return;if(!e.body)return setTimeout(p.ready,1);p.isReady=!0;if(a!==!0&&--p.readyWait>0)return;d.resolveWith(e,[p]),p.fn.trigger&&p(e).trigger("ready").off("ready")},isFunction:function(a){return p.type(a)==="function"},isArray:Array.isArray||function(a){return p.type(a)==="array"},isWindow:function(a){return a!=null&&a==a.window},isNumeric:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},type:function(a){return a==null?String(a):E[m.call(a)]||"object"},isPlainObject:function(a){if(!a||p.type(a)!=="object"||a.nodeType||p.isWindow(a))return!1;try{if(a.constructor&&!n.call(a,"constructor")&&!n.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||n.call(a,d)},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},error:function(a){throw new Error(a)},parseHTML:function(a,b,c){var d;return!a||typeof a!="string"?null:(typeof b=="boolean"&&(c=b,b=0),b=b||e,(d=v.exec(a))?[b.createElement(d[1])]:(d=p.buildFragment([a],b,c?null:[]),p.merge([],(d.cacheable?p.clone(d.fragment):d.fragment).childNodes)))},parseJSON:function(b){if(!b||typeof b!="string")return null;b=p.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(w.test(b.replace(y,"@").replace(z,"]").replace(x,"")))return(new Function("return "+b))();p.error("Invalid JSON: "+b)},parseXML:function(c){var d,e;if(!c||typeof c!="string")return null;try{a.DOMParser?(e=new DOMParser,d=e.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(f){d=b}return(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&p.error("Invalid XML: "+c),d},noop:function(){},globalEval:function(b){b&&r.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(A,"ms-").replace(B,C)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var e,f=0,g=a.length,h=g===b||p.isFunction(a);if(d){if(h){for(e in a)if(c.apply(a[e],d)===!1)break}else for(;f<g;)if(c.apply(a[f++],d)===!1)break}else if(h){for(e in a)if(c.call(a[e],e,a[e])===!1)break}else for(;f<g;)if(c.call(a[f],f,a[f++])===!1)break;return a},trim:o?function(a){return a==null?"":o.call(a)}:function(a){return a==null?"":a.toString().replace(t,"")},makeArray:function(a,b){var c,d=b||[];return a!=null&&(c=p.type(a),a.length==null||c==="string"||c==="function"||c==="regexp"||p.isWindow(a)?j.call(d,a):p.merge(d,a)),d},inArray:function(a,b,c){var d;if(b){if(l)return l.call(b,a,c);d=b.length,c=c?c<0?Math.max(0,d+c):c:0;for(;c<d;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,c){var d=c.length,e=a.length,f=0;if(typeof d=="number")for(;f<d;f++)a[e++]=c[f];else while(c[f]!==b)a[e++]=c[f++];return a.length=e,a},grep:function(a,b,c){var d,e=[],f=0,g=a.length;c=!!c;for(;f<g;f++)d=!!b(a[f],f),c!==d&&e.push(a[f]);return e},map:function(a,c,d){var e,f,g=[],h=0,i=a.length,j=a instanceof p||i!==b&&typeof i=="number"&&(i>0&&a[0]&&a[i-1]||i===0||p.isArray(a));if(j)for(;h<i;h++)e=c(a[h],h,d),e!=null&&(g[g.length]=e);else for(f in a)e=c(a[f],f,d),e!=null&&(g[g.length]=e);return g.concat.apply([],g)},guid:1,proxy:function(a,c){var d,e,f;return typeof c=="string"&&(d=a[c],c=a,a=d),p.isFunction(a)?(e=k.call(arguments,2),f=function(){return a.apply(c,e.concat(k.call(arguments)))},f.guid=a.guid=a.guid||f.guid||p.guid++,f):b},access:function(a,c,d,e,f,g,h){var i,j=d==null,k=0,l=a.length;if(d&&typeof d=="object"){for(k in d)p.access(a,c,k,d[k],1,g,e);f=1}else if(e!==b){i=h===b&&p.isFunction(e),j&&(i?(i=c,c=function(a,b,c){return i.call(p(a),c)}):(c.call(a,e),c=null));if(c)for(;k<l;k++)c(a[k],d,i?e.call(a[k],k,c(a[k],d)):e,h);f=1}return f?a:j?c.call(a):l?c(a[0],d):g},now:function(){return(new Date).getTime()}}),p.ready.promise=function(b){if(!d){d=p.Deferred();if(e.readyState==="complete"||e.readyState!=="loading"&&e.addEventListener)setTimeout(p.ready,1);else if(e.addEventListener)e.addEventListener("DOMContentLoaded",D,!1),a.addEventListener("load",p.ready,!1);else{e.attachEvent("onreadystatechange",D),a.attachEvent("onload",p.ready);var c=!1;try{c=a.frameElement==null&&e.documentElement}catch(f){}c&&c.doScroll&&function g(){if(!p.isReady){try{c.doScroll("left")}catch(a){return setTimeout(g,50)}p.ready()}}()}}return d.promise(b)},p.each("Boolean Number String Function Array Date RegExp Object".split(" "),function(a,b){E["[object "+b+"]"]=b.toLowerCase()}),c=p(e);var F={};p.Callbacks=function(a){a=typeof a=="string"?F[a]||G(a):p.extend({},a);var c,d,e,f,g,h,i=[],j=!a.once&&[],k=function(b){c=a.memory&&b,d=!0,h=f||0,f=0,g=i.length,e=!0;for(;i&&h<g;h++)if(i[h].apply(b[0],b[1])===!1&&a.stopOnFalse){c=!1;break}e=!1,i&&(j?j.length&&k(j.shift()):c?i=[]:l.disable())},l={add:function(){if(i){var b=i.length;(function d(b){p.each(b,function(b,c){p.isFunction(c)&&(!a.unique||!l.has(c))?i.push(c):c&&c.length&&d(c)})})(arguments),e?g=i.length:c&&(f=b,k(c))}return this},remove:function(){return i&&p.each(arguments,function(a,b){var c;while((c=p.inArray(b,i,c))>-1)i.splice(c,1),e&&(c<=g&&g--,c<=h&&h--)}),this},has:function(a){return p.inArray(a,i)>-1},empty:function(){return i=[],this},disable:function(){return i=j=c=b,this},disabled:function(){return!i},lock:function(){return j=b,c||l.disable(),this},locked:function(){return!j},fireWith:function(a,b){return b=b||[],b=[a,b.slice?b.slice():b],i&&(!d||j)&&(e?j.push(b):k(b)),this},fire:function(){return l.fireWith(this,arguments),this},fired:function(){return!!d}};return l},p.extend({Deferred:function(a){var b=[["resolve","done",p.Callbacks("once memory"),"resolved"],["reject","fail",p.Callbacks("once memory"),"rejected"],["notify","progress",p.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return p.Deferred(function(c){p.each(b,function(b,d){var f=d[0],g=a[b];e[d[1]](p.isFunction(g)?function(){var a=g.apply(this,arguments);a&&p.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f+"With"](this===e?c:this,[a])}:c[f])}),a=null}).promise()},promise:function(a){return typeof a=="object"?p.extend(a,d):d}},e={};return d.pipe=d.then,p.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[a^1][2].disable,b[2][2].lock),e[f[0]]=g.fire,e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=k.call(arguments),d=c.length,e=d!==1||a&&p.isFunction(a.promise)?d:0,f=e===1?a:p.Deferred(),g=function(a,b,c){return function(d){b[a]=this,c[a]=arguments.length>1?k.call(arguments):d,c===h?f.notifyWith(b,c):--e||f.resolveWith(b,c)}},h,i,j;if(d>1){h=new Array(d),i=new Array(d),j=new Array(d);for(;b<d;b++)c[b]&&p.isFunction(c[b].promise)?c[b].promise().done(g(b,j,c)).fail(f.reject).progress(g(b,i,h)):--e}return e||f.resolveWith(j,c),f.promise()}}),p.support=function(){var b,c,d,f,g,h,i,j,k,l,m,n=e.createElement("div");n.setAttribute("className","t"),n.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",c=n.getElementsByTagName("*"),d=n.getElementsByTagName("a")[0],d.style.cssText="top:1px;float:left;opacity:.5";if(!c||!c.length||!d)return{};f=e.createElement("select"),g=f.appendChild(e.createElement("option")),h=n.getElementsByTagName("input")[0],b={leadingWhitespace:n.firstChild.nodeType===3,tbody:!n.getElementsByTagName("tbody").length,htmlSerialize:!!n.getElementsByTagName("link").length,style:/top/.test(d.getAttribute("style")),hrefNormalized:d.getAttribute("href")==="/a",opacity:/^0.5/.test(d.style.opacity),cssFloat:!!d.style.cssFloat,checkOn:h.value==="on",optSelected:g.selected,getSetAttribute:n.className!=="t",enctype:!!e.createElement("form").enctype,html5Clone:e.createElement("nav").cloneNode(!0).outerHTML!=="<:nav></:nav>",boxModel:e.compatMode==="CSS1Compat",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,boxSizingReliable:!0,pixelPosition:!1},h.checked=!0,b.noCloneChecked=h.cloneNode(!0).checked,f.disabled=!0,b.optDisabled=!g.disabled;try{delete n.test}catch(o){b.deleteExpando=!1}!n.addEventListener&&n.attachEvent&&n.fireEvent&&(n.attachEvent("onclick",m=function(){b.noCloneEvent=!1}),n.cloneNode(!0).fireEvent("onclick"),n.detachEvent("onclick",m)),h=e.createElement("input"),h.value="t",h.setAttribute("type","radio"),b.radioValue=h.value==="t",h.setAttribute("checked","checked"),h.setAttribute("name","t"),n.appendChild(h),i=e.createDocumentFragment(),i.appendChild(n.lastChild),b.checkClone=i.cloneNode(!0).cloneNode(!0).lastChild.checked,b.appendChecked=h.checked,i.removeChild(h),i.appendChild(n);if(n.attachEvent)for(k in{submit:!0,change:!0,focusin:!0})j="on"+k,l=j in n,l||(n.setAttribute(j,"return;"),l=typeof n[j]=="function"),b[k+"Bubbles"]=l;return p(function(){var c,d,f,g,h="padding:0;margin:0;border:0;display:block;overflow:hidden;",i=e.getElementsByTagName("body")[0];if(!i)return;c=e.createElement("div"),c.style.cssText="visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:1px",i.insertBefore(c,i.firstChild),d=e.createElement("div"),c.appendChild(d),d.innerHTML="<table><tr><td></td><td>t</td></tr></table>",f=d.getElementsByTagName("td"),f[0].style.cssText="padding:0;margin:0;border:0;display:none",l=f[0].offsetHeight===0,f[0].style.display="",f[1].style.display="none",b.reliableHiddenOffsets=l&&f[0].offsetHeight===0,d.innerHTML="",d.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",b.boxSizing=d.offsetWidth===4,b.doesNotIncludeMarginInBodyOffset=i.offsetTop!==1,a.getComputedStyle&&(b.pixelPosition=(a.getComputedStyle(d,null)||{}).top!=="1%",b.boxSizingReliable=(a.getComputedStyle(d,null)||{width:"4px"}).width==="4px",g=e.createElement("div"),g.style.cssText=d.style.cssText=h,g.style.marginRight=g.style.width="0",d.style.width="1px",d.appendChild(g),b.reliableMarginRight=!parseFloat((a.getComputedStyle(g,null)||{}).marginRight)),typeof d.style.zoom!="undefined"&&(d.innerHTML="",d.style.cssText=h+"width:1px;padding:1px;display:inline;zoom:1",b.inlineBlockNeedsLayout=d.offsetWidth===3,d.style.display="block",d.style.overflow="visible",d.innerHTML="<div></div>",d.firstChild.style.width="5px",b.shrinkWrapBlocks=d.offsetWidth!==3,c.style.zoom=1),i.removeChild(c),c=d=f=g=null}),i.removeChild(n),c=d=f=g=h=i=n=null,b}();var H=/^(?:\{.*\}|\[.*\])$/,I=/([A-Z])/g;p.extend({cache:{},deletedIds:[],uuid:0,expando:"jQuery"+(p.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){return a=a.nodeType?p.cache[a[p.expando]]:a[p.expando],!!a&&!K(a)},data:function(a,c,d,e){if(!p.acceptData(a))return;var f,g,h=p.expando,i=typeof c=="string",j=a.nodeType,k=j?p.cache:a,l=j?a[h]:a[h]&&h;if((!l||!k[l]||!e&&!k[l].data)&&i&&d===b)return;l||(j?a[h]=l=p.deletedIds.pop()||++p.uuid:l=h),k[l]||(k[l]={},j||(k[l].toJSON=p.noop));if(typeof c=="object"||typeof c=="function")e?k[l]=p.extend(k[l],c):k[l].data=p.extend(k[l].data,c);return f=k[l],e||(f.data||(f.data={}),f=f.data),d!==b&&(f[p.camelCase(c)]=d),i?(g=f[c],g==null&&(g=f[p.camelCase(c)])):g=f,g},removeData:function(a,b,c){if(!p.acceptData(a))return;var d,e,f,g=a.nodeType,h=g?p.cache:a,i=g?a[p.expando]:p.expando;if(!h[i])return;if(b){d=c?h[i]:h[i].data;if(d){p.isArray(b)||(b in d?b=[b]:(b=p.camelCase(b),b in d?b=[b]:b=b.split(" ")));for(e=0,f=b.length;e<f;e++)delete d[b[e]];if(!(c?K:p.isEmptyObject)(d))return}}if(!c){delete h[i].data;if(!K(h[i]))return}g?p.cleanData([a],!0):p.support.deleteExpando||h!=h.window?delete h[i]:h[i]=null},_data:function(a,b,c){return p.data(a,b,c,!0)},acceptData:function(a){var b=a.nodeName&&p.noData[a.nodeName.toLowerCase()];return!b||b!==!0&&a.getAttribute("classid")===b}}),p.fn.extend({data:function(a,c){var d,e,f,g,h,i=this[0],j=0,k=null;if(a===b){if(this.length){k=p.data(i);if(i.nodeType===1&&!p._data(i,"parsedAttrs")){f=i.attributes;for(h=f.length;j<h;j++)g=f[j].name,g.indexOf("data-")===0&&(g=p.camelCase(g.substring(5)),J(i,g,k[g]));p._data(i,"parsedAttrs",!0)}}return k}return typeof a=="object"?this.each(function(){p.data(this,a)}):(d=a.split(".",2),d[1]=d[1]?"."+d[1]:"",e=d[1]+"!",p.access(this,function(c){if(c===b)return k=this.triggerHandler("getData"+e,[d[0]]),k===b&&i&&(k=p.data(i,a),k=J(i,a,k)),k===b&&d[1]?this.data(d[0]):k;d[1]=c,this.each(function(){var b=p(this);b.triggerHandler("setData"+e,d),p.data(this,a,c),b.triggerHandler("changeData"+e,d)})},null,c,arguments.length>1,null,!1))},removeData:function(a){return this.each(function(){p.removeData(this,a)})}}),p.extend({queue:function(a,b,c){var d;if(a)return b=(b||"fx")+"queue",d=p._data(a,b),c&&(!d||p.isArray(c)?d=p._data(a,b,p.makeArray(c)):d.push(c)),d||[]},dequeue:function(a,b){b=b||"fx";var c=p.queue(a,b),d=c.shift(),e=p._queueHooks(a,b),f=function(){p.dequeue(a,b)};d==="inprogress"&&(d=c.shift()),d&&(b==="fx"&&c.unshift("inprogress"),delete e.stop,d.call(a,f,e)),!c.length&&e&&e.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return p._data(a,c)||p._data(a,c,{empty:p.Callbacks("once memory").add(function(){p.removeData(a,b+"queue",!0),p.removeData(a,c,!0)})})}}),p.fn.extend({queue:function(a,c){var d=2;return typeof a!="string"&&(c=a,a="fx",d--),arguments.length<d?p.queue(this[0],a):c===b?this:this.each(function(){var b=p.queue(this,a,c);p._queueHooks(this,a),a==="fx"&&b[0]!=="inprogress"&&p.dequeue(this,a)})},dequeue:function(a){return this.each(function(){p.dequeue(this,a)})},delay:function(a,b){return a=p.fx?p.fx.speeds[a]||a:a,b=b||"fx",this.queue(b,function(b,c){var d=setTimeout(b,a);c.stop=function(){clearTimeout(d)}})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,c){var d,e=1,f=p.Deferred(),g=this,h=this.length,i=function(){--e||f.resolveWith(g,[g])};typeof a!="string"&&(c=a,a=b),a=a||"fx";while(h--)(d=p._data(g[h],a+"queueHooks"))&&d.empty&&(e++,d.empty.add(i));return i(),f.promise(c)}});var L,M,N,O=/[\t\r\n]/g,P=/\r/g,Q=/^(?:button|input)$/i,R=/^(?:button|input|object|select|textarea)$/i,S=/^a(?:rea|)$/i,T=/^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,U=p.support.getSetAttribute;p.fn.extend({attr:function(a,b){return p.access(this,p.attr,a,b,arguments.length>1)},removeAttr:function(a){return this.each(function(){p.removeAttr(this,a)})},prop:function(a,b){return p.access(this,p.prop,a,b,arguments.length>1)},removeProp:function(a){return a=p.propFix[a]||a,this.each(function(){try{this[a]=b,delete this[a]}catch(c){}})},addClass:function(a){var b,c,d,e,f,g,h;if(p.isFunction(a))return this.each(function(b){p(this).addClass(a.call(this,b,this.className))});if(a&&typeof a=="string"){b=a.split(s);for(c=0,d=this.length;c<d;c++){e=this[c];if(e.nodeType===1)if(!e.className&&b.length===1)e.className=a;else{f=" "+e.className+" ";for(g=0,h=b.length;g<h;g++)~f.indexOf(" "+b[g]+" ")||(f+=b[g]+" ");e.className=p.trim(f)}}}return this},removeClass:function(a){var c,d,e,f,g,h,i;if(p.isFunction(a))return this.each(function(b){p(this).removeClass(a.call(this,b,this.className))});if(a&&typeof a=="string"||a===b){c=(a||"").split(s);for(h=0,i=this.length;h<i;h++){e=this[h];if(e.nodeType===1&&e.className){d=(" "+e.className+" ").replace(O," ");for(f=0,g=c.length;f<g;f++)while(d.indexOf(" "+c[f]+" ")>-1)d=d.replace(" "+c[f]+" "," ");e.className=a?p.trim(d):""}}}return this},toggleClass:function(a,b){var c=typeof a,d=typeof b=="boolean";return p.isFunction(a)?this.each(function(c){p(this).toggleClass(a.call(this,c,this.className,b),b)}):this.each(function(){if(c==="string"){var e,f=0,g=p(this),h=b,i=a.split(s);while(e=i[f++])h=d?h:!g.hasClass(e),g[h?"addClass":"removeClass"](e)}else if(c==="undefined"||c==="boolean")this.className&&p._data(this,"__className__",this.className),this.className=this.className||a===!1?"":p._data(this,"__className__")||""})},hasClass:function(a){var b=" "+a+" ",c=0,d=this.length;for(;c<d;c++)if(this[c].nodeType===1&&(" "+this[c].className+" ").replace(O," ").indexOf(b)>-1)return!0;return!1},val:function(a){var c,d,e,f=this[0];if(!arguments.length){if(f)return c=p.valHooks[f.type]||p.valHooks[f.nodeName.toLowerCase()],c&&"get"in c&&(d=c.get(f,"value"))!==b?d:(d=f.value,typeof d=="string"?d.replace(P,""):d==null?"":d);return}return e=p.isFunction(a),this.each(function(d){var f,g=p(this);if(this.nodeType!==1)return;e?f=a.call(this,d,g.val()):f=a,f==null?f="":typeof f=="number"?f+="":p.isArray(f)&&(f=p.map(f,function(a){return a==null?"":a+""})),c=p.valHooks[this.type]||p.valHooks[this.nodeName.toLowerCase()];if(!c||!("set"in c)||c.set(this,f,"value")===b)this.value=f})}}),p.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c,d,e,f=a.selectedIndex,g=[],h=a.options,i=a.type==="select-one";if(f<0)return null;c=i?f:0,d=i?f+1:h.length;for(;c<d;c++){e=h[c];if(e.selected&&(p.support.optDisabled?!e.disabled:e.getAttribute("disabled")===null)&&(!e.parentNode.disabled||!p.nodeName(e.parentNode,"optgroup"))){b=p(e).val();if(i)return b;g.push(b)}}return i&&!g.length&&h.length?p(h[f]).val():g},set:function(a,b){var c=p.makeArray(b);return p(a).find("option").each(function(){this.selected=p.inArray(p(this).val(),c)>=0}),c.length||(a.selectedIndex=-1),c}}},attrFn:{},attr:function(a,c,d,e){var f,g,h,i=a.nodeType;if(!a||i===3||i===8||i===2)return;if(e&&p.isFunction(p.fn[c]))return p(a)[c](d);if(typeof a.getAttribute=="undefined")return p.prop(a,c,d);h=i!==1||!p.isXMLDoc(a),h&&(c=c.toLowerCase(),g=p.attrHooks[c]||(T.test(c)?M:L));if(d!==b){if(d===null){p.removeAttr(a,c);return}return g&&"set"in g&&h&&(f=g.set(a,d,c))!==b?f:(a.setAttribute(c,""+d),d)}return g&&"get"in g&&h&&(f=g.get(a,c))!==null?f:(f=a.getAttribute(c),f===null?b:f)},removeAttr:function(a,b){var c,d,e,f,g=0;if(b&&a.nodeType===1){d=b.split(s);for(;g<d.length;g++)e=d[g],e&&(c=p.propFix[e]||e,f=T.test(e),f||p.attr(a,e,""),a.removeAttribute(U?e:c),f&&c in a&&(a[c]=!1))}},attrHooks:{type:{set:function(a,b){if(Q.test(a.nodeName)&&a.parentNode)p.error("type property can't be changed");else if(!p.support.radioValue&&b==="radio"&&p.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}},value:{get:function(a,b){return L&&p.nodeName(a,"button")?L.get(a,b):b in a?a.value:null},set:function(a,b,c){if(L&&p.nodeName(a,"button"))return L.set(a,b,c);a.value=b}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(a,c,d){var e,f,g,h=a.nodeType;if(!a||h===3||h===8||h===2)return;return g=h!==1||!p.isXMLDoc(a),g&&(c=p.propFix[c]||c,f=p.propHooks[c]),d!==b?f&&"set"in f&&(e=f.set(a,d,c))!==b?e:a[c]=d:f&&"get"in f&&(e=f.get(a,c))!==null?e:a[c]},propHooks:{tabIndex:{get:function(a){var c=a.getAttributeNode("tabindex");return c&&c.specified?parseInt(c.value,10):R.test(a.nodeName)||S.test(a.nodeName)&&a.href?0:b}}}}),M={get:function(a,c){var d,e=p.prop(a,c);return e===!0||typeof e!="boolean"&&(d=a.getAttributeNode(c))&&d.nodeValue!==!1?c.toLowerCase():b},set:function(a,b,c){var d;return b===!1?p.removeAttr(a,c):(d=p.propFix[c]||c,d in a&&(a[d]=!0),a.setAttribute(c,c.toLowerCase())),c}},U||(N={name:!0,id:!0,coords:!0},L=p.valHooks.button={get:function(a,c){var d;return d=a.getAttributeNode(c),d&&(N[c]?d.value!=="":d.specified)?d.value:b},set:function(a,b,c){var d=a.getAttributeNode(c);return d||(d=e.createAttribute(c),a.setAttributeNode(d)),d.value=b+""}},p.each(["width","height"],function(a,b){p.attrHooks[b]=p.extend(p.attrHooks[b],{set:function(a,c){if(c==="")return a.setAttribute(b,"auto"),c}})}),p.attrHooks.contenteditable={get:L.get,set:function(a,b,c){b===""&&(b="false"),L.set(a,b,c)}}),p.support.hrefNormalized||p.each(["href","src","width","height"],function(a,c){p.attrHooks[c]=p.extend(p.attrHooks[c],{get:function(a){var d=a.getAttribute(c,2);return d===null?b:d}})}),p.support.style||(p.attrHooks.style={get:function(a){return a.style.cssText.toLowerCase()||b},set:function(a,b){return a.style.cssText=""+b}}),p.support.optSelected||(p.propHooks.selected=p.extend(p.propHooks.selected,{get:function(a){var b=a.parentNode;return b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex),null}})),p.support.enctype||(p.propFix.enctype="encoding"),p.support.checkOn||p.each(["radio","checkbox"],function(){p.valHooks[this]={get:function(a){return a.getAttribute("value")===null?"on":a.value}}}),p.each(["radio","checkbox"],function(){p.valHooks[this]=p.extend(p.valHooks[this],{set:function(a,b){if(p.isArray(b))return a.checked=p.inArray(p(a).val(),b)>=0}})});var V=/^(?:textarea|input|select)$/i,W=/^([^\.]*|)(?:\.(.+)|)$/,X=/(?:^|\s)hover(\.\S+|)\b/,Y=/^key/,Z=/^(?:mouse|contextmenu)|click/,$=/^(?:focusinfocus|focusoutblur)$/,_=function(a){return p.event.special.hover?a:a.replace(X,"mouseenter$1 mouseleave$1")};p.event={add:function(a,c,d,e,f){var g,h,i,j,k,l,m,n,o,q,r;if(a.nodeType===3||a.nodeType===8||!c||!d||!(g=p._data(a)))return;d.handler&&(o=d,d=o.handler,f=o.selector),d.guid||(d.guid=p.guid++),i=g.events,i||(g.events=i={}),h=g.handle,h||(g.handle=h=function(a){return typeof p!="undefined"&&(!a||p.event.triggered!==a.type)?p.event.dispatch.apply(h.elem,arguments):b},h.elem=a),c=p.trim(_(c)).split(" ");for(j=0;j<c.length;j++){k=W.exec(c[j])||[],l=k[1],m=(k[2]||"").split(".").sort(),r=p.event.special[l]||{},l=(f?r.delegateType:r.bindType)||l,r=p.event.special[l]||{},n=p.extend({type:l,origType:k[1],data:e,handler:d,guid:d.guid,selector:f,namespace:m.join(".")},o),q=i[l];if(!q){q=i[l]=[],q.delegateCount=0;if(!r.setup||r.setup.call(a,e,m,h)===!1)a.addEventListener?a.addEventListener(l,h,!1):a.attachEvent&&a.attachEvent("on"+l,h)}r.add&&(r.add.call(a,n),n.handler.guid||(n.handler.guid=d.guid)),f?q.splice(q.delegateCount++,0,n):q.push(n),p.event.global[l]=!0}a=null},global:{},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,q,r=p.hasData(a)&&p._data(a);if(!r||!(m=r.events))return;b=p.trim(_(b||"")).split(" ");for(f=0;f<b.length;f++){g=W.exec(b[f])||[],h=i=g[1],j=g[2];if(!h){for(h in m)p.event.remove(a,h+b[f],c,d,!0);continue}n=p.event.special[h]||{},h=(d?n.delegateType:n.bindType)||h,o=m[h]||[],k=o.length,j=j?new RegExp("(^|\\.)"+j.split(".").sort().join("\\.(?:.*\\.|)")+"(\\.|$)"):null;for(l=0;l<o.length;l++)q=o[l],(e||i===q.origType)&&(!c||c.guid===q.guid)&&(!j||j.test(q.namespace))&&(!d||d===q.selector||d==="**"&&q.selector)&&(o.splice(l--,1),q.selector&&o.delegateCount--,n.remove&&n.remove.call(a,q));o.length===0&&k!==o.length&&((!n.teardown||n.teardown.call(a,j,r.handle)===!1)&&p.removeEvent(a,h,r.handle),delete m[h])}p.isEmptyObject(m)&&(delete r.handle,p.removeData(a,"events",!0))},customEvent:{getData:!0,setData:!0,changeData:!0},trigger:function(c,d,f,g){if(!f||f.nodeType!==3&&f.nodeType!==8){var h,i,j,k,l,m,n,o,q,r,s=c.type||c,t=[];if($.test(s+p.event.triggered))return;s.indexOf("!")>=0&&(s=s.slice(0,-1),i=!0),s.indexOf(".")>=0&&(t=s.split("."),s=t.shift(),t.sort());if((!f||p.event.customEvent[s])&&!p.event.global[s])return;c=typeof c=="object"?c[p.expando]?c:new p.Event(s,c):new p.Event(s),c.type=s,c.isTrigger=!0,c.exclusive=i,c.namespace=t.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+t.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,m=s.indexOf(":")<0?"on"+s:"";if(!f){h=p.cache;for(j in h)h[j].events&&h[j].events[s]&&p.event.trigger(c,d,h[j].handle.elem,!0);return}c.result=b,c.target||(c.target=f),d=d!=null?p.makeArray(d):[],d.unshift(c),n=p.event.special[s]||{};if(n.trigger&&n.trigger.apply(f,d)===!1)return;q=[[f,n.bindType||s]];if(!g&&!n.noBubble&&!p.isWindow(f)){r=n.delegateType||s,k=$.test(r+s)?f:f.parentNode;for(l=f;k;k=k.parentNode)q.push([k,r]),l=k;l===(f.ownerDocument||e)&&q.push([l.defaultView||l.parentWindow||a,r])}for(j=0;j<q.length&&!c.isPropagationStopped();j++)k=q[j][0],c.type=q[j][1],o=(p._data(k,"events")||{})[c.type]&&p._data(k,"handle"),o&&o.apply(k,d),o=m&&k[m],o&&p.acceptData(k)&&o.apply(k,d)===!1&&c.preventDefault();return c.type=s,!g&&!c.isDefaultPrevented()&&(!n._default||n._default.apply(f.ownerDocument,d)===!1)&&(s!=="click"||!p.nodeName(f,"a"))&&p.acceptData(f)&&m&&f[s]&&(s!=="focus"&&s!=="blur"||c.target.offsetWidth!==0)&&!p.isWindow(f)&&(l=f[m],l&&(f[m]=null),p.event.triggered=s,f[s](),p.event.triggered=b,l&&(f[m]=l)),c.result}return},dispatch:function(c){c=p.event.fix(c||a.event);var d,e,f,g,h,i,j,k,l,m,n,o=(p._data(this,"events")||{})[c.type]||[],q=o.delegateCount,r=[].slice.call(arguments),s=!c.exclusive&&!c.namespace,t=p.event.special[c.type]||{},u=[];r[0]=c,c.delegateTarget=this;if(t.preDispatch&&t.preDispatch.call(this,c)===!1)return;if(q&&(!c.button||c.type!=="click")){g=p(this),g.context=this;for(f=c.target;f!=this;f=f.parentNode||this)if(f.disabled!==!0||c.type!=="click"){i={},k=[],g[0]=f;for(d=0;d<q;d++)l=o[d],m=l.selector,i[m]===b&&(i[m]=g.is(m)),i[m]&&k.push(l);k.length&&u.push({elem:f,matches:k})}}o.length>q&&u.push({elem:this,matches:o.slice(q)});for(d=0;d<u.length&&!c.isPropagationStopped();d++){j=u[d],c.currentTarget=j.elem;for(e=0;e<j.matches.length&&!c.isImmediatePropagationStopped();e++){l=j.matches[e];if(s||!c.namespace&&!l.namespace||c.namespace_re&&c.namespace_re.test(l.namespace))c.data=l.data,c.handleObj=l,h=((p.event.special[l.origType]||{}).handle||l.handler).apply(j.elem,r),h!==b&&(c.result=h,h===!1&&(c.preventDefault(),c.stopPropagation()))}}return t.postDispatch&&t.postDispatch.call(this,c),c.result},props:"attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(a,b){return a.which==null&&(a.which=b.charCode!=null?b.charCode:b.keyCode),a}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(a,c){var d,f,g,h=c.button,i=c.fromElement;return a.pageX==null&&c.clientX!=null&&(d=a.target.ownerDocument||e,f=d.documentElement,g=d.body,a.pageX=c.clientX+(f&&f.scrollLeft||g&&g.scrollLeft||0)-(f&&f.clientLeft||g&&g.clientLeft||0),a.pageY=c.clientY+(f&&f.scrollTop||g&&g.scrollTop||0)-(f&&f.clientTop||g&&g.clientTop||0)),!a.relatedTarget&&i&&(a.relatedTarget=i===a.target?c.toElement:i),!a.which&&h!==b&&(a.which=h&1?1:h&2?3:h&4?2:0),a}},fix:function(a){if(a[p.expando])return a;var b,c,d=a,f=p.event.fixHooks[a.type]||{},g=f.props?this.props.concat(f.props):this.props;a=p.Event(d);for(b=g.length;b;)c=g[--b],a[c]=d[c];return a.target||(a.target=d.srcElement||e),a.target.nodeType===3&&(a.target=a.target.parentNode),a.metaKey=!!a.metaKey,f.filter?f.filter(a,d):a},special:{ready:{setup:p.bindReady},load:{noBubble:!0},focus:{delegateType:"focusin"},blur:{delegateType:"focusout"},beforeunload:{setup:function(a,b,c){p.isWindow(this)&&(this.onbeforeunload=c)},teardown:function(a,b){this.onbeforeunload===b&&(this.onbeforeunload=null)}}},simulate:function(a,b,c,d){var e=p.extend(new p.Event,c,{type:a,isSimulated:!0,originalEvent:{}});d?p.event.trigger(e,null,b):p.event.dispatch.call(b,e),e.isDefaultPrevented()&&c.preventDefault()}},p.event.handle=p.event.dispatch,p.removeEvent=e.removeEventListener?function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c,!1)}:function(a,b,c){var d="on"+b;a.detachEvent&&(typeof a[d]=="undefined"&&(a[d]=null),a.detachEvent(d,c))},p.Event=function(a,b){if(this instanceof p.Event)a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||a.returnValue===!1||a.getPreventDefault&&a.getPreventDefault()?bb:ba):this.type=a,b&&p.extend(this,b),this.timeStamp=a&&a.timeStamp||p.now(),this[p.expando]=!0;else return new p.Event(a,b)},p.Event.prototype={preventDefault:function(){this.isDefaultPrevented=bb;var a=this.originalEvent;if(!a)return;a.preventDefault?a.preventDefault():a.returnValue=!1},stopPropagation:function(){this.isPropagationStopped=bb;var a=this.originalEvent;if(!a)return;a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=bb,this.stopPropagation()},isDefaultPrevented:ba,isPropagationStopped:ba,isImmediatePropagationStopped:ba},p.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){p.event.special[a]={delegateType:b,bindType:b,handle:function(a){var c,d=this,e=a.relatedTarget,f=a.handleObj,g=f.selector;if(!e||e!==d&&!p.contains(d,e))a.type=f.origType,c=f.handler.apply(this,arguments),a.type=b;return c}}}),p.support.submitBubbles||(p.event.special.submit={setup:function(){if(p.nodeName(this,"form"))return!1;p.event.add(this,"click._submit keypress._submit",function(a){var c=a.target,d=p.nodeName(c,"input")||p.nodeName(c,"button")?c.form:b;d&&!p._data(d,"_submit_attached")&&(p.event.add(d,"submit._submit",function(a){a._submit_bubble=!0}),p._data(d,"_submit_attached",!0))})},postDispatch:function(a){a._submit_bubble&&(delete a._submit_bubble,this.parentNode&&!a.isTrigger&&p.event.simulate("submit",this.parentNode,a,!0))},teardown:function(){if(p.nodeName(this,"form"))return!1;p.event.remove(this,"._submit")}}),p.support.changeBubbles||(p.event.special.change={setup:function(){if(V.test(this.nodeName)){if(this.type==="checkbox"||this.type==="radio")p.event.add(this,"propertychange._change",function(a){a.originalEvent.propertyName==="checked"&&(this._just_changed=!0)}),p.event.add(this,"click._change",function(a){this._just_changed&&!a.isTrigger&&(this._just_changed=!1),p.event.simulate("change",this,a,!0)});return!1}p.event.add(this,"beforeactivate._change",function(a){var b=a.target;V.test(b.nodeName)&&!p._data(b,"_change_attached")&&(p.event.add(b,"change._change",function(a){this.parentNode&&!a.isSimulated&&!a.isTrigger&&p.event.simulate("change",this.parentNode,a,!0)}),p._data(b,"_change_attached",!0))})},handle:function(a){var b=a.target;if(this!==b||a.isSimulated||a.isTrigger||b.type!=="radio"&&b.type!=="checkbox")return a.handleObj.handler.apply(this,arguments)},teardown:function(){return p.event.remove(this,"._change"),V.test(this.nodeName)}}),p.support.focusinBubbles||p.each({focus:"focusin",blur:"focusout"},function(a,b){var c=0,d=function(a){p.event.simulate(b,a.target,p.event.fix(a),!0)};p.event.special[b]={setup:function(){c++===0&&e.addEventListener(a,d,!0)},teardown:function(){--c===0&&e.removeEventListener(a,d,!0)}}}),p.fn.extend({on:function(a,c,d,e,f){var g,h;if(typeof a=="object"){typeof c!="string"&&(d=d||c,c=b);for(h in a)this.on(h,c,d,a[h],f);return this}d==null&&e==null?(e=c,d=c=b):e==null&&(typeof c=="string"?(e=d,d=b):(e=d,d=c,c=b));if(e===!1)e=ba;else if(!e)return this;return f===1&&(g=e,e=function(a){return p().off(a),g.apply(this,arguments)},e.guid=g.guid||(g.guid=p.guid++)),this.each(function(){p.event.add(this,a,e,d,c)})},one:function(a,b,c,d){return this.on(a,b,c,d,1)},off:function(a,c,d){var e,f;if(a&&a.preventDefault&&a.handleObj)return e=a.handleObj,p(a.delegateTarget).off(e.namespace?e.origType+"."+e.namespace:e.origType,e.selector,e.handler),this;if(typeof a=="object"){for(f in a)this.off(f,c,a[f]);return this}if(c===!1||typeof c=="function")d=c,c=b;return d===!1&&(d=ba),this.each(function(){p.event.remove(this,a,d,c)})},bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},live:function(a,b,c){return p(this.context).on(a,this.selector,b,c),this},die:function(a,b){return p(this.context).off(a,this.selector||"**",b),this},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return arguments.length==1?this.off(a,"**"):this.off(b,a||"**",c)},trigger:function(a,b){return this.each(function(){p.event.trigger(a,b,this)})},triggerHandler:function(a,b){if(this[0])return p.event.trigger(a,b,this[0],!0)},toggle:function(a){var b=arguments,c=a.guid||p.guid++,d=0,e=function(c){var e=(p._data(this,"lastToggle"+a.guid)||0)%d;return p._data(this,"lastToggle"+a.guid,e+1),c.preventDefault(),b[e].apply(this,arguments)||!1};e.guid=c;while(d<b.length)b[d++].guid=c;return this.click(e)},hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}}),p.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){p.fn[b]=function(a,c){return c==null&&(c=a,a=null),arguments.length>0?this.on(b,null,a,c):this.trigger(b)},Y.test(b)&&(p.event.fixHooks[b]=p.event.keyHooks),Z.test(b)&&(p.event.fixHooks[b]=p.event.mouseHooks)}),function(a,b){function bd(a,b,c,d){var e=0,f=b.length;for(;e<f;e++)Z(a,b[e],c,d)}function be(a,b,c,d,e,f){var g,h=$.setFilters[b.toLowerCase()];return h||Z.error(b),(a||!(g=e))&&bd(a||"*",d,g=[],e),g.length>0?h(g,c,f):[]}function bf(a,c,d,e,f){var g,h,i,j,k,l,m,n,p=0,q=f.length,s=L.POS,t=new RegExp("^"+s.source+"(?!"+r+")","i"),u=function(){var a=1,c=arguments.length-2;for(;a<c;a++)arguments[a]===b&&(g[a]=b)};for(;p<q;p++){s.exec(""),a=f[p],j=[],i=0,k=e;while(g=s.exec(a)){n=s.lastIndex=g.index+g[0].length;if(n>i){m=a.slice(i,g.index),i=n,l=[c],B.test(m)&&(k&&(l=k),k=e);if(h=H.test(m))m=m.slice(0,-5).replace(B,"$&*");g.length>1&&g[0].replace(t,u),k=be(m,g[1],g[2],l,k,h)}}k?(j=j.concat(k),(m=a.slice(i))&&m!==")"?B.test(m)?bd(m,j,d,e):Z(m,c,d,e?e.concat(k):k):o.apply(d,j)):Z(a,c,d,e)}return q===1?d:Z.uniqueSort(d)}function bg(a,b,c){var d,e,f,g=[],i=0,j=D.exec(a),k=!j.pop()&&!j.pop(),l=k&&a.match(C)||[""],m=$.preFilter,n=$.filter,o=!c&&b!==h;for(;(e=l[i])!=null&&k;i++){g.push(d=[]),o&&(e=" "+e);while(e){k=!1;if(j=B.exec(e))e=e.slice(j[0].length),k=d.push({part:j.pop().replace(A," "),captures:j});for(f in n)(j=L[f].exec(e))&&(!m[f]||(j=m[f](j,b,c)))&&(e=e.slice(j.shift().length),k=d.push({part:f,captures:j}));if(!k)break}}return k||Z.error(a),g}function bh(a,b,e){var f=b.dir,g=m++;return a||(a=function(a){return a===e}),b.first?function(b,c){while(b=b[f])if(b.nodeType===1)return a(b,c)&&b}:function(b,e){var h,i=g+"."+d,j=i+"."+c;while(b=b[f])if(b.nodeType===1){if((h=b[q])===j)return b.sizset;if(typeof h=="string"&&h.indexOf(i)===0){if(b.sizset)return b}else{b[q]=j;if(a(b,e))return b.sizset=!0,b;b.sizset=!1}}}}function bi(a,b){return a?function(c,d){var e=b(c,d);return e&&a(e===!0?c:e,d)}:b}function bj(a,b,c){var d,e,f=0;for(;d=a[f];f++)$.relative[d.part]?e=bh(e,$.relative[d.part],b):(d.captures.push(b,c),e=bi(e,$.filter[d.part].apply(null,d.captures)));return e}function bk(a){return function(b,c){var d,e=0;for(;d=a[e];e++)if(d(b,c))return!0;return!1}}var c,d,e,f,g,h=a.document,i=h.documentElement,j="undefined",k=!1,l=!0,m=0,n=[].slice,o=[].push,q=("sizcache"+Math.random()).replace(".",""),r="[\\x20\\t\\r\\n\\f]",s="(?:\\\\.|[-\\w]|[^\\x00-\\xa0])+",t=s.replace("w","w#"),u="([*^$|!~]?=)",v="\\["+r+"*("+s+")"+r+"*(?:"+u+r+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+t+")|)|)"+r+"*\\]",w=":("+s+")(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|((?:[^,]|\\\\,|(?:,(?=[^\\[]*\\]))|(?:,(?=[^\\(]*\\))))*))\\)|)",x=":(nth|eq|gt|lt|first|last|even|odd)(?:\\((\\d*)\\)|)(?=[^-]|$)",y=r+"*([\\x20\\t\\r\\n\\f>+~])"+r+"*",z="(?=[^\\x20\\t\\r\\n\\f])(?:\\\\.|"+v+"|"+w.replace(2,7)+"|[^\\\\(),])+",A=new RegExp("^"+r+"+|((?:^|[^\\\\])(?:\\\\.)*)"+r+"+$","g"),B=new RegExp("^"+y),C=new RegExp(z+"?(?="+r+"*,|$)","g"),D=new RegExp("^(?:(?!,)(?:(?:^|,)"+r+"*"+z+")*?|"+r+"*(.*?))(\\)|$)"),E=new RegExp(z.slice(19,-6)+"\\x20\\t\\r\\n\\f>+~])+|"+y,"g"),F=/^(?:#([\w\-]+)|(\w+)|\.([\w\-]+))$/,G=/[\x20\t\r\n\f]*[+~]/,H=/:not\($/,I=/h\d/i,J=/input|select|textarea|button/i,K=/\\(?!\\)/g,L={ID:new RegExp("^#("+s+")"),CLASS:new RegExp("^\\.("+s+")"),NAME:new RegExp("^\\[name=['\"]?("+s+")['\"]?\\]"),TAG:new RegExp("^("+s.replace("[-","[-\\*")+")"),ATTR:new RegExp("^"+v),PSEUDO:new RegExp("^"+w),CHILD:new RegExp("^:(only|nth|last|first)-child(?:\\("+r+"*(even|odd|(([+-]|)(\\d*)n|)"+r+"*(?:([+-]|)"+r+"*(\\d+)|))"+r+"*\\)|)","i"),POS:new RegExp(x,"ig"),needsContext:new RegExp("^"+r+"*[>+~]|"+x,"i")},M={},N=[],O={},P=[],Q=function(a){return a.sizzleFilter=!0,a},R=function(a){return function(b){return b.nodeName.toLowerCase()==="input"&&b.type===a}},S=function(a){return function(b){var c=b.nodeName.toLowerCase();return(c==="input"||c==="button")&&b.type===a}},T=function(a){var b=!1,c=h.createElement("div");try{b=a(c)}catch(d){}return c=null,b},U=T(function(a){a.innerHTML="<select></select>";var b=typeof a.lastChild.getAttribute("multiple");return b!=="boolean"&&b!=="string"}),V=T(function(a){a.id=q+0,a.innerHTML="<a name='"+q+"'></a><div name='"+q+"'></div>",i.insertBefore(a,i.firstChild);var b=h.getElementsByName&&h.getElementsByName(q).length===2+h.getElementsByName(q+0).length;return g=!h.getElementById(q),i.removeChild(a),b}),W=T(function(a){return a.appendChild(h.createComment("")),a.getElementsByTagName("*").length===0}),X=T(function(a){return a.innerHTML="<a href='#'></a>",a.firstChild&&typeof a.firstChild.getAttribute!==j&&a.firstChild.getAttribute("href")==="#"}),Y=T(function(a){return a.innerHTML="<div class='hidden e'></div><div class='hidden'></div>",!a.getElementsByClassName||a.getElementsByClassName("e").length===0?!1:(a.lastChild.className="e",a.getElementsByClassName("e").length!==1)}),Z=function(a,b,c,d){c=c||[],b=b||h;var e,f,g,i,j=b.nodeType;if(j!==1&&j!==9)return[];if(!a||typeof a!="string")return c;g=ba(b);if(!g&&!d)if(e=F.exec(a))if(i=e[1]){if(j===9){f=b.getElementById(i);if(!f||!f.parentNode)return c;if(f.id===i)return c.push(f),c}else if(b.ownerDocument&&(f=b.ownerDocument.getElementById(i))&&bb(b,f)&&f.id===i)return c.push(f),c}else{if(e[2])return o.apply(c,n.call(b.getElementsByTagName(a),0)),c;if((i=e[3])&&Y&&b.getElementsByClassName)return o.apply(c,n.call(b.getElementsByClassName(i),0)),c}return bm(a,b,c,d,g)},$=Z.selectors={cacheLength:50,match:L,order:["ID","TAG"],attrHandle:{},createPseudo:Q,find:{ID:g?function(a,b,c){if(typeof b.getElementById!==j&&!c){var d=b.getElementById(a);return d&&d.parentNode?[d]:[]}}:function(a,c,d){if(typeof c.getElementById!==j&&!d){var e=c.getElementById(a);return e?e.id===a||typeof e.getAttributeNode!==j&&e.getAttributeNode("id").value===a?[e]:b:[]}},TAG:W?function(a,b){if(typeof b.getElementsByTagName!==j)return b.getElementsByTagName(a)}:function(a,b){var c=b.getElementsByTagName(a);if(a==="*"){var d,e=[],f=0;for(;d=c[f];f++)d.nodeType===1&&e.push(d);return e}return c}},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(K,""),a[3]=(a[4]||a[5]||"").replace(K,""),a[2]==="~="&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),a[1]==="nth"?(a[2]||Z.error(a[0]),a[3]=+(a[3]?a[4]+(a[5]||1):2*(a[2]==="even"||a[2]==="odd")),a[4]=+(a[6]+a[7]||a[2]==="odd")):a[2]&&Z.error(a[0]),a},PSEUDO:function(a){var b,c=a[4];return L.CHILD.test(a[0])?null:(c&&(b=D.exec(c))&&b.pop()&&(a[0]=a[0].slice(0,b[0].length-c.length-1),c=b[0].slice(0,-1)),a.splice(2,3,c||a[3]),a)}},filter:{ID:g?function(a){return a=a.replace(K,""),function(b){return b.getAttribute("id")===a}}:function(a){return a=a.replace(K,""),function(b){var c=typeof b.getAttributeNode!==j&&b.getAttributeNode("id");return c&&c.value===a}},TAG:function(a){return a==="*"?function(){return!0}:(a=a.replace(K,"").toLowerCase(),function(b){return b.nodeName&&b.nodeName.toLowerCase()===a})},CLASS:function(a){var b=M[a];return b||(b=M[a]=new RegExp("(^|"+r+")"+a+"("+r+"|$)"),N.push(a),N.length>$.cacheLength&&delete M[N.shift()]),function(a){return b.test(a.className||typeof a.getAttribute!==j&&a.getAttribute("class")||"")}},ATTR:function(a,b,c){return b?function(d){var e=Z.attr(d,a),f=e+"";if(e==null)return b==="!=";switch(b){case"=":return f===c;case"!=":return f!==c;case"^=":return c&&f.indexOf(c)===0;case"*=":return c&&f.indexOf(c)>-1;case"$=":return c&&f.substr(f.length-c.length)===c;case"~=":return(" "+f+" ").indexOf(c)>-1;case"|=":return f===c||f.substr(0,c.length+1)===c+"-"}}:function(b){return Z.attr(b,a)!=null}},CHILD:function(a,b,c,d){if(a==="nth"){var e=m++;return function(a){var b,f,g=0,h=a;if(c===1&&d===0)return!0;b=a.parentNode;if(b&&(b[q]!==e||!a.sizset)){for(h=b.firstChild;h;h=h.nextSibling)if(h.nodeType===1){h.sizset=++g;if(h===a)break}b[q]=e}return f=a.sizset-d,c===0?f===0:f%c===0&&f/c>=0}}return function(b){var c=b;switch(a){case"only":case"first":while(c=c.previousSibling)if(c.nodeType===1)return!1;if(a==="first")return!0;c=b;case"last":while(c=c.nextSibling)if(c.nodeType===1)return!1;return!0}}},PSEUDO:function(a,b,c,d){var e=$.pseudos[a]||$.pseudos[a.toLowerCase()];return e||Z.error("unsupported pseudo: "+a),e.sizzleFilter?e(b,c,d):e}},pseudos:{not:Q(function(a,b,c){var d=bl(a.replace(A,"$1"),b,c);return function(a){return!d(a)}}),enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&!!a.checked||b==="option"&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},parent:function(a){return!$.pseudos.empty(a)},empty:function(a){var b;a=a.firstChild;while(a){if(a.nodeName>"@"||(b=a.nodeType)===3||b===4)return!1;a=a.nextSibling}return!0},contains:Q(function(a){return function(b){return(b.textContent||b.innerText||bc(b)).indexOf(a)>-1}}),has:Q(function(a){return function(b){return Z(a,b).length>0}}),header:function(a){return I.test(a.nodeName)},text:function(a){var b,c;return a.nodeName.toLowerCase()==="input"&&(b=a.type)==="text"&&((c=a.getAttribute("type"))==null||c.toLowerCase()===b)},radio:R("radio"),checkbox:R("checkbox"),file:R("file"),password:R("password"),image:R("image"),submit:S("submit"),reset:S("reset"),button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&a.type==="button"||b==="button"},input:function(a){return J.test(a.nodeName)},focus:function(a){var b=a.ownerDocument;return a===b.activeElement&&(!b.hasFocus||b.hasFocus())&&(!!a.type||!!a.href)},active:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b,c){return c?a.slice(1):[a[0]]},last:function(a,b,c){var d=a.pop();return c?a:[d]},even:function(a,b,c){var d=[],e=c?1:0,f=a.length;for(;e<f;e=e+2)d.push(a[e]);return d},odd:function(a,b,c){var d=[],e=c?0:1,f=a.length;for(;e<f;e=e+2)d.push(a[e]);return d},lt:function(a,b,c){return c?a.slice(+b):a.slice(0,+b)},gt:function(a,b,c){return c?a.slice(0,+b+1):a.slice(+b+1)},eq:function(a,b,c){var d=a.splice(+b,1);return c?a:d}}};$.setFilters.nth=$.setFilters.eq,$.filters=$.pseudos,X||($.attrHandle={href:function(a){return a.getAttribute("href",2)},type:function(a){return a.getAttribute("type")}}),V&&($.order.push("NAME"),$.find.NAME=function(a,b){if(typeof b.getElementsByName!==j)return b.getElementsByName(a)}),Y&&($.order.splice(1,0,"CLASS"),$.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!==j&&!c)return b.getElementsByClassName(a)});try{n.call(i.childNodes,0)[0].nodeType}catch(_){n=function(a){var b,c=[];for(;b=this[a];a++)c.push(b);return c}}var ba=Z.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?b.nodeName!=="HTML":!1},bb=Z.contains=i.compareDocumentPosition?function(a,b){return!!(a.compareDocumentPosition(b)&16)}:i.contains?function(a,b){var c=a.nodeType===9?a.documentElement:a,d=b.parentNode;return a===d||!!(d&&d.nodeType===1&&c.contains&&c.contains(d))}:function(a,b){while(b=b.parentNode)if(b===a)return!0;return!1},bc=Z.getText=function(a){var b,c="",d=0,e=a.nodeType;if(e){if(e===1||e===9||e===11){if(typeof a.textContent=="string")return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=bc(a)}else if(e===3||e===4)return a.nodeValue}else for(;b=a[d];d++)c+=bc(b);return c};Z.attr=function(a,b){var c,d=ba(a);return d||(b=b.toLowerCase()),$.attrHandle[b]?$.attrHandle[b](a):U||d?a.getAttribute(b):(c=a.getAttributeNode(b),c?typeof a[b]=="boolean"?a[b]?b:null:c.specified?c.value:null:null)},Z.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},[0,0].sort(function(){return l=0}),i.compareDocumentPosition?e=function(a,b){return a===b?(k=!0,0):(!a.compareDocumentPosition||!b.compareDocumentPosition?a.compareDocumentPosition:a.compareDocumentPosition(b)&4)?-1:1}:(e=function(a,b){if(a===b)return k=!0,0;if(a.sourceIndex&&b.sourceIndex)return a.sourceIndex-b.sourceIndex;var c,d,e=[],g=[],h=a.parentNode,i=b.parentNode,j=h;if(h===i)return f(a,b);if(!h)return-1;if(!i)return 1;while(j)e.unshift(j),j=j.parentNode;j=i;while(j)g.unshift(j),j=j.parentNode;c=e.length,d=g.length;for(var l=0;l<c&&l<d;l++)if(e[l]!==g[l])return f(e[l],g[l]);return l===c?f(a,g[l],-1):f(e[l],b,1)},f=function(a,b,c){if(a===b)return c;var d=a.nextSibling;while(d){if(d===b)return-1;d=d.nextSibling}return 1}),Z.uniqueSort=function(a){var b,c=1;if(e){k=l,a.sort(e);if(k)for(;b=a[c];c++)b===a[c-1]&&a.splice(c--,1)}return a};var bl=Z.compile=function(a,b,c){var d,e,f,g=O[a];if(g&&g.context===b)return g;e=bg(a,b,c);for(f=0;d=e[f];f++)e[f]=bj(d,b,c);return g=O[a]=bk(e),g.context=b,g.runs=g.dirruns=0,P.push(a),P.length>$.cacheLength&&delete O[P.shift()],g};Z.matches=function(a,b){return Z(a,null,null,b)},Z.matchesSelector=function(a,b){return Z(b,null,null,[a]).length>0};var bm=function(a,b,e,f,g){a=a.replace(A,"$1");var h,i,j,k,l,m,p,q,r,s=a.match(C),t=a.match(E),u=b.nodeType;if(L.POS.test(a))return bf(a,b,e,f,s);if(f)h=n.call(f,0);else if(s&&s.length===1){if(t.length>1&&u===9&&!g&&(s=L.ID.exec(t[0]))){b=$.find.ID(s[1],b,g)[0];if(!b)return e;a=a.slice(t.shift().length)}q=(s=G.exec(t[0]))&&!s.index&&b.parentNode||b,r=t.pop(),m=r.split(":not")[0];for(j=0,k=$.order.length;j<k;j++){p=$.order[j];if(s=L[p].exec(m)){h=$.find[p]((s[1]||"").replace(K,""),q,g);if(h==null)continue;m===r&&(a=a.slice(0,a.length-r.length)+m.replace(L[p],""),a||o.apply(e,n.call(h,0)));break}}}if(a){i=bl(a,b,g),d=i.dirruns++,h==null&&(h=$.find.TAG("*",G.test(a)&&b.parentNode||b));for(j=0;l=h[j];j++)c=i.runs++,i(l,b)&&e.push(l)}return e};h.querySelectorAll&&function(){var a,b=bm,c=/'|\\/g,d=/\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,e=[],f=[":active"],g=i.matchesSelector||i.mozMatchesSelector||i.webkitMatchesSelector||i.oMatchesSelector||i.msMatchesSelector;T(function(a){a.innerHTML="<select><option selected></option></select>",a.querySelectorAll("[selected]").length||e.push("\\["+r+"*(?:checked|disabled|ismap|multiple|readonly|selected|value)"),a.querySelectorAll(":checked").length||e.push(":checked")}),T(function(a){a.innerHTML="<p test=''></p>",a.querySelectorAll("[test^='']").length&&e.push("[*^$]="+r+"*(?:\"\"|'')"),a.innerHTML="<input type='hidden'>",a.querySelectorAll(":enabled").length||e.push(":enabled",":disabled")}),e=e.length&&new RegExp(e.join("|")),bm=function(a,d,f,g,h){if(!g&&!h&&(!e||!e.test(a)))if(d.nodeType===9)try{return o.apply(f,n.call(d.querySelectorAll(a),0)),f}catch(i){}else if(d.nodeType===1&&d.nodeName.toLowerCase()!=="object"){var j=d.getAttribute("id"),k=j||q,l=G.test(a)&&d.parentNode||d;j?k=k.replace(c,"\\$&"):d.setAttribute("id",k);try{return o.apply(f,n.call(l.querySelectorAll(a.replace(C,"[id='"+k+"'] $&")),0)),f}catch(i){}finally{j||d.removeAttribute("id")}}return b(a,d,f,g,h)},g&&(T(function(b){a=g.call(b,"div");try{g.call(b,"[test!='']:sizzle"),f.push($.match.PSEUDO)}catch(c){}}),f=new RegExp(f.join("|")),Z.matchesSelector=function(b,c){c=c.replace(d,"='$1']");if(!ba(b)&&!f.test(c)&&(!e||!e.test(c)))try{var h=g.call(b,c);if(h||a||b.document&&b.document.nodeType!==11)return h}catch(i){}return Z(c,null,null,[b]).length>0})}(),Z.attr=p.attr,p.find=Z,p.expr=Z.selectors,p.expr[":"]=p.expr.pseudos,p.unique=Z.uniqueSort,p.text=Z.getText,p.isXMLDoc=Z.isXML,p.contains=Z.contains}(a);var bc=/Until$/,bd=/^(?:parents|prev(?:Until|All))/,be=/^.[^:#\[\.,]*$/,bf=p.expr.match.needsContext,bg={children:!0,contents:!0,next:!0,prev:!0};p.fn.extend({find:function(a){var b,c,d,e,f,g,h=this;if(typeof a!="string")return p(a).filter(function(){for(b=0,c=h.length;b<c;b++)if(p.contains(h[b],this))return!0});g=this.pushStack("","find",a);for(b=0,c=this.length;b<c;b++){d=g.length,p.find(a,this[b],g);if(b>0)for(e=d;e<g.length;e++)for(f=0;f<d;f++)if(g[f]===g[e]){g.splice(e--,1);break}}return g},has:function(a){var b,c=p(a,this),d=c.length;return this.filter(function(){for(b=0;b<d;b++)if(p.contains(this,c[b]))return!0})},not:function(a){return this.pushStack(bj(this,a,!1),"not",a)},filter:function(a){return this.pushStack(bj(this,a,!0),"filter",a)},is:function(a){return!!a&&(typeof a=="string"?bf.test(a)?p(a,this.context).index(this[0])>=0:p.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c,d=0,e=this.length,f=[],g=bf.test(a)||typeof a!="string"?p(a,b||this.context):0;for(;d<e;d++){c=this[d];while(c&&c.ownerDocument&&c!==b&&c.nodeType!==11){if(g?g.index(c)>-1:p.find.matchesSelector(c,a)){f.push(c);break}c=c.parentNode}}return f=f.length>1?p.unique(f):f,this.pushStack(f,"closest",a)},index:function(a){return a?typeof a=="string"?p.inArray(this[0],p(a)):p.inArray(a.jquery?a[0]:a,this):this[0]&&this[0].parentNode?this.prevAll().length:-1},add:function(a,b){var c=typeof a=="string"?p(a,b):p.makeArray(a&&a.nodeType?[a]:a),d=p.merge(this.get(),c);return this.pushStack(bh(c[0])||bh(d[0])?d:p.unique(d))},addBack:function(a){return this.add(a==null?this.prevObject:this.prevObject.filter(a))}}),p.fn.andSelf=p.fn.addBack,p.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return p.dir(a,"parentNode")},parentsUntil:function(a,b,c){return p.dir(a,"parentNode",c)},next:function(a){return bi(a,"nextSibling")},prev:function(a){return bi(a,"previousSibling")},nextAll:function(a){return p.dir(a,"nextSibling")},prevAll:function(a){return p.dir(a,"previousSibling")},nextUntil:function(a,b,c){return p.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return p.dir(a,"previousSibling",c)},siblings:function(a){return p.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return p.sibling(a.firstChild)},contents:function(a){return p.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:p.merge([],a.childNodes)}},function(a,b){p.fn[a]=function(c,d){var e=p.map(this,b,c);return bc.test(a)||(d=c),d&&typeof d=="string"&&(e=p.filter(d,e)),e=this.length>1&&!bg[a]?p.unique(e):e,this.length>1&&bd.test(a)&&(e=e.reverse()),this.pushStack(e,a,k.call(arguments).join(","))}}),p.extend({filter:function(a,b,c){return c&&(a=":not("+a+")"),b.length===1?p.find.matchesSelector(b[0],a)?[b[0]]:[]:p.find.matches(a,b)},dir:function(a,c,d){var e=[],f=a[c];while(f&&f.nodeType!==9&&(d===b||f.nodeType!==1||!p(f).is(d)))f.nodeType===1&&e.push(f),f=f[c];return e},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var bl="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",bm=/ jQuery\d+="(?:null|\d+)"/g,bn=/^\s+/,bo=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,bp=/<([\w:]+)/,bq=/<tbody/i,br=/<|&#?\w+;/,bs=/<(?:script|style|link)/i,bt=/<(?:script|object|embed|option|style)/i,bu=new RegExp("<(?:"+bl+")[\\s/>]","i"),bv=/^(?:checkbox|radio)$/,bw=/checked\s*(?:[^=]|=\s*.checked.)/i,bx=/\/(java|ecma)script/i,by=/^\s*<!(?:\[CDATA\[|\-\-)|[\]\-]{2}>\s*$/g,bz={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]},bA=bk(e),bB=bA.appendChild(e.createElement("div"));bz.optgroup=bz.option,bz.tbody=bz.tfoot=bz.colgroup=bz.caption=bz.thead,bz.th=bz.td,p.support.htmlSerialize||(bz._default=[1,"X<div>","</div>"]),p.fn.extend({text:function(a){return p.access(this,function(a){return a===b?p.text(this):this.empty().append((this[0]&&this[0].ownerDocument||e).createTextNode(a))},null,a,arguments.length)},wrapAll:function(a){if(p.isFunction(a))return this.each(function(b){p(this).wrapAll(a.call(this,b))});if(this[0]){var b=p(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){return p.isFunction(a)?this.each(function(b){p(this).wrapInner(a.call(this,b))}):this.each(function(){var b=p(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=p.isFunction(a);return this.each(function(c){p(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){p.nodeName(this,"body")||p(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){(this.nodeType===1||this.nodeType===11)&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){(this.nodeType===1||this.nodeType===11)&&this.insertBefore(a,this.firstChild)})},before:function(){if(!bh(this[0]))return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=p.clean(arguments);return this.pushStack(p.merge(a,this),"before",this.selector)}},after:function(){if(!bh(this[0]))return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=p.clean(arguments);return this.pushStack(p.merge(this,a),"after",this.selector)}},remove:function(a,b){var c,d=0;for(;(c=this[d])!=null;d++)if(!a||p.filter(a,[c]).length)!b&&c.nodeType===1&&(p.cleanData(c.getElementsByTagName("*")),p.cleanData([c])),c.parentNode&&c.parentNode.removeChild(c);return this},empty:function(){var a,b=0;for(;(a=this[b])!=null;b++){a.nodeType===1&&p.cleanData(a.getElementsByTagName("*"));while(a.firstChild)a.removeChild(a.firstChild)}return this},clone:function(a,b){return a=a==null?!1:a,b=b==null?a:b,this.map(function(){return p.clone(this,a,b)})},html:function(a){return p.access(this,function(a){var c=this[0]||{},d=0,e=this.length;if(a===b)return c.nodeType===1?c.innerHTML.replace(bm,""):b;if(typeof a=="string"&&!bs.test(a)&&(p.support.htmlSerialize||!bu.test(a))&&(p.support.leadingWhitespace||!bn.test(a))&&!bz[(bp.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(bo,"<$1></$2>");try{for(;d<e;d++)c=this[d]||{},c.nodeType===1&&(p.cleanData(c.getElementsByTagName("*")),c.innerHTML=a);c=0}catch(f){}}c&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(a){return bh(this[0])?this.length?this.pushStack(p(p.isFunction(a)?a():a),"replaceWith",a):this:p.isFunction(a)?this.each(function(b){var c=p(this),d=c.html();c.replaceWith(a.call(this,b,d))}):(typeof a!="string"&&(a=p(a).detach()),this.each(function(){var b=this.nextSibling,c=this.parentNode;p(this).remove(),b?p(b).before(a):p(c).append(a)}))},detach:function(a){return this.remove(a,!0)},domManip:function(a,c,d){a=[].concat.apply([],a);var e,f,g,h,i=0,j=a[0],k=[],l=this.length;if(!p.support.checkClone&&l>1&&typeof j=="string"&&bw.test(j))return this.each(function(){p(this).domManip(a,c,d)});if(p.isFunction(j))return this.each(function(e){var f=p(this);a[0]=j.call(this,e,c?f.html():b),f.domManip(a,c,d)});if(this[0]){e=p.buildFragment(a,this,k),g=e.fragment,f=g.firstChild,g.childNodes.length===1&&(g=f);if(f){c=c&&p.nodeName(f,"tr");for(h=e.cacheable||l-1;i<l;i++)d.call(c&&p.nodeName(this[i],"table")?bC(this[i],"tbody"):this[i],i===h?g:p.clone(g,!0,!0))}g=f=null,k.length&&p.each(k,function(a,b){b.src?p.ajax?p.ajax({url:b.src,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0}):p.error("no ajax"):p.globalEval((b.text||b.textContent||b.innerHTML||"").replace(by,"")),b.parentNode&&b.parentNode.removeChild(b)})}return this}}),p.buildFragment=function(a,c,d){var f,g,h,i=a[0];return c=c||e,c=(c[0]||c).ownerDocument||c[0]||c,typeof c.createDocumentFragment=="undefined"&&(c=e),a.length===1&&typeof i=="string"&&i.length<512&&c===e&&i.charAt(0)==="<"&&!bt.test(i)&&(p.support.checkClone||!bw.test(i))&&(p.support.html5Clone||!bu.test(i))&&(g=!0,f=p.fragments[i],h=f!==b),f||(f=c.createDocumentFragment(),p.clean(a,c,f,d),g&&(p.fragments[i]=h&&f)),{fragment:f,cacheable:g}},p.fragments={},p.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){p.fn[a]=function(c){var d,e=0,f=[],g=p(c),h=g.length,i=this.length===1&&this[0].parentNode;if((i==null||i&&i.nodeType===11&&i.childNodes.length===1)&&h===1)return g[b](this[0]),this;for(;e<h;e++)d=(e>0?this.clone(!0):this).get(),p(g[e])[b](d),f=f.concat(d);return this.pushStack(f,a,g.selector)}}),p.extend({clone:function(a,b,c){var d,e,f,g;p.support.html5Clone||p.isXMLDoc(a)||!bu.test("<"+a.nodeName+">")?g=a.cloneNode(!0):(bB.innerHTML=a.outerHTML,bB.removeChild(g=bB.firstChild));if((!p.support.noCloneEvent||!p.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!p.isXMLDoc(a)){bE(a,g),d=bF(a),e=bF(g);for(f=0;d[f];++f)e[f]&&bE(d[f],e[f])}if(b){bD(a,g);if(c){d=bF(a),e=bF(g);for(f=0;d[f];++f)bD(d[f],e[f])}}return d=e=null,g},clean:function(a,b,c,d){var f,g,h,i,j,k,l,m,n,o,q,r,s=0,t=[];if(!b||typeof b.createDocumentFragment=="undefined")b=e;for(g=b===e&&bA;(h=a[s])!=null;s++){typeof h=="number"&&(h+="");if(!h)continue;if(typeof h=="string")if(!br.test(h))h=b.createTextNode(h);else{g=g||bk(b),l=l||g.appendChild(b.createElement("div")),h=h.replace(bo,"<$1></$2>"),i=(bp.exec(h)||["",""])[1].toLowerCase(),j=bz[i]||bz._default,k=j[0],l.innerHTML=j[1]+h+j[2];while(k--)l=l.lastChild;if(!p.support.tbody){m=bq.test(h),n=i==="table"&&!m?l.firstChild&&l.firstChild.childNodes:j[1]==="<table>"&&!m?l.childNodes:[];for(f=n.length-1;f>=0;--f)p.nodeName(n[f],"tbody")&&!n[f].childNodes.length&&n[f].parentNode.removeChild(n[f])}!p.support.leadingWhitespace&&bn.test(h)&&l.insertBefore(b.createTextNode(bn.exec(h)[0]),l.firstChild),h=l.childNodes,l=g.lastChild}h.nodeType?t.push(h):t=p.merge(t,h)}l&&(g.removeChild(l),h=l=g=null);if(!p.support.appendChecked)for(s=0;(h=t[s])!=null;s++)p.nodeName(h,"input")?bG(h):typeof h.getElementsByTagName!="undefined"&&p.grep(h.getElementsByTagName("input"),bG);if(c){q=function(a){if(!a.type||bx.test(a.type))return d?d.push(a.parentNode?a.parentNode.removeChild(a):a):c.appendChild(a)};for(s=0;(h=t[s])!=null;s++)if(!p.nodeName(h,"script")||!q(h))c.appendChild(h),typeof h.getElementsByTagName!="undefined"&&(r=p.grep(p.merge([],h.getElementsByTagName("script")),q),t.splice.apply(t,[s+1,0].concat(r)),s+=r.length)}return t},cleanData:function(a,b){var c,d,e,f,g=0,h=p.expando,i=p.cache,j=p.support.deleteExpando,k=p.event.special;for(;(e=a[g])!=null;g++)if(b||p.acceptData(e)){d=e[h],c=d&&i[d];if(c){if(c.events)for(f in c.events)k[f]?p.event.remove(e,f):p.removeEvent(e,f,c.handle);i[d]&&(delete i[d],j?delete e[h]:e.removeAttribute?e.removeAttribute(h):e[h]=null,p.deletedIds.push(d))}}}}),function(){var a,b;p.uaMatch=function(a){a=a.toLowerCase();var b=/(chrome)[ \/]([\w.]+)/.exec(a)||/(webkit)[ \/]([\w.]+)/.exec(a)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(a)||/(msie) ([\w.]+)/.exec(a)||a.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(a)||[];return{browser:b[1]||"",version:b[2]||"0"}},a=p.uaMatch(g.userAgent),b={},a.browser&&(b[a.browser]=!0,b.version=a.version),b.webkit&&(b.safari=!0),p.browser=b,p.sub=function(){function a(b,c){return new a.fn.init(b,c)}p.extend(!0,a,this),a.superclass=this,a.fn=a.prototype=this(),a.fn.constructor=a,a.sub=this.sub,a.fn.init=function c(c,d){return d&&d instanceof p&&!(d instanceof a)&&(d=a(d)),p.fn.init.call(this,c,d,b)},a.fn.init.prototype=a.fn;var b=a(e);return a}}();var bH,bI,bJ,bK=/alpha\([^)]*\)/i,bL=/opacity=([^)]*)/,bM=/^(top|right|bottom|left)$/,bN=/^margin/,bO=new RegExp("^("+q+")(.*)$","i"),bP=new RegExp("^("+q+")(?!px)[a-z%]+$","i"),bQ=new RegExp("^([-+])=("+q+")","i"),bR={},bS={position:"absolute",visibility:"hidden",display:"block"},bT={letterSpacing:0,fontWeight:400,lineHeight:1},bU=["Top","Right","Bottom","Left"],bV=["Webkit","O","Moz","ms"],bW=p.fn.toggle;p.fn.extend({css:function(a,c){return p.access(this,function(a,c,d){return d!==b?p.style(a,c,d):p.css(a,c)},a,c,arguments.length>1)},show:function(){return bZ(this,!0)},hide:function(){return bZ(this)},toggle:function(a,b){var c=typeof a=="boolean";return p.isFunction(a)&&p.isFunction(b)?bW.apply(this,arguments):this.each(function(){(c?a:bY(this))?p(this).show():p(this).hide()})}}),p.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=bH(a,"opacity");return c===""?"1":c}}}},cssNumber:{fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":p.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,d,e){if(!a||a.nodeType===3||a.nodeType===8||!a.style)return;var f,g,h,i=p.camelCase(c),j=a.style;c=p.cssProps[i]||(p.cssProps[i]=bX(j,i)),h=p.cssHooks[c]||p.cssHooks[i];if(d===b)return h&&"get"in h&&(f=h.get(a,!1,e))!==b?f:j[c];g=typeof d,g==="string"&&(f=bQ.exec(d))&&(d=(f[1]+1)*f[2]+parseFloat(p.css(a,c)),g="number");if(d==null||g==="number"&&isNaN(d))return;g==="number"&&!p.cssNumber[i]&&(d+="px");if(!h||!("set"in h)||(d=h.set(a,d,e))!==b)try{j[c]=d}catch(k){}},css:function(a,c,d,e){var f,g,h,i=p.camelCase(c);return c=p.cssProps[i]||(p.cssProps[i]=bX(a.style,i)),h=p.cssHooks[c]||p.cssHooks[i],h&&"get"in h&&(f=h.get(a,!0,e)),f===b&&(f=bH(a,c)),f==="normal"&&c in bT&&(f=bT[c]),d||e!==b?(g=parseFloat(f),d||p.isNumeric(g)?g||0:f):f},swap:function(a,b,c){var d,e,f={};for(e in b)f[e]=a.style[e],a.style[e]=b[e];d=c.call(a);for(e in b)a.style[e]=f[e];return d}}),a.getComputedStyle?bH=function(a,b){var c,d,e,f,g=getComputedStyle(a,null),h=a.style;return g&&(c=g[b],c===""&&!p.contains(a.ownerDocument.documentElement,a)&&(c=p.style(a,b)),bP.test(c)&&bN.test(b)&&(d=h.width,e=h.minWidth,f=h.maxWidth,h.minWidth=h.maxWidth=h.width=c,c=g.width,h.width=d,h.minWidth=e,h.maxWidth=f)),c}:e.documentElement.currentStyle&&(bH=function(a,b){var c,d,e=a.currentStyle&&a.currentStyle[b],f=a.style;return e==null&&f&&f[b]&&(e=f[b]),bP.test(e)&&!bM.test(b)&&(c=f.left,d=a.runtimeStyle&&a.runtimeStyle.left,d&&(a.runtimeStyle.left=a.currentStyle.left),f.left=b==="fontSize"?"1em":e,e=f.pixelLeft+"px",f.left=c,d&&(a.runtimeStyle.left=d)),e===""?"auto":e}),p.each(["height","width"],function(a,b){p.cssHooks[b]={get:function(a,c,d){if(c)return a.offsetWidth!==0||bH(a,"display")!=="none"?ca(a,b,d):p.swap(a,bS,function(){return ca(a,b,d)})},set:function(a,c,d){return b$(a,c,d?b_(a,b,d,p.support.boxSizing&&p.css(a,"boxSizing")==="border-box"):0)}}}),p.support.opacity||(p.cssHooks.opacity={get:function(a,b){return bL.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=p.isNumeric(b)?"alpha(opacity="+b*100+")":"",f=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&p.trim(f.replace(bK,""))===""&&c.removeAttribute){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bK.test(f)?f.replace(bK,e):f+" "+e}}),p(function(){p.support.reliableMarginRight||(p.cssHooks.marginRight={get:function(a,b){return p.swap(a,{display:"inline-block"},function(){if(b)return bH(a,"marginRight")})}}),!p.support.pixelPosition&&p.fn.position&&p.each(["top","left"],function(a,b){p.cssHooks[b]={get:function(a,c){if(c){var d=bH(a,b);return bP.test(d)?p(a).position()[b]+"px":d}}}})}),p.expr&&p.expr.filters&&(p.expr.filters.hidden=function(a){return a.offsetWidth===0&&a.offsetHeight===0||!p.support.reliableHiddenOffsets&&(a.style&&a.style.display||bH(a,"display"))==="none"},p.expr.filters.visible=function(a){return!p.expr.filters.hidden(a)}),p.each({margin:"",padding:"",border:"Width"},function(a,b){p.cssHooks[a+b]={expand:function(c){var d,e=typeof c=="string"?c.split(" "):[c],f={};for(d=0;d<4;d++)f[a+bU[d]+b]=e[d]||e[d-2]||e[0];return f}},bN.test(a)||(p.cssHooks[a+b].set=b$)});var cc=/%20/g,cd=/\[\]$/,ce=/\r?\n/g,cf=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,cg=/^(?:select|textarea)/i;p.fn.extend({serialize:function(){return p.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?p.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||cg.test(this.nodeName)||cf.test(this.type))}).map(function(a,b){var c=p(this).val();return c==null?null:p.isArray(c)?p.map(c,function(a,c){return{name:b.name,value:a.replace(ce,"\r\n")}}):{name:b.name,value:c.replace(ce,"\r\n")}}).get()}}),p.param=function(a,c){var d,e=[],f=function(a,b){b=p.isFunction(b)?b():b==null?"":b,e[e.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=p.ajaxSettings&&p.ajaxSettings.traditional);if(p.isArray(a)||a.jquery&&!p.isPlainObject(a))p.each(a,function(){f(this.name,this.value)});else for(d in a)ch(d,a[d],c,f);return e.join("&").replace(cc,"+")};var ci,cj,ck=/#.*$/,cl=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,cm=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,cn=/^(?:GET|HEAD)$/,co=/^\/\//,cp=/\?/,cq=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,cr=/([?&])_=[^&]*/,cs=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,ct=p.fn.load,cu={},cv={},cw=["*/"]+["*"];try{ci=f.href}catch(cx){ci=e.createElement("a"),ci.href="",ci=ci.href}cj=cs.exec(ci.toLowerCase())||[],p.fn.load=function(a,c,d){if(typeof a!="string"&&ct)return ct.apply(this,arguments);if(!this.length)return this;var e,f,g,h=this,i=a.indexOf(" ");return i>=0&&(e=a.slice(i,a.length),a=a.slice(0,i)),p.isFunction(c)?(d=c,c=b):typeof c=="object"&&(f="POST"),p.ajax({url:a,type:f,dataType:"html",data:c,complete:function(a,b){d&&h.each(d,g||[a.responseText,b,a])}}).done(function(a){g=arguments,h.html(e?p("<div>").append(a.replace(cq,"")).find(e):a)}),this},p.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){p.fn[b]=function(a){return this.on(b,a)}}),p.each(["get","post"],function(a,c){p[c]=function(a,d,e,f){return p.isFunction(d)&&(f=f||e,e=d,d=b),p.ajax({type:c,url:a,data:d,success:e,dataType:f})}}),p.extend({getScript:function(a,c){return p.get(a,b,c,"script")},getJSON:function(a,b,c){return p.get(a,b,c,"json")},ajaxSetup:function(a,b){return b?cA(a,p.ajaxSettings):(b=a,a=p.ajaxSettings),cA(a,b),a},ajaxSettings:{url:ci,isLocal:cm.test(cj[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded; charset=UTF-8",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":cw},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":p.parseJSON,"text xml":p.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:cy(cu),ajaxTransport:cy(cv),ajax:function(a,c){function y(a,c,f,i){var k,s,t,u,w,y=c;if(v===2)return;v=2,h&&clearTimeout(h),g=b,e=i||"",x.readyState=a>0?4:0,f&&(u=cB(l,x,f));if(a>=200&&a<300||a===304)l.ifModified&&(w=x.getResponseHeader("Last-Modified"),w&&(p.lastModified[d]=w),w=x.getResponseHeader("Etag"),w&&(p.etag[d]=w)),a===304?(y="notmodified",k=!0):(k=cC(l,u),y=k.state,s=k.data,t=k.error,k=!t);else{t=y;if(!y||a)y="error",a<0&&(a=0)}x.status=a,x.statusText=""+(c||y),k?o.resolveWith(m,[s,y,x]):o.rejectWith(m,[x,y,t]),x.statusCode(r),r=b,j&&n.trigger("ajax"+(k?"Success":"Error"),[x,l,k?s:t]),q.fireWith(m,[x,y]),j&&(n.trigger("ajaxComplete",[x,l]),--p.active||p.event.trigger("ajaxStop"))}typeof a=="object"&&(c=a,a=b),c=c||{};var d,e,f,g,h,i,j,k,l=p.ajaxSetup({},c),m=l.context||l,n=m!==l&&(m.nodeType||m instanceof p)?p(m):p.event,o=p.Deferred(),q=p.Callbacks("once memory"),r=l.statusCode||{},t={},u={},v=0,w="canceled",x={readyState:0,setRequestHeader:function(a,b){if(!v){var c=a.toLowerCase();a=u[c]=u[c]||a,t[a]=b}return this},getAllResponseHeaders:function(){return v===2?e:null},getResponseHeader:function(a){var c;if(v===2){if(!f){f={};while(c=cl.exec(e))f[c[1].toLowerCase()]=c[2]}c=f[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){return v||(l.mimeType=a),this},abort:function(a){return a=a||w,g&&g.abort(a),y(0,a),this}};o.promise(x),x.success=x.done,x.error=x.fail,x.complete=q.add,x.statusCode=function(a){if(a){var b;if(v<2)for(b in a)r[b]=[r[b],a[b]];else b=a[x.status],x.always(b)}return this},l.url=((a||l.url)+"").replace(ck,"").replace(co,cj[1]+"//"),l.dataTypes=p.trim(l.dataType||"*").toLowerCase().split(s),l.crossDomain==null&&(i=cs.exec(l.url.toLowerCase()),l.crossDomain=!(!i||i[1]==cj[1]&&i[2]==cj[2]&&(i[3]||(i[1]==="http:"?80:443))==(cj[3]||(cj[1]==="http:"?80:443)))),l.data&&l.processData&&typeof l.data!="string"&&(l.data=p.param(l.data,l.traditional)),cz(cu,l,c,x);if(v===2)return x;j=l.global,l.type=l.type.toUpperCase(),l.hasContent=!cn.test(l.type),j&&p.active++===0&&p.event.trigger("ajaxStart");if(!l.hasContent){l.data&&(l.url+=(cp.test(l.url)?"&":"?")+l.data,delete l.data),d=l.url;if(l.cache===!1){var z=p.now(),A=l.url.replace(cr,"$1_="+z);l.url=A+(A===l.url?(cp.test(l.url)?"&":"?")+"_="+z:"")}}(l.data&&l.hasContent&&l.contentType!==!1||c.contentType)&&x.setRequestHeader("Content-Type",l.contentType),l.ifModified&&(d=d||l.url,p.lastModified[d]&&x.setRequestHeader("If-Modified-Since",p.lastModified[d]),p.etag[d]&&x.setRequestHeader("If-None-Match",p.etag[d])),x.setRequestHeader("Accept",l.dataTypes[0]&&l.accepts[l.dataTypes[0]]?l.accepts[l.dataTypes[0]]+(l.dataTypes[0]!=="*"?", "+cw+"; q=0.01":""):l.accepts["*"]);for(k in l.headers)x.setRequestHeader(k,l.headers[k]);if(!l.beforeSend||l.beforeSend.call(m,x,l)!==!1&&v!==2){w="abort";for(k in{success:1,error:1,complete:1})x[k](l[k]);g=cz(cv,l,c,x);if(!g)y(-1,"No Transport");else{x.readyState=1,j&&n.trigger("ajaxSend",[x,l]),l.async&&l.timeout>0&&(h=setTimeout(function(){x.abort("timeout")},l.timeout));try{v=1,g.send(t,y)}catch(B){if(v<2)y(-1,B);else throw B}}return x}return x.abort()},active:0,lastModified:{},etag:{}});var cD=[],cE=/\?/,cF=/(=)\?(?=&|$)|\?\?/,cG=p.now();p.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var a=cD.pop()||p.expando+"_"+cG++;return this[a]=!0,a}}),p.ajaxPrefilter("json jsonp",function(c,d,e){var f,g,h,i=c.data,j=c.url,k=c.jsonp!==!1,l=k&&cF.test(j),m=k&&!l&&typeof i=="string"&&!(c.contentType||"").indexOf("application/x-www-form-urlencoded")&&cF.test(i);if(c.dataTypes[0]==="jsonp"||l||m)return f=c.jsonpCallback=p.isFunction(c.jsonpCallback)?c.jsonpCallback():c.jsonpCallback,g=a[f],l?c.url=j.replace(cF,"$1"+f):m?c.data=i.replace(cF,"$1"+f):k&&(c.url+=(cE.test(j)?"&":"?")+c.jsonp+"="+f),c.converters["script json"]=function(){return h||p.error(f+" was not called"),h[0]},c.dataTypes[0]="json",a[f]=function(){h=arguments},e.always(function(){a[f]=g,c[f]&&(c.jsonpCallback=d.jsonpCallback,cD.push(f)),h&&p.isFunction(g)&&g(h[0]),h=g=b}),"script"}),p.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){return p.globalEval(a),a}}}),p.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),p.ajaxTransport("script",function(a){if(a.crossDomain){var c,d=e.head||e.getElementsByTagName("head")[0]||e.documentElement;return{send:function(f,g){c=e.createElement("script"),c.async="async",a.scriptCharset&&(c.charset=a.scriptCharset),c.src=a.url,c.onload=c.onreadystatechange=function(a,e){if(e||!c.readyState||/loaded|complete/.test(c.readyState))c.onload=c.onreadystatechange=null,d&&c.parentNode&&d.removeChild(c),c=b,e||g(200,"success")},d.insertBefore(c,d.firstChild)},abort:function(){c&&c.onload(0,1)}}}});var cH,cI=a.ActiveXObject?function(){for(var a in cH)cH[a](0,1)}:!1,cJ=0;p.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&cK()||cL()}:cK,function(a){p.extend(p.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(p.ajaxSettings.xhr()),p.support.ajax&&p.ajaxTransport(function(c){if(!c.crossDomain||p.support.cors){var d;return{send:function(e,f){var g,h,i=c.xhr();c.username?i.open(c.type,c.url,c.async,c.username,c.password):i.open(c.type,c.url,c.async);if(c.xhrFields)for(h in c.xhrFields)i[h]=c.xhrFields[h];c.mimeType&&i.overrideMimeType&&i.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(h in e)i.setRequestHeader(h,e[h])}catch(j){}i.send(c.hasContent&&c.data||null),d=function(a,e){var h,j,k,l,m;try{if(d&&(e||i.readyState===4)){d=b,g&&(i.onreadystatechange=p.noop,cI&&delete cH[g]);if(e)i.readyState!==4&&i.abort();else{h=i.status,k=i.getAllResponseHeaders(),l={},m=i.responseXML,m&&m.documentElement&&(l.xml=m);try{l.text=i.responseText}catch(a){}try{j=i.statusText}catch(n){j=""}!h&&c.isLocal&&!c.crossDomain?h=l.text?200:404:h===1223&&(h=204)}}}catch(o){e||f(-1,o)}l&&f(h,j,l,k)},c.async?i.readyState===4?setTimeout(d,0):(g=++cJ,cI&&(cH||(cH={},p(a).unload(cI)),cH[g]=d),i.onreadystatechange=d):d()},abort:function(){d&&d(0,1)}}}});var cM,cN,cO=/^(?:toggle|show|hide)$/,cP=new RegExp("^(?:([-+])=|)("+q+")([a-z%]*)$","i"),cQ=/queueHooks$/,cR=[cX],cS={"*":[function(a,b){var c,d,e,f=this.createTween(a,b),g=cP.exec(b),h=f.cur(),i=+h||0,j=1;if(g){c=+g[2],d=g[3]||(p.cssNumber[a]?"":"px");if(d!=="px"&&i){i=p.css(f.elem,a,!0)||c||1;do e=j=j||".5",i=i/j,p.style(f.elem,a,i+d),j=f.cur()/h;while(j!==1&&j!==e)}f.unit=d,f.start=i,f.end=g[1]?i+(g[1]+1)*c:c}return f}]};p.Animation=p.extend(cV,{tweener:function(a,b){p.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");var c,d=0,e=a.length;for(;d<e;d++)c=a[d],cS[c]=cS[c]||[],cS[c].unshift(b)},prefilter:function(a,b){b?cR.unshift(a):cR.push(a)}}),p.Tween=cY,cY.prototype={constructor:cY,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||"swing",this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(p.cssNumber[c]?"":"px")},cur:function(){var a=cY.propHooks[this.prop];return a&&a.get?a.get(this):cY.propHooks._default.get(this)},run:function(a){var b,c=cY.propHooks[this.prop];return this.pos=b=p.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration),this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):cY.propHooks._default.set(this),this}},cY.prototype.init.prototype=cY.prototype,cY.propHooks={_default:{get:function(a){var b;return a.elem[a.prop]==null||!!a.elem.style&&a.elem.style[a.prop]!=null?(b=p.css(a.elem,a.prop,!1,""),!b||b==="auto"?0:b):a.elem[a.prop]},set:function(a){p.fx.step[a.prop]?p.fx.step[a.prop](a):a.elem.style&&(a.elem.style[p.cssProps[a.prop]]!=null||p.cssHooks[a.prop])?p.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},cY.propHooks.scrollTop=cY.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},p.each(["toggle","show","hide"],function(a,b){var c=p.fn[b];p.fn[b]=function(d,e,f){return d==null||typeof d=="boolean"||!a&&p.isFunction(d)&&p.isFunction(e)?c.apply(this,arguments):this.animate(cZ(b,!0),d,e,f)}}),p.fn.extend({fadeTo:function(a,b,c,d){return this.filter(bY).css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=p.isEmptyObject(a),f=p.speed(b,c,d),g=function(){var b=cV(this,p.extend({},a),f);e&&b.stop(!0)};return e||f.queue===!1?this.each(g):this.queue(f.queue,g)},stop:function(a,c,d){var e=function(a){var b=a.stop;delete a.stop,b(d)};return typeof a!="string"&&(d=c,c=a,a=b),c&&a!==!1&&this.queue(a||"fx",[]),this.each(function(){var b=!0,c=a!=null&&a+"queueHooks",f=p.timers,g=p._data(this);if(c)g[c]&&g[c].stop&&e(g[c]);else for(c in g)g[c]&&g[c].stop&&cQ.test(c)&&e(g[c]);for(c=f.length;c--;)f[c].elem===this&&(a==null||f[c].queue===a)&&(f[c].anim.stop(d),b=!1,f.splice(c,1));(b||!d)&&p.dequeue(this,a)})}}),p.each({slideDown:cZ("show"),slideUp:cZ("hide"),slideToggle:cZ("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){p.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),p.speed=function(a,b,c){var d=a&&typeof a=="object"?p.extend({},a):{complete:c||!c&&b||p.isFunction(a)&&a,duration:a,easing:c&&b||b&&!p.isFunction(b)&&b};d.duration=p.fx.off?0:typeof d.duration=="number"?d.duration:d.duration in p.fx.speeds?p.fx.speeds[d.duration]:p.fx.speeds._default;if(d.queue==null||d.queue===!0)d.queue="fx";return d.old=d.complete,d.complete=function(){p.isFunction(d.old)&&d.old.call(this),d.queue&&p.dequeue(this,d.queue)},d},p.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},p.timers=[],p.fx=cY.prototype.init,p.fx.tick=function(){var a,b=p.timers,c=0;for(;c<b.length;c++)a=b[c],!a()&&b[c]===a&&b.splice(c--,1);b.length||p.fx.stop()},p.fx.timer=function(a){a()&&p.timers.push(a)&&!cN&&(cN=setInterval(p.fx.tick,p.fx.interval))},p.fx.interval=13,p.fx.stop=function(){clearInterval(cN),cN=null},p.fx.speeds={slow:600,fast:200,_default:400},p.fx.step={},p.expr&&p.expr.filters&&(p.expr.filters.animated=function(a){return p.grep(p.timers,function(b){return a===b.elem}).length});var c$=/^(?:body|html)$/i;p.fn.offset=function(a){if(arguments.length)return a===b?this:this.each(function(b){p.offset.setOffset(this,a,b)});var c,d,e,f,g,h,i,j,k,l,m=this[0],n=m&&m.ownerDocument;if(!n)return;return(e=n.body)===m?p.offset.bodyOffset(m):(d=n.documentElement,p.contains(d,m)?(c=m.getBoundingClientRect(),f=c_(n),g=d.clientTop||e.clientTop||0,h=d.clientLeft||e.clientLeft||0,i=f.pageYOffset||d.scrollTop,j=f.pageXOffset||d.scrollLeft,k=c.top+i-g,l=c.left+j-h,{top:k,left:l}):{top:0,left:0})},p.offset={bodyOffset:function(a){var b=a.offsetTop,c=a.offsetLeft;return p.support.doesNotIncludeMarginInBodyOffset&&(b+=parseFloat(p.css(a,"marginTop"))||0,c+=parseFloat(p.css(a,"marginLeft"))||0),{top:b,left:c}},setOffset:function(a,b,c){var d=p.css(a,"position");d==="static"&&(a.style.position="relative");var e=p(a),f=e.offset(),g=p.css(a,"top"),h=p.css(a,"left"),i=(d==="absolute"||d==="fixed")&&p.inArray("auto",[g,h])>-1,j={},k={},l,m;i?(k=e.position(),l=k.top,m=k.left):(l=parseFloat(g)||0,m=parseFloat(h)||0),p.isFunction(b)&&(b=b.call(a,c,f)),b.top!=null&&(j.top=b.top-f.top+l),b.left!=null&&(j.left=b.left-f.left+m),"using"in b?b.using.call(a,j):e.css(j)}},p.fn.extend({position:function(){if(!this[0])return;var a=this[0],b=this.offsetParent(),c=this.offset(),d=c$.test(b[0].nodeName)?{top:0,left:0}:b.offset();return c.top-=parseFloat(p.css(a,"marginTop"))||0,c.left-=parseFloat(p.css(a,"marginLeft"))||0,d.top+=parseFloat(p.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(p.css(b[0],"borderLeftWidth"))||0,{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||e.body;while(a&&!c$.test(a.nodeName)&&p.css(a,"position")==="static")a=a.offsetParent;return a||e.body})}}),p.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,c){var d=/Y/.test(c);p.fn[a]=function(e){return p.access(this,function(a,e,f){var g=c_(a);if(f===b)return g?c in g?g[c]:g.document.documentElement[e]:a[e];g?g.scrollTo(d?p(g).scrollLeft():f,d?f:p(g).scrollTop()):a[e]=f},a,e,arguments.length,null)}}),p.each({Height:"height",Width:"width"},function(a,c){p.each({padding:"inner"+a,content:c,"":"outer"+a},function(d,e){p.fn[e]=function(e,f){var g=arguments.length&&(d||typeof e!="boolean"),h=d||(e===!0||f===!0?"margin":"border");return p.access(this,function(c,d,e){var f;return p.isWindow(c)?c.document.documentElement["client"+a]:c.nodeType===9?(f=c.documentElement,Math.max(c.body["scroll"+a],f["scroll"+a],c.body["offset"+a],f["offset"+a],f["client"+a])):e===b?p.css(c,d,e,h):p.style(c,d,e,h)},c,g?e:b,g)}})}),a.jQuery=a.$=p,typeof define=="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return p})})(window);
\ No newline at end of file
profiles/killpay/src/main/webapp/lib/shred.bundle.js 2765(+2765 -0)
diff --git a/profiles/killpay/src/main/webapp/lib/shred.bundle.js b/profiles/killpay/src/main/webapp/lib/shred.bundle.js
new file mode 100644
index 0000000..74d0816
--- /dev/null
+++ b/profiles/killpay/src/main/webapp/lib/shred.bundle.js
@@ -0,0 +1,2765 @@
+var require = function (file, cwd) {
+ var resolved = require.resolve(file, cwd || '/');
+ var mod = require.modules[resolved];
+ if (!mod) throw new Error(
+ 'Failed to resolve module ' + file + ', tried ' + resolved
+ );
+ var res = mod._cached ? mod._cached : mod();
+ return res;
+}
+
+require.paths = [];
+require.modules = {};
+require.extensions = [".js",".coffee"];
+
+require._core = {
+ 'assert': true,
+ 'events': true,
+ 'fs': true,
+ 'path': true,
+ 'vm': true
+};
+
+require.resolve = (function () {
+ return function (x, cwd) {
+ if (!cwd) cwd = '/';
+
+ if (require._core[x]) return x;
+ var path = require.modules.path();
+ var y = cwd || '.';
+
+ if (x.match(/^(?:\.\.?\/|\/)/)) {
+ var m = loadAsFileSync(path.resolve(y, x))
+ || loadAsDirectorySync(path.resolve(y, x));
+ if (m) return m;
+ }
+
+ var n = loadNodeModulesSync(x, y);
+ if (n) return n;
+
+ throw new Error("Cannot find module '" + x + "'");
+
+ function loadAsFileSync (x) {
+ if (require.modules[x]) {
+ return x;
+ }
+
+ for (var i = 0; i < require.extensions.length; i++) {
+ var ext = require.extensions[i];
+ if (require.modules[x + ext]) return x + ext;
+ }
+ }
+
+ function loadAsDirectorySync (x) {
+ x = x.replace(/\/+$/, '');
+ var pkgfile = x + '/package.json';
+ if (require.modules[pkgfile]) {
+ var pkg = require.modules[pkgfile]();
+ var b = pkg.browserify;
+ if (typeof b === 'object' && b.main) {
+ var m = loadAsFileSync(path.resolve(x, b.main));
+ if (m) return m;
+ }
+ else if (typeof b === 'string') {
+ var m = loadAsFileSync(path.resolve(x, b));
+ if (m) return m;
+ }
+ else if (pkg.main) {
+ var m = loadAsFileSync(path.resolve(x, pkg.main));
+ if (m) return m;
+ }
+ }
+
+ return loadAsFileSync(x + '/index');
+ }
+
+ function loadNodeModulesSync (x, start) {
+ var dirs = nodeModulesPathsSync(start);
+ for (var i = 0; i < dirs.length; i++) {
+ var dir = dirs[i];
+ var m = loadAsFileSync(dir + '/' + x);
+ if (m) return m;
+ var n = loadAsDirectorySync(dir + '/' + x);
+ if (n) return n;
+ }
+
+ var m = loadAsFileSync(x);
+ if (m) return m;
+ }
+
+ function nodeModulesPathsSync (start) {
+ var parts;
+ if (start === '/') parts = [ '' ];
+ else parts = path.normalize(start).split('/');
+
+ var dirs = [];
+ for (var i = parts.length - 1; i >= 0; i--) {
+ if (parts[i] === 'node_modules') continue;
+ var dir = parts.slice(0, i + 1).join('/') + '/node_modules';
+ dirs.push(dir);
+ }
+
+ return dirs;
+ }
+ };
+})();
+
+require.alias = function (from, to) {
+ var path = require.modules.path();
+ var res = null;
+ try {
+ res = require.resolve(from + '/package.json', '/');
+ }
+ catch (err) {
+ res = require.resolve(from, '/');
+ }
+ var basedir = path.dirname(res);
+
+ var keys = (Object.keys || function (obj) {
+ var res = [];
+ for (var key in obj) res.push(key)
+ return res;
+ })(require.modules);
+
+ for (var i = 0; i < keys.length; i++) {
+ var key = keys[i];
+ if (key.slice(0, basedir.length + 1) === basedir + '/') {
+ var f = key.slice(basedir.length);
+ require.modules[to + f] = require.modules[basedir + f];
+ }
+ else if (key === basedir) {
+ require.modules[to] = require.modules[basedir];
+ }
+ }
+};
+
+require.define = function (filename, fn) {
+ var dirname = require._core[filename]
+ ? ''
+ : require.modules.path().dirname(filename)
+ ;
+
+ var require_ = function (file) {
+ return require(file, dirname)
+ };
+ require_.resolve = function (name) {
+ return require.resolve(name, dirname);
+ };
+ require_.modules = require.modules;
+ require_.define = require.define;
+ var module_ = { exports : {} };
+
+ require.modules[filename] = function () {
+ require.modules[filename]._cached = module_.exports;
+ fn.call(
+ module_.exports,
+ require_,
+ module_,
+ module_.exports,
+ dirname,
+ filename
+ );
+ require.modules[filename]._cached = module_.exports;
+ return module_.exports;
+ };
+};
+
+if (typeof process === 'undefined') process = {};
+
+if (!process.nextTick) process.nextTick = (function () {
+ var queue = [];
+ var canPost = typeof window !== 'undefined'
+ && window.postMessage && window.addEventListener
+ ;
+
+ if (canPost) {
+ window.addEventListener('message', function (ev) {
+ if (ev.source === window && ev.data === 'browserify-tick') {
+ ev.stopPropagation();
+ if (queue.length > 0) {
+ var fn = queue.shift();
+ fn();
+ }
+ }
+ }, true);
+ }
+
+ return function (fn) {
+ if (canPost) {
+ queue.push(fn);
+ window.postMessage('browserify-tick', '*');
+ }
+ else setTimeout(fn, 0);
+ };
+})();
+
+if (!process.title) process.title = 'browser';
+
+if (!process.binding) process.binding = function (name) {
+ if (name === 'evals') return require('vm')
+ else throw new Error('No such module')
+};
+
+if (!process.cwd) process.cwd = function () { return '.' };
+
+require.define("path", function (require, module, exports, __dirname, __filename) {
+ function filter (xs, fn) {
+ var res = [];
+ for (var i = 0; i < xs.length; i++) {
+ if (fn(xs[i], i, xs)) res.push(xs[i]);
+ }
+ return res;
+}
+
+// resolves . and .. elements in a path array with directory names there
+// must be no slashes, empty elements, or device names (c:\) in the array
+// (so also no leading and trailing slashes - it does not distinguish
+// relative and absolute paths)
+function normalizeArray(parts, allowAboveRoot) {
+ // if the path tries to go above the root, `up` ends up > 0
+ var up = 0;
+ for (var i = parts.length; i >= 0; i--) {
+ var last = parts[i];
+ if (last == '.') {
+ parts.splice(i, 1);
+ } else if (last === '..') {
+ parts.splice(i, 1);
+ up++;
+ } else if (up) {
+ parts.splice(i, 1);
+ up--;
+ }
+ }
+
+ // if the path is allowed to go above the root, restore leading ..s
+ if (allowAboveRoot) {
+ for (; up--; up) {
+ parts.unshift('..');
+ }
+ }
+
+ return parts;
+}
+
+// Regex to split a filename into [*, dir, basename, ext]
+// posix version
+var splitPathRe = /^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;
+
+// path.resolve([from ...], to)
+// posix version
+exports.resolve = function() {
+var resolvedPath = '',
+ resolvedAbsolute = false;
+
+for (var i = arguments.length; i >= -1 && !resolvedAbsolute; i--) {
+ var path = (i >= 0)
+ ? arguments[i]
+ : process.cwd();
+
+ // Skip empty and invalid entries
+ if (typeof path !== 'string' || !path) {
+ continue;
+ }
+
+ resolvedPath = path + '/' + resolvedPath;
+ resolvedAbsolute = path.charAt(0) === '/';
+}
+
+// At this point the path should be resolved to a full absolute path, but
+// handle relative paths to be safe (might happen when process.cwd() fails)
+
+// Normalize the path
+resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
+ return !!p;
+ }), !resolvedAbsolute).join('/');
+
+ return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
+};
+
+// path.normalize(path)
+// posix version
+exports.normalize = function(path) {
+var isAbsolute = path.charAt(0) === '/',
+ trailingSlash = path.slice(-1) === '/';
+
+// Normalize the path
+path = normalizeArray(filter(path.split('/'), function(p) {
+ return !!p;
+ }), !isAbsolute).join('/');
+
+ if (!path && !isAbsolute) {
+ path = '.';
+ }
+ if (path && trailingSlash) {
+ path += '/';
+ }
+
+ return (isAbsolute ? '/' : '') + path;
+};
+
+
+// posix version
+exports.join = function() {
+ var paths = Array.prototype.slice.call(arguments, 0);
+ return exports.normalize(filter(paths, function(p, index) {
+ return p && typeof p === 'string';
+ }).join('/'));
+};
+
+
+exports.dirname = function(path) {
+ var dir = splitPathRe.exec(path)[1] || '';
+ var isWindows = false;
+ if (!dir) {
+ // No dirname
+ return '.';
+ } else if (dir.length === 1 ||
+ (isWindows && dir.length <= 3 && dir.charAt(1) === ':')) {
+ // It is just a slash or a drive letter with a slash
+ return dir;
+ } else {
+ // It is a full dirname, strip trailing slash
+ return dir.substring(0, dir.length - 1);
+ }
+};
+
+
+exports.basename = function(path, ext) {
+ var f = splitPathRe.exec(path)[2] || '';
+ // TODO: make this comparison case-insensitive on windows?
+ if (ext && f.substr(-1 * ext.length) === ext) {
+ f = f.substr(0, f.length - ext.length);
+ }
+ return f;
+};
+
+
+exports.extname = function(path) {
+ return splitPathRe.exec(path)[3] || '';
+};
+
+});
+
+require.define("/shred.js", function (require, module, exports, __dirname, __filename) {
+ // Shred is an HTTP client library intended to simplify the use of Node's
+// built-in HTTP library. In particular, we wanted to make it easier to interact
+// with HTTP-based APIs.
+//
+// See the [examples](./examples.html) for more details.
+
+// Ax is a nice logging library we wrote. You can use any logger, providing it
+// has `info`, `warn`, `debug`, and `error` methods that take a string.
+var Ax = require("ax")
+ , CookieJarLib = require( "cookiejar" )
+ , CookieJar = CookieJarLib.CookieJar
+;
+
+// Shred takes some options, including a logger and request defaults.
+
+var Shred = function(options) {
+ options = (options||{});
+ this.agent = options.agent;
+ this.defaults = options.defaults||{};
+ this.log = options.logger||(new Ax({ level: "info" }));
+ this._sharedCookieJar = new CookieJar();
+ this.logCurl = options.logCurl || false;
+};
+
+// Most of the real work is done in the request and reponse classes.
+
+Shred.Request = require("./shred/request");
+Shred.Response = require("./shred/response");
+
+// The `request` method kicks off a new request, instantiating a new `Request`
+// object and passing along whatever default options we were given.
+
+Shred.prototype = {
+ request: function(options) {
+ options.logger = this.log;
+ options.logCurl = options.logCurl || this.logCurl;
+ options.cookieJar = ( 'cookieJar' in options ) ? options.cookieJar : this._sharedCookieJar; // let them set cookieJar = null
+ options.agent = options.agent || this.agent;
+ // fill in default options
+ for (var key in this.defaults) {
+ if (this.defaults.hasOwnProperty(key) && !options[key]) {
+ options[key] = this.defaults[key]
+ }
+ }
+ return new Shred.Request(options);
+ }
+};
+
+// Define a bunch of convenience methods so that you don't have to include
+// a `method` property in your request options.
+
+"get put post delete".split(" ").forEach(function(method) {
+ Shred.prototype[method] = function(options) {
+ options.method = method;
+ return this.request(options);
+ };
+});
+
+
+module.exports = Shred;
+
+});
+
+require.define("/node_modules/ax/package.json", function (require, module, exports, __dirname, __filename) {
+ module.exports = {"main":"./lib/ax.js"}
+});
+
+require.define("/node_modules/ax/lib/ax.js", function (require, module, exports, __dirname, __filename) {
+ var inspect = require("util").inspect
+ , fs = require("fs")
+;
+
+
+// this is a quick-and-dirty logger. there are other nicer loggers out there
+// but the ones i found were also somewhat involved. this one has a Ruby
+// logger type interface
+//
+// we can easily replace this, provide the info, debug, etc. methods are the
+// same. or, we can change Haiku to use a more standard node.js interface
+
+var format = function(level,message) {
+ var debug = (level=="debug"||level=="error");
+ if (!message) { return message.toString(); }
+ if (typeof(message) == "object") {
+ if (message instanceof Error && debug) {
+ return message.stack;
+ } else {
+ return inspect(message);
+ }
+ } else {
+ return message.toString();
+ }
+};
+
+var noOp = function(message) { return this; }
+var makeLogger = function(level,fn) {
+ return function(message) {
+ this.stream.write(this.format(level, message)+"\n");
+ return this;
+ }
+};
+
+var Logger = function(options) {
+ var logger = this;
+ var options = options||{};
+
+ // Default options
+ options.level = options.level || "info";
+ options.timestamp = options.timestamp || true;
+ options.prefix = options.prefix || "";
+ logger.options = options;
+
+ // Allows a prefix to be added to the message.
+ //
+ // var logger = new Ax({ module: 'Haiku' })
+ // logger.warn('this is going to be awesome!');
+ // //=> Haiku: this is going to be awesome!
+ //
+ if (logger.options.module){
+ logger.options.prefix = logger.options.module;
+ }
+
+ // Write to stderr or a file
+ if (logger.options.file){
+ logger.stream = fs.createWriteStream(logger.options.file, {"flags": "a"});
+ } else {
+ if(process.title === "node")
+ logger.stream = process.stderr;
+ else if(process.title === "browser")
+ logger.stream = function () {
+ // Work around weird console context issue: http://code.google.com/p/chromium/issues/detail?id=48662
+ return console[logger.options.level].apply(console, arguments);
+ };
+ }
+
+ switch(logger.options.level){
+ case 'debug':
+ ['debug', 'info', 'warn'].forEach(function (level) {
+ logger[level] = Logger.writer(level);
+ });
+ case 'info':
+ ['info', 'warn'].forEach(function (level) {
+ logger[level] = Logger.writer(level);
+ });
+ case 'warn':
+ logger.warn = Logger.writer('warn');
+ }
+}
+
+// Used to define logger methods
+Logger.writer = function(level){
+ return function(message){
+ var logger = this;
+
+ if(process.title === "node")
+ logger.stream.write(logger.format(level, message) + '\n');
+ else if(process.title === "browser")
+ logger.stream(logger.format(level, message) + '\n');
+
+ };
+}
+
+
+Logger.prototype = {
+ info: function(){},
+ debug: function(){},
+ warn: function(){},
+ error: Logger.writer('error'),
+ format: function(level, message){
+ if (! message) return '';
+
+ var logger = this
+ , prefix = logger.options.prefix
+ , timestamp = logger.options.timestamp ? " " + (new Date().toISOString()) : ""
+ ;
+
+ return (prefix + timestamp + ": " + message);
+ }
+};
+
+module.exports = Logger;
+
+});
+
+require.define("util", function (require, module, exports, __dirname, __filename) {
+ // todo
+
+});
+
+require.define("fs", function (require, module, exports, __dirname, __filename) {
+ // nothing to see here... no file methods for the browser
+
+});
+
+require.define("/node_modules/cookiejar/package.json", function (require, module, exports, __dirname, __filename) {
+ module.exports = {"main":"cookiejar.js"}
+});
+
+require.define("/node_modules/cookiejar/cookiejar.js", function (require, module, exports, __dirname, __filename) {
+ exports.CookieAccessInfo=CookieAccessInfo=function CookieAccessInfo(domain,path,secure,script) {
+ if(this instanceof CookieAccessInfo) {
+ this.domain=domain||undefined;
+ this.path=path||"/";
+ this.secure=!!secure;
+ this.script=!!script;
+ return this;
+ }
+ else {
+ return new CookieAccessInfo(domain,path,secure,script)
+ }
+}
+
+exports.Cookie=Cookie=function Cookie(cookiestr) {
+ if(cookiestr instanceof Cookie) {
+ return cookiestr;
+ }
+ else {
+ if(this instanceof Cookie) {
+ this.name = null;
+ this.value = null;
+ this.expiration_date = Infinity;
+ this.path = "/";
+ this.domain = null;
+ this.secure = false; //how to define?
+ this.noscript = false; //httponly
+ if(cookiestr) {
+ this.parse(cookiestr)
+ }
+ return this;
+ }
+ return new Cookie(cookiestr)
+ }
+}
+
+Cookie.prototype.toString = function toString() {
+ var str=[this.name+"="+this.value];
+ if(this.expiration_date !== Infinity) {
+ str.push("expires="+(new Date(this.expiration_date)).toGMTString());
+ }
+ if(this.domain) {
+ str.push("domain="+this.domain);
+ }
+ if(this.path) {
+ str.push("path="+this.path);
+ }
+ if(this.secure) {
+ str.push("secure");
+ }
+ if(this.noscript) {
+ str.push("httponly");
+ }
+ return str.join("; ");
+}
+
+Cookie.prototype.toValueString = function toValueString() {
+ return this.name+"="+this.value;
+}
+
+var cookie_str_splitter=/[:](?=\s*[a-zA-Z0-9_\-]+\s*[=])/g
+Cookie.prototype.parse = function parse(str) {
+ if(this instanceof Cookie) {
+ var parts=str.split(";")
+ , pair=parts[0].match(/([^=]+)=((?:.|\n)*)/)
+ , key=pair[1]
+ , value=pair[2];
+ this.name = key;
+ this.value = value;
+
+ for(var i=1;i<parts.length;i++) {
+ pair=parts[i].match(/([^=]+)(?:=((?:.|\n)*))?/)
+ , key=pair[1].trim().toLowerCase()
+ , value=pair[2];
+ switch(key) {
+ case "httponly":
+ this.noscript = true;
+ break;
+ case "expires":
+ this.expiration_date = value
+ ? Number(Date.parse(value))
+ : Infinity;
+ break;
+ case "path":
+ this.path = value
+ ? value.trim()
+ : "";
+ break;
+ case "domain":
+ this.domain = value
+ ? value.trim()
+ : "";
+ break;
+ case "secure":
+ this.secure = true;
+ break
+ }
+ }
+
+ return this;
+ }
+ return new Cookie().parse(str)
+}
+
+Cookie.prototype.matches = function matches(access_info) {
+ if(this.noscript && access_info.script
+ || this.secure && !access_info.secure
+ || !this.collidesWith(access_info)) {
+ return false
+ }
+ return true;
+}
+
+Cookie.prototype.collidesWith = function collidesWith(access_info) {
+ if((this.path && !access_info.path) || (this.domain && !access_info.domain)) {
+ return false
+ }
+ if(this.path && access_info.path.indexOf(this.path) !== 0) {
+ return false;
+ }
+ if (this.domain===access_info.domain) {
+ return true;
+ }
+ else if(this.domain && this.domain.charAt(0)===".")
+ {
+ var wildcard=access_info.domain.indexOf(this.domain.slice(1))
+ if(wildcard===-1 || wildcard!==access_info.domain.length-this.domain.length+1) {
+ return false;
+ }
+ }
+ else if(this.domain){
+ return false
+ }
+ return true;
+}
+
+exports.CookieJar=CookieJar=function CookieJar() {
+ if(this instanceof CookieJar) {
+ var cookies = {} //name: [Cookie]
+
+ this.setCookie = function setCookie(cookie) {
+ cookie = Cookie(cookie);
+ //Delete the cookie if the set is past the current time
+ var remove = cookie.expiration_date <= Date.now();
+ if(cookie.name in cookies) {
+ var cookies_list = cookies[cookie.name];
+ for(var i=0;i<cookies_list.length;i++) {
+ var collidable_cookie = cookies_list[i];
+ if(collidable_cookie.collidesWith(cookie)) {
+ if(remove) {
+ cookies_list.splice(i,1);
+ if(cookies_list.length===0) {
+ delete cookies[cookie.name]
+ }
+ return false;
+ }
+ else {
+ return cookies_list[i]=cookie;
+ }
+ }
+ }
+ if(remove) {
+ return false;
+ }
+ cookies_list.push(cookie);
+ return cookie;
+ }
+ else if(remove){
+ return false;
+ }
+ else {
+ return cookies[cookie.name]=[cookie];
+ }
+ }
+ //returns a cookie
+ this.getCookie = function getCookie(cookie_name,access_info) {
+ var cookies_list = cookies[cookie_name];
+ for(var i=0;i<cookies_list.length;i++) {
+ var cookie = cookies_list[i];
+ if(cookie.expiration_date <= Date.now()) {
+ if(cookies_list.length===0) {
+ delete cookies[cookie.name]
+ }
+ continue;
+ }
+ if(cookie.matches(access_info)) {
+ return cookie;
+ }
+ }
+ }
+ //returns a list of cookies
+ this.getCookies = function getCookies(access_info) {
+ var matches=[];
+ for(var cookie_name in cookies) {
+ var cookie=this.getCookie(cookie_name,access_info);
+ if (cookie) {
+ matches.push(cookie);
+ }
+ }
+ matches.toString=function toString(){return matches.join(":");}
+ matches.toValueString=function() {return matches.map(function(c){return c.toValueString();}).join(';');}
+ return matches;
+ }
+
+ return this;
+ }
+ return new CookieJar()
+}
+
+
+//returns list of cookies that were set correctly
+CookieJar.prototype.setCookies = function setCookies(cookies) {
+ cookies=Array.isArray(cookies)
+ ?cookies
+ :cookies.split(cookie_str_splitter);
+ var successful=[]
+ for(var i=0;i<cookies.length;i++) {
+ var cookie = Cookie(cookies[i]);
+ if(this.setCookie(cookie)) {
+ successful.push(cookie);
+ }
+ }
+ return successful;
+}
+
+});
+
+require.define("/shred/request.js", function (require, module, exports, __dirname, __filename) {
+ // The request object encapsulates a request, creating a Node.js HTTP request and
+// then handling the response.
+
+var HTTP = require("http")
+ , HTTPS = require("https")
+ , parseUri = require("./parseUri")
+ , Emitter = require('events').EventEmitter
+ , sprintf = require("sprintf").sprintf
+ , Response = require("./response")
+ , HeaderMixins = require("./mixins/headers")
+ , Content = require("./content")
+;
+
+var STATUS_CODES = HTTP.STATUS_CODES || {
+ 100 : 'Continue',
+ 101 : 'Switching Protocols',
+ 102 : 'Processing', // RFC 2518, obsoleted by RFC 4918
+ 200 : 'OK',
+ 201 : 'Created',
+ 202 : 'Accepted',
+ 203 : 'Non-Authoritative Information',
+ 204 : 'No Content',
+ 205 : 'Reset Content',
+ 206 : 'Partial Content',
+ 207 : 'Multi-Status', // RFC 4918
+ 300 : 'Multiple Choices',
+ 301 : 'Moved Permanently',
+ 302 : 'Moved Temporarily',
+ 303 : 'See Other',
+ 304 : 'Not Modified',
+ 305 : 'Use Proxy',
+ 307 : 'Temporary Redirect',
+ 400 : 'Bad Request',
+ 401 : 'Unauthorized',
+ 402 : 'Payment Required',
+ 403 : 'Forbidden',
+ 404 : 'Not Found',
+ 405 : 'Method Not Allowed',
+ 406 : 'Not Acceptable',
+ 407 : 'Proxy Authentication Required',
+ 408 : 'Request Time-out',
+ 409 : 'Conflict',
+ 410 : 'Gone',
+ 411 : 'Length Required',
+ 412 : 'Precondition Failed',
+ 413 : 'Request Entity Too Large',
+ 414 : 'Request-URI Too Large',
+ 415 : 'Unsupported Media Type',
+ 416 : 'Requested Range Not Satisfiable',
+ 417 : 'Expectation Failed',
+ 418 : 'I\'m a teapot', // RFC 2324
+ 422 : 'Unprocessable Entity', // RFC 4918
+ 423 : 'Locked', // RFC 4918
+ 424 : 'Failed Dependency', // RFC 4918
+ 425 : 'Unordered Collection', // RFC 4918
+ 426 : 'Upgrade Required', // RFC 2817
+ 500 : 'Internal Server Error',
+ 501 : 'Not Implemented',
+ 502 : 'Bad Gateway',
+ 503 : 'Service Unavailable',
+ 504 : 'Gateway Time-out',
+ 505 : 'HTTP Version not supported',
+ 506 : 'Variant Also Negotiates', // RFC 2295
+ 507 : 'Insufficient Storage', // RFC 4918
+ 509 : 'Bandwidth Limit Exceeded',
+ 510 : 'Not Extended' // RFC 2774
+};
+
+// The Shred object itself constructs the `Request` object. You should rarely
+// need to do this directly.
+
+var Request = function(options) {
+ this.log = options.logger;
+ this.cookieJar = options.cookieJar;
+ this.encoding = options.encoding;
+ this.logCurl = options.logCurl;
+ processOptions(this,options||{});
+ createRequest(this);
+};
+
+// A `Request` has a number of properties, many of which help with details like
+// URL parsing or defaulting the port for the request.
+
+Object.defineProperties(Request.prototype, {
+
+// - **url**. You can set the `url` property with a valid URL string and all the
+// URL-related properties (host, port, etc.) will be automatically set on the
+// request object.
+
+ url: {
+ get: function() {
+ if (!this.scheme) { return null; }
+ return sprintf("%s://%s:%s%s",
+ this.scheme, this.host, this.port,
+ (this.proxy ? "/" : this.path) +
+ (this.query ? ("?" + this.query) : ""));
+ },
+ set: function(_url) {
+ _url = parseUri(_url);
+ this.scheme = _url.protocol;
+ this.host = _url.host;
+ this.port = _url.port;
+ this.path = _url.path;
+ this.query = _url.query;
+ return this;
+ },
+ enumerable: true
+ },
+
+// - **headers**. Returns a hash representing the request headers. You can't set
+// this directly, only get it. You can add or modify headers by using the
+// `setHeader` or `setHeaders` method. This ensures that the headers are
+// normalized - that is, you don't accidentally send `Content-Type` and
+// `content-type` headers. Keep in mind that if you modify the returned hash,
+// it will *not* modify the request headers.
+
+ headers: {
+ get: function() {
+ return this.getHeaders();
+ },
+ enumerable: true
+ },
+
+// - **port**. Unless you set the `port` explicitly or include it in the URL, it
+// will default based on the scheme.
+
+ port: {
+ get: function() {
+ if (!this._port) {
+ switch(this.scheme) {
+ case "https": return this._port = 443;
+ case "http":
+ default: return this._port = 80;
+ }
+ }
+ return this._port;
+ },
+ set: function(value) { this._port = value; return this; },
+ enumerable: true
+ },
+
+// - **method**. The request method - `get`, `put`, `post`, etc. that will be
+// used to make the request. Defaults to `get`.
+
+ method: {
+ get: function() {
+ return this._method = (this._method||"GET");
+ },
+ set: function(value) {
+ this._method = value; return this;
+ },
+ enumerable: true
+ },
+
+// - **query**. Can be set either with a query string or a hash (object). Get
+// will always return a properly escaped query string or null if there is no
+// query component for the request.
+
+ query: {
+ get: function() {return this._query;},
+ set: function(value) {
+ var stringify = function (hash) {
+ var query = "";
+ for (var key in hash) {
+ query += encodeURIComponent(key) + '=' + encodeURIComponent(hash[key]) + '&';
+ }
+ // Remove the last '&'
+ query = query.slice(0, -1);
+ return query;
+ }
+
+ if (value) {
+ if (typeof value === 'object') {
+ value = stringify(value);
+ }
+ this._query = value;
+ } else {
+ this._query = "";
+ }
+ return this;
+ },
+ enumerable: true
+ },
+
+// - **parameters**. This will return the query parameters in the form of a hash
+// (object).
+
+ parameters: {
+ get: function() { return QueryString.parse(this._query||""); },
+ enumerable: true
+ },
+
+// - **content**. (Aliased as `body`.) Set this to add a content entity to the
+// request. Attempts to use the `content-type` header to determine what to do
+// with the content value. Get this to get back a [`Content`
+// object](./content.html).
+
+ body: {
+ get: function() { return this._body; },
+ set: function(value) {
+ this._body = new Content({
+ data: value,
+ type: this.getHeader("Content-Type")
+ });
+ this.setHeader("Content-Type",this.content.type);
+ this.setHeader("Content-Length",this.content.length);
+ return this;
+ },
+ enumerable: true
+ },
+
+// - **timeout**. Used to determine how long to wait for a response. Does not
+// distinguish between connect timeouts versus request timeouts. Set either in
+// milliseconds or with an object with temporal attributes (hours, minutes,
+// seconds) and convert it into milliseconds. Get will always return
+// milliseconds.
+
+ timeout: {
+ get: function() { return this._timeout; }, // in milliseconds
+ set: function(timeout) {
+ var request = this
+ , milliseconds = 0;
+ ;
+ if (!timeout) return this;
+ if (typeof timeout==="number") { milliseconds = timeout; }
+ else {
+ milliseconds = (timeout.milliseconds||0) +
+ (1000 * ((timeout.seconds||0) +
+ (60 * ((timeout.minutes||0) +
+ (60 * (timeout.hours||0))))));
+ }
+ this._timeout = milliseconds;
+ return this;
+ },
+ enumerable: true
+ }
+});
+
+// Alias `body` property to `content`. Since the [content object](./content.html)
+// has a `body` attribute, it's preferable to use `content` since you can then
+// access the raw content data using `content.body`.
+
+Object.defineProperty(Request.prototype,"content",
+ Object.getOwnPropertyDescriptor(Request.prototype, "body"));
+
+// The `Request` object can be pretty overwhelming to view using the built-in
+// Node.js inspect method. We want to make it a bit more manageable. This
+// probably goes [too far in the other
+// direction](https://github.com/spire-io/shred/issues/2).
+
+Request.prototype.inspect = function () {
+ var request = this;
+ var headers = this.format_headers();
+ var summary = ["<Shred Request> ", request.method.toUpperCase(),
+ request.url].join(" ")
+ return [ summary, "- Headers:", headers].join("\n");
+};
+
+Request.prototype.format_headers = function () {
+ var array = []
+ var headers = this._headers
+ for (var key in headers) {
+ if (headers.hasOwnProperty(key)) {
+ var value = headers[key]
+ array.push("\t" + key + ": " + value);
+ }
+ }
+ return array.join("\n");
+};
+
+// Allow chainable 'on's: shred.get({ ... }).on( ... ). You can pass in a
+// single function, a pair (event, function), or a hash:
+// { event: function, event: function }
+Request.prototype.on = function (eventOrHash, listener) {
+ var emitter = this.emitter;
+ // Pass in a single argument as a function then make it the default response handler
+ if (arguments.length === 1 && typeof(eventOrHash) === 'function') {
+ emitter.on('response', eventOrHash);
+ } else if (arguments.length === 1 && typeof(eventOrHash) === 'object') {
+ for (var key in eventOrHash) {
+ if (eventOrHash.hasOwnProperty(key)) {
+ emitter.on(key, eventOrHash[key]);
+ }
+ }
+ } else {
+ emitter.on(eventOrHash, listener);
+ }
+ return this;
+};
+
+// Add in the header methods. Again, these ensure we don't get the same header
+// multiple times with different case conventions.
+HeaderMixins.gettersAndSetters(Request);
+
+// `processOptions` is called from the constructor to handle all the work
+// associated with making sure we do our best to ensure we have a valid request.
+
+var processOptions = function(request,options) {
+
+ request.log.debug("Processing request options ..");
+
+ // We'll use `request.emitter` to manage the `on` event handlers.
+ request.emitter = (new Emitter);
+
+ request.agent = options.agent;
+
+ // Set up the handlers ...
+ if (options.on) {
+ for (var key in options.on) {
+ if (options.on.hasOwnProperty(key)) {
+ request.emitter.on(key, options.on[key]);
+ }
+ }
+ }
+
+ // Make sure we were give a URL or a host
+ if (!options.url && !options.host) {
+ request.emitter.emit("request_error",
+ new Error("No url or url options (host, port, etc.)"));
+ return;
+ }
+
+ // Allow for the [use of a proxy](http://www.jmarshall.com/easy/http/#proxies).
+
+ if (options.url) {
+ if (options.proxy) {
+ request.url = options.proxy;
+ request.path = options.url;
+ } else {
+ request.url = options.url;
+ }
+ }
+
+ // Set the remaining options.
+ request.query = options.query||options.parameters||request.query ;
+ request.method = options.method;
+ request.setHeader("user-agent",options.agent||"Shred");
+ request.setHeaders(options.headers);
+
+ if (request.cookieJar) {
+ var cookies = request.cookieJar.getCookies( CookieAccessInfo( request.host, request.path ) );
+ if (cookies.length) {
+ var cookieString = request.getHeader('cookie')||'';
+ for (var cookieIndex = 0; cookieIndex < cookies.length; ++cookieIndex) {
+ if ( cookieString.length && cookieString[ cookieString.length - 1 ] != ';' )
+ {
+ cookieString += ';';
+ }
+ cookieString += cookies[ cookieIndex ].name + '=' + cookies[ cookieIndex ].value + ';';
+ }
+ request.setHeader("cookie", cookieString);
+ }
+ }
+
+ // The content entity can be set either using the `body` or `content` attributes.
+ if (options.body||options.content) {
+ request.content = options.body||options.content;
+ }
+ request.timeout = options.timeout;
+
+};
+
+// `createRequest` is also called by the constructor, after `processOptions`.
+// This actually makes the request and processes the response, so `createRequest`
+// is a bit of a misnomer.
+
+var createRequest = function(request) {
+ var timeout ;
+
+ request.log.debug("Creating request ..");
+ request.log.debug(request);
+
+ var reqParams = {
+ host: request.host,
+ port: request.port,
+ method: request.method,
+ path: request.path + (request.query ? '?'+request.query : ""),
+ headers: request.getHeaders(),
+ // Node's HTTP/S modules will ignore this, but we are using the
+ // browserify-http module in the browser for both HTTP and HTTPS, and this
+ // is how you differentiate the two.
+ scheme: request.scheme,
+ // Use a provided agent. 'Undefined' is the default, which uses a global
+ // agent.
+ agent: request.agent
+ };
+
+ if (request.logCurl) {
+ logCurl(request);
+ }
+
+ var http = request.scheme == "http" ? HTTP : HTTPS;
+
+ // Set up the real request using the selected library. The request won't be
+ // sent until we call `.end()`.
+ request._raw = http.request(reqParams, function(response) {
+ request.log.debug("Received response ..");
+
+ // We haven't timed out and we have a response, so make sure we clear the
+ // timeout so it doesn't fire while we're processing the response.
+ clearTimeout(timeout);
+
+ // Construct a Shred `Response` object from the response. This will stream
+ // the response, thus the need for the callback. We can access the response
+ // entity safely once we're in the callback.
+ response = new Response(response, request, function(response) {
+
+ // Set up some event magic. The precedence is given first to
+ // status-specific handlers, then to responses for a given event, and then
+ // finally to the more general `response` handler. In the last case, we
+ // need to first make sure we're not dealing with a a redirect.
+ var emit = function(event) {
+ var emitter = request.emitter;
+ var textStatus = STATUS_CODES[response.status] ? STATUS_CODES[response.status].toLowerCase() : null;
+ if (emitter.listeners(response.status).length > 0 || emitter.listeners(textStatus).length > 0) {
+ emitter.emit(response.status, response);
+ emitter.emit(textStatus, response);
+ } else {
+ if (emitter.listeners(event).length>0) {
+ emitter.emit(event, response);
+ } else if (!response.isRedirect) {
+ emitter.emit("response", response);
+ //console.warn("Request has no event listener for status code " + response.status);
+ }
+ }
+ };
+
+ // Next, check for a redirect. We simply repeat the request with the URL
+ // given in the `Location` header. We fire a `redirect` event.
+ if (response.isRedirect) {
+ request.log.debug("Redirecting to "
+ + response.getHeader("Location"));
+ request.url = response.getHeader("Location");
+ emit("redirect");
+ createRequest(request);
+
+ // Okay, it's not a redirect. Is it an error of some kind?
+ } else if (response.isError) {
+ emit("error");
+ } else {
+ // It looks like we're good shape. Trigger the `success` event.
+ emit("success");
+ }
+ });
+ });
+
+ // We're still setting up the request. Next, we're going to handle error cases
+ // where we have no response. We don't emit an error event because that event
+ // takes a response. We don't response handlers to have to check for a null
+ // value. However, we [should introduce a different event
+ // type](https://github.com/spire-io/shred/issues/3) for this type of error.
+ request._raw.on("error", function(error) {
+ request.emitter.emit("request_error", error);
+ });
+
+ request._raw.on("socket", function(socket) {
+ request.emitter.emit("socket", socket);
+ });
+
+ // TCP timeouts should also trigger the "response_error" event.
+ request._raw.on('socket', function () {
+ request._raw.socket.on('timeout', function () {
+ // This should trigger the "error" event on the raw request, which will
+ // trigger the "response_error" on the shred request.
+ request._raw.abort();
+ });
+ });
+
+
+ // We're almost there. Next, we need to write the request entity to the
+ // underlying request object.
+ if (request.content) {
+ request.log.debug("Streaming body: '" +
+ request.content.data.slice(0,59) + "' ... ");
+ request._raw.write(request.content.data);
+ }
+
+ // Finally, we need to set up the timeout. We do this last so that we don't
+ // start the clock ticking until the last possible moment.
+ if (request.timeout) {
+ timeout = setTimeout(function() {
+ request.log.debug("Timeout fired, aborting request ...");
+ request._raw.abort();
+ request.emitter.emit("timeout", request);
+ },request.timeout);
+ }
+
+ // The `.end()` method will cause the request to fire. Technically, it might
+ // have already sent the headers and body.
+ request.log.debug("Sending request ...");
+ request._raw.end();
+};
+
+// Logs the curl command for the request.
+var logCurl = function (req) {
+ var headers = req.getHeaders();
+ var headerString = "";
+
+ for (var key in headers) {
+ headerString += '-H "' + key + ": " + headers[key] + '" ';
+ }
+
+ var bodyString = ""
+
+ if (req.content) {
+ bodyString += "-d '" + req.content.body + "' ";
+ }
+
+ var query = req.query ? '?' + req.query : "";
+
+ console.log("curl " +
+ "-X " + req.method.toUpperCase() + " " +
+ req.scheme + "://" + req.host + ":" + req.port + req.path + query + " " +
+ headerString +
+ bodyString
+ );
+};
+
+
+module.exports = Request;
+
+});
+
+require.define("http", function (require, module, exports, __dirname, __filename) {
+ // todo
+
+});
+
+require.define("https", function (require, module, exports, __dirname, __filename) {
+ // todo
+
+});
+
+require.define("/shred/parseUri.js", function (require, module, exports, __dirname, __filename) {
+ // parseUri 1.2.2
+// (c) Steven Levithan <stevenlevithan.com>
+// MIT License
+
+function parseUri (str) {
+ var o = parseUri.options,
+ m = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
+ uri = {},
+ i = 14;
+
+ while (i--) uri[o.key[i]] = m[i] || "";
+
+ uri[o.q.name] = {};
+ uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
+ if ($1) uri[o.q.name][$1] = $2;
+ });
+
+ return uri;
+};
+
+parseUri.options = {
+ strictMode: false,
+ key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
+ q: {
+ name: "queryKey",
+ parser: /(?:^|&)([^&=]*)=?([^&]*)/g
+ },
+ parser: {
+ strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
+ loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
+ }
+};
+
+module.exports = parseUri;
+
+});
+
+require.define("events", function (require, module, exports, __dirname, __filename) {
+ if (!process.EventEmitter) process.EventEmitter = function () {};
+
+var EventEmitter = exports.EventEmitter = process.EventEmitter;
+var isArray = typeof Array.isArray === 'function'
+ ? Array.isArray
+ : function (xs) {
+ return Object.toString.call(xs) === '[object Array]'
+ }
+;
+
+// By default EventEmitters will print a warning if more than
+// 10 listeners are added to it. This is a useful default which
+// helps finding memory leaks.
+//
+// Obviously not all Emitters should be limited to 10. This function allows
+// that to be increased. Set to zero for unlimited.
+var defaultMaxListeners = 10;
+EventEmitter.prototype.setMaxListeners = function(n) {
+ if (!this._events) this._events = {};
+ this._events.maxListeners = n;
+};
+
+
+EventEmitter.prototype.emit = function(type) {
+ // If there is no 'error' event listener then throw.
+ if (type === 'error') {
+ if (!this._events || !this._events.error ||
+ (isArray(this._events.error) && !this._events.error.length))
+ {
+ if (arguments[1] instanceof Error) {
+ throw arguments[1]; // Unhandled 'error' event
+ } else {
+ throw new Error("Uncaught, unspecified 'error' event.");
+ }
+ return false;
+ }
+ }
+
+ if (!this._events) return false;
+ var handler = this._events[type];
+ if (!handler) return false;
+
+ if (typeof handler == 'function') {
+ switch (arguments.length) {
+ // fast cases
+ case 1:
+ handler.call(this);
+ break;
+ case 2:
+ handler.call(this, arguments[1]);
+ break;
+ case 3:
+ handler.call(this, arguments[1], arguments[2]);
+ break;
+ // slower
+ default:
+ var args = Array.prototype.slice.call(arguments, 1);
+ handler.apply(this, args);
+ }
+ return true;
+
+ } else if (isArray(handler)) {
+ var args = Array.prototype.slice.call(arguments, 1);
+
+ var listeners = handler.slice();
+ for (var i = 0, l = listeners.length; i < l; i++) {
+ listeners[i].apply(this, args);
+ }
+ return true;
+
+ } else {
+ return false;
+ }
+};
+
+// EventEmitter is defined in src/node_events.cc
+// EventEmitter.prototype.emit() is also defined there.
+EventEmitter.prototype.addListener = function(type, listener) {
+ if ('function' !== typeof listener) {
+ throw new Error('addListener only takes instances of Function');
+ }
+
+ if (!this._events) this._events = {};
+
+ // To avoid recursion in the case that type == "newListeners"! Before
+ // adding it to the listeners, first emit "newListeners".
+ this.emit('newListener', type, listener);
+
+ if (!this._events[type]) {
+ // Optimize the case of one listener. Don't need the extra array object.
+ this._events[type] = listener;
+ } else if (isArray(this._events[type])) {
+
+ // Check for listener leak
+ if (!this._events[type].warned) {
+ var m;
+ if (this._events.maxListeners !== undefined) {
+ m = this._events.maxListeners;
+ } else {
+ m = defaultMaxListeners;
+ }
+
+ if (m && m > 0 && this._events[type].length > m) {
+ this._events[type].warned = true;
+ console.error('(node) warning: possible EventEmitter memory ' +
+ 'leak detected. %d listeners added. ' +
+ 'Use emitter.setMaxListeners() to increase limit.',
+ this._events[type].length);
+ console.trace();
+ }
+ }
+
+ // If we've already got an array, just append.
+ this._events[type].push(listener);
+ } else {
+ // Adding the second element, need to change to array.
+ this._events[type] = [this._events[type], listener];
+ }
+
+ return this;
+};
+
+EventEmitter.prototype.on = EventEmitter.prototype.addListener;
+
+EventEmitter.prototype.once = function(type, listener) {
+ var self = this;
+ self.on(type, function g() {
+ self.removeListener(type, g);
+ listener.apply(this, arguments);
+ });
+
+ return this;
+};
+
+EventEmitter.prototype.removeListener = function(type, listener) {
+ if ('function' !== typeof listener) {
+ throw new Error('removeListener only takes instances of Function');
+ }
+
+ // does not use listeners(), so no side effect of creating _events[type]
+ if (!this._events || !this._events[type]) return this;
+
+ var list = this._events[type];
+
+ if (isArray(list)) {
+ var i = list.indexOf(listener);
+ if (i < 0) return this;
+ list.splice(i, 1);
+ if (list.length == 0)
+ delete this._events[type];
+ } else if (this._events[type] === listener) {
+ delete this._events[type];
+ }
+
+ return this;
+};
+
+EventEmitter.prototype.removeAllListeners = function(type) {
+ // does not use listeners(), so no side effect of creating _events[type]
+ if (type && this._events && this._events[type]) this._events[type] = null;
+ return this;
+};
+
+EventEmitter.prototype.listeners = function(type) {
+ if (!this._events) this._events = {};
+ if (!this._events[type]) this._events[type] = [];
+ if (!isArray(this._events[type])) {
+ this._events[type] = [this._events[type]];
+ }
+ return this._events[type];
+};
+
+});
+
+require.define("/node_modules/sprintf/package.json", function (require, module, exports, __dirname, __filename) {
+ module.exports = {"main":"./lib/sprintf"}
+});
+
+require.define("/node_modules/sprintf/lib/sprintf.js", function (require, module, exports, __dirname, __filename) {
+ /**
+sprintf() for JavaScript 0.7-beta1
+http://www.diveintojavascript.com/projects/javascript-sprintf
+
+Copyright (c) Alexandru Marasteanu <alexaholic [at) gmail (dot] com>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of sprintf() for JavaScript nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL Alexandru Marasteanu BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+Changelog:
+2010.11.07 - 0.7-beta1-node
+ - converted it to a node.js compatible module
+
+2010.09.06 - 0.7-beta1
+ - features: vsprintf, support for named placeholders
+ - enhancements: format cache, reduced global namespace pollution
+
+2010.05.22 - 0.6:
+ - reverted to 0.4 and fixed the bug regarding the sign of the number 0
+ Note:
+ Thanks to Raphael Pigulla <raph (at] n3rd [dot) org> (http://www.n3rd.org/)
+ who warned me about a bug in 0.5, I discovered that the last update was
+ a regress. I appologize for that.
+
+2010.05.09 - 0.5:
+ - bug fix: 0 is now preceeded with a + sign
+ - bug fix: the sign was not at the right position on padded results (Kamal Abdali)
+ - switched from GPL to BSD license
+
+2007.10.21 - 0.4:
+ - unit test and patch (David Baird)
+
+2007.09.17 - 0.3:
+ - bug fix: no longer throws exception on empty paramenters (Hans Pufal)
+
+2007.09.11 - 0.2:
+ - feature: added argument swapping
+
+2007.04.03 - 0.1:
+ - initial release
+**/
+
+var sprintf = (function() {
+ function get_type(variable) {
+ return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase();
+ }
+ function str_repeat(input, multiplier) {
+ for (var output = []; multiplier > 0; output[--multiplier] = input) {/* do nothing */}
+ return output.join('');
+ }
+
+ var str_format = function() {
+ if (!str_format.cache.hasOwnProperty(arguments[0])) {
+ str_format.cache[arguments[0]] = str_format.parse(arguments[0]);
+ }
+ return str_format.format.call(null, str_format.cache[arguments[0]], arguments);
+ };
+
+ str_format.format = function(parse_tree, argv) {
+ var cursor = 1, tree_length = parse_tree.length, node_type = '', arg, output = [], i, k, match, pad, pad_character, pad_length;
+ for (i = 0; i < tree_length; i++) {
+ node_type = get_type(parse_tree[i]);
+ if (node_type === 'string') {
+ output.push(parse_tree[i]);
+ }
+ else if (node_type === 'array') {
+ match = parse_tree[i]; // convenience purposes only
+ if (match[2]) { // keyword argument
+ arg = argv[cursor];
+ for (k = 0; k < match[2].length; k++) {
+ if (!arg.hasOwnProperty(match[2][k])) {
+ throw(sprintf('[sprintf] property "%s" does not exist', match[2][k]));
+ }
+ arg = arg[match[2][k]];
+ }
+ }
+ else if (match[1]) { // positional argument (explicit)
+ arg = argv[match[1]];
+ }
+ else { // positional argument (implicit)
+ arg = argv[cursor++];
+ }
+
+ if (/[^s]/.test(match[8]) && (get_type(arg) != 'number')) {
+ throw(sprintf('[sprintf] expecting number but found %s', get_type(arg)));
+ }
+ switch (match[8]) {
+ case 'b': arg = arg.toString(2); break;
+ case 'c': arg = String.fromCharCode(arg); break;
+ case 'd': arg = parseInt(arg, 10); break;
+ case 'e': arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential(); break;
+ case 'f': arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg); break;
+ case 'o': arg = arg.toString(8); break;
+ case 's': arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg); break;
+ case 'u': arg = Math.abs(arg); break;
+ case 'x': arg = arg.toString(16); break;
+ case 'X': arg = arg.toString(16).toUpperCase(); break;
+ }
+ arg = (/[def]/.test(match[8]) && match[3] && arg >= 0 ? '+'+ arg : arg);
+ pad_character = match[4] ? match[4] == '0' ? '0' : match[4].charAt(1) : ' ';
+ pad_length = match[6] - String(arg).length;
+ pad = match[6] ? str_repeat(pad_character, pad_length) : '';
+ output.push(match[5] ? arg + pad : pad + arg);
+ }
+ }
+ return output.join('');
+ };
+
+ str_format.cache = {};
+
+ str_format.parse = function(fmt) {
+ var _fmt = fmt, match = [], parse_tree = [], arg_names = 0;
+ while (_fmt) {
+ if ((match = /^[^\x25]+/.exec(_fmt)) !== null) {
+ parse_tree.push(match[0]);
+ }
+ else if ((match = /^\x25{2}/.exec(_fmt)) !== null) {
+ parse_tree.push('%');
+ }
+ else if ((match = /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(_fmt)) !== null) {
+ if (match[2]) {
+ arg_names |= 1;
+ var field_list = [], replacement_field = match[2], field_match = [];
+ if ((field_match = /^([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
+ field_list.push(field_match[1]);
+ while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') {
+ if ((field_match = /^\.([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
+ field_list.push(field_match[1]);
+ }
+ else if ((field_match = /^\[(\d+)\]/.exec(replacement_field)) !== null) {
+ field_list.push(field_match[1]);
+ }
+ else {
+ throw('[sprintf] huh?');
+ }
+ }
+ }
+ else {
+ throw('[sprintf] huh?');
+ }
+ match[2] = field_list;
+ }
+ else {
+ arg_names |= 2;
+ }
+ if (arg_names === 3) {
+ throw('[sprintf] mixing positional and named placeholders is not (yet) supported');
+ }
+ parse_tree.push(match);
+ }
+ else {
+ throw('[sprintf] huh?');
+ }
+ _fmt = _fmt.substring(match[0].length);
+ }
+ return parse_tree;
+ };
+
+ return str_format;
+})();
+
+var vsprintf = function(fmt, argv) {
+ argv.unshift(fmt);
+ return sprintf.apply(null, argv);
+};
+
+exports.sprintf = sprintf;
+exports.vsprintf = vsprintf;
+});
+
+require.define("/shred/response.js", function (require, module, exports, __dirname, __filename) {
+ // The `Response object` encapsulates a Node.js HTTP response.
+
+var Content = require("./content")
+ , HeaderMixins = require("./mixins/headers")
+ , CookieJarLib = require( "cookiejar" )
+ , Cookie = CookieJarLib.Cookie
+;
+
+// Browser doesn't have zlib.
+var zlib = null;
+try {
+ zlib = require('zlib');
+} catch (e) {
+ console.warn("no zlib library");
+}
+
+// Iconv doesn't work in browser
+var Iconv = null;
+try {
+ Iconv = require('iconv-lite');
+} catch (e) {
+ console.warn("no iconv library");
+}
+
+// Construct a `Response` object. You should never have to do this directly. The
+// `Request` object handles this, getting the raw response object and passing it
+// in here, along with the request. The callback allows us to stream the response
+// and then use the callback to let the request know when it's ready.
+var Response = function(raw, request, callback) {
+ var response = this;
+ this._raw = raw;
+
+ // The `._setHeaders` method is "private"; you can't otherwise set headers on
+ // the response.
+ this._setHeaders.call(this,raw.headers);
+
+ // store any cookies
+ if (request.cookieJar && this.getHeader('set-cookie')) {
+ var cookieStrings = this.getHeader('set-cookie');
+ var cookieObjs = []
+ , cookie;
+
+ for (var i = 0; i < cookieStrings.length; i++) {
+ var cookieString = cookieStrings[i];
+ if (!cookieString) {
+ continue;
+ }
+
+ if (!cookieString.match(/domain\=/i)) {
+ cookieString += '; domain=' + request.host;
+ }
+
+ if (!cookieString.match(/path\=/i)) {
+ cookieString += '; path=' + request.path;
+ }
+
+ try {
+ cookie = new Cookie(cookieString);
+ if (cookie) {
+ cookieObjs.push(cookie);
+ }
+ } catch (e) {
+ console.warn("Tried to set bad cookie: " + cookieString);
+ }
+ }
+
+ request.cookieJar.setCookies(cookieObjs);
+ }
+
+ this.request = request;
+ this.client = request.client;
+ this.log = this.request.log;
+
+ // Stream the response content entity and fire the callback when we're done.
+ // Store the incoming data in a array of Buffers which we concatinate into one
+ // buffer at the end. We need to use buffers instead of strings here in order
+ // to preserve binary data.
+ var chunkBuffers = [];
+ var dataLength = 0;
+ raw.on("data", function(chunk) {
+ chunkBuffers.push(chunk);
+ dataLength += chunk.length;
+ });
+ raw.on("end", function() {
+ var body;
+ if (typeof Buffer === 'undefined') {
+ // Just concatinate into a string
+ body = chunkBuffers.join('');
+ } else {
+ // Initialize new buffer and add the chunks one-at-a-time.
+ body = new Buffer(dataLength);
+ for (var i = 0, pos = 0; i < chunkBuffers.length; i++) {
+ chunkBuffers[i].copy(body, pos);
+ pos += chunkBuffers[i].length;
+ }
+ }
+
+ var setBodyAndFinish = function (body) {
+ response._body = new Content({
+ body: body,
+ type: response.getHeader("Content-Type")
+ });
+ callback(response);
+ }
+
+ if (zlib && response.getHeader("Content-Encoding") === 'gzip'){
+ zlib.gunzip(body, function (err, gunzippedBody) {
+ if (Iconv && response.request.encoding){
+ body = Iconv.fromEncoding(gunzippedBody,response.request.encoding);
+ } else {
+ body = gunzippedBody.toString();
+ }
+ setBodyAndFinish(body);
+ })
+ }
+ else{
+ if (response.request.encoding){
+ body = Iconv.fromEncoding(body,response.request.encoding);
+ }
+ setBodyAndFinish(body);
+ }
+ });
+};
+
+// The `Response` object can be pretty overwhelming to view using the built-in
+// Node.js inspect method. We want to make it a bit more manageable. This
+// probably goes [too far in the other
+// direction](https://github.com/spire-io/shred/issues/2).
+
+Response.prototype = {
+ inspect: function() {
+ var response = this;
+ var headers = this.format_headers();
+ var summary = ["<Shred Response> ", response.status].join(" ")
+ return [ summary, "- Headers:", headers].join("\n");
+ },
+ format_headers: function () {
+ var array = []
+ var headers = this._headers
+ for (var key in headers) {
+ if (headers.hasOwnProperty(key)) {
+ var value = headers[key]
+ array.push("\t" + key + ": " + value);
+ }
+ }
+ return array.join("\n");
+ }
+};
+
+// `Response` object properties, all of which are read-only:
+Object.defineProperties(Response.prototype, {
+
+// - **status**. The HTTP status code for the response.
+ status: {
+ get: function() { return this._raw.statusCode; },
+ enumerable: true
+ },
+
+// - **content**. The HTTP content entity, if any. Provided as a [content
+// object](./content.html), which will attempt to convert the entity based upon
+// the `content-type` header. The converted value is available as
+// `content.data`. The original raw content entity is available as
+// `content.body`.
+ body: {
+ get: function() { return this._body; }
+ },
+ content: {
+ get: function() { return this.body; },
+ enumerable: true
+ },
+
+// - **isRedirect**. Is the response a redirect? These are responses with 3xx
+// status and a `Location` header.
+ isRedirect: {
+ get: function() {
+ return (this.status>299
+ &&this.status<400
+ &&this.getHeader("Location"));
+ },
+ enumerable: true
+ },
+
+// - **isError**. Is the response an error? These are responses with status of
+// 400 or greater.
+ isError: {
+ get: function() {
+ return (this.status === 0 || this.status > 399)
+ },
+ enumerable: true
+ }
+});
+
+// Add in the [getters for accessing the normalized headers](./headers.js).
+HeaderMixins.getters(Response);
+HeaderMixins.privateSetters(Response);
+
+// Work around Mozilla bug #608735 [https://bugzil.la/608735], which causes
+// getAllResponseHeaders() to return {} if the response is a CORS request.
+// xhr.getHeader still works correctly.
+var getHeader = Response.prototype.getHeader;
+Response.prototype.getHeader = function (name) {
+ return (getHeader.call(this,name) ||
+ (typeof this._raw.getHeader === 'function' && this._raw.getHeader(name)));
+};
+
+module.exports = Response;
+
+});
+
+require.define("/shred/content.js", function (require, module, exports, __dirname, __filename) {
+
+// The purpose of the `Content` object is to abstract away the data conversions
+// to and from raw content entities as strings. For example, you want to be able
+// to pass in a Javascript object and have it be automatically converted into a
+// JSON string if the `content-type` is set to a JSON-based media type.
+// Conversely, you want to be able to transparently get back a Javascript object
+// in the response if the `content-type` is a JSON-based media-type.
+
+// One limitation of the current implementation is that it [assumes the `charset` is UTF-8](https://github.com/spire-io/shred/issues/5).
+
+// The `Content` constructor takes an options object, which *must* have either a
+// `body` or `data` property and *may* have a `type` property indicating the
+// media type. If there is no `type` attribute, a default will be inferred.
+var Content = function(options) {
+ this.body = options.body;
+ this.data = options.data;
+ this.type = options.type;
+};
+
+Content.prototype = {
+ // Treat `toString()` as asking for the `content.body`. That is, the raw content entity.
+ //
+ // toString: function() { return this.body; }
+ //
+ // Commented out, but I've forgotten why. :/
+};
+
+
+// `Content` objects have the following attributes:
+Object.defineProperties(Content.prototype,{
+
+// - **type**. Typically accessed as `content.type`, reflects the `content-type`
+// header associated with the request or response. If not passed as an options
+// to the constructor or set explicitly, it will infer the type the `data`
+// attribute, if possible, and, failing that, will default to `text/plain`.
+ type: {
+ get: function() {
+ if (this._type) {
+ return this._type;
+ } else {
+ if (this._data) {
+ switch(typeof this._data) {
+ case "string": return "text/plain";
+ case "object": return "application/json";
+ }
+ }
+ }
+ return "text/plain";
+ },
+ set: function(value) {
+ this._type = value;
+ return this;
+ },
+ enumerable: true
+ },
+
+// - **data**. Typically accessed as `content.data`, reflects the content entity
+// converted into Javascript data. This can be a string, if the `type` is, say,
+// `text/plain`, but can also be a Javascript object. The conversion applied is
+// based on the `processor` attribute. The `data` attribute can also be set
+// directly, in which case the conversion will be done the other way, to infer
+// the `body` attribute.
+ data: {
+ get: function() {
+ if (this._body) {
+ return this.processor.parser(this._body);
+ } else {
+ return this._data;
+ }
+ },
+ set: function(data) {
+ if (this._body&&data) Errors.setDataWithBody(this);
+ this._data = data;
+ return this;
+ },
+ enumerable: true
+ },
+
+// - **body**. Typically accessed as `content.body`, reflects the content entity
+// as a UTF-8 string. It is the mirror of the `data` attribute. If you set the
+// `data` attribute, the `body` attribute will be inferred and vice-versa. If
+// you attempt to set both, an exception is raised.
+ body: {
+ get: function() {
+ if (this._data) {
+ return this.processor.stringify(this._data);
+ } else {
+ return this.processor.stringify(this._body);
+ }
+ },
+ set: function(body) {
+ if (this._data&&body) Errors.setBodyWithData(this);
+ this._body = body;
+ return this;
+ },
+ enumerable: true
+ },
+
+// - **processor**. The functions that will be used to convert to/from `data` and
+// `body` attributes. You can add processors. The two that are built-in are for
+// `text/plain`, which is basically an identity transformation and
+// `application/json` and other JSON-based media types (including custom media
+// types with `+json`). You can add your own processors. See below.
+ processor: {
+ get: function() {
+ var processor = Content.processors[this.type];
+ if (processor) {
+ return processor;
+ } else {
+ // Return the first processor that matches any part of the
+ // content type. ex: application/vnd.foobar.baz+json will match json.
+ var main = this.type.split(";")[0];
+ var parts = main.split(/\+|\//);
+ for (var i=0, l=parts.length; i < l; i++) {
+ processor = Content.processors[parts[i]]
+ }
+ return processor || {parser:identity,stringify:toString};
+ }
+ },
+ enumerable: true
+ },
+
+// - **length**. Typically accessed as `content.length`, returns the length in
+// bytes of the raw content entity.
+ length: {
+ get: function() {
+ if (typeof Buffer !== 'undefined') {
+ return Buffer.byteLength(this.body);
+ }
+ return this.body.length;
+ }
+ }
+});
+
+Content.processors = {};
+
+// The `registerProcessor` function allows you to add your own processors to
+// convert content entities. Each processor consists of a Javascript object with
+// two properties:
+// - **parser**. The function used to parse a raw content entity and convert it
+// into a Javascript data type.
+// - **stringify**. The function used to convert a Javascript data type into a
+// raw content entity.
+Content.registerProcessor = function(types,processor) {
+
+// You can pass an array of types that will trigger this processor, or just one.
+// We determine the array via duck-typing here.
+ if (types.forEach) {
+ types.forEach(function(type) {
+ Content.processors[type] = processor;
+ });
+ } else {
+ // If you didn't pass an array, we just use what you pass in.
+ Content.processors[types] = processor;
+ }
+};
+
+// Register the identity processor, which is used for text-based media types.
+var identity = function(x) { return x; }
+ , toString = function(x) { return x.toString(); }
+Content.registerProcessor(
+ ["text/html","text/plain","text"],
+ { parser: identity, stringify: toString });
+
+// Register the JSON processor, which is used for JSON-based media types.
+Content.registerProcessor(
+ ["application/json; charset=utf-8","application/json","json"],
+ {
+ parser: function(string) {
+ return JSON.parse(string);
+ },
+ stringify: function(data) {
+ return JSON.stringify(data); }});
+
+// Error functions are defined separately here in an attempt to make the code
+// easier to read.
+var Errors = {
+ setDataWithBody: function(object) {
+ throw new Error("Attempt to set data attribute of a content object " +
+ "when the body attributes was already set.");
+ },
+ setBodyWithData: function(object) {
+ throw new Error("Attempt to set body attribute of a content object " +
+ "when the data attributes was already set.");
+ }
+}
+module.exports = Content;
+
+});
+
+require.define("/shred/mixins/headers.js", function (require, module, exports, __dirname, __filename) {
+ // The header mixins allow you to add HTTP header support to any object. This
+// might seem pointless: why not simply use a hash? The main reason is that, per
+// the [HTTP spec](http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2),
+// headers are case-insensitive. So, for example, `content-type` is the same as
+// `CONTENT-TYPE` which is the same as `Content-Type`. Since there is no way to
+// overload the index operator in Javascript, using a hash to represent the
+// headers means it's possible to have two conflicting values for a single
+// header.
+//
+// The solution to this is to provide explicit methods to set or get headers.
+// This also has the benefit of allowing us to introduce additional variations,
+// including snake case, which we automatically convert to what Matthew King has
+// dubbed "corset case" - the hyphen-separated names with initial caps:
+// `Content-Type`. We use corset-case just in case we're dealing with servers
+// that haven't properly implemented the spec.
+
+// Convert headers to corset-case. **Example:** `CONTENT-TYPE` will be converted
+// to `Content-Type`.
+
+var corsetCase = function(string) {
+ return string.toLowerCase()
+ //.replace("_","-")
+ .replace(/(^|-)(\w)/g,
+ function(s) { return s.toUpperCase(); });
+};
+
+// We suspect that `initializeHeaders` was once more complicated ...
+var initializeHeaders = function(object) {
+ return {};
+};
+
+// Access the `_headers` property using lazy initialization. **Warning:** If you
+// mix this into an object that is using the `_headers` property already, you're
+// going to have trouble.
+var $H = function(object) {
+ return object._headers||(object._headers=initializeHeaders(object));
+};
+
+// Hide the implementations as private functions, separate from how we expose them.
+
+// The "real" `getHeader` function: get the header after normalizing the name.
+var getHeader = function(object,name) {
+ return $H(object)[corsetCase(name)];
+};
+
+// The "real" `getHeader` function: get one or more headers, or all of them
+// if you don't ask for any specifics.
+var getHeaders = function(object,names) {
+ var keys = (names && names.length>0) ? names : Object.keys($H(object));
+ var hash = keys.reduce(function(hash,key) {
+ hash[key] = getHeader(object,key);
+ return hash;
+ },{});
+ // Freeze the resulting hash so you don't mistakenly think you're modifying
+ // the real headers.
+ Object.freeze(hash);
+ return hash;
+};
+
+// The "real" `setHeader` function: set a header, after normalizing the name.
+var setHeader = function(object,name,value) {
+ $H(object)[corsetCase(name)] = value;
+ return object;
+};
+
+// The "real" `setHeaders` function: set multiple headers based on a hash.
+var setHeaders = function(object,hash) {
+ for( var key in hash ) { setHeader(object,key,hash[key]); };
+ return this;
+};
+
+// Here's where we actually bind the functionality to an object. These mixins work by
+// exposing mixin functions. Each function mixes in a specific batch of features.
+module.exports = {
+
+ // Add getters.
+ getters: function(constructor) {
+ constructor.prototype.getHeader = function(name) { return getHeader(this,name); };
+ constructor.prototype.getHeaders = function() { return getHeaders(this,arguments); };
+ },
+ // Add setters but as "private" methods.
+ privateSetters: function(constructor) {
+ constructor.prototype._setHeader = function(key,value) { return setHeader(this,key,value); };
+ constructor.prototype._setHeaders = function(hash) { return setHeaders(this,hash); };
+ },
+ // Add setters.
+ setters: function(constructor) {
+ constructor.prototype.setHeader = function(key,value) { return setHeader(this,key,value); };
+ constructor.prototype.setHeaders = function(hash) { return setHeaders(this,hash); };
+ },
+ // Add both getters and setters.
+ gettersAndSetters: function(constructor) {
+ constructor.prototype.getHeader = function(name) { return getHeader(this,name); };
+ constructor.prototype.getHeaders = function() { return getHeaders(this,arguments); };
+ constructor.prototype.setHeader = function(key,value) { return setHeader(this,key,value); };
+ constructor.prototype.setHeaders = function(hash) { return setHeaders(this,hash); };
+ },
+};
+
+});
+
+require.define("/node_modules/iconv-lite/package.json", function (require, module, exports, __dirname, __filename) {
+ module.exports = {}
+});
+
+require.define("/node_modules/iconv-lite/index.js", function (require, module, exports, __dirname, __filename) {
+ // Module exports
+var iconv = module.exports = {
+ toEncoding: function(str, encoding) {
+ return iconv.getCodec(encoding).toEncoding(str);
+ },
+ fromEncoding: function(buf, encoding) {
+ return iconv.getCodec(encoding).fromEncoding(buf);
+ },
+
+ defaultCharUnicode: '�',
+ defaultCharSingleByte: '?',
+
+ // Get correct codec for given encoding.
+ getCodec: function(encoding) {
+ var enc = encoding || "utf8";
+ var codecOptions = undefined;
+ while (1) {
+ if (getType(enc) === "String")
+ enc = enc.replace(/[- ]/g, "").toLowerCase();
+ var codec = iconv.encodings[enc];
+ var type = getType(codec);
+ if (type === "String") {
+ // Link to other encoding.
+ codecOptions = {originalEncoding: enc};
+ enc = codec;
+ }
+ else if (type === "Object" && codec.type != undefined) {
+ // Options for other encoding.
+ codecOptions = codec;
+ enc = codec.type;
+ }
+ else if (type === "Function")
+ // Codec itself.
+ return codec(codecOptions);
+ else
+ throw new Error("Encoding not recognized: '" + encoding + "' (searched as: '"+enc+"')");
+ }
+ },
+
+ // Define basic encodings
+ encodings: {
+ internal: function(options) {
+ return {
+ toEncoding: function(str) {
+ return new Buffer(ensureString(str), options.originalEncoding);
+ },
+ fromEncoding: function(buf) {
+ return ensureBuffer(buf).toString(options.originalEncoding);
+ }
+ };
+ },
+ utf8: "internal",
+ ucs2: "internal",
+ binary: "internal",
+ ascii: "internal",
+ base64: "internal",
+
+ // Codepage single-byte encodings.
+ singlebyte: function(options) {
+ // Prepare chars if needed
+ if (!options.chars || (options.chars.length !== 128 && options.chars.length !== 256))
+ throw new Error("Encoding '"+options.type+"' has incorrect 'chars' (must be of len 128 or 256)");
+
+ if (options.chars.length === 128)
+ options.chars = asciiString + options.chars;
+
+ if (!options.charsBuf) {
+ options.charsBuf = new Buffer(options.chars, 'ucs2');
+ }
+
+ if (!options.revCharsBuf) {
+ options.revCharsBuf = new Buffer(65536);
+ var defChar = iconv.defaultCharSingleByte.charCodeAt(0);
+ for (var i = 0; i < options.revCharsBuf.length; i++)
+ options.revCharsBuf[i] = defChar;
+ for (var i = 0; i < options.chars.length; i++)
+ options.revCharsBuf[options.chars.charCodeAt(i)] = i;
+ }
+
+ return {
+ toEncoding: function(str) {
+ str = ensureString(str);
+
+ var buf = new Buffer(str.length);
+ var revCharsBuf = options.revCharsBuf;
+ for (var i = 0; i < str.length; i++)
+ buf[i] = revCharsBuf[str.charCodeAt(i)];
+
+ return buf;
+ },
+ fromEncoding: function(buf) {
+ buf = ensureBuffer(buf);
+
+ // Strings are immutable in JS -> we use ucs2 buffer to speed up computations.
+ var charsBuf = options.charsBuf;
+ var newBuf = new Buffer(buf.length*2);
+ var idx1 = 0, idx2 = 0;
+ for (var i = 0, _len = buf.length; i < _len; i++) {
+ idx1 = buf[i]*2; idx2 = i*2;
+ newBuf[idx2] = charsBuf[idx1];
+ newBuf[idx2+1] = charsBuf[idx1+1];
+ }
+ return newBuf.toString('ucs2');
+ }
+ };
+ },
+
+ // Codepage double-byte encodings.
+ table: function(options) {
+ var table = options.table, key, revCharsTable = options.revCharsTable;
+ if (!table) {
+ throw new Error("Encoding '" + options.type +"' has incorect 'table' option");
+ }
+ if(!revCharsTable) {
+ revCharsTable = options.revCharsTable = {};
+ for (key in table) {
+ revCharsTable[table[key]] = parseInt(key);
+ }
+ }
+
+ return {
+ toEncoding: function(str) {
+ str = ensureString(str);
+ var strLen = str.length;
+ var bufLen = strLen;
+ for (var i = 0; i < strLen; i++)
+ if (str.charCodeAt(i) >> 7)
+ bufLen++;
+
+ var newBuf = new Buffer(bufLen), gbkcode, unicode,
+ defaultChar = revCharsTable[iconv.defaultCharUnicode.charCodeAt(0)];
+
+ for (var i = 0, j = 0; i < strLen; i++) {
+ unicode = str.charCodeAt(i);
+ if (unicode >> 7) {
+ gbkcode = revCharsTable[unicode] || defaultChar;
+ newBuf[j++] = gbkcode >> 8; //high byte;
+ newBuf[j++] = gbkcode & 0xFF; //low byte
+ } else {//ascii
+ newBuf[j++] = unicode;
+ }
+ }
+ return newBuf;
+ },
+ fromEncoding: function(buf) {
+ buf = ensureBuffer(buf);
+ var bufLen = buf.length, strLen = 0;
+ for (var i = 0; i < bufLen; i++) {
+ strLen++;
+ if (buf[i] & 0x80) //the high bit is 1, so this byte is gbkcode's high byte.skip next byte
+ i++;
+ }
+ var newBuf = new Buffer(strLen*2), unicode, gbkcode,
+ defaultChar = iconv.defaultCharUnicode.charCodeAt(0);
+
+ for (var i = 0, j = 0; i < bufLen; i++, j+=2) {
+ gbkcode = buf[i];
+ if (gbkcode & 0x80) {
+ gbkcode = (gbkcode << 8) + buf[++i];
+ unicode = table[gbkcode] || defaultChar;
+ } else {
+ unicode = gbkcode;
+ }
+ newBuf[j] = unicode & 0xFF; //low byte
+ newBuf[j+1] = unicode >> 8; //high byte
+ }
+ return newBuf.toString('ucs2');
+ }
+ }
+ }
+ }
+};
+
+// Add aliases to convert functions
+iconv.encode = iconv.toEncoding;
+iconv.decode = iconv.fromEncoding;
+
+// Load other encodings from files in /encodings dir.
+var encodingsDir = __dirname+"/encodings/",
+ fs = require('fs');
+fs.readdirSync(encodingsDir).forEach(function(file) {
+ if(fs.statSync(encodingsDir + file).isDirectory()) return;
+ var encodings = require(encodingsDir + file)
+ for (var key in encodings)
+ iconv.encodings[key] = encodings[key]
+});
+
+// Utilities
+var asciiString = '\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f'+
+ ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f';
+
+var ensureBuffer = function(buf) {
+ buf = buf || new Buffer(0);
+ return (buf instanceof Buffer) ? buf : new Buffer(buf.toString(), "utf8");
+}
+
+var ensureString = function(str) {
+ str = str || "";
+ return (str instanceof String) ? str : str.toString((str instanceof Buffer) ? 'utf8' : undefined);
+}
+
+var getType = function(obj) {
+ return Object.prototype.toString.call(obj).slice(8, -1);
+}
+
+
+});
+
+require.define("/node_modules/http-browserify/package.json", function (require, module, exports, __dirname, __filename) {
+ module.exports = {"main":"index.js","browserify":"browser.js"}
+});
+
+require.define("/node_modules/http-browserify/browser.js", function (require, module, exports, __dirname, __filename) {
+ var http = module.exports;
+var EventEmitter = require('events').EventEmitter;
+var Request = require('./lib/request');
+
+http.request = function (params, cb) {
+ if (!params) params = {};
+ if (!params.host) params.host = window.location.host.split(':')[0];
+ if (!params.port) params.port = window.location.port;
+
+ var req = new Request(new xhrHttp, params);
+ if (cb) req.on('response', cb);
+ return req;
+};
+
+http.get = function (params, cb) {
+ params.method = 'GET';
+ var req = http.request(params, cb);
+ req.end();
+ return req;
+};
+
+var xhrHttp = (function () {
+ if (typeof window === 'undefined') {
+ throw new Error('no window object present');
+ }
+ else if (window.XMLHttpRequest) {
+ return window.XMLHttpRequest;
+ }
+ else if (window.ActiveXObject) {
+ var axs = [
+ 'Msxml2.XMLHTTP.6.0',
+ 'Msxml2.XMLHTTP.3.0',
+ 'Microsoft.XMLHTTP'
+ ];
+ for (var i = 0; i < axs.length; i++) {
+ try {
+ var ax = new(window.ActiveXObject)(axs[i]);
+ return function () {
+ if (ax) {
+ var ax_ = ax;
+ ax = null;
+ return ax_;
+ }
+ else {
+ return new(window.ActiveXObject)(axs[i]);
+ }
+ };
+ }
+ catch (e) {}
+ }
+ throw new Error('ajax not supported in this browser')
+ }
+ else {
+ throw new Error('ajax not supported in this browser');
+ }
+})();
+
+http.STATUS_CODES = {
+ 100 : 'Continue',
+ 101 : 'Switching Protocols',
+ 102 : 'Processing', // RFC 2518, obsoleted by RFC 4918
+ 200 : 'OK',
+ 201 : 'Created',
+ 202 : 'Accepted',
+ 203 : 'Non-Authoritative Information',
+ 204 : 'No Content',
+ 205 : 'Reset Content',
+ 206 : 'Partial Content',
+ 207 : 'Multi-Status', // RFC 4918
+ 300 : 'Multiple Choices',
+ 301 : 'Moved Permanently',
+ 302 : 'Moved Temporarily',
+ 303 : 'See Other',
+ 304 : 'Not Modified',
+ 305 : 'Use Proxy',
+ 307 : 'Temporary Redirect',
+ 400 : 'Bad Request',
+ 401 : 'Unauthorized',
+ 402 : 'Payment Required',
+ 403 : 'Forbidden',
+ 404 : 'Not Found',
+ 405 : 'Method Not Allowed',
+ 406 : 'Not Acceptable',
+ 407 : 'Proxy Authentication Required',
+ 408 : 'Request Time-out',
+ 409 : 'Conflict',
+ 410 : 'Gone',
+ 411 : 'Length Required',
+ 412 : 'Precondition Failed',
+ 413 : 'Request Entity Too Large',
+ 414 : 'Request-URI Too Large',
+ 415 : 'Unsupported Media Type',
+ 416 : 'Requested Range Not Satisfiable',
+ 417 : 'Expectation Failed',
+ 418 : 'I\'m a teapot', // RFC 2324
+ 422 : 'Unprocessable Entity', // RFC 4918
+ 423 : 'Locked', // RFC 4918
+ 424 : 'Failed Dependency', // RFC 4918
+ 425 : 'Unordered Collection', // RFC 4918
+ 426 : 'Upgrade Required', // RFC 2817
+ 500 : 'Internal Server Error',
+ 501 : 'Not Implemented',
+ 502 : 'Bad Gateway',
+ 503 : 'Service Unavailable',
+ 504 : 'Gateway Time-out',
+ 505 : 'HTTP Version not supported',
+ 506 : 'Variant Also Negotiates', // RFC 2295
+ 507 : 'Insufficient Storage', // RFC 4918
+ 509 : 'Bandwidth Limit Exceeded',
+ 510 : 'Not Extended' // RFC 2774
+};
+
+});
+
+require.define("/node_modules/http-browserify/lib/request.js", function (require, module, exports, __dirname, __filename) {
+ var EventEmitter = require('events').EventEmitter;
+var Response = require('./response');
+var isSafeHeader = require('./isSafeHeader');
+
+var Request = module.exports = function (xhr, params) {
+ var self = this;
+ self.xhr = xhr;
+ self.body = '';
+
+ var uri = params.host + ':' + params.port + (params.path || '/');
+
+ xhr.open(
+ params.method || 'GET',
+ (params.scheme || 'http') + '://' + uri,
+ true
+ );
+
+ if (params.headers) {
+ Object.keys(params.headers).forEach(function (key) {
+ if (!isSafeHeader(key)) return;
+ var value = params.headers[key];
+ if (Array.isArray(value)) {
+ value.forEach(function (v) {
+ xhr.setRequestHeader(key, v);
+ });
+ }
+ else xhr.setRequestHeader(key, value)
+ });
+ }
+
+ var res = new Response(xhr);
+ res.on('ready', function () {
+ self.emit('response', res);
+ });
+
+ xhr.onreadystatechange = function () {
+ res.handle(xhr);
+ };
+};
+
+Request.prototype = new EventEmitter;
+
+Request.prototype.setHeader = function (key, value) {
+ if ((Array.isArray && Array.isArray(value))
+ || value instanceof Array) {
+ for (var i = 0; i < value.length; i++) {
+ this.xhr.setRequestHeader(key, value[i]);
+ }
+ }
+ else {
+ this.xhr.setRequestHeader(key, value);
+ }
+};
+
+Request.prototype.write = function (s) {
+ this.body += s;
+};
+
+Request.prototype.end = function (s) {
+ if (s !== undefined) this.write(s);
+ this.xhr.send(this.body);
+};
+
+});
+
+require.define("/node_modules/http-browserify/lib/response.js", function (require, module, exports, __dirname, __filename) {
+ var EventEmitter = require('events').EventEmitter;
+var isSafeHeader = require('./isSafeHeader');
+
+var Response = module.exports = function (xhr) {
+ this.xhr = xhr;
+ this.offset = 0;
+};
+
+Response.prototype = new EventEmitter;
+
+var capable = {
+ streaming : true,
+ status2 : true
+};
+
+function parseHeaders (xhr) {
+ var lines = xhr.getAllResponseHeaders().split(/\r?\n/);
+ var headers = {};
+ for (var i = 0; i < lines.length; i++) {
+ var line = lines[i];
+ if (line === '') continue;
+
+ var m = line.match(/^([^:]+):\s*(.*)/);
+ if (m) {
+ var key = m[1].toLowerCase(), value = m[2];
+
+ if (headers[key] !== undefined) {
+ if ((Array.isArray && Array.isArray(headers[key]))
+ || headers[key] instanceof Array) {
+ headers[key].push(value);
+ }
+ else {
+ headers[key] = [ headers[key], value ];
+ }
+ }
+ else {
+ headers[key] = value;
+ }
+ }
+ else {
+ headers[line] = true;
+ }
+ }
+ return headers;
+}
+
+Response.prototype.getHeader = function (key) {
+ var header = this.headers ? this.headers[key.toLowerCase()] : null;
+ if (header) return header;
+
+ // Work around Mozilla bug #608735 [https://bugzil.la/608735], which causes
+ // getAllResponseHeaders() to return {} if the response is a CORS request.
+ // xhr.getHeader still works correctly.
+ if (isSafeHeader(key)) {
+ return this.xhr.getResponseHeader(key);
+ }
+ return null;
+};
+
+Response.prototype.handle = function () {
+ var xhr = this.xhr;
+ if (xhr.readyState === 2 && capable.status2) {
+ try {
+ this.statusCode = xhr.status;
+ this.headers = parseHeaders(xhr);
+ }
+ catch (err) {
+ capable.status2 = false;
+ }
+
+ if (capable.status2) {
+ this.emit('ready');
+ }
+ }
+ else if (capable.streaming && xhr.readyState === 3) {
+ try {
+ if (!this.statusCode) {
+ this.statusCode = xhr.status;
+ this.headers = parseHeaders(xhr);
+ this.emit('ready');
+ }
+ }
+ catch (err) {}
+
+ try {
+ this.write();
+ }
+ catch (err) {
+ capable.streaming = false;
+ }
+ }
+ else if (xhr.readyState === 4) {
+ if (!this.statusCode) {
+ this.statusCode = xhr.status;
+ this.emit('ready');
+ }
+ this.write();
+
+ if (xhr.error) {
+ this.emit('error', xhr.responseText);
+ }
+ else this.emit('end');
+ }
+};
+
+Response.prototype.write = function () {
+ var xhr = this.xhr;
+ if (xhr.responseText.length > this.offset) {
+ this.emit('data', xhr.responseText.slice(this.offset));
+ this.offset = xhr.responseText.length;
+ }
+};
+
+});
+
+require.define("/node_modules/http-browserify/lib/isSafeHeader.js", function (require, module, exports, __dirname, __filename) {
+ // Taken from http://dxr.mozilla.org/mozilla/mozilla-central/content/base/src/nsXMLHttpRequest.cpp.html
+var unsafeHeaders = [
+ "accept-charset",
+ "accept-encoding",
+ "access-control-request-headers",
+ "access-control-request-method",
+ "connection",
+ "content-length",
+ "cookie",
+ "cookie2",
+ "content-transfer-encoding",
+ "date",
+ "expect",
+ "host",
+ "keep-alive",
+ "origin",
+ "referer",
+ "set-cookie",
+ "te",
+ "trailer",
+ "transfer-encoding",
+ "upgrade",
+ "user-agent",
+ "via"
+];
+
+module.exports = function (headerName) {
+ if (!headerName) return false;
+ return (unsafeHeaders.indexOf(headerName.toLowerCase()) === -1)
+};
+
+});
+
+require.alias("http-browserify", "/node_modules/http");
+
+require.alias("http-browserify", "/node_modules/https");
\ No newline at end of file
diff --git a/profiles/killpay/src/main/webapp/lib/shred/content.js b/profiles/killpay/src/main/webapp/lib/shred/content.js
new file mode 100644
index 0000000..b8051fe
--- /dev/null
+++ b/profiles/killpay/src/main/webapp/lib/shred/content.js
@@ -0,0 +1,193 @@
+
+// The purpose of the `Content` object is to abstract away the data conversions
+// to and from raw content entities as strings. For example, you want to be able
+// to pass in a Javascript object and have it be automatically converted into a
+// JSON string if the `content-type` is set to a JSON-based media type.
+// Conversely, you want to be able to transparently get back a Javascript object
+// in the response if the `content-type` is a JSON-based media-type.
+
+// One limitation of the current implementation is that it [assumes the `charset` is UTF-8](https://github.com/spire-io/shred/issues/5).
+
+// The `Content` constructor takes an options object, which *must* have either a
+// `body` or `data` property and *may* have a `type` property indicating the
+// media type. If there is no `type` attribute, a default will be inferred.
+var Content = function(options) {
+ this.body = options.body;
+ this.data = options.data;
+ this.type = options.type;
+};
+
+Content.prototype = {
+ // Treat `toString()` as asking for the `content.body`. That is, the raw content entity.
+ //
+ // toString: function() { return this.body; }
+ //
+ // Commented out, but I've forgotten why. :/
+};
+
+
+// `Content` objects have the following attributes:
+Object.defineProperties(Content.prototype,{
+
+// - **type**. Typically accessed as `content.type`, reflects the `content-type`
+// header associated with the request or response. If not passed as an options
+// to the constructor or set explicitly, it will infer the type the `data`
+// attribute, if possible, and, failing that, will default to `text/plain`.
+ type: {
+ get: function() {
+ if (this._type) {
+ return this._type;
+ } else {
+ if (this._data) {
+ switch(typeof this._data) {
+ case "string": return "text/plain";
+ case "object": return "application/json";
+ }
+ }
+ }
+ return "text/plain";
+ },
+ set: function(value) {
+ this._type = value;
+ return this;
+ },
+ enumerable: true
+ },
+
+// - **data**. Typically accessed as `content.data`, reflects the content entity
+// converted into Javascript data. This can be a string, if the `type` is, say,
+// `text/plain`, but can also be a Javascript object. The conversion applied is
+// based on the `processor` attribute. The `data` attribute can also be set
+// directly, in which case the conversion will be done the other way, to infer
+// the `body` attribute.
+ data: {
+ get: function() {
+ if (this._body) {
+ return this.processor.parser(this._body);
+ } else {
+ return this._data;
+ }
+ },
+ set: function(data) {
+ if (this._body&&data) Errors.setDataWithBody(this);
+ this._data = data;
+ return this;
+ },
+ enumerable: true
+ },
+
+// - **body**. Typically accessed as `content.body`, reflects the content entity
+// as a UTF-8 string. It is the mirror of the `data` attribute. If you set the
+// `data` attribute, the `body` attribute will be inferred and vice-versa. If
+// you attempt to set both, an exception is raised.
+ body: {
+ get: function() {
+ if (this._data) {
+ return this.processor.stringify(this._data);
+ } else {
+ return this._body.toString();
+ }
+ },
+ set: function(body) {
+ if (this._data&&body) Errors.setBodyWithData(this);
+ this._body = body;
+ return this;
+ },
+ enumerable: true
+ },
+
+// - **processor**. The functions that will be used to convert to/from `data` and
+// `body` attributes. You can add processors. The two that are built-in are for
+// `text/plain`, which is basically an identity transformation and
+// `application/json` and other JSON-based media types (including custom media
+// types with `+json`). You can add your own processors. See below.
+ processor: {
+ get: function() {
+ var processor = Content.processors[this.type];
+ if (processor) {
+ return processor;
+ } else {
+ // Return the first processor that matches any part of the
+ // content type. ex: application/vnd.foobar.baz+json will match json.
+ var main = this.type.split(";")[0];
+ var parts = main.split(/\+|\//);
+ for (var i=0, l=parts.length; i < l; i++) {
+ processor = Content.processors[parts[i]]
+ }
+ return processor || {parser:identity,stringify:toString};
+ }
+ },
+ enumerable: true
+ },
+
+// - **length**. Typically accessed as `content.length`, returns the length in
+// bytes of the raw content entity.
+ length: {
+ get: function() {
+ if (typeof Buffer !== 'undefined') {
+ return Buffer.byteLength(this.body);
+ }
+ return this.body.length;
+ }
+ }
+});
+
+Content.processors = {};
+
+// The `registerProcessor` function allows you to add your own processors to
+// convert content entities. Each processor consists of a Javascript object with
+// two properties:
+// - **parser**. The function used to parse a raw content entity and convert it
+// into a Javascript data type.
+// - **stringify**. The function used to convert a Javascript data type into a
+// raw content entity.
+Content.registerProcessor = function(types,processor) {
+
+// You can pass an array of types that will trigger this processor, or just one.
+// We determine the array via duck-typing here.
+ if (types.forEach) {
+ types.forEach(function(type) {
+ Content.processors[type] = processor;
+ });
+ } else {
+ // If you didn't pass an array, we just use what you pass in.
+ Content.processors[types] = processor;
+ }
+};
+
+// Register the identity processor, which is used for text-based media types.
+var identity = function(x) { return x; }
+ , toString = function(x) { return x.toString(); }
+Content.registerProcessor(
+ ["text/html","text/plain","text"],
+ { parser: identity, stringify: toString });
+
+// Register the JSON processor, which is used for JSON-based media types.
+Content.registerProcessor(
+ ["application/json; charset=utf-8","application/json","json"],
+ {
+ parser: function(string) {
+ return JSON.parse(string);
+ },
+ stringify: function(data) {
+ return JSON.stringify(data); }});
+
+var qs = require('querystring');
+// Register the post processor, which is used for JSON-based media types.
+Content.registerProcessor(
+ ["application/x-www-form-urlencoded"],
+ { parser : qs.parse, stringify : qs.stringify });
+
+// Error functions are defined separately here in an attempt to make the code
+// easier to read.
+var Errors = {
+ setDataWithBody: function(object) {
+ throw new Error("Attempt to set data attribute of a content object " +
+ "when the body attributes was already set.");
+ },
+ setBodyWithData: function(object) {
+ throw new Error("Attempt to set body attribute of a content object " +
+ "when the data attributes was already set.");
+ }
+}
+module.exports = Content;
\ No newline at end of file
profiles/killpay/src/main/webapp/lib/swagger.js 1665(+1665 -0)
diff --git a/profiles/killpay/src/main/webapp/lib/swagger.js b/profiles/killpay/src/main/webapp/lib/swagger.js
new file mode 100644
index 0000000..2871608
--- /dev/null
+++ b/profiles/killpay/src/main/webapp/lib/swagger.js
@@ -0,0 +1,1665 @@
+// swagger.js
+// version 2.0.41
+
+(function () {
+
+ var __bind = function (fn, me) {
+ return function () {
+ return fn.apply(me, arguments);
+ };
+ };
+
+ var log = function () {
+ log.history = log.history || [];
+ log.history.push(arguments);
+ if (this.console) {
+ console.log(Array.prototype.slice.call(arguments)[0]);
+ }
+ };
+
+ // if you want to apply conditional formatting of parameter values
+ var parameterMacro = function (value) {
+ return value;
+ }
+
+ // if you want to apply conditional formatting of model property values
+ var modelPropertyMacro = function (value) {
+ return value;
+ }
+
+ if (!Array.prototype.indexOf) {
+ Array.prototype.indexOf = function (obj, start) {
+ for (var i = (start || 0), j = this.length; i < j; i++) {
+ if (this[i] === obj) { return i; }
+ }
+ return -1;
+ }
+ }
+
+ if (!('filter' in Array.prototype)) {
+ Array.prototype.filter = function (filter, that /*opt*/) {
+ var other = [], v;
+ for (var i = 0, n = this.length; i < n; i++)
+ if (i in this && filter.call(that, v = this[i], i, this))
+ other.push(v);
+ return other;
+ };
+ }
+
+ if (!('map' in Array.prototype)) {
+ Array.prototype.map = function (mapper, that /*opt*/) {
+ var other = new Array(this.length);
+ for (var i = 0, n = this.length; i < n; i++)
+ if (i in this)
+ other[i] = mapper.call(that, this[i], i, this);
+ return other;
+ };
+ }
+
+ Object.keys = Object.keys || (function () {
+ var hasOwnProperty = Object.prototype.hasOwnProperty,
+ hasDontEnumBug = !{ toString: null }.propertyIsEnumerable("toString"),
+ DontEnums = [
+ 'toString',
+ 'toLocaleString',
+ 'valueOf',
+ 'hasOwnProperty',
+ 'isPrototypeOf',
+ 'propertyIsEnumerable',
+ 'constructor'
+ ],
+ DontEnumsLength = DontEnums.length;
+
+ return function (o) {
+ if (typeof o != "object" && typeof o != "function" || o === null)
+ throw new TypeError("Object.keys called on a non-object");
+
+ var result = [];
+ for (var name in o) {
+ if (hasOwnProperty.call(o, name))
+ result.push(name);
+ }
+
+ if (hasDontEnumBug) {
+ for (var i = 0; i < DontEnumsLength; i++) {
+ if (hasOwnProperty.call(o, DontEnums[i]))
+ result.push(DontEnums[i]);
+ }
+ }
+
+ return result;
+ };
+ })();
+
+ var SwaggerApi = function (url, options) {
+ this.isBuilt = false;
+ this.url = null;
+ this.debug = false;
+ this.basePath = null;
+ this.authorizations = null;
+ this.authorizationScheme = null;
+ this.info = null;
+ this.useJQuery = false;
+ this.modelsArray = [];
+ this.isValid;
+
+ options = (options || {});
+ if (url)
+ if (url.url)
+ options = url;
+ else
+ this.url = url;
+ else
+ options = url;
+
+ if (options.url != null)
+ this.url = options.url;
+
+ if (options.success != null)
+ this.success = options.success;
+
+ if (typeof options.useJQuery === 'boolean')
+ this.useJQuery = options.useJQuery;
+
+ this.failure = options.failure != null ? options.failure : function () { };
+ this.progress = options.progress != null ? options.progress : function () { };
+ if (options.success != null) {
+ this.build();
+ this.isBuilt = true;
+ }
+ }
+
+ SwaggerApi.prototype.build = function () {
+ if (this.isBuilt)
+ return this;
+ var _this = this;
+ this.progress('fetching resource list: ' + this.url);
+ var obj = {
+ useJQuery: this.useJQuery,
+ url: this.url,
+ method: "get",
+ headers: {
+ accept: "application/json,application/json;charset=\"utf-8\",*/*"
+ },
+ on: {
+ error: function (response) {
+ if (_this.url.substring(0, 4) !== 'http') {
+ return _this.fail('Please specify the protocol for ' + _this.url);
+ } else if (response.status === 0) {
+ return _this.fail('Can\'t read from server. It may not have the appropriate access-control-origin settings.');
+ } else if (response.status === 404) {
+ return _this.fail('Can\'t read swagger JSON from ' + _this.url);
+ } else {
+ return _this.fail(response.status + ' : ' + response.statusText + ' ' + _this.url);
+ }
+ },
+ response: function (resp) {
+ var responseObj = resp.obj || JSON.parse(resp.data);
+ _this.swaggerVersion = responseObj.swaggerVersion;
+ if (_this.swaggerVersion === "1.2") {
+ return _this.buildFromSpec(responseObj);
+ } else {
+ return _this.buildFrom1_1Spec(responseObj);
+ }
+ }
+ }
+ };
+ var e = (typeof window !== 'undefined' ? window : exports);
+ e.authorizations.apply(obj);
+ new SwaggerHttp().execute(obj);
+ return this;
+ };
+
+ SwaggerApi.prototype.buildFromSpec = function (response) {
+ if (response.apiVersion != null) {
+ this.apiVersion = response.apiVersion;
+ }
+ this.apis = {};
+ this.apisArray = [];
+ this.consumes = response.consumes;
+ this.produces = response.produces;
+ this.authSchemes = response.authorizations;
+ if (response.info != null) {
+ this.info = response.info;
+ }
+ var isApi = false;
+ var i;
+ for (i = 0; i < response.apis.length; i++) {
+ var api = response.apis[i];
+ if (api.operations) {
+ var j;
+ for (j = 0; j < api.operations.length; j++) {
+ operation = api.operations[j];
+ isApi = true;
+ }
+ }
+ }
+ if (response.basePath)
+ this.basePath = response.basePath;
+ else if (this.url.indexOf('?') > 0)
+ this.basePath = this.url.substring(0, this.url.lastIndexOf('?'));
+ else
+ this.basePath = this.url;
+
+ if (isApi) {
+ var newName = response.resourcePath.replace(/\//g, '');
+ this.resourcePath = response.resourcePath;
+ var res = new SwaggerResource(response, this);
+ this.apis[newName] = res;
+ this.apisArray.push(res);
+ } else {
+ var k;
+ for (k = 0; k < response.apis.length; k++) {
+ var resource = response.apis[k];
+ var res = new SwaggerResource(resource, this);
+ this.apis[res.name] = res;
+ this.apisArray.push(res);
+ }
+ }
+ this.isValid = true;
+ if (this.success) {
+ this.success();
+ }
+ return this;
+ };
+
+ SwaggerApi.prototype.buildFrom1_1Spec = function (response) {
+ log("This API is using a deprecated version of Swagger! Please see http://github.com/wordnik/swagger-core/wiki for more info");
+ if (response.apiVersion != null)
+ this.apiVersion = response.apiVersion;
+ this.apis = {};
+ this.apisArray = [];
+ this.produces = response.produces;
+ if (response.info != null) {
+ this.info = response.info;
+ }
+ var isApi = false;
+ for (var i = 0; i < response.apis.length; i++) {
+ var api = response.apis[i];
+ if (api.operations) {
+ for (var j = 0; j < api.operations.length; j++) {
+ operation = api.operations[j];
+ isApi = true;
+ }
+ }
+ }
+ if (response.basePath) {
+ this.basePath = response.basePath;
+ } else if (this.url.indexOf('?') > 0) {
+ this.basePath = this.url.substring(0, this.url.lastIndexOf('?'));
+ } else {
+ this.basePath = this.url;
+ }
+ if (isApi) {
+ var newName = response.resourcePath.replace(/\//g, '');
+ this.resourcePath = response.resourcePath;
+ var res = new SwaggerResource(response, this);
+ this.apis[newName] = res;
+ this.apisArray.push(res);
+ } else {
+ for (k = 0; k < response.apis.length; k++) {
+ resource = response.apis[k];
+ var res = new SwaggerResource(resource, this);
+ this.apis[res.name] = res;
+ this.apisArray.push(res);
+ }
+ }
+ this.isValid = true;
+ if (this.success) {
+ this.success();
+ }
+ return this;
+ };
+
+ SwaggerApi.prototype.selfReflect = function () {
+ var resource, resource_name, _ref;
+ if (this.apis == null) {
+ return false;
+ }
+ _ref = this.apis;
+ for (resource_name in _ref) {
+ resource = _ref[resource_name];
+ if (resource.ready == null) {
+ return false;
+ }
+ }
+ this.setConsolidatedModels();
+ this.ready = true;
+ if (this.success != null) {
+ return this.success();
+ }
+ };
+
+ SwaggerApi.prototype.fail = function (message) {
+ this.failure(message);
+ throw message;
+ };
+
+ SwaggerApi.prototype.setConsolidatedModels = function () {
+ var model, modelName, resource, resource_name, _i, _len, _ref, _ref1, _results;
+ this.models = {};
+ _ref = this.apis;
+ for (resource_name in _ref) {
+ resource = _ref[resource_name];
+ for (modelName in resource.models) {
+ if (this.models[modelName] == null) {
+ this.models[modelName] = resource.models[modelName];
+ this.modelsArray.push(resource.models[modelName]);
+ }
+ }
+ }
+ _ref1 = this.modelsArray;
+ _results = [];
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
+ model = _ref1[_i];
+ _results.push(model.setReferencedModels(this.models));
+ }
+ return _results;
+ };
+
+ SwaggerApi.prototype.help = function () {
+ var operation, operation_name, parameter, resource, resource_name, _i, _len, _ref, _ref1, _ref2;
+ _ref = this.apis;
+ for (resource_name in _ref) {
+ resource = _ref[resource_name];
+ log(resource_name);
+ _ref1 = resource.operations;
+ for (operation_name in _ref1) {
+ operation = _ref1[operation_name];
+ log(" " + operation.nickname);
+ _ref2 = operation.parameters;
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
+ parameter = _ref2[_i];
+ log(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
+ }
+ }
+ }
+ return this;
+ };
+
+ var SwaggerResource = function (resourceObj, api) {
+ var _this = this;
+ this.api = api;
+ this.api = this.api;
+ var consumes = (this.consumes | []);
+ var produces = (this.produces | []);
+ this.path = this.api.resourcePath != null ? this.api.resourcePath : resourceObj.path;
+ this.description = resourceObj.description;
+
+ var parts = this.path.split("/");
+ this.name = parts[parts.length - 1].replace('.{format}', '');
+ this.basePath = this.api.basePath;
+ this.operations = {};
+ this.operationsArray = [];
+ this.modelsArray = [];
+ this.models = {};
+ this.rawModels = {};
+ this.useJQuery = (typeof api.useJQuery !== 'undefined' ? api.useJQuery : null);
+
+ if ((resourceObj.apis != null) && (this.api.resourcePath != null)) {
+ this.addApiDeclaration(resourceObj);
+ } else {
+ if (this.path == null) {
+ this.api.fail("SwaggerResources must have a path.");
+ }
+ if (this.path.substring(0, 4) === 'http') {
+ this.url = this.path.replace('{format}', 'json');
+ } else {
+ this.url = this.api.basePath + this.path.replace('{format}', 'json');
+ }
+ this.api.progress('fetching resource ' + this.name + ': ' + this.url);
+ var obj = {
+ url: this.url,
+ method: "get",
+ useJQuery: this.useJQuery,
+ headers: {
+ accept: "application/json,application/json;charset=\"utf-8\",*/*"
+ },
+ on: {
+ response: function (resp) {
+ var responseObj = resp.obj || JSON.parse(resp.data);
+ return _this.addApiDeclaration(responseObj);
+ },
+ error: function (response) {
+ return _this.api.fail("Unable to read api '" +
+ _this.name + "' from path " + _this.url + " (server returned " + response.statusText + ")");
+ }
+ }
+ };
+ var e = typeof window !== 'undefined' ? window : exports;
+ e.authorizations.apply(obj);
+ new SwaggerHttp().execute(obj);
+ }
+ }
+
+ SwaggerResource.prototype.getAbsoluteBasePath = function (relativeBasePath) {
+ var pos, url;
+ url = this.api.basePath;
+ pos = url.lastIndexOf(relativeBasePath);
+ var parts = url.split("/");
+ var rootUrl = parts[0] + "//" + parts[2];
+
+ if (relativeBasePath.indexOf("http") === 0)
+ return relativeBasePath;
+ if (relativeBasePath === "/")
+ return rootUrl;
+ if (relativeBasePath.substring(0, 1) == "/") {
+ // use root + relative
+ return rootUrl + relativeBasePath;
+ }
+ else {
+ var pos = this.basePath.lastIndexOf("/");
+ var base = this.basePath.substring(0, pos);
+ if (base.substring(base.length - 1) == "/")
+ return base + relativeBasePath;
+ else
+ return base + "/" + relativeBasePath;
+ }
+ };
+
+ SwaggerResource.prototype.addApiDeclaration = function (response) {
+ if (response.produces != null)
+ this.produces = response.produces;
+ if (response.consumes != null)
+ this.consumes = response.consumes;
+ if ((response.basePath != null) && response.basePath.replace(/\s/g, '').length > 0)
+ this.basePath = response.basePath.indexOf("http") === -1 ? this.getAbsoluteBasePath(response.basePath) : response.basePath;
+
+ this.addModels(response.models);
+ if (response.apis) {
+ for (var i = 0 ; i < response.apis.length; i++) {
+ var endpoint = response.apis[i];
+ this.addOperations(endpoint.path, endpoint.operations, response.consumes, response.produces);
+ }
+ }
+ this.api[this.name] = this;
+ this.ready = true;
+ return this.api.selfReflect();
+ };
+
+ SwaggerResource.prototype.addModels = function (models) {
+ if (models != null) {
+ var modelName;
+ for (modelName in models) {
+ if (this.models[modelName] == null) {
+ var swaggerModel = new SwaggerModel(modelName, models[modelName]);
+ this.modelsArray.push(swaggerModel);
+ this.models[modelName] = swaggerModel;
+ this.rawModels[modelName] = models[modelName];
+ }
+ }
+ var output = [];
+ for (var i = 0; i < this.modelsArray.length; i++) {
+ var model = this.modelsArray[i];
+ output.push(model.setReferencedModels(this.models));
+ }
+ return output;
+ }
+ };
+
+ SwaggerResource.prototype.addOperations = function (resource_path, ops, consumes, produces) {
+ if (ops) {
+ var output = [];
+ for (var i = 0; i < ops.length; i++) {
+ var o = ops[i];
+ consumes = this.consumes;
+ produces = this.produces;
+ if (o.consumes != null)
+ consumes = o.consumes;
+ else
+ consumes = this.consumes;
+
+ if (o.produces != null)
+ produces = o.produces;
+ else
+ produces = this.produces;
+ var type = (o.type || o.responseClass);
+
+ if (type === "array") {
+ ref = null;
+ if (o.items)
+ ref = o.items["type"] || o.items["$ref"];
+ type = "array[" + ref + "]";
+ }
+ var responseMessages = o.responseMessages;
+ var method = o.method;
+ if (o.httpMethod) {
+ method = o.httpMethod;
+ }
+ if (o.supportedContentTypes) {
+ consumes = o.supportedContentTypes;
+ }
+ if (o.errorResponses) {
+ responseMessages = o.errorResponses;
+ for (var j = 0; j < responseMessages.length; j++) {
+ r = responseMessages[j];
+ r.message = r.reason;
+ r.reason = null;
+ }
+ }
+ o.nickname = this.sanitize(o.nickname);
+ var op = new SwaggerOperation(o.nickname, resource_path, method, o.parameters, o.summary, o.notes, type, responseMessages, this, consumes, produces, o.authorizations);
+ this.operations[op.nickname] = op;
+ output.push(this.operationsArray.push(op));
+ }
+ return output;
+ }
+ };
+
+ SwaggerResource.prototype.sanitize = function (nickname) {
+ var op;
+ op = nickname.replace(/[\s!@#$%^&*()_+=\[{\]};:<>|.\/?,\\'""-]/g, '_');
+ op = op.replace(/((_){2,})/g, '_');
+ op = op.replace(/^(_)*/g, '');
+ op = op.replace(/([_])*$/g, '');
+ return op;
+ };
+
+ SwaggerResource.prototype.help = function () {
+ var op = this.operations;
+ var output = [];
+ var operation_name;
+ for (operation_name in op) {
+ operation = op[operation_name];
+ var msg = " " + operation.nickname;
+ for (var i = 0; i < operation.parameters; i++) {
+ parameter = operation.parameters[i];
+ msg.concat(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
+ }
+ output.push(msg);
+ }
+ return output;
+ };
+
+ var SwaggerModel = function (modelName, obj) {
+ this.name = obj.id != null ? obj.id : modelName;
+ this.properties = [];
+ var propertyName;
+ for (propertyName in obj.properties) {
+ if (obj.required != null) {
+ var value;
+ for (value in obj.required) {
+ if (propertyName === obj.required[value]) {
+ obj.properties[propertyName].required = true;
+ }
+ }
+ }
+ var prop = new SwaggerModelProperty(propertyName, obj.properties[propertyName]);
+ this.properties.push(prop);
+ }
+ }
+
+ SwaggerModel.prototype.setReferencedModels = function (allModels) {
+ var results = [];
+ for (var i = 0; i < this.properties.length; i++) {
+ var property = this.properties[i];
+ var type = property.type || property.dataType;
+ if (allModels[type] != null)
+ results.push(property.refModel = allModels[type]);
+ else if ((property.refDataType != null) && (allModels[property.refDataType] != null))
+ results.push(property.refModel = allModels[property.refDataType]);
+ else
+ results.push(void 0);
+ }
+ return results;
+ };
+
+ SwaggerModel.prototype.getMockSignature = function (modelsToIgnore) {
+ var propertiesStr = [];
+ for (var i = 0; i < this.properties.length; i++) {
+ var prop = this.properties[i];
+ propertiesStr.push(prop.toString());
+ }
+
+ var strong = '<span class="strong">';
+ var stronger = '<span class="stronger">';
+ var strongClose = '</span>';
+ var classOpen = strong + this.name + ' {' + strongClose;
+ var classClose = strong + '}' + strongClose;
+ var returnVal = classOpen + '<div>' + propertiesStr.join(',</div><div>') + '</div>' + classClose;
+ if (!modelsToIgnore)
+ modelsToIgnore = [];
+ modelsToIgnore.push(this.name);
+
+ for (var i = 0; i < this.properties.length; i++) {
+ var prop = this.properties[i];
+ if ((prop.refModel != null) && modelsToIgnore.indexOf(prop.refModel.name) === -1) {
+ returnVal = returnVal + ('<br>' + prop.refModel.getMockSignature(modelsToIgnore));
+ }
+ }
+ return returnVal;
+ };
+
+ SwaggerModel.prototype.createJSONSample = function (modelsToIgnore) {
+ if (sampleModels[this.name]) {
+ return sampleModels[this.name];
+ }
+ else {
+ var result = {};
+ var modelsToIgnore = (modelsToIgnore || [])
+ modelsToIgnore.push(this.name);
+ for (var i = 0; i < this.properties.length; i++) {
+ var prop = this.properties[i];
+ result[prop.name] = prop.getSampleValue(modelsToIgnore);
+ }
+ modelsToIgnore.pop(this.name);
+ return result;
+ }
+ };
+
+ var SwaggerModelProperty = function (name, obj) {
+ this.name = name;
+ this.dataType = obj.type || obj.dataType || obj["$ref"];
+ this.isCollection = this.dataType && (this.dataType.toLowerCase() === 'array' || this.dataType.toLowerCase() === 'list' || this.dataType.toLowerCase() === 'set');
+ this.descr = obj.description;
+ this.required = obj.required;
+ this.defaultValue = modelPropertyMacro(obj.defaultValue);
+ if (obj.items != null) {
+ if (obj.items.type != null) {
+ this.refDataType = obj.items.type;
+ }
+ if (obj.items.$ref != null) {
+ this.refDataType = obj.items.$ref;
+ }
+ }
+ this.dataTypeWithRef = this.refDataType != null ? (this.dataType + '[' + this.refDataType + ']') : this.dataType;
+ if (obj.allowableValues != null) {
+ this.valueType = obj.allowableValues.valueType;
+ this.values = obj.allowableValues.values;
+ if (this.values != null) {
+ this.valuesString = "'" + this.values.join("' or '") + "'";
+ }
+ }
+ if (obj["enum"] != null) {
+ this.valueType = "string";
+ this.values = obj["enum"];
+ if (this.values != null) {
+ this.valueString = "'" + this.values.join("' or '") + "'";
+ }
+ }
+ }
+
+ SwaggerModelProperty.prototype.getSampleValue = function (modelsToIgnore) {
+ var result;
+ if ((this.refModel != null) && (modelsToIgnore.indexOf(this.refModel.name) === -1)) {
+ result = this.refModel.createJSONSample(modelsToIgnore);
+ } else {
+ if (this.isCollection) {
+ result = this.toSampleValue(this.refDataType);
+ } else {
+ result = this.toSampleValue(this.dataType);
+ }
+ }
+ if (this.isCollection) {
+ return [result];
+ } else {
+ return result;
+ }
+ };
+
+ SwaggerModelProperty.prototype.toSampleValue = function (value) {
+ var result;
+ if ((typeof this.defaultValue !== 'undefined') && this.defaultValue !== null) {
+ result = this.defaultValue;
+ } else if (value === "integer") {
+ result = 0;
+ } else if (value === "boolean") {
+ result = false;
+ } else if (value === "double" || value === "number") {
+ result = 0.0;
+ } else if (value === "string") {
+ result = "";
+ } else {
+ result = value;
+ }
+ return result;
+ };
+
+ SwaggerModelProperty.prototype.toString = function () {
+ var req = this.required ? 'propReq' : 'propOpt';
+ var str = '<span class="propName ' + req + '">' + this.name + '</span> (<span class="propType">' + this.dataTypeWithRef + '</span>';
+ if (!this.required) {
+ str += ', <span class="propOptKey">optional</span>';
+ }
+ str += ')';
+ if (this.values != null) {
+ str += " = <span class='propVals'>['" + this.values.join("' or '") + "']</span>";
+ }
+ if (this.descr != null) {
+ str += ': <span class="propDesc">' + this.descr + '</span>';
+ }
+ return str;
+ };
+
+ var SwaggerOperation = function (nickname, path, method, parameters, summary, notes, type, responseMessages, resource, consumes, produces, authorizations) {
+ var _this = this;
+
+ var errors = [];
+ this.nickname = (nickname || errors.push("SwaggerOperations must have a nickname."));
+ this.path = (path || errors.push("SwaggerOperation " + nickname + " is missing path."));
+ this.method = (method || errors.push("SwaggerOperation " + nickname + " is missing method."));
+ this.parameters = parameters != null ? parameters : [];
+ this.summary = summary;
+ this.notes = notes;
+ this.type = type;
+ this.responseMessages = (responseMessages || []);
+ this.resource = (resource || errors.push("Resource is required"));
+ this.consumes = consumes;
+ this.produces = produces;
+ this.authorizations = authorizations;
+ this["do"] = __bind(this["do"], this);
+
+ if (errors.length > 0) {
+ console.error('SwaggerOperation errors', errors, arguments);
+ this.resource.api.fail(errors);
+ }
+
+ this.path = this.path.replace('{format}', 'json');
+ this.method = this.method.toLowerCase();
+ this.isGetMethod = this.method === "get";
+
+ this.resourceName = this.resource.name;
+ if (typeof this.type !== 'undefined' && this.type === 'void')
+ this.type = null;
+ else {
+ this.responseClassSignature = this.getSignature(this.type, this.resource.models);
+ this.responseSampleJSON = this.getSampleJSON(this.type, this.resource.models);
+ }
+
+ for (var i = 0; i < this.parameters.length; i++) {
+ var param = this.parameters[i];
+ // might take this away
+ param.name = param.name || param.type || param.dataType;
+
+ // for 1.1 compatibility
+ var type = param.type || param.dataType;
+ if (type === 'array') {
+ type = 'array[' + (param.items.$ref ? param.items.$ref : param.items.type) + ']';
+ }
+ param.type = type;
+
+ if (type.toLowerCase() === 'boolean') {
+ param.allowableValues = {};
+ param.allowableValues.values = ["true", "false"];
+ }
+ param.signature = this.getSignature(type, this.resource.models);
+ param.sampleJSON = this.getSampleJSON(type, this.resource.models);
+
+ var enumValue = param["enum"];
+ if (enumValue != null) {
+ param.isList = true;
+ param.allowableValues = {};
+ param.allowableValues.descriptiveValues = [];
+
+ for (var j = 0; j < enumValue.length; j++) {
+ var v = enumValue[j];
+ if (param.defaultValue != null) {
+ param.allowableValues.descriptiveValues.push({
+ value: String(v),
+ isDefault: (v === param.defaultValue)
+ });
+ }
+ else {
+ param.allowableValues.descriptiveValues.push({
+ value: String(v),
+ isDefault: false
+ });
+ }
+ }
+ }
+ else if (param.allowableValues != null) {
+ if (param.allowableValues.valueType === "RANGE")
+ param.isRange = true;
+ else
+ param.isList = true;
+ if (param.allowableValues != null) {
+ param.allowableValues.descriptiveValues = [];
+ if (param.allowableValues.values) {
+ for (var j = 0; j < param.allowableValues.values.length; j++) {
+ var v = param.allowableValues.values[j];
+ if (param.defaultValue != null) {
+ param.allowableValues.descriptiveValues.push({
+ value: String(v),
+ isDefault: (v === param.defaultValue)
+ });
+ }
+ else {
+ param.allowableValues.descriptiveValues.push({
+ value: String(v),
+ isDefault: false
+ });
+ }
+ }
+ }
+ }
+ }
+ param.defaultValue = parameterMacro(param.defaultValue);
+ }
+ this.resource[this.nickname] = function (args, callback, error) {
+ return _this["do"](args, callback, error);
+ };
+ this.resource[this.nickname].help = function () {
+ return _this.help();
+ };
+ }
+
+ SwaggerOperation.prototype.isListType = function (type) {
+ if (type && type.indexOf('[') >= 0) {
+ return type.substring(type.indexOf('[') + 1, type.indexOf(']'));
+ } else {
+ return void 0;
+ }
+ };
+
+ SwaggerOperation.prototype.getSignature = function (type, models) {
+ var isPrimitive, listType;
+ listType = this.isListType(type);
+ isPrimitive = ((listType != null) && models[listType]) || (models[type] != null) ? false : true;
+ if (isPrimitive) {
+ return type;
+ } else {
+ if (listType != null) {
+ return models[listType].getMockSignature();
+ } else {
+ return models[type].getMockSignature();
+ }
+ }
+ };
+
+ SwaggerOperation.prototype.getSampleJSON = function (type, models) {
+ var isPrimitive, listType, val;
+ listType = this.isListType(type);
+ isPrimitive = ((listType != null) && models[listType]) || (models[type] != null) ? false : true;
+ val = isPrimitive ? void 0 : (listType != null ? models[listType].createJSONSample() : models[type].createJSONSample());
+ if (val) {
+ val = listType ? [val] : val;
+ if (typeof val == "string")
+ return val;
+ else if (typeof val === "object") {
+ var t = val;
+ if (val instanceof Array && val.length > 0) {
+ t = val[0];
+ }
+ if (t.nodeName) {
+ var xmlString = new XMLSerializer().serializeToString(t);
+ return this.formatXml(xmlString);
+ }
+ else
+ return JSON.stringify(val, null, 2);
+ }
+ else
+ return val;
+ }
+ };
+
+ SwaggerOperation.prototype["do"] = function (args, opts, callback, error) {
+ var key, param, params, possibleParams, req, requestContentType, responseContentType, value, _i, _len, _ref;
+ if (args == null) {
+ args = {};
+ }
+ if (opts == null) {
+ opts = {};
+ }
+ requestContentType = null;
+ responseContentType = null;
+ if ((typeof args) === "function") {
+ error = opts;
+ callback = args;
+ args = {};
+ }
+ if ((typeof opts) === "function") {
+ error = callback;
+ callback = opts;
+ }
+ if (error == null) {
+ error = function (xhr, textStatus, error) {
+ return log(xhr, textStatus, error);
+ };
+ }
+ if (callback == null) {
+ callback = function (response) {
+ var content;
+ content = null;
+ if (response != null) {
+ content = response.data;
+ } else {
+ content = "no data";
+ }
+ return log("default callback: " + content);
+ };
+ }
+ params = {};
+ params.headers = [];
+ if (args.headers != null) {
+ params.headers = args.headers;
+ delete args.headers;
+ }
+
+ var possibleParams = [];
+ for (var i = 0; i < this.parameters.length; i++) {
+ var param = this.parameters[i];
+ if (param.paramType === 'header') {
+ if (args[param.name])
+ params.headers[param.name] = args[param.name];
+ }
+ else if (param.paramType === 'form' || param.paramType.toLowerCase() === 'file')
+ possibleParams.push(param);
+ }
+
+ if (args.body != null) {
+ params.body = args.body;
+ delete args.body;
+ }
+
+ if (possibleParams) {
+ var key;
+ for (key in possibleParams) {
+ var value = possibleParams[key];
+ if (args[value.name]) {
+ params[value.name] = args[value.name];
+ }
+ }
+ }
+
+ req = new SwaggerRequest(this.method, this.urlify(args), params, opts, callback, error, this);
+ if (opts.mock != null) {
+ return req;
+ } else {
+ return true;
+ }
+ };
+
+ SwaggerOperation.prototype.pathJson = function () {
+ return this.path.replace("{format}", "json");
+ };
+
+ SwaggerOperation.prototype.pathXml = function () {
+ return this.path.replace("{format}", "xml");
+ };
+
+ SwaggerOperation.prototype.encodePathParam = function (pathParam) {
+ var encParts, part, parts, _i, _len;
+ pathParam = pathParam.toString();
+ if (pathParam.indexOf("/") === -1) {
+ return encodeURIComponent(pathParam);
+ } else {
+ parts = pathParam.split("/");
+ encParts = [];
+ for (_i = 0, _len = parts.length; _i < _len; _i++) {
+ part = parts[_i];
+ encParts.push(encodeURIComponent(part));
+ }
+ return encParts.join("/");
+ }
+ };
+
+ SwaggerOperation.prototype.urlify = function (args) {
+ var url = this.resource.basePath + this.pathJson();
+ var params = this.parameters;
+ for (var i = 0; i < params.length; i++) {
+ var param = params[i];
+ if (param.paramType === 'path') {
+ if (args[param.name]) {
+ // apply path params and remove from args
+ var reg = new RegExp('\\{\\s*?' + param.name + '.*?\\}(?=\\s*?(\\/|$))', 'gi');
+ url = url.replace(reg, this.encodePathParam(args[param.name]));
+ delete args[param.name];
+ }
+ else
+ throw "" + param.name + " is a required path param.";
+ }
+ }
+
+ var queryParams = "";
+ for (var i = 0; i < params.length; i++) {
+ var param = params[i];
+ if (param.paramType === 'query') {
+ if (args[param.name] !== undefined) {
+ if (queryParams !== '')
+ queryParams += "&";
+ queryParams += encodeURIComponent(param.name) + '=' + encodeURIComponent(args[param.name]);
+ }
+ }
+ }
+ if ((queryParams != null) && queryParams.length > 0)
+ url += '?' + queryParams;
+ return url;
+ };
+
+ SwaggerOperation.prototype.supportHeaderParams = function () {
+ return this.resource.api.supportHeaderParams;
+ };
+
+ SwaggerOperation.prototype.supportedSubmitMethods = function () {
+ return this.resource.api.supportedSubmitMethods;
+ };
+
+ SwaggerOperation.prototype.getQueryParams = function (args) {
+ return this.getMatchingParams(['query'], args);
+ };
+
+ SwaggerOperation.prototype.getHeaderParams = function (args) {
+ return this.getMatchingParams(['header'], args);
+ };
+
+ SwaggerOperation.prototype.getMatchingParams = function (paramTypes, args) {
+ var matchingParams = {};
+ var params = this.parameters;
+ for (var i = 0; i < params.length; i++) {
+ param = params[i];
+ if (args && args[param.name])
+ matchingParams[param.name] = args[param.name];
+ }
+ var headers = this.resource.api.headers;
+ var name;
+ for (name in headers) {
+ var value = headers[name];
+ matchingParams[name] = value;
+ }
+ return matchingParams;
+ };
+
+ SwaggerOperation.prototype.help = function () {
+ var msg = "";
+ var params = this.parameters;
+ for (var i = 0; i < params.length; i++) {
+ var param = params[i];
+ if (msg !== "")
+ msg += "\n";
+ msg += "* " + param.name + (param.required ? ' (required)' : '') + " - " + param.description;
+ }
+ return msg;
+ };
+
+
+ SwaggerOperation.prototype.formatXml = function (xml) {
+ var contexp, formatted, indent, lastType, lines, ln, pad, reg, transitions, wsexp, _fn, _i, _len;
+ reg = /(>)(<)(\/*)/g;
+ wsexp = /[ ]*(.*)[ ]+\n/g;
+ contexp = /(<.+>)(.+\n)/g;
+ xml = xml.replace(reg, '$1\n$2$3').replace(wsexp, '$1\n').replace(contexp, '$1\n$2');
+ pad = 0;
+ formatted = '';
+ lines = xml.split('\n');
+ indent = 0;
+ lastType = 'other';
+ transitions = {
+ 'single->single': 0,
+ 'single->closing': -1,
+ 'single->opening': 0,
+ 'single->other': 0,
+ 'closing->single': 0,
+ 'closing->closing': -1,
+ 'closing->opening': 0,
+ 'closing->other': 0,
+ 'opening->single': 1,
+ 'opening->closing': 0,
+ 'opening->opening': 1,
+ 'opening->other': 1,
+ 'other->single': 0,
+ 'other->closing': -1,
+ 'other->opening': 0,
+ 'other->other': 0
+ };
+ _fn = function (ln) {
+ var fromTo, j, key, padding, type, types, value;
+ types = {
+ single: Boolean(ln.match(/<.+\/>/)),
+ closing: Boolean(ln.match(/<\/.+>/)),
+ opening: Boolean(ln.match(/<[^!?].*>/))
+ };
+ type = ((function () {
+ var _results;
+ _results = [];
+ for (key in types) {
+ value = types[key];
+ if (value) {
+ _results.push(key);
+ }
+ }
+ return _results;
+ })())[0];
+ type = type === void 0 ? 'other' : type;
+ fromTo = lastType + '->' + type;
+ lastType = type;
+ padding = '';
+ indent += transitions[fromTo];
+ padding = ((function () {
+ var _j, _ref5, _results;
+ _results = [];
+ for (j = _j = 0, _ref5 = indent; 0 <= _ref5 ? _j < _ref5 : _j > _ref5; j = 0 <= _ref5 ? ++_j : --_j) {
+ _results.push(' ');
+ }
+ return _results;
+ })()).join('');
+ if (fromTo === 'opening->closing') {
+ return formatted = formatted.substr(0, formatted.length - 1) + ln + '\n';
+ } else {
+ return formatted += padding + ln + '\n';
+ }
+ };
+ for (_i = 0, _len = lines.length; _i < _len; _i++) {
+ ln = lines[_i];
+ _fn(ln);
+ }
+ return formatted;
+ };
+
+ var SwaggerRequest = function (type, url, params, opts, successCallback, errorCallback, operation, execution) {
+ var _this = this;
+ var errors = [];
+ this.useJQuery = (typeof operation.resource.useJQuery !== 'undefined' ? operation.resource.useJQuery : null);
+ this.type = (type || errors.push("SwaggerRequest type is required (get/post/put/delete/patch/options)."));
+ this.url = (url || errors.push("SwaggerRequest url is required."));
+ this.params = params;
+ this.opts = opts;
+ this.successCallback = (successCallback || errors.push("SwaggerRequest successCallback is required."));
+ this.errorCallback = (errorCallback || errors.push("SwaggerRequest error callback is required."));
+ this.operation = (operation || errors.push("SwaggerRequest operation is required."));
+ this.execution = execution;
+ this.headers = (params.headers || {});
+
+ if (errors.length > 0) {
+ throw errors;
+ }
+
+ this.type = this.type.toUpperCase();
+
+ // set request, response content type headers
+ var headers = this.setHeaders(params, this.operation);
+ var body = params.body;
+
+ // encode the body for form submits
+ if (headers["Content-Type"]) {
+ var values = {};
+ var i;
+ var operationParams = this.operation.parameters;
+ for (i = 0; i < operationParams.length; i++) {
+ var param = operationParams[i];
+ if (param.paramType === "form")
+ values[param.name] = param;
+ }
+
+ if (headers["Content-Type"].indexOf("application/x-www-form-urlencoded") === 0) {
+ var encoded = "";
+ var key, value;
+ for (key in values) {
+ value = this.params[key];
+ if (typeof value !== 'undefined') {
+ if (encoded !== "")
+ encoded += "&";
+ encoded += encodeURIComponent(key) + '=' + encodeURIComponent(value);
+ }
+ }
+ body = encoded;
+ }
+ else if (headers["Content-Type"].indexOf("multipart/form-data") === 0) {
+ // encode the body for form submits
+ var data = "";
+ var boundary = "----SwaggerFormBoundary" + Date.now();
+ var key, value;
+ for (key in values) {
+ value = this.params[key];
+ if (typeof value !== 'undefined') {
+ data += '--' + boundary + '\n';
+ data += 'Content-Disposition: form-data; name="' + key + '"';
+ data += '\n\n';
+ data += value + "\n";
+ }
+ }
+ data += "--" + boundary + "--\n";
+ headers["Content-Type"] = "multipart/form-data; boundary=" + boundary;
+ body = data;
+ }
+ }
+
+ var obj;
+ if (!((this.headers != null) && (this.headers.mock != null))) {
+ obj = {
+ url: this.url,
+ method: this.type,
+ headers: headers,
+ body: body,
+ useJQuery: this.useJQuery,
+ on: {
+ error: function (response) {
+ return _this.errorCallback(response, _this.opts.parent);
+ },
+ redirect: function (response) {
+ return _this.successCallback(response, _this.opts.parent);
+ },
+ 307: function (response) {
+ return _this.successCallback(response, _this.opts.parent);
+ },
+ response: function (response) {
+ return _this.successCallback(response, _this.opts.parent);
+ }
+ }
+ };
+ var e;
+ if (typeof window !== 'undefined') {
+ e = window;
+ } else {
+ e = exports;
+ }
+ var status = e.authorizations.apply(obj, this.operation.authorizations);
+ if (opts.mock == null) {
+ if (status !== false) {
+ new SwaggerHttp().execute(obj);
+ } else {
+ obj.canceled = true;
+ }
+ } else {
+ return obj;
+ }
+ }
+ return obj;
+ };
+
+ SwaggerRequest.prototype.setHeaders = function (params, operation) {
+ // default type
+ var accepts = "application/json";
+ var consumes = "application/json";
+
+ var allDefinedParams = this.operation.parameters;
+ var definedFormParams = [];
+ var definedFileParams = [];
+ var body = params.body;
+ var headers = {};
+
+ // get params from the operation and set them in definedFileParams, definedFormParams, headers
+ var i;
+ for (i = 0; i < allDefinedParams.length; i++) {
+ var param = allDefinedParams[i];
+ if (param.paramType === "form")
+ definedFormParams.push(param);
+ else if (param.paramType === "file")
+ definedFileParams.push(param);
+ else if (param.paramType === "header" && this.params.headers) {
+ var key = param.name;
+ var headerValue = this.params.headers[param.name];
+ if (typeof this.params.headers[param.name] !== 'undefined')
+ headers[key] = headerValue;
+ }
+ }
+
+ // if there's a body, need to set the accepts header via requestContentType
+ if (body && (this.type === "POST" || this.type === "PUT" || this.type === "PATCH" || this.type === "DELETE")) {
+ if (this.opts.requestContentType)
+ consumes = this.opts.requestContentType;
+ } else {
+ // if any form params, content type must be set
+ if (definedFormParams.length > 0) {
+ if (definedFileParams.length > 0)
+ consumes = "multipart/form-data";
+ else
+ consumes = "application/x-www-form-urlencoded";
+ }
+ else if (this.type === "DELETE")
+ body = "{}";
+ else if (this.type != "DELETE")
+ accepts = null;
+ }
+
+ if (consumes && this.operation.consumes) {
+ if (this.operation.consumes.indexOf(consumes) === -1) {
+ log("server doesn't consume " + consumes + ", try " + JSON.stringify(this.operation.consumes));
+ consumes = this.operation.consumes[0];
+ }
+ }
+
+ if (this.opts.responseContentType) {
+ accepts = this.opts.responseContentType;
+ } else {
+ accepts = "application/json";
+ }
+ if (accepts && this.operation.produces) {
+ if (this.operation.produces.indexOf(accepts) === -1) {
+ log("server can't produce " + accepts);
+ accepts = this.operation.produces[0];
+ }
+ }
+
+ if ((consumes && body !== "") || (consumes === "application/x-www-form-urlencoded"))
+ headers["Content-Type"] = consumes;
+ if (accepts)
+ headers["Accept"] = accepts;
+ return headers;
+ }
+
+ SwaggerRequest.prototype.asCurl = function () {
+ var results = [];
+ if (this.headers) {
+ var key;
+ for (key in this.headers) {
+ results.push("--header \"" + key + ": " + this.headers[v] + "\"");
+ }
+ }
+ return "curl " + (results.join(" ")) + " " + this.url;
+ };
+
+ /**
+ * SwaggerHttp is a wrapper for executing requests
+ */
+ var SwaggerHttp = function () { };
+
+ SwaggerHttp.prototype.execute = function (obj) {
+ if (obj && (typeof obj.useJQuery === 'boolean'))
+ this.useJQuery = obj.useJQuery;
+ else
+ this.useJQuery = this.isIE8();
+
+ if (this.useJQuery)
+ return new JQueryHttpClient().execute(obj);
+ else
+ return new ShredHttpClient().execute(obj);
+ }
+
+ SwaggerHttp.prototype.isIE8 = function () {
+ var detectedIE = false;
+ if (typeof navigator !== 'undefined' && navigator.userAgent) {
+ nav = navigator.userAgent.toLowerCase();
+ if (nav.indexOf('msie') !== -1) {
+ var version = parseInt(nav.split('msie')[1]);
+ if (version <= 8) {
+ detectedIE = true;
+ }
+ }
+ }
+ return detectedIE;
+ };
+
+ /*
+ * JQueryHttpClient lets a browser take advantage of JQuery's cross-browser magic.
+ * NOTE: when jQuery is available it will export both '$' and 'jQuery' to the global space.
+ * Since we are using closures here we need to alias it for internal use.
+ */
+ var JQueryHttpClient = function (options) {
+ "use strict";
+ if (!jQuery) {
+ var jQuery = window.jQuery;
+ }
+ }
+
+ JQueryHttpClient.prototype.execute = function (obj) {
+ var cb = obj.on;
+ var request = obj;
+
+ obj.type = obj.method;
+ obj.cache = false;
+
+ obj.beforeSend = function (xhr) {
+ var key, results;
+ if (obj.headers) {
+ results = [];
+ var key;
+ for (key in obj.headers) {
+ if (key.toLowerCase() === "content-type") {
+ results.push(obj.contentType = obj.headers[key]);
+ } else if (key.toLowerCase() === "accept") {
+ results.push(obj.accepts = obj.headers[key]);
+ } else {
+ results.push(xhr.setRequestHeader(key, obj.headers[key]));
+ }
+ }
+ return results;
+ }
+ };
+
+ obj.data = obj.body;
+ obj.complete = function (response, textStatus, opts) {
+ var headers = {},
+ headerArray = response.getAllResponseHeaders().split("\n");
+
+ for (var i = 0; i < headerArray.length; i++) {
+ var toSplit = headerArray[i].trim();
+ if (toSplit.length === 0)
+ continue;
+ var separator = toSplit.indexOf(":");
+ if (separator === -1) {
+ // Name but no value in the header
+ headers[toSplit] = null;
+ continue;
+ }
+ var name = toSplit.substring(0, separator).trim(),
+ value = toSplit.substring(separator + 1).trim();
+ headers[name] = value;
+ }
+
+ var out = {
+ url: request.url,
+ method: request.method,
+ status: response.status,
+ data: response.responseText,
+ headers: headers
+ };
+
+ var contentType = (headers["content-type"] || headers["Content-Type"] || null)
+
+ if (contentType != null) {
+ if (contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) {
+ if (response.responseText && response.responseText !== "")
+ out.obj = JSON.parse(response.responseText);
+ else
+ out.obj = {}
+ }
+ }
+
+ if (response.status >= 200 && response.status < 300)
+ cb.response(out);
+ else if (response.status === 0 || (response.status >= 400 && response.status < 599))
+ cb.error(out);
+ else
+ return cb.response(out);
+ };
+
+ jQuery.support.cors = true;
+ return jQuery.ajax(obj);
+ }
+
+ /*
+ * ShredHttpClient is a light-weight, node or browser HTTP client
+ */
+ var ShredHttpClient = function (options) {
+ this.options = (options || {});
+ this.isInitialized = false;
+
+ var identity, toString;
+
+ if (typeof window !== 'undefined') {
+ this.Shred = require("./shred");
+ this.content = require("./shred/content");
+ }
+ else
+ this.Shred = require("shred");
+ this.shred = new this.Shred();
+ }
+
+ ShredHttpClient.prototype.initShred = function () {
+ this.isInitialized = true;
+ this.registerProcessors(this.shred);
+ }
+
+ ShredHttpClient.prototype.registerProcessors = function (shred) {
+ var identity = function (x) {
+ return x;
+ };
+ var toString = function (x) {
+ return x.toString();
+ };
+
+ if (typeof window !== 'undefined') {
+ this.content.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
+ parser: identity,
+ stringify: toString
+ });
+ } else {
+ this.Shred.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
+ parser: identity,
+ stringify: toString
+ });
+ }
+ }
+
+ ShredHttpClient.prototype.execute = function (obj) {
+ if (!this.isInitialized)
+ this.initShred();
+
+ var cb = obj.on, res;
+
+ var transform = function (response) {
+ var out = {
+ headers: response._headers,
+ url: response.request.url,
+ method: response.request.method,
+ status: response.status,
+ data: response.content.data
+ };
+
+ var contentType = (response._headers["content-type"] || response._headers["Content-Type"] || null)
+
+ if (contentType != null) {
+ if (contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) {
+ if (response.content.data && response.content.data !== "")
+ out.obj = JSON.parse(response.content.data);
+ else
+ out.obj = {}
+ }
+ }
+ return out;
+ };
+
+ // Transform an error into a usable response-like object
+ var transformError = function (error) {
+ var out = {
+ // Default to a status of 0 - The client will treat this as a generic permissions sort of error
+ status: 0,
+ data: error.message || error
+ };
+
+ if (error.code) {
+ out.obj = error;
+
+ if (error.code === 'ENOTFOUND' || error.code === 'ECONNREFUSED') {
+ // We can tell the client that this should be treated as a missing resource and not as a permissions thing
+ out.status = 404;
+ }
+ }
+
+ return out;
+ };
+
+ var res = {
+ error: function (response) {
+ if (obj)
+ return cb.error(transform(response));
+ },
+ // Catch the Shred error raised when the request errors as it is made (i.e. No Response is coming)
+ request_error: function (err) {
+ if (obj)
+ return cb.error(transformError(err));
+ },
+ redirect: function (response) {
+ if (obj)
+ return cb.redirect(transform(response));
+ },
+ 307: function (response) {
+ if (obj)
+ return cb.redirect(transform(response));
+ },
+ response: function (response) {
+ if (obj)
+ return cb.response(transform(response));
+ }
+ };
+ if (obj) {
+ obj.on = res;
+ }
+ return this.shred.request(obj);
+ };
+
+ /**
+ * SwaggerAuthorizations applys the correct authorization to an operation being executed
+ */
+ var SwaggerAuthorizations = function () {
+ this.authz = {};
+ };
+
+ SwaggerAuthorizations.prototype.add = function (name, auth) {
+ this.authz[name] = auth;
+ return auth;
+ };
+
+ SwaggerAuthorizations.prototype.remove = function (name) {
+ return delete this.authz[name];
+ };
+
+ SwaggerAuthorizations.prototype.apply = function (obj, authorizations) {
+ var status = null;
+ var key, value, result;
+
+ // if the "authorizations" key is undefined, or has an empty array, add all keys
+ if (typeof authorizations === 'undefined' || Object.keys(authorizations).length == 0) {
+ for (key in this.authz) {
+ value = this.authz[key];
+ result = value.apply(obj, authorizations);
+ if (result === true)
+ status = true;
+ }
+ }
+ else {
+ for (name in authorizations) {
+ for (key in this.authz) {
+ if (key == name) {
+ value = this.authz[key];
+ result = value.apply(obj, authorizations);
+ if (result === true)
+ status = true;
+ }
+ }
+ }
+ }
+
+ return status;
+ };
+
+ /**
+ * ApiKeyAuthorization allows a query param or header to be injected
+ */
+ var ApiKeyAuthorization = function (name, value, type, delimiter) {
+ this.name = name;
+ this.value = value;
+ this.type = type;
+ this.delimiter = delimiter;
+ };
+
+ ApiKeyAuthorization.prototype.apply = function (obj, authorizations) {
+ if (this.type === "query") {
+ if (obj.url.indexOf('?') > 0)
+ obj.url = obj.url + "&" + this.name + "=" + this.value;
+ else
+ obj.url = obj.url + "?" + this.name + "=" + this.value;
+ return true;
+ } else if (this.type === "header") {
+ if (typeof obj.headers[this.name] !== 'undefined') {
+ if (typeof this.delimiter !== 'undefined')
+ obj.headers[this.name] = obj.headers[this.name] + this.delimiter + this.value;
+ }
+ else
+ obj.headers[this.name] = this.value;
+ return true;
+ }
+ };
+
+ var CookieAuthorization = function (cookie) {
+ this.cookie = cookie;
+ }
+
+ CookieAuthorization.prototype.apply = function (obj, authorizations) {
+ obj.cookieJar = obj.cookieJar || CookieJar();
+ obj.cookieJar.setCookie(this.cookie);
+ return true;
+ }
+
+ /**
+ * Password Authorization is a basic auth implementation
+ */
+ var PasswordAuthorization = function (name, username, password) {
+ this.name = name;
+ this.username = username;
+ this.password = password;
+ this._btoa = null;
+ if (typeof window !== 'undefined')
+ this._btoa = btoa;
+ else
+ this._btoa = require("btoa");
+ };
+
+ PasswordAuthorization.prototype.apply = function (obj, authorizations) {
+ var base64encoder = this._btoa;
+ obj.headers["Authorization"] = "Basic " + base64encoder(this.username + ":" + this.password);
+ return true;
+ };
+
+ var e = (typeof window !== 'undefined' ? window : exports);
+
+ var sampleModels = {};
+ var cookies = {};
+
+ e.SampleModels = sampleModels;
+ e.SwaggerHttp = SwaggerHttp;
+ e.SwaggerRequest = SwaggerRequest;
+ e.authorizations = new SwaggerAuthorizations();
+ e.ApiKeyAuthorization = ApiKeyAuthorization;
+ e.PasswordAuthorization = PasswordAuthorization;
+ e.CookieAuthorization = CookieAuthorization;
+ e.JQueryHttpClient = JQueryHttpClient;
+ e.ShredHttpClient = ShredHttpClient;
+ e.SwaggerOperation = SwaggerOperation;
+ e.SwaggerModel = SwaggerModel;
+ e.SwaggerModelProperty = SwaggerModelProperty;
+ e.SwaggerResource = SwaggerResource;
+ e.SwaggerApi = SwaggerApi;
+ e.log = log;
+
+})();
profiles/killpay/src/main/webapp/lib/swagger-client.js 1382(+1382 -0)
diff --git a/profiles/killpay/src/main/webapp/lib/swagger-client.js b/profiles/killpay/src/main/webapp/lib/swagger-client.js
new file mode 100644
index 0000000..6bb8031
--- /dev/null
+++ b/profiles/killpay/src/main/webapp/lib/swagger-client.js
@@ -0,0 +1,1382 @@
+// swagger-client.js
+// version 2.1.0
+
+/**
+ * SwaggerAuthorizations applys the correct authorization to an operation being executed
+ */
+var SwaggerAuthorizations = function() {
+ this.authz = {};
+};
+
+SwaggerAuthorizations.prototype.add = function(name, auth) {
+ this.authz[name] = auth;
+ return auth;
+};
+
+SwaggerAuthorizations.prototype.remove = function(name) {
+ return delete this.authz[name];
+};
+
+SwaggerAuthorizations.prototype.apply = function(obj, authorizations) {
+ var status = null;
+ var key;
+
+ // if the "authorizations" key is undefined, or has an empty array, add all keys
+ if(typeof authorizations === 'undefined' || Object.keys(authorizations).length == 0) {
+ for (key in this.authz) {
+ value = this.authz[key];
+ result = value.apply(obj, authorizations);
+ if (result === true)
+ status = true;
+ }
+ }
+ else {
+ for(name in authorizations) {
+ for (key in this.authz) {
+ if(key == name) {
+ value = this.authz[key];
+ result = value.apply(obj, authorizations);
+ if (result === true)
+ status = true;
+ }
+ }
+ }
+ }
+
+ return status;
+};
+
+/**
+ * ApiKeyAuthorization allows a query param or header to be injected
+ */
+var ApiKeyAuthorization = function(name, value, type) {
+ this.name = name;
+ this.value = value;
+ this.type = type;
+};
+
+ApiKeyAuthorization.prototype.apply = function(obj, authorizations) {
+ if (this.type === "query") {
+ if (obj.url.indexOf('?') > 0)
+ obj.url = obj.url + "&" + this.name + "=" + this.value;
+ else
+ obj.url = obj.url + "?" + this.name + "=" + this.value;
+ return true;
+ } else if (this.type === "header") {
+ obj.headers[this.name] = this.value;
+ return true;
+ }
+};
+
+var CookieAuthorization = function(cookie) {
+ this.cookie = cookie;
+}
+
+CookieAuthorization.prototype.apply = function(obj, authorizations) {
+ obj.cookieJar = obj.cookieJar || CookieJar();
+ obj.cookieJar.setCookie(this.cookie);
+ return true;
+}
+
+/**
+ * Password Authorization is a basic auth implementation
+ */
+var PasswordAuthorization = function(name, username, password) {
+ this.name = name;
+ this.username = username;
+ this.password = password;
+ this._btoa = null;
+ if (typeof window !== 'undefined')
+ this._btoa = btoa;
+ else
+ this._btoa = require("btoa");
+};
+
+PasswordAuthorization.prototype.apply = function(obj, authorizations) {
+ var base64encoder = this._btoa;
+ obj.headers["Authorization"] = "Basic " + base64encoder(this.username + ":" + this.password);
+ return true;
+};var __bind = function(fn, me){
+ return function(){
+ return fn.apply(me, arguments);
+ };
+};
+
+fail = function(message) {
+ log(message);
+}
+
+log = function(){
+ log.history = log.history || [];
+ log.history.push(arguments);
+ if(this.console){
+ console.log( Array.prototype.slice.call(arguments)[0] );
+ }
+};
+
+if (!Array.prototype.indexOf) {
+ Array.prototype.indexOf = function(obj, start) {
+ for (var i = (start || 0), j = this.length; i < j; i++) {
+ if (this[i] === obj) { return i; }
+ }
+ return -1;
+ }
+}
+
+if (!('filter' in Array.prototype)) {
+ Array.prototype.filter= function(filter, that /*opt*/) {
+ var other= [], v;
+ for (var i=0, n= this.length; i<n; i++)
+ if (i in this && filter.call(that, v= this[i], i, this))
+ other.push(v);
+ return other;
+ };
+}
+
+if (!('map' in Array.prototype)) {
+ Array.prototype.map= function(mapper, that /*opt*/) {
+ var other= new Array(this.length);
+ for (var i= 0, n= this.length; i<n; i++)
+ if (i in this)
+ other[i]= mapper.call(that, this[i], i, this);
+ return other;
+ };
+}
+
+Object.keys = Object.keys || (function () {
+ var hasOwnProperty = Object.prototype.hasOwnProperty,
+ hasDontEnumBug = !{toString:null}.propertyIsEnumerable("toString"),
+ DontEnums = [
+ 'toString',
+ 'toLocaleString',
+ 'valueOf',
+ 'hasOwnProperty',
+ 'isPrototypeOf',
+ 'propertyIsEnumerable',
+ 'constructor'
+ ],
+ DontEnumsLength = DontEnums.length;
+
+ return function (o) {
+ if (typeof o != "object" && typeof o != "function" || o === null)
+ throw new TypeError("Object.keys called on a non-object");
+
+ var result = [];
+ for (var name in o) {
+ if (hasOwnProperty.call(o, name))
+ result.push(name);
+ }
+
+ if (hasDontEnumBug) {
+ for (var i = 0; i < DontEnumsLength; i++) {
+ if (hasOwnProperty.call(o, DontEnums[i]))
+ result.push(DontEnums[i]);
+ }
+ }
+
+ return result;
+ };
+})();
+var SwaggerClient = function(url, options) {
+ this.isBuilt = false;
+ this.url = null;
+ this.debug = false;
+ this.basePath = null;
+ this.authorizations = null;
+ this.authorizationScheme = null;
+ this.isValid = false;
+ this.info = null;
+ this.useJQuery = false;
+ this.models = models;
+
+ options = (options||{});
+ if (url)
+ if (url.url) options = url;
+ else this.url = url;
+ else options = url;
+
+ if (options.url != null)
+ this.url = options.url;
+
+ if (options.success != null)
+ this.success = options.success;
+
+ if (typeof options.useJQuery === 'boolean')
+ this.useJQuery = options.useJQuery;
+
+ this.failure = options.failure != null ? options.failure : function() {};
+ this.progress = options.progress != null ? options.progress : function() {};
+ this.spec = options.spec;
+
+ if (options.success != null)
+ this.build();
+}
+
+SwaggerClient.prototype.build = function() {
+ var self = this;
+ this.progress('fetching resource list: ' + this.url);
+ var obj = {
+ useJQuery: this.useJQuery,
+ url: this.url,
+ method: "get",
+ headers: {
+ accept: "application/json, */*"
+ },
+ on: {
+ error: function(response) {
+ if (self.url.substring(0, 4) !== 'http')
+ return self.fail('Please specify the protocol for ' + self.url);
+ else if (response.status === 0)
+ return self.fail('Can\'t read from server. It may not have the appropriate access-control-origin settings.');
+ else if (response.status === 404)
+ return self.fail('Can\'t read swagger JSON from ' + self.url);
+ else
+ return self.fail(response.status + ' : ' + response.statusText + ' ' + self.url);
+ },
+ response: function(resp) {
+ var responseObj = resp.obj || JSON.parse(resp.data);
+ self.swaggerVersion = responseObj.swaggerVersion;
+
+ if(responseObj.swagger && responseObj.swagger === 2.0) {
+ self.swaggerVersion = responseObj.swagger;
+ self.buildFromSpec(responseObj);
+ self.isValid = true;
+ }
+ else {
+ self.isValid = false;
+ self.failure();
+ }
+ }
+ }
+ };
+ if(this.spec) {
+ var self = this;
+ setTimeout(function() {
+ self.buildFromSpec(self.spec);
+ }, 10);
+ }
+ else {
+ var e = (typeof window !== 'undefined' ? window : exports);
+ var status = e.authorizations.apply(obj);
+ new SwaggerHttp().execute(obj);
+ }
+
+ return this;
+};
+
+SwaggerClient.prototype.buildFromSpec = function(response) {
+ if(this.isBuilt)
+ return this;
+ this.info = response.info || {};
+ this.title = response.title || '';
+ this.host = response.host || '';
+ this.schemes = response.schemes || [ 'http' ];
+ this.basePath = response.basePath || '';
+ this.apis = {};
+ this.apisArray = [];
+ this.consumes = response.consumes;
+ this.produces = response.produces;
+ this.authSchemes = response.authorizations;
+
+ if(typeof this.host === 'undefined' || this.host === '') {
+ var location = this.parseUri(this.url);
+ this.host = location.host;
+ }
+
+ this.definitions = response.definitions;
+ var key;
+ for(key in this.definitions) {
+ var model = new Model(key, this.definitions[key]);
+ if(model) {
+ models[key] = model;
+ }
+ }
+
+ // get paths, create functions for each operationId
+ var path;
+ var operations = [];
+ for(path in response.paths) {
+ var httpMethod;
+ for(httpMethod in response.paths[path]) {
+ var operation = response.paths[path][httpMethod];
+ var tags = operation.tags;
+ if(typeof tags === 'undefined') {
+ operation.tags = [ 'default' ];
+ tags = operation.tags;
+ }
+ var operationId = this.idFromOp(path, httpMethod, operation);
+ var operationObject = new Operation (
+ this,
+ operationId,
+ httpMethod,
+ path,
+ operation,
+ this.definitions
+ );
+ // bind this operation's execute command to the api
+ if(tags.length > 0) {
+ var i;
+ for(i = 0; i < tags.length; i++) {
+ var tag = this.tagFromLabel(tags[i]);
+ var operationGroup = this[tag];
+ if(typeof operationGroup === 'undefined') {
+ this[tag] = [];
+ operationGroup = this[tag];
+ operationGroup.label = tag;
+ operationGroup.apis = [];
+ this[tag].help = this.help.bind(operationGroup);
+ this.apisArray.push(new OperationGroup(tag, operationObject));
+ }
+ operationGroup[operationId] = operationObject.execute.bind(operationObject);
+ operationGroup[operationId].help = operationObject.help.bind(operationObject);
+ operationGroup.apis.push(operationObject);
+
+ // legacy UI feature
+ var j;
+ var api = null;
+ for(j = 0; j < this.apisArray.length; j++) {
+ if(this.apisArray[j].tag === tag) {
+ api = this.apisArray[j];
+ }
+ }
+ if(api) {
+ api.operationsArray.push(operationObject);
+ }
+ }
+ }
+ else {
+ log('no group to bind to');
+ }
+ }
+ }
+ this.isBuilt = true;
+ if (this.success)
+ this.success();
+ return this;
+}
+
+SwaggerClient.prototype.parseUri = function(uri) {
+ var urlParseRE = /^(((([^:\/#\?]+:)?(?:(\/\/)((?:(([^:@\/#\?]+)(?:\:([^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?:\:([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/;
+ var parts = urlParseRE.exec(uri);
+ return {
+ scheme: parts[4].replace(':',''),
+ host: parts[11],
+ path: parts[15]
+ };
+}
+
+SwaggerClient.prototype.help = function() {
+ var i;
+ log('operations for the "' + this.label + '" tag');
+ for(i = 0; i < this.apis.length; i++) {
+ var api = this.apis[i];
+ log(' * ' + api.nickname + ': ' + api.operation.summary);
+ }
+}
+
+SwaggerClient.prototype.tagFromLabel = function(label) {
+ return label;
+}
+
+SwaggerClient.prototype.idFromOp = function(path, httpMethod, op) {
+ if(typeof op.operationId !== 'undefined') {
+ return (op.operationId);
+ }
+ else {
+ return path.substring(1).replace(/\//g, "_").replace(/\{/g, "").replace(/\}/g, "") + "_" + httpMethod;
+ }
+}
+
+SwaggerClient.prototype.fail = function(message) {
+ this.failure(message);
+ throw message;
+};
+
+var OperationGroup = function(tag, operation) {
+ this.tag = tag;
+ this.path = tag;
+ this.name = tag;
+ this.operation = operation;
+ this.operationsArray = [];
+
+ this.description = operation.description || "";
+}
+
+var Operation = function(parent, operationId, httpMethod, path, args, definitions) {
+ var errors = [];
+ this.operation = args;
+ this.deprecated = args.deprecated;
+ this.consumes = args.consumes;
+ this.produces = args.produces;
+ this.parent = parent;
+ this.host = parent.host;
+ this.schemes = parent.schemes;
+ this.basePath = parent.basePath;
+ this.nickname = (operationId||errors.push('Operations must have a nickname.'));
+ this.method = (httpMethod||errors.push('Operation ' + operationId + ' is missing method.'));
+ this.path = (path||errors.push('Operation ' + nickname + ' is missing path.'));
+ this.parameters = args != null ? (args.parameters||[]) : {};
+ this.summary = args.summary || '';
+ this.responses = (args.responses||{});
+ this.type = null;
+ this.security = args.security;
+ this.description = args.description;
+
+ var i;
+ for(i = 0; i < this.parameters.length; i++) {
+ var param = this.parameters[i];
+ type = this.getType(param);
+
+ param.signature = this.getSignature(type, models);
+ param.sampleJSON = this.getSampleJSON(type, models);
+ param.responseClassSignature = param.signature;
+ }
+
+ var response;
+ var model;
+ var responses = this.responses;
+
+ if(responses['200']) {
+ response = responses['200'];
+ defaultResponseCode = '200';
+ }
+ else if(responses['201']) {
+ response = responses['201'];
+ defaultResponseCode = '201';
+ }
+ else if(responses['202']) {
+ response = responses['202'];
+ defaultResponseCode = '202';
+ }
+ else if(responses['203']) {
+ response = responses['203'];
+ defaultResponseCode = '203';
+ }
+ else if(responses['204']) {
+ response = responses['204'];
+ defaultResponseCode = '204';
+ }
+ else if(responses['205']) {
+ response = responses['205'];
+ defaultResponseCode = '205';
+ }
+ else if(responses['206']) {
+ response = responses['206'];
+ defaultResponseCode = '206';
+ }
+ else if(responses['default']) {
+ response = responses['default'];
+ defaultResponseCode = 'default';
+ }
+
+ if(response && response.schema) {
+ var resolvedModel = this.resolveModel(response.schema, definitions);
+ if(resolvedModel) {
+ this.type = resolvedModel.name;
+ this.responseSampleJSON = JSON.stringify(resolvedModel.getSampleValue(), null, 2);
+ this.responseClassSignature = resolvedModel.getMockSignature();
+ delete responses[defaultResponseCode];
+ }
+ else {
+ this.type = response.schema.type;
+ }
+ }
+
+ if (errors.length > 0)
+ this.resource.api.fail(errors);
+
+ return this;
+}
+
+OperationGroup.prototype.sort = function(sorter) {
+
+}
+
+Operation.prototype.getType = function (param) {
+ var type = param.type;
+ var format = param.format;
+ var isArray = false;
+ var str;
+ if(type === 'integer' && format === 'int32')
+ str = 'integer';
+ else if(type === 'integer' && format === 'int64')
+ str = 'long';
+ else if(type === 'string' && format === 'date-time')
+ str = 'date-time';
+ else if(type === 'string' && format === 'date')
+ str = 'date';
+ else if(type === 'number' && format === 'float')
+ str = 'float';
+ else if(type === 'number' && format === 'double')
+ str = 'double';
+ else if(type === 'boolean')
+ str = 'boolean';
+ else if(type === 'string')
+ str = 'string';
+ else if(type === 'array') {
+ isArray = true;
+ if(param.items)
+ str = this.getType(param.items);
+ }
+ if(param['$ref'])
+ str = param['$ref'];
+
+ var schema = param.schema;
+ if(schema) {
+ var ref = schema['$ref'];
+ if(ref) {
+ ref = simpleRef(ref);
+ if(isArray)
+ return [ ref ];
+ else
+ return ref;
+ }
+ else
+ return this.getType(schema);
+ }
+ if(isArray)
+ return [ str ];
+ else
+ return str;
+}
+
+Operation.prototype.resolveModel = function (schema, definitions) {
+ if(typeof schema['$ref'] !== 'undefined') {
+ var ref = schema['$ref'];
+ if(ref.indexOf('#/definitions/') == 0)
+ ref = ref.substring('#/definitions/'.length);
+ if(definitions[ref])
+ return new Model(ref, definitions[ref]);
+ }
+ if(schema.type === 'array')
+ return new ArrayModel(schema);
+ else
+ return null;
+}
+
+Operation.prototype.help = function() {
+ log(this.nickname + ': ' + this.operation.summary);
+ for(var i = 0; i < this.parameters.length; i++) {
+ var param = this.parameters[i];
+ log(' * ' + param.name + ': ' + param.description);
+ }
+}
+
+Operation.prototype.getSignature = function(type, models) {
+ var isPrimitive, listType;
+
+ if(type instanceof Array) {
+ listType = true;
+ type = type[0];
+ }
+
+ if(type === 'string')
+ isPrimitive = true
+ else
+ isPrimitive = ((listType != null) && models[listType]) || (models[type] != null) ? false : true;
+ if (isPrimitive) {
+ return type;
+ } else {
+ if (listType != null) {
+ return models[type].getMockSignature();
+ } else {
+ return models[type].getMockSignature();
+ }
+ }
+};
+
+Operation.prototype.getSampleJSON = function(type, models) {
+ var isPrimitive, listType, sampleJson;
+
+ listType = (type instanceof Array);
+ isPrimitive = (models[type] != null) ? false : true;
+ sampleJson = isPrimitive ? void 0 : models[type].createJSONSample();
+
+ if (sampleJson) {
+ sampleJson = listType ? [sampleJson] : sampleJson;
+ if(typeof sampleJson == 'string')
+ return sampleJson;
+ else if(typeof sampleJson === 'object') {
+ var t = sampleJson;
+ if(sampleJson instanceof Array && sampleJson.length > 0) {
+ t = sampleJson[0];
+ }
+ if(t.nodeName) {
+ var xmlString = new XMLSerializer().serializeToString(t);
+ return this.formatXml(xmlString);
+ }
+ else
+ return JSON.stringify(sampleJson, null, 2);
+ }
+ else
+ return sampleJson;
+ }
+};
+
+// legacy support
+Operation.prototype["do"] = function(args, opts, callback, error, parent) {
+ return this.execute(args, opts, callback, error, parent);
+}
+
+Operation.prototype.execute = function(arg1, arg2, arg3, arg4, parent) {
+ var args = (arg1||{});
+ var opts = {}, success, error;
+ if(typeof arg2 === 'object') {
+ opts = arg2;
+ success = arg3;
+ error = arg4;
+ }
+ if(typeof arg2 === 'function') {
+ success = arg2;
+ error = arg3;
+ }
+
+ var formParams = {};
+ var headers = {};
+ var requestUrl = this.path;
+
+ success = (success||log)
+ error = (error||log)
+
+ var requiredParams = [];
+ var missingParams = [];
+ // check required params
+ for(var i = 0; i < this.parameters.length; i++) {
+ var param = this.parameters[i];
+ if(param.required === true) {
+ requiredParams.push(param.name);
+ if(typeof args[param.name] === 'undefined')
+ missingParams = param.name;
+ }
+ }
+
+ if(missingParams.length > 0) {
+ var message = 'missing required params: ' + missingParams;
+ fail(message);
+ return;
+ }
+
+ // set content type negotiation
+ var consumes = this.consumes || this.parent.consumes || [ 'application/json' ];
+ var produces = this.produces || this.parent.produces || [ 'application/json' ];
+
+ headers = this.setContentTypes(args, opts);
+
+ // grab params from the args, build the querystring along the way
+ var querystring = "";
+ for(var i = 0; i < this.parameters.length; i++) {
+ var param = this.parameters[i];
+ if(typeof args[param.name] !== 'undefined') {
+ if(param.in === 'path') {
+ var reg = new RegExp('\{' + param.name + '[^\}]*\}', 'gi');
+ requestUrl = requestUrl.replace(reg, this.encodePathParam(args[param.name]));
+ }
+ else if (param.in === 'query') {
+ if(querystring === '')
+ querystring += '?';
+ else
+ querystring += '&';
+ if(typeof param.collectionFormat !== 'undefined') {
+ var qp = args[param.name];
+ if(Array.isArray(qp))
+ querystring += this.encodeCollection(param.collectionFormat, param.name, qp);
+ else
+ querystring += this.encodeQueryParam(param.name) + '=' + this.encodeQueryParam(args[param.name]);
+ }
+ else
+ querystring += this.encodeQueryParam(param.name) + '=' + this.encodeQueryParam(args[param.name]);
+ }
+ else if (param.in === 'header')
+ headers[param.name] = args[param.name];
+ else if (param.in === 'form')
+ formParams[param.name] = args[param.name];
+ }
+ }
+ var scheme = this.schemes[0];
+ var url = scheme + '://' + this.host + this.basePath + requestUrl + querystring;
+
+ var obj = {
+ url: url,
+ method: this.method,
+ body: args.body,
+ useJQuery: this.useJQuery,
+ headers: headers,
+ on: {
+ response: function(response) {
+ return success(response, parent);
+ },
+ error: function(response) {
+ return error(response, parent);
+ }
+ }
+ };
+ var status = e.authorizations.apply(obj, this.operation.security);
+ new SwaggerHttp().execute(obj);
+}
+
+Operation.prototype.setContentTypes = function(args, opts) {
+ // default type
+ var accepts = 'application/json';
+ var consumes = 'application/json';
+
+ var allDefinedParams = this.parameters;
+ var definedFormParams = [];
+ var definedFileParams = [];
+ var body = args.body;
+ var headers = {};
+
+ // get params from the operation and set them in definedFileParams, definedFormParams, headers
+ var i;
+ for(i = 0; i < allDefinedParams.length; i++) {
+ var param = allDefinedParams[i];
+ if(param.in === 'form')
+ definedFormParams.push(param);
+ else if(param.in === 'file')
+ definedFileParams.push(param);
+ else if(param.in === 'header' && this.headers) {
+ var key = param.name;
+ var headerValue = this.headers[param.name];
+ if(typeof this.headers[param.name] !== 'undefined')
+ headers[key] = headerValue;
+ }
+ }
+
+ // if there's a body, need to set the accepts header via requestContentType
+ if (body && (this.type === 'post' || this.type === 'put' || this.type === 'patch' || this.type === 'delete')) {
+ if (opts.requestContentType)
+ consumes = opts.requestContentType;
+ } else {
+ // if any form params, content type must be set
+ if(definedFormParams.length > 0) {
+ if(definedFileParams.length > 0)
+ consumes = 'multipart/form-data';
+ else
+ consumes = 'application/x-www-form-urlencoded';
+ }
+ else if (this.type == 'DELETE')
+ body = '{}';
+ else if (this.type != 'DELETE')
+ accepts = null;
+ }
+
+ if (consumes && this.consumes) {
+ if (this.consumes.indexOf(consumes) === -1) {
+ log('server doesn\'t consume ' + consumes + ', try ' + JSON.stringify(this.consumes));
+ consumes = this.operation.consumes[0];
+ }
+ }
+
+ if (opts.responseContentType) {
+ accepts = opts.responseContentType;
+ } else {
+ accepts = 'application/json';
+ }
+ if (accepts && this.produces) {
+ if (this.produces.indexOf(accepts) === -1) {
+ log('server can\'t produce ' + accepts);
+ accepts = this.produces[0];
+ }
+ }
+
+ if ((consumes && body !== '') || (consumes === 'application/x-www-form-urlencoded'))
+ headers['Content-Type'] = consumes;
+ if (accepts)
+ headers['Accept'] = accepts;
+ return headers;
+}
+
+Operation.prototype.encodeCollection = function(type, name, value) {
+ var encoded = '';
+ var i;
+ if(type === 'jaxrs') {
+ for(i = 0; i < value.length; i++) {
+ if(i > 0) encoded += '&'
+ encoded += this.encodeQueryParam(name) + '=' + this.encodeQueryParam(value[i]);
+ }
+ }
+ return encoded;
+}
+
+Operation.prototype.encodeQueryParam = function(arg) {
+ return escape(arg);
+}
+
+Operation.prototype.encodePathParam = function(pathParam) {
+ var encParts, part, parts, _i, _len;
+ pathParam = pathParam.toString();
+ if (pathParam.indexOf('/') === -1) {
+ return encodeURIComponent(pathParam);
+ } else {
+ parts = pathParam.split('/');
+ encParts = [];
+ for (_i = 0, _len = parts.length; _i < _len; _i++) {
+ part = parts[_i];
+ encParts.push(encodeURIComponent(part));
+ }
+ return encParts.join('/');
+ }
+};
+
+Operation.prototype.encodePathParam = function(pathParam) {
+ var encParts, part, parts, _i, _len;
+ pathParam = pathParam.toString();
+ if (pathParam.indexOf('/') === -1) {
+ return encodeURIComponent(pathParam);
+ } else {
+ parts = pathParam.split('/');
+ encParts = [];
+ for (_i = 0, _len = parts.length; _i < _len; _i++) {
+ part = parts[_i];
+ encParts.push(encodeURIComponent(part));
+ }
+ return encParts.join('/');
+ }
+};
+
+var ArrayModel = function(definition) {
+ this.name = "name";
+ this.definition = definition || {};
+ this.properties = [];
+ this.type;
+ this.ref;
+
+ var requiredFields = definition.enum || [];
+ var items = definition.items;
+ if(items) {
+ var type = items.type;
+ if(items.type) {
+ this.type = typeFromJsonSchema(type.type, type.format);
+ }
+ else {
+ this.ref = items['$ref'];
+ }
+ }
+}
+
+ArrayModel.prototype.createJSONSample = function(modelsToIgnore) {
+ var result;
+ var modelsToIgnore = (modelsToIgnore||[])
+ if(this.type) {
+ result = type;
+ }
+ else if (this.ref) {
+ var name = simpleRef(this.ref);
+ result = models[name].createJSONSample();
+ }
+ return [ result ];
+};
+
+ArrayModel.prototype.getSampleValue = function() {
+ var result;
+ var modelsToIgnore = (modelsToIgnore||[])
+ if(this.type) {
+ result = type;
+ }
+ else if (this.ref) {
+ var name = simpleRef(this.ref);
+ result = models[name].getSampleValue();
+ }
+ return [ result ];
+}
+
+ArrayModel.prototype.getMockSignature = function(modelsToIgnore) {
+ var propertiesStr = [];
+
+ if(this.ref) {
+ return models[simpleRef(this.ref)].getMockSignature();
+ }
+};
+
+
+var PrimitiveModel = function(definition) {
+ this.name = "name";
+ this.definition = definition || {};
+ this.properties = [];
+ this.type;
+
+ var requiredFields = definition.enum || [];
+ this.type = typeFromJsonSchema(definition.type, definition.format);
+}
+
+PrimitiveModel.prototype.createJSONSample = function(modelsToIgnore) {
+ var result = this.type;
+ return result;
+};
+
+PrimitiveModel.prototype.getSampleValue = function() {
+ var result = this.type;
+ return null;
+}
+
+PrimitiveModel.prototype.getMockSignature = function(modelsToIgnore) {
+ var propertiesStr = [];
+ var i;
+ for (i = 0; i < this.properties.length; i++) {
+ var prop = this.properties[i];
+ propertiesStr.push(prop.toString());
+ }
+
+ var strong = '<span class="strong">';
+ var stronger = '<span class="stronger">';
+ var strongClose = '</span>';
+ var classOpen = strong + this.name + ' {' + strongClose;
+ var classClose = strong + '}' + strongClose;
+ var returnVal = classOpen + '<div>' + propertiesStr.join(',</div><div>') + '</div>' + classClose;
+ if (!modelsToIgnore)
+ modelsToIgnore = [];
+
+ modelsToIgnore.push(this.name);
+ var i;
+ for (i = 0; i < this.properties.length; i++) {
+ var prop = this.properties[i];
+ var ref = prop['$ref'];
+ var model = models[ref];
+ if (model && modelsToIgnore.indexOf(ref) === -1) {
+ returnVal = returnVal + ('<br>' + model.getMockSignature(modelsToIgnore));
+ }
+ }
+ return returnVal;
+};
+
+var Model = function(name, definition) {
+ this.name = name;
+ this.definition = definition || {};
+ this.properties = [];
+ var requiredFields = definition.enum || [];
+
+ var key;
+ var props = definition.properties;
+ if(props) {
+ for(key in props) {
+ var required = false;
+ var property = props[key];
+ if(requiredFields.indexOf(key) >= 0)
+ required = true;
+ this.properties.push(new Property(key, property, required));
+ }
+ }
+}
+
+Model.prototype.createJSONSample = function(modelsToIgnore) {
+ var result = {};
+ var modelsToIgnore = (modelsToIgnore||[])
+ modelsToIgnore.push(this.name);
+ for (var i = 0; i < this.properties.length; i++) {
+ prop = this.properties[i];
+ result[prop.name] = prop.getSampleValue(modelsToIgnore);
+ }
+ modelsToIgnore.pop(this.name);
+ return result;
+};
+
+Model.prototype.getSampleValue = function() {
+ var i;
+ var obj = {};
+ for(i = 0; i < this.properties.length; i++ ) {
+ var property = this.properties[i];
+ obj[property.name] = property.sampleValue();
+ }
+ return obj;
+}
+
+Model.prototype.getMockSignature = function(modelsToIgnore) {
+ var propertiesStr = [];
+ var i;
+ for (i = 0; i < this.properties.length; i++) {
+ var prop = this.properties[i];
+ propertiesStr.push(prop.toString());
+ }
+
+ var strong = '<span class="strong">';
+ var stronger = '<span class="stronger">';
+ var strongClose = '</span>';
+ var classOpen = strong + this.name + ' {' + strongClose;
+ var classClose = strong + '}' + strongClose;
+ var returnVal = classOpen + '<div>' + propertiesStr.join(',</div><div>') + '</div>' + classClose;
+ if (!modelsToIgnore)
+ modelsToIgnore = [];
+
+ modelsToIgnore.push(this.name);
+ var i;
+ for (i = 0; i < this.properties.length; i++) {
+ var prop = this.properties[i];
+ var ref = prop['$ref'];
+ var model = models[ref];
+ if (model && modelsToIgnore.indexOf(ref) === -1) {
+ returnVal = returnVal + ('<br>' + model.getMockSignature(modelsToIgnore));
+ }
+ }
+ return returnVal;
+};
+
+var Property = function(name, obj, required) {
+ this.schema = obj;
+ this.required = required;
+ if(obj['$ref']) {
+ var refType = obj['$ref'];
+ refType = refType.indexOf('#/definitions') === -1 ? refType : refType.substring('#/definitions').length;
+ this['$ref'] = refType;
+ }
+ else if (obj.type === 'array') {
+ if(obj.items['$ref'])
+ this['$ref'] = obj.items['$ref'];
+ else
+ obj = obj.items;
+ }
+ this.name = name;
+ this.obj = obj;
+ this.optional = true;
+ this.example = obj.example || null;
+}
+
+Property.prototype.getSampleValue = function () {
+ return this.sampleValue(false);
+}
+
+Property.prototype.isArray = function () {
+ var schema = this.schema;
+ if(schema.type === 'array')
+ return true;
+ else
+ return false;
+}
+
+Property.prototype.sampleValue = function(isArray, ignoredModels) {
+ isArray = (isArray || this.isArray());
+ ignoredModels = (ignoredModels || {})
+ var type = getStringSignature(this.obj);
+ var output;
+
+ if(this['$ref']) {
+ var refModel = models[this['$ref']];
+ if(refModel && typeof ignoredModels[refModel] === 'undefined') {
+ output = refModel.getSampleValue(ignoredModels);
+ }
+ else
+ type = refModel;
+ }
+ else if(this.example)
+ output = this.example;
+ else if(type === 'date-time') {
+ output = new Date().toISOString();
+ }
+ else if(type === 'string') {
+ output = 'string';
+ }
+ else if(type === 'integer') {
+ output = 0;
+ }
+ else if(type === 'long') {
+ output = 0;
+ }
+ else if(type === 'float') {
+ output = 0.0;
+ }
+ else if(type === 'double') {
+ output = 0.0;
+ }
+ else if(type === 'boolean') {
+ output = true;
+ }
+ else
+ output = {};
+ if(isArray) return [output];
+ else return output;
+}
+
+getStringSignature = function(obj) {
+ var str = '';
+ if(obj.type === 'array') {
+ obj = (obj.items || obj['$ref'] || {});
+ str += 'Array[';
+ }
+ if(obj.type === 'integer' && obj.format === 'int32')
+ str += 'integer';
+ else if(obj.type === 'integer' && obj.format === 'int64')
+ str += 'long';
+ else if(obj.type === 'string' && obj.format === 'date-time')
+ str += 'date-time';
+ else if(obj.type === 'string' && obj.format === 'date')
+ str += 'date';
+ else if(obj.type === 'number' && obj.format === 'float')
+ str += 'float';
+ else if(obj.type === 'number' && obj.format === 'double')
+ str += 'double';
+ else if(obj.type === 'boolean')
+ str += 'boolean';
+ else
+ str += obj.type || obj['$ref'];
+ if(obj.type === 'array')
+ str += ']';
+ return str;
+}
+
+simpleRef = function(name) {
+ if(name.indexOf("#/definitions/") === 0)
+ return name.substring('#/definitions/'.length)
+ else
+ return name;
+}
+
+Property.prototype.toString = function() {
+ var str = getStringSignature(this.obj);
+ if(str !== '')
+ str = this.name + ' : ' + str;
+ else
+ str = this.name + ' : ' + JSON.stringify(this.obj);
+ if(!this.required)
+ str += ' (optional)';
+ return str;
+}
+
+typeFromJsonSchema = function(type, format) {
+ var str;
+ if(type === 'integer' && format === 'int32')
+ str = 'integer';
+ else if(type === 'integer' && format === 'int64')
+ str = 'long';
+ else if(type === 'string' && format === 'date-time')
+ str = 'date-time';
+ else if(type === 'string' && format === 'date')
+ str = 'date';
+ else if(type === 'number' && format === 'float')
+ str = 'float';
+ else if(type === 'number' && format === 'double')
+ str = 'double';
+ else if(type === 'boolean')
+ str = 'boolean';
+ else if(type === 'string')
+ str = 'string';
+
+ return str;
+}
+
+var e = (typeof window !== 'undefined' ? window : exports);
+
+var sampleModels = {};
+var cookies = {};
+var models = {};
+
+e.authorizations = new SwaggerAuthorizations();
+e.ApiKeyAuthorization = ApiKeyAuthorization;
+e.PasswordAuthorization = PasswordAuthorization;
+e.CookieAuthorization = CookieAuthorization;
+e.SwaggerClient = SwaggerClient;/**
+ * SwaggerHttp is a wrapper for executing requests
+ */
+var SwaggerHttp = function() {};
+
+SwaggerHttp.prototype.execute = function(obj) {
+ if(obj && (typeof obj.useJQuery === 'boolean'))
+ this.useJQuery = obj.useJQuery;
+ else
+ this.useJQuery = this.isIE8();
+
+ if(this.useJQuery)
+ return new JQueryHttpClient().execute(obj);
+ else
+ return new ShredHttpClient().execute(obj);
+}
+
+SwaggerHttp.prototype.isIE8 = function() {
+ var detectedIE = false;
+ if (typeof navigator !== 'undefined' && navigator.userAgent) {
+ nav = navigator.userAgent.toLowerCase();
+ if (nav.indexOf('msie') !== -1) {
+ var version = parseInt(nav.split('msie')[1]);
+ if (version <= 8) {
+ detectedIE = true;
+ }
+ }
+ }
+ return detectedIE;
+};
+
+/*
+ * JQueryHttpClient lets a browser take advantage of JQuery's cross-browser magic.
+ * NOTE: when jQuery is available it will export both '$' and 'jQuery' to the global space.
+ * Since we are using closures here we need to alias it for internal use.
+ */
+var JQueryHttpClient = function(options) {
+ "use strict";
+ if(!jQuery){
+ var jQuery = window.jQuery;
+ }
+}
+
+JQueryHttpClient.prototype.execute = function(obj) {
+ var cb = obj.on;
+ var request = obj;
+
+ obj.type = obj.method;
+ obj.cache = false;
+
+ obj.beforeSend = function(xhr) {
+ var key, results;
+ if (obj.headers) {
+ results = [];
+ var key;
+ for (key in obj.headers) {
+ if (key.toLowerCase() === "content-type") {
+ results.push(obj.contentType = obj.headers[key]);
+ } else if (key.toLowerCase() === "accept") {
+ results.push(obj.accepts = obj.headers[key]);
+ } else {
+ results.push(xhr.setRequestHeader(key, obj.headers[key]));
+ }
+ }
+ return results;
+ }
+ };
+
+ obj.data = obj.body;
+ obj.complete = function(response, textStatus, opts) {
+ var headers = {},
+ headerArray = response.getAllResponseHeaders().split("\n");
+
+ for(var i = 0; i < headerArray.length; i++) {
+ var toSplit = headerArray[i].trim();
+ if(toSplit.length === 0)
+ continue;
+ var separator = toSplit.indexOf(":");
+ if(separator === -1) {
+ // Name but no value in the header
+ headers[toSplit] = null;
+ continue;
+ }
+ var name = toSplit.substring(0, separator).trim(),
+ value = toSplit.substring(separator + 1).trim();
+ headers[name] = value;
+ }
+
+ var out = {
+ url: request.url,
+ method: request.method,
+ status: response.status,
+ data: response.responseText,
+ headers: headers
+ };
+
+ var contentType = (headers["content-type"]||headers["Content-Type"]||null)
+
+ if(contentType != null) {
+ if(contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) {
+ if(response.responseText && response.responseText !== "")
+ out.obj = JSON.parse(response.responseText);
+ else
+ out.obj = {}
+ }
+ }
+
+ if(response.status >= 200 && response.status < 300)
+ cb.response(out);
+ else if(response.status === 0 || (response.status >= 400 && response.status < 599))
+ cb.error(out);
+ else
+ return cb.response(out);
+ };
+
+ jQuery.support.cors = true;
+ return jQuery.ajax(obj);
+}
+
+/*
+ * ShredHttpClient is a light-weight, node or browser HTTP client
+ */
+var ShredHttpClient = function(options) {
+ this.options = (options||{});
+ this.isInitialized = false;
+
+ var identity, toString;
+
+ if (typeof window !== 'undefined') {
+ this.Shred = require("./shred");
+ this.content = require("./shred/content");
+ }
+ else
+ this.Shred = require("shred");
+ this.shred = new this.Shred();
+}
+
+ShredHttpClient.prototype.initShred = function () {
+ this.isInitialized = true;
+ this.registerProcessors(this.shred);
+}
+
+ShredHttpClient.prototype.registerProcessors = function(shred) {
+ var identity = function(x) {
+ return x;
+ };
+ var toString = function(x) {
+ return x.toString();
+ };
+
+ if (typeof window !== 'undefined') {
+ this.content.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
+ parser: identity,
+ stringify: toString
+ });
+ } else {
+ this.Shred.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
+ parser: identity,
+ stringify: toString
+ });
+ }
+}
+
+ShredHttpClient.prototype.execute = function(obj) {
+ if(!this.isInitialized)
+ this.initShred();
+
+ var cb = obj.on, res;
+
+ var transform = function(response) {
+ var out = {
+ headers: response._headers,
+ url: response.request.url,
+ method: response.request.method,
+ status: response.status,
+ data: response.content.data
+ };
+
+ var contentType = (response._headers["content-type"]||response._headers["Content-Type"]||null)
+
+ if(contentType != null) {
+ if(contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) {
+ if(response.content.data && response.content.data !== "")
+ try{
+ out.obj = JSON.parse(response.content.data);
+ }
+ catch (e) {
+ // unable to parse
+ }
+ else
+ out.obj = {}
+ }
+ }
+ return out;
+ };
+
+ res = {
+ error: function(response) {
+ if (obj)
+ return cb.error(transform(response));
+ },
+ redirect: function(response) {
+ if (obj)
+ return cb.redirect(transform(response));
+ },
+ 307: function(response) {
+ if (obj)
+ return cb.redirect(transform(response));
+ },
+ response: function(response) {
+ if (obj)
+ return cb.response(transform(response));
+ }
+ };
+ if (obj) {
+ obj.on = res;
+ }
+ return this.shred.request(obj);
+};
\ No newline at end of file
diff --git a/profiles/killpay/src/main/webapp/lib/swagger-oauth.js b/profiles/killpay/src/main/webapp/lib/swagger-oauth.js
new file mode 100644
index 0000000..8bb17fb
--- /dev/null
+++ b/profiles/killpay/src/main/webapp/lib/swagger-oauth.js
@@ -0,0 +1,211 @@
+var appName;
+var popupMask;
+var popupDialog;
+var clientId;
+var realm;
+
+function handleLogin() {
+ var scopes = [];
+
+ if(window.swaggerUi.api.authSchemes
+ && window.swaggerUi.api.authSchemes.oauth2
+ && window.swaggerUi.api.authSchemes.oauth2.scopes) {
+ scopes = window.swaggerUi.api.authSchemes.oauth2.scopes;
+ }
+
+ if(window.swaggerUi.api
+ && window.swaggerUi.api.info) {
+ appName = window.swaggerUi.api.info.title;
+ }
+
+ if(popupDialog.length > 0)
+ popupDialog = popupDialog.last();
+ else {
+ popupDialog = $(
+ [
+ '<div class="api-popup-dialog">',
+ '<div class="api-popup-title">Select OAuth2.0 Scopes</div>',
+ '<div class="api-popup-content">',
+ '<p>Scopes are used to grant an application different levels of access to data on behalf of the end user. Each API may declare one or more scopes.',
+ '<a href="#">Learn how to use</a>',
+ '</p>',
+ '<p><strong>' + appName + '</strong> API requires the following scopes. Select which ones you want to grant to Swagger UI.</p>',
+ '<ul class="api-popup-scopes">',
+ '</ul>',
+ '<p class="error-msg"></p>',
+ '<div class="api-popup-actions"><button class="api-popup-authbtn api-button green" type="button">Authorize</button><button class="api-popup-cancel api-button gray" type="button">Cancel</button></div>',
+ '</div>',
+ '</div>'].join(''));
+ $(document.body).append(popupDialog);
+
+ popup = popupDialog.find('ul.api-popup-scopes').empty();
+ for (i = 0; i < scopes.length; i ++) {
+ scope = scopes[i];
+ str = '<li><input type="checkbox" id="scope_' + i + '" scope="' + scope.scope + '"/>' + '<label for="scope_' + i + '">' + scope.scope;
+ if (scope.description) {
+ str += '<br/><span class="api-scope-desc">' + scope.description + '</span>';
+ }
+ str += '</label></li>';
+ popup.append(str);
+ }
+ }
+
+ var $win = $(window),
+ dw = $win.width(),
+ dh = $win.height(),
+ st = $win.scrollTop(),
+ dlgWd = popupDialog.outerWidth(),
+ dlgHt = popupDialog.outerHeight(),
+ top = (dh -dlgHt)/2 + st,
+ left = (dw - dlgWd)/2;
+
+ popupDialog.css({
+ top: (top < 0? 0 : top) + 'px',
+ left: (left < 0? 0 : left) + 'px'
+ });
+
+ popupDialog.find('button.api-popup-cancel').click(function() {
+ popupMask.hide();
+ popupDialog.hide();
+ });
+ popupDialog.find('button.api-popup-authbtn').click(function() {
+ popupMask.hide();
+ popupDialog.hide();
+
+ var authSchemes = window.swaggerUi.api.authSchemes;
+ var host = window.location;
+ var pathname = location.pathname.substring(0, location.pathname.lastIndexOf("/"));
+ var redirectUrl = host.protocol + '//' + host.host + pathname + "/o2c.html";
+ var url = null;
+
+ for (var key in authSchemes) {
+ if (authSchemes.hasOwnProperty(key)) {
+ var o = authSchemes[key].grantTypes;
+ for(var t in o) {
+ if(o.hasOwnProperty(t) && t === 'implicit') {
+ var dets = o[t];
+ url = dets.loginEndpoint.url + "?response_type=token";
+ window.swaggerUi.tokenName = dets.tokenName;
+ }
+ }
+ }
+ }
+ var scopes = []
+ var o = $('.api-popup-scopes').find('input:checked');
+
+ for(k =0; k < o.length; k++) {
+ scopes.push($(o[k]).attr("scope"));
+ }
+
+ window.enabledScopes=scopes;
+
+ url += '&redirect_uri=' + encodeURIComponent(redirectUrl);
+ url += '&realm=' + encodeURIComponent(realm);
+ url += '&client_id=' + encodeURIComponent(clientId);
+ url += '&scope=' + encodeURIComponent(scopes);
+
+ window.open(url);
+ });
+
+ popupMask.show();
+ popupDialog.show();
+ return;
+}
+
+
+function handleLogout() {
+ for(key in window.authorizations.authz){
+ window.authorizations.remove(key)
+ }
+ window.enabledScopes = null;
+ $('.api-ic.ic-on').addClass('ic-off');
+ $('.api-ic.ic-on').removeClass('ic-on');
+
+ // set the info box
+ $('.api-ic.ic-warning').addClass('ic-error');
+ $('.api-ic.ic-warning').removeClass('ic-warning');
+}
+
+function initOAuth(opts) {
+ var o = (opts||{});
+ var errors = [];
+
+ appName = (o.appName||errors.push("missing appName"));
+ popupMask = (o.popupMask||$('#api-common-mask'));
+ popupDialog = (o.popupDialog||$('.api-popup-dialog'));
+ clientId = (o.clientId||errors.push("missing client id"));
+ realm = (o.realm||errors.push("missing realm"));
+
+ if(errors.length > 0){
+ log("auth unable initialize oauth: " + errors);
+ return;
+ }
+
+ $('pre code').each(function(i, e) {hljs.highlightBlock(e)});
+ $('.api-ic').click(function(s) {
+ if($(s.target).hasClass('ic-off'))
+ handleLogin();
+ else {
+ handleLogout();
+ }
+ false;
+ });
+}
+
+function onOAuthComplete(token) {
+ if(token) {
+ if(token.error) {
+ var checkbox = $('input[type=checkbox],.secured')
+ checkbox.each(function(pos){
+ checkbox[pos].checked = false;
+ });
+ alert(token.error);
+ }
+ else {
+ var b = token[window.swaggerUi.tokenName];
+ if(b){
+ // if all roles are satisfied
+ var o = null;
+ $.each($('.auth #api_information_panel'), function(k, v) {
+ var children = v;
+ if(children && children.childNodes) {
+ var requiredScopes = [];
+ $.each((children.childNodes), function (k1, v1){
+ var inner = v1.innerHTML;
+ if(inner)
+ requiredScopes.push(inner);
+ });
+ var diff = [];
+ for(var i=0; i < requiredScopes.length; i++) {
+ var s = requiredScopes[i];
+ if(window.enabledScopes && window.enabledScopes.indexOf(s) == -1) {
+ diff.push(s);
+ }
+ }
+ if(diff.length > 0){
+ o = v.parentNode;
+ $(o.parentNode).find('.api-ic.ic-on').addClass('ic-off');
+ $(o.parentNode).find('.api-ic.ic-on').removeClass('ic-on');
+
+ // sorry, not all scopes are satisfied
+ $(o).find('.api-ic').addClass('ic-warning');
+ $(o).find('.api-ic').removeClass('ic-error');
+ }
+ else {
+ o = v.parentNode;
+ $(o.parentNode).find('.api-ic.ic-off').addClass('ic-on');
+ $(o.parentNode).find('.api-ic.ic-off').removeClass('ic-off');
+
+ // all scopes are satisfied
+ $(o).find('.api-ic').addClass('ic-info');
+ $(o).find('.api-ic').removeClass('ic-warning');
+ $(o).find('.api-ic').removeClass('ic-error');
+ }
+ }
+ });
+
+ window.authorizations.add("oauth2", new ApiKeyAuthorization("Authorization", "Bearer " + b, "header"));
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/profiles/killpay/src/main/webapp/lib/swagger-ui.min.js b/profiles/killpay/src/main/webapp/lib/swagger-ui.min.js
new file mode 100644
index 0000000..0d60523
--- /dev/null
+++ b/profiles/killpay/src/main/webapp/lib/swagger-ui.min.js
@@ -0,0 +1 @@
+$(function(){$.fn.vAlign=function(){return this.each(function(c){var a=$(this).height();var d=$(this).parent().height();var b=(d-a)/2;$(this).css("margin-top",b)})};$.fn.stretchFormtasticInputWidthToParent=function(){return this.each(function(b){var d=$(this).closest("form").innerWidth();var c=parseInt($(this).closest("form").css("padding-left"),10)+parseInt($(this).closest("form").css("padding-right"),10);var a=parseInt($(this).css("padding-left"),10)+parseInt($(this).css("padding-right"),10);$(this).css("width",d-c-a)})};$("form.formtastic li.string input, form.formtastic textarea").stretchFormtasticInputWidthToParent();$("ul.downplayed li div.content p").vAlign();$("form.sandbox").submit(function(){var a=true;$(this).find("input.required").each(function(){$(this).removeClass("error");if($(this).val()==""){$(this).addClass("error");$(this).wiggle();a=false}});return a})});function clippyCopiedCallback(b){$("#api_key_copied").fadeIn().delay(1000).fadeOut()}log=function(){log.history=log.history||[];log.history.push(arguments);if(this.console){console.log(Array.prototype.slice.call(arguments)[0])}};if(Function.prototype.bind&&console&&typeof console.log=="object"){["log","info","warn","error","assert","dir","clear","profile","profileEnd"].forEach(function(a){console[a]=this.bind(console[a],console)},Function.prototype.call)}var Docs={shebang:function(){var b=$.param.fragment().split("/");b.shift();switch(b.length){case 1:var d="resource_"+b[0];Docs.expandEndpointListForResource(b[0]);$("#"+d).slideto({highlight:false});break;case 2:Docs.expandEndpointListForResource(b[0]);$("#"+d).slideto({highlight:false});var c=b.join("_");var a=c+"_content";Docs.expandOperation($("#"+a));$("#"+c).slideto({highlight:false});break}},toggleEndpointListForResource:function(b){var a=$("li#resource_"+Docs.escapeResourceName(b)+" ul.endpoints");if(a.is(":visible")){Docs.collapseEndpointListForResource(b)}else{Docs.expandEndpointListForResource(b)}},expandEndpointListForResource:function(b){var b=Docs.escapeResourceName(b);if(b==""){$(".resource ul.endpoints").slideDown();return}$("li#resource_"+b).addClass("active");var a=$("li#resource_"+b+" ul.endpoints");a.slideDown()},collapseEndpointListForResource:function(b){var b=Docs.escapeResourceName(b);$("li#resource_"+b).removeClass("active");var a=$("li#resource_"+b+" ul.endpoints");a.slideUp()},expandOperationsForResource:function(a){Docs.expandEndpointListForResource(a);if(a==""){$(".resource ul.endpoints li.operation div.content").slideDown();return}$("li#resource_"+Docs.escapeResourceName(a)+" li.operation div.content").each(function(){Docs.expandOperation($(this))})},collapseOperationsForResource:function(a){Docs.expandEndpointListForResource(a);$("li#resource_"+Docs.escapeResourceName(a)+" li.operation div.content").each(function(){Docs.collapseOperation($(this))})},escapeResourceName:function(a){return a.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g,"\\$&")},expandOperation:function(a){a.slideDown()},collapseOperation:function(a){a.slideUp()}};(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.content_type=b(function(g,l,f,k,j){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);j=j||{};var i="",c,h="function",m=this;function e(r,q){var o="",p;o+="\n ";p=f.each.call(r,r.produces,{hash:{},inverse:m.noop,fn:m.program(2,d,q),data:q});if(p||p===0){o+=p}o+="\n";return o}function d(r,q){var o="",p;o+='\n <option value="';p=(typeof r===h?r.apply(r):r);if(p||p===0){o+=p}o+='">';p=(typeof r===h?r.apply(r):r);if(p||p===0){o+=p}o+="</option>\n ";return o}function n(p,o){return'\n <option value="application/json">application/json</option>\n'}i+='<label for="contentType"></label>\n<select name="contentType">\n';c=f["if"].call(l,l.produces,{hash:{},inverse:m.program(4,n,j),fn:m.program(1,e,j),data:j});if(c||c===0){i+=c}i+="\n</select>\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.main=b(function(h,n,g,m,l){this.compilerInfo=[4,">= 1.0.0"];g=this.merge(g,h.helpers);l=l||{};var j="",c,s,i="function",k=this.escapeExpression,q=this;function f(x,w){var t="",v,u;t+='\n <div class="info_title">'+k(((v=((v=x.info),v==null||v===false?v:v.title)),typeof v===i?v.apply(x):v))+'</div>\n <div class="info_description">';u=((v=((v=x.info),v==null||v===false?v:v.description)),typeof v===i?v.apply(x):v);if(u||u===0){t+=u}t+="</div>\n ";u=g["if"].call(x,((v=x.info),v==null||v===false?v:v.termsOfServiceUrl),{hash:{},inverse:q.noop,fn:q.program(2,d,w),data:w});if(u||u===0){t+=u}t+="\n ";u=g["if"].call(x,((v=x.info),v==null||v===false?v:v.contact),{hash:{},inverse:q.noop,fn:q.program(4,r,w),data:w});if(u||u===0){t+=u}t+="\n ";u=g["if"].call(x,((v=x.info),v==null||v===false?v:v.license),{hash:{},inverse:q.noop,fn:q.program(6,p,w),data:w});if(u||u===0){t+=u}t+="\n ";return t}function d(w,v){var t="",u;t+='<div class="info_tos"><a href="'+k(((u=((u=w.info),u==null||u===false?u:u.termsOfServiceUrl)),typeof u===i?u.apply(w):u))+'">Terms of service</a></div>';return t}function r(w,v){var t="",u;t+="<div class='info_contact'><a href=\"mailto:"+k(((u=((u=((u=w.info),u==null||u===false?u:u.contact)),u==null||u===false?u:u.name)),typeof u===i?u.apply(w):u))+'">Contact the developer</a></div>';return t}function p(w,v){var t="",u;t+="<div class='info_license'><a href='"+k(((u=((u=((u=w.info),u==null||u===false?u:u.license)),u==null||u===false?u:u.url)),typeof u===i?u.apply(w):u))+"'>"+k(((u=((u=((u=w.info),u==null||u===false?u:u.license)),u==null||u===false?u:u.name)),typeof u===i?u.apply(w):u))+"</a></div>";return t}function o(w,v){var t="",u;t+='\n , <span style="font-variant: small-caps">api version</span>: '+k(((u=((u=w.info),u==null||u===false?u:u.version)),typeof u===i?u.apply(w):u))+"\n ";return t}function e(w,v){var t="",u;t+='\n <span style="float:right"><a href="http://online.swagger.io/validator/debug?url=';if(u=g.url){u=u.call(w,{hash:{},data:v})}else{u=w.url;u=typeof u===i?u.apply(w):u}t+=k(u)+'"><img id="validator" src="http://online.swagger.io/validator?url=';if(u=g.url){u=u.call(w,{hash:{},data:v})}else{u=w.url;u=typeof u===i?u.apply(w):u}t+=k(u)+'"></a>\n </span>\n ';return t}j+="<div class='info' id='api_info'>\n ";c=g["if"].call(n,n.info,{hash:{},inverse:q.noop,fn:q.program(1,f,l),data:l});if(c||c===0){j+=c}j+="\n</div>\n<div class='container' id='resources_container'>\n <ul id='resources'>\n </ul>\n\n <div class=\"footer\">\n <br>\n <br>\n <h4 style=\"color: #999\">[ <span style=\"font-variant: small-caps\">base url</span>: ";if(c=g.basePath){c=c.call(n,{hash:{},data:l})}else{c=n.basePath;c=typeof c===i?c.apply(n):c}j+=k(c)+"\n ";s=g["if"].call(n,((c=n.info),c==null||c===false?c:c.version),{hash:{},inverse:q.noop,fn:q.program(8,o,l),data:l});if(s||s===0){j+=s}j+="]\n ";s=g["if"].call(n,n.validatorUrl,{hash:{},inverse:q.noop,fn:q.program(10,e,l),data:l});if(s||s===0){j+=s}j+="\n </h4>\n </div>\n</div>\n";return j})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.operation=b(function(g,s,q,m,y){this.compilerInfo=[4,">= 1.0.0"];q=this.merge(q,g.helpers);y=y||{};var r="",i,f,e="function",d=this.escapeExpression,p=this,c=q.blockHelperMissing;function o(C,B){var z="",A;z+="\n <h4>Implementation Notes</h4>\n <p>";if(A=q.description){A=A.call(C,{hash:{},data:B})}else{A=C.description;A=typeof A===e?A.apply(C):A}if(A||A===0){z+=A}z+="</p>\n ";return z}function n(A,z){return'\n <div class="auth">\n <span class="api-ic ic-error"></span>'}function l(C,B){var z="",A;z+='\n <div id="api_information_panel" style="top: 526px; left: 776px; display: none;">\n ';A=q.each.call(C,C,{hash:{},inverse:p.noop,fn:p.program(6,k,B),data:B});if(A||A===0){z+=A}z+="\n </div>\n ";return z}function k(D,C){var z="",B,A;z+="\n <div title='";A=((B=D.description),typeof B===e?B.apply(D):B);if(A||A===0){z+=A}z+="'>"+d(((B=D.scope),typeof B===e?B.apply(D):B))+"</div>\n ";return z}function h(A,z){return"</div>"}function x(A,z){return'\n <div class=\'access\'>\n <span class="api-ic ic-off" title="click to authenticate"></span>\n </div>\n '}function w(A,z){return'\n <h4>Response Class</h4>\n <p><span class="model-signature" /></p>\n <br/>\n <div class="response-content-type" />\n '}function v(A,z){return'\n <h4>Parameters</h4>\n <table class=\'fullwidth\'>\n <thead>\n <tr>\n <th style="width: 100px; max-width: 100px">Parameter</th>\n <th style="width: 310px; max-width: 310px">Value</th>\n <th style="width: 200px; max-width: 200px">Description</th>\n <th style="width: 100px; max-width: 100px">Parameter Type</th>\n <th style="width: 220px; max-width: 230px">Data Type</th>\n </tr>\n </thead>\n <tbody class="operation-params">\n\n </tbody>\n </table>\n '}function u(A,z){return"\n <div style='margin:0;padding:0;display:inline'></div>\n <h4>Response Messages</h4>\n <table class='fullwidth'>\n <thead>\n <tr>\n <th>HTTP Status Code</th>\n <th>Reason</th>\n <th>Response Model</th>\n </tr>\n </thead>\n <tbody class=\"operation-status\">\n \n </tbody>\n </table>\n "}function t(A,z){return"\n "}function j(A,z){return"\n <div class='sandbox_header'>\n <input class='submit' name='commit' type='button' value='Try it out!' />\n <a href='#' class='response_hider' style='display:none'>Hide Response</a>\n <span class='response_throbber' style='display:none'></span>\n </div>\n "}r+="\n <ul class='operations' >\n <li class='";if(i=q.method){i=i.call(s,{hash:{},data:y})}else{i=s.method;i=typeof i===e?i.apply(s):i}r+=d(i)+" operation' id='";if(i=q.parentId){i=i.call(s,{hash:{},data:y})}else{i=s.parentId;i=typeof i===e?i.apply(s):i}r+=d(i)+"_";if(i=q.nickname){i=i.call(s,{hash:{},data:y})}else{i=s.nickname;i=typeof i===e?i.apply(s):i}r+=d(i)+"'>\n <div class='heading'>\n <h3>\n <span class='http_method'>\n <a href='#!/";if(i=q.parentId){i=i.call(s,{hash:{},data:y})}else{i=s.parentId;i=typeof i===e?i.apply(s):i}r+=d(i)+"/";if(i=q.nickname){i=i.call(s,{hash:{},data:y})}else{i=s.nickname;i=typeof i===e?i.apply(s):i}r+=d(i)+'\' class="toggleOperation">';if(i=q.method){i=i.call(s,{hash:{},data:y})}else{i=s.method;i=typeof i===e?i.apply(s):i}r+=d(i)+"</a>\n </span>\n <span class='path'>\n <a href='#!/";if(i=q.parentId){i=i.call(s,{hash:{},data:y})}else{i=s.parentId;i=typeof i===e?i.apply(s):i}r+=d(i)+"/";if(i=q.nickname){i=i.call(s,{hash:{},data:y})}else{i=s.nickname;i=typeof i===e?i.apply(s):i}r+=d(i)+'\' class="toggleOperation">';if(i=q.path){i=i.call(s,{hash:{},data:y})}else{i=s.path;i=typeof i===e?i.apply(s):i}r+=d(i)+"</a>\n </span>\n </h3>\n <ul class='options'>\n <li>\n <a href='#!/";if(i=q.parentId){i=i.call(s,{hash:{},data:y})}else{i=s.parentId;i=typeof i===e?i.apply(s):i}r+=d(i)+"/";if(i=q.nickname){i=i.call(s,{hash:{},data:y})}else{i=s.nickname;i=typeof i===e?i.apply(s):i}r+=d(i)+'\' class="toggleOperation">';if(i=q.summary){i=i.call(s,{hash:{},data:y})}else{i=s.summary;i=typeof i===e?i.apply(s):i}if(i||i===0){r+=i}r+="</a>\n </li>\n </ul>\n </div>\n <div class='content' id='";if(i=q.parentId){i=i.call(s,{hash:{},data:y})}else{i=s.parentId;i=typeof i===e?i.apply(s):i}r+=d(i)+"_";if(i=q.nickname){i=i.call(s,{hash:{},data:y})}else{i=s.nickname;i=typeof i===e?i.apply(s):i}r+=d(i)+"_content' style='display:none'>\n ";i=q["if"].call(s,s.description,{hash:{},inverse:p.noop,fn:p.program(1,o,y),data:y});if(i||i===0){r+=i}r+="\n ";f={hash:{},inverse:p.noop,fn:p.program(3,n,y),data:y};if(i=q.oauth){i=i.call(s,f)}else{i=s.oauth;i=typeof i===e?i.apply(s):i}if(!q.oauth){i=c.call(s,i,f)}if(i||i===0){r+=i}r+="\n ";i=q.each.call(s,s.oauth,{hash:{},inverse:p.noop,fn:p.program(5,l,y),data:y});if(i||i===0){r+=i}r+="\n ";f={hash:{},inverse:p.noop,fn:p.program(8,h,y),data:y};if(i=q.oauth){i=i.call(s,f)}else{i=s.oauth;i=typeof i===e?i.apply(s):i}if(!q.oauth){i=c.call(s,i,f)}if(i||i===0){r+=i}r+="\n ";f={hash:{},inverse:p.noop,fn:p.program(10,x,y),data:y};if(i=q.oauth){i=i.call(s,f)}else{i=s.oauth;i=typeof i===e?i.apply(s):i}if(!q.oauth){i=c.call(s,i,f)}if(i||i===0){r+=i}r+="\n ";i=q["if"].call(s,s.type,{hash:{},inverse:p.noop,fn:p.program(12,w,y),data:y});if(i||i===0){r+=i}r+="\n <form accept-charset='UTF-8' class='sandbox'>\n <div style='margin:0;padding:0;display:inline'></div>\n ";i=q["if"].call(s,s.parameters,{hash:{},inverse:p.noop,fn:p.program(14,v,y),data:y});if(i||i===0){r+=i}r+="\n ";i=q["if"].call(s,s.responseMessages,{hash:{},inverse:p.noop,fn:p.program(16,u,y),data:y});if(i||i===0){r+=i}r+="\n ";i=q["if"].call(s,s.isReadOnly,{hash:{},inverse:p.program(20,j,y),fn:p.program(18,t,y),data:y});if(i||i===0){r+=i}r+="\n </form>\n <div class='response' style='display:none'>\n <h4>Request URL</h4>\n <div class='block request_url'></div>\n <h4>Response Body</h4>\n <div class='block response_body'></div>\n <h4>Response Code</h4>\n <div class='block response_code'></div>\n <h4>Response Headers</h4>\n <div class='block response_headers'></div>\n </div>\n </div>\n </li>\n </ul>\n";return r})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param=b(function(f,q,o,j,t){this.compilerInfo=[4,">= 1.0.0"];o=this.merge(o,f.helpers);t=t||{};var p="",g,d="function",c=this.escapeExpression,n=this;function m(y,x){var v="",w;v+="\n ";w=o["if"].call(y,y.isFile,{hash:{},inverse:n.program(4,k,x),fn:n.program(2,l,x),data:x});if(w||w===0){v+=w}v+="\n ";return v}function l(y,x){var v="",w;v+='\n <input type="file" name=\'';if(w=o.name){w=w.call(y,{hash:{},data:x})}else{w=y.name;w=typeof w===d?w.apply(y):w}v+=c(w)+'\'/>\n <div class="parameter-content-type" />\n ';return v}function k(y,x){var v="",w;v+="\n ";w=o["if"].call(y,y["default"],{hash:{},inverse:n.program(7,h,x),fn:n.program(5,i,x),data:x});if(w||w===0){v+=w}v+="\n ";return v}function i(y,x){var v="",w;v+="\n <textarea class='body-textarea' name='";if(w=o.name){w=w.call(y,{hash:{},data:x})}else{w=y.name;w=typeof w===d?w.apply(y):w}v+=c(w)+"'>";if(w=o["default"]){w=w.call(y,{hash:{},data:x})}else{w=y["default"];w=typeof w===d?w.apply(y):w}v+=c(w)+"</textarea>\n ";return v}function h(y,x){var v="",w;v+="\n <textarea class='body-textarea' name='";if(w=o.name){w=w.call(y,{hash:{},data:x})}else{w=y.name;w=typeof w===d?w.apply(y):w}v+=c(w)+'\'></textarea>\n <br />\n <div class="parameter-content-type" />\n ';return v}function e(y,x){var v="",w;v+="\n ";w=o["if"].call(y,y.isFile,{hash:{},inverse:n.program(10,u,x),fn:n.program(2,l,x),data:x});if(w||w===0){v+=w}v+="\n ";return v}function u(y,x){var v="",w;v+="\n ";w=o["if"].call(y,y["default"],{hash:{},inverse:n.program(13,r,x),fn:n.program(11,s,x),data:x});if(w||w===0){v+=w}v+="\n ";return v}function s(y,x){var v="",w;v+="\n <input class='parameter' minlength='0' name='";if(w=o.name){w=w.call(y,{hash:{},data:x})}else{w=y.name;w=typeof w===d?w.apply(y):w}v+=c(w)+"' placeholder='' type='text' value='";if(w=o["default"]){w=w.call(y,{hash:{},data:x})}else{w=y["default"];w=typeof w===d?w.apply(y):w}v+=c(w)+"'/>\n ";return v}function r(y,x){var v="",w;v+="\n <input class='parameter' minlength='0' name='";if(w=o.name){w=w.call(y,{hash:{},data:x})}else{w=y.name;w=typeof w===d?w.apply(y):w}v+=c(w)+"' placeholder='' type='text' value=''/>\n ";return v}p+="<td class='code'>";if(g=o.name){g=g.call(q,{hash:{},data:t})}else{g=q.name;g=typeof g===d?g.apply(q):g}p+=c(g)+"</td>\n<td>\n\n ";g=o["if"].call(q,q.isBody,{hash:{},inverse:n.program(9,e,t),fn:n.program(1,m,t),data:t});if(g||g===0){p+=g}p+="\n\n</td>\n<td>";if(g=o.description){g=g.call(q,{hash:{},data:t})}else{g=q.description;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+="</td>\n<td>";if(g=o.paramType){g=g.call(q,{hash:{},data:t})}else{g=q.paramType;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+='</td>\n<td>\n <span class="model-signature"></span>\n</td>\n';return p})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_list=b(function(h,t,r,m,y){this.compilerInfo=[4,">= 1.0.0"];r=this.merge(r,h.helpers);y=y||{};var s="",j,g,e,p=this,q=r.helperMissing,d="function",c=this.escapeExpression;function o(A,z){return" multiple='multiple'"}function n(A,z){return"\n "}function l(C,B){var z="",A;z+="\n ";A=r["if"].call(C,C.defaultValue,{hash:{},inverse:p.program(8,i,B),fn:p.program(6,k,B),data:B});if(A||A===0){z+=A}z+="\n ";return z}function k(A,z){return"\n "}function i(E,D){var z="",C,B,A;z+="\n ";A={hash:{},inverse:p.program(11,x,D),fn:p.program(9,f,D),data:D};B=((C=r.isArray||E.isArray),C?C.call(E,E,A):q.call(E,"isArray",E,A));if(B||B===0){z+=B}z+="\n ";return z}function f(A,z){return"\n "}function x(A,z){return"\n <option selected=\"\" value=''></option>\n "}function w(C,B){var z="",A;z+="\n ";A=r["if"].call(C,C.isDefault,{hash:{},inverse:p.program(16,u,B),fn:p.program(14,v,B),data:B});if(A||A===0){z+=A}z+="\n ";return z}function v(C,B){var z="",A;z+='\n <option selected="" value=\'';if(A=r.value){A=A.call(C,{hash:{},data:B})}else{A=C.value;A=typeof A===d?A.apply(C):A}z+=c(A)+"'>";if(A=r.value){A=A.call(C,{hash:{},data:B})}else{A=C.value;A=typeof A===d?A.apply(C):A}z+=c(A)+" (default)</option>\n ";return z}function u(C,B){var z="",A;z+="\n <option value='";if(A=r.value){A=A.call(C,{hash:{},data:B})}else{A=C.value;A=typeof A===d?A.apply(C):A}z+=c(A)+"'>";if(A=r.value){A=A.call(C,{hash:{},data:B})}else{A=C.value;A=typeof A===d?A.apply(C):A}z+=c(A)+"</option>\n ";return z}s+="<td class='code'>";if(j=r.name){j=j.call(t,{hash:{},data:y})}else{j=t.name;j=typeof j===d?j.apply(t):j}s+=c(j)+"</td>\n<td>\n <select ";e={hash:{},inverse:p.noop,fn:p.program(1,o,y),data:y};g=((j=r.isArray||t.isArray),j?j.call(t,t,e):q.call(t,"isArray",t,e));if(g||g===0){s+=g}s+=" class='parameter' name='";if(g=r.name){g=g.call(t,{hash:{},data:y})}else{g=t.name;g=typeof g===d?g.apply(t):g}s+=c(g)+"'>\n ";g=r["if"].call(t,t.required,{hash:{},inverse:p.program(5,l,y),fn:p.program(3,n,y),data:y});if(g||g===0){s+=g}s+="\n ";g=r.each.call(t,((j=t.allowableValues),j==null||j===false?j:j.descriptiveValues),{hash:{},inverse:p.noop,fn:p.program(13,w,y),data:y});if(g||g===0){s+=g}s+="\n </select>\n</td>\n<td>";if(g=r.description){g=g.call(t,{hash:{},data:y})}else{g=t.description;g=typeof g===d?g.apply(t):g}if(g||g===0){s+=g}s+="</td>\n<td>";if(g=r.paramType){g=g.call(t,{hash:{},data:y})}else{g=t.paramType;g=typeof g===d?g.apply(t):g}if(g||g===0){s+=g}s+='</td>\n<td><span class="model-signature"></span></td>';return s})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly=b(function(g,m,f,l,k){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);k=k||{};var i="",d,h="function",j=this.escapeExpression,o=this;function e(t,s){var q="",r;q+="\n <textarea class='body-textarea' readonly='readonly' name='";if(r=f.name){r=r.call(t,{hash:{},data:s})}else{r=t.name;r=typeof r===h?r.apply(t):r}q+=j(r)+"'>";if(r=f.defaultValue){r=r.call(t,{hash:{},data:s})}else{r=t.defaultValue;r=typeof r===h?r.apply(t):r}q+=j(r)+"</textarea>\n ";return q}function c(t,s){var q="",r;q+="\n ";r=f["if"].call(t,t.defaultValue,{hash:{},inverse:o.program(6,n,s),fn:o.program(4,p,s),data:s});if(r||r===0){q+=r}q+="\n ";return q}function p(t,s){var q="",r;q+="\n ";if(r=f.defaultValue){r=r.call(t,{hash:{},data:s})}else{r=t.defaultValue;r=typeof r===h?r.apply(t):r}q+=j(r)+"\n ";return q}function n(r,q){return"\n (empty)\n "}i+="<td class='code'>";if(d=f.name){d=d.call(m,{hash:{},data:k})}else{d=m.name;d=typeof d===h?d.apply(m):d}i+=j(d)+"</td>\n<td>\n ";d=f["if"].call(m,m.isBody,{hash:{},inverse:o.program(3,c,k),fn:o.program(1,e,k),data:k});if(d||d===0){i+=d}i+="\n</td>\n<td>";if(d=f.description){d=d.call(m,{hash:{},data:k})}else{d=m.description;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+="</td>\n<td>";if(d=f.paramType){d=d.call(m,{hash:{},data:k})}else{d=m.paramType;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+='</td>\n<td><span class="model-signature"></span></td>\n';return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly_required=b(function(g,m,f,l,k){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);k=k||{};var i="",d,h="function",j=this.escapeExpression,o=this;function e(t,s){var q="",r;q+="\n <textarea class='body-textarea' readonly='readonly' placeholder='(required)' name='";if(r=f.name){r=r.call(t,{hash:{},data:s})}else{r=t.name;r=typeof r===h?r.apply(t):r}q+=j(r)+"'>";if(r=f.defaultValue){r=r.call(t,{hash:{},data:s})}else{r=t.defaultValue;r=typeof r===h?r.apply(t):r}q+=j(r)+"</textarea>\n ";return q}function c(t,s){var q="",r;q+="\n ";r=f["if"].call(t,t.defaultValue,{hash:{},inverse:o.program(6,n,s),fn:o.program(4,p,s),data:s});if(r||r===0){q+=r}q+="\n ";return q}function p(t,s){var q="",r;q+="\n ";if(r=f.defaultValue){r=r.call(t,{hash:{},data:s})}else{r=t.defaultValue;r=typeof r===h?r.apply(t):r}q+=j(r)+"\n ";return q}function n(r,q){return"\n (empty)\n "}i+="<td class='code required'>";if(d=f.name){d=d.call(m,{hash:{},data:k})}else{d=m.name;d=typeof d===h?d.apply(m):d}i+=j(d)+"</td>\n<td>\n ";d=f["if"].call(m,m.isBody,{hash:{},inverse:o.program(3,c,k),fn:o.program(1,e,k),data:k});if(d||d===0){i+=d}i+="\n</td>\n<td>";if(d=f.description){d=d.call(m,{hash:{},data:k})}else{d=m.description;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+="</td>\n<td>";if(d=f.paramType){d=d.call(m,{hash:{},data:k})}else{d=m.paramType;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+='</td>\n<td><span class="model-signature"></span></td>\n';return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_required=b(function(f,q,o,j,u){this.compilerInfo=[4,">= 1.0.0"];o=this.merge(o,f.helpers);u=u||{};var p="",g,d="function",c=this.escapeExpression,n=this;function m(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.isFile,{hash:{},inverse:n.program(4,k,y),fn:n.program(2,l,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function l(z,y){var w="",x;w+='\n <input type="file" name=\'';if(x=o.name){x=x.call(z,{hash:{},data:y})}else{x=z.name;x=typeof x===d?x.apply(z):x}w+=c(x)+"'/>\n ";return w}function k(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.defaultValue,{hash:{},inverse:n.program(7,h,y),fn:n.program(5,i,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function i(z,y){var w="",x;w+="\n <textarea class='body-textarea' placeholder='(required)' name='";if(x=o.name){x=x.call(z,{hash:{},data:y})}else{x=z.name;x=typeof x===d?x.apply(z):x}w+=c(x)+"'>";if(x=o.defaultValue){x=x.call(z,{hash:{},data:y})}else{x=z.defaultValue;x=typeof x===d?x.apply(z):x}w+=c(x)+"</textarea>\n ";return w}function h(z,y){var w="",x;w+="\n <textarea class='body-textarea' placeholder='(required)' name='";if(x=o.name){x=x.call(z,{hash:{},data:y})}else{x=z.name;x=typeof x===d?x.apply(z):x}w+=c(x)+'\'></textarea>\n <br />\n <div class="parameter-content-type" />\n ';return w}function e(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.isFile,{hash:{},inverse:n.program(12,t,y),fn:n.program(10,v,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function v(z,y){var w="",x;w+="\n <input class='parameter' class='required' type='file' name='";if(x=o.name){x=x.call(z,{hash:{},data:y})}else{x=z.name;x=typeof x===d?x.apply(z):x}w+=c(x)+"'/>\n ";return w}function t(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.defaultValue,{hash:{},inverse:n.program(15,r,y),fn:n.program(13,s,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function s(z,y){var w="",x;w+="\n <input class='parameter required' minlength='1' name='";if(x=o.name){x=x.call(z,{hash:{},data:y})}else{x=z.name;x=typeof x===d?x.apply(z):x}w+=c(x)+"' placeholder='(required)' type='text' value='";if(x=o.defaultValue){x=x.call(z,{hash:{},data:y})}else{x=z.defaultValue;x=typeof x===d?x.apply(z):x}w+=c(x)+"'/>\n ";return w}function r(z,y){var w="",x;w+="\n <input class='parameter required' minlength='1' name='";if(x=o.name){x=x.call(z,{hash:{},data:y})}else{x=z.name;x=typeof x===d?x.apply(z):x}w+=c(x)+"' placeholder='(required)' type='text' value=''/>\n ";return w}p+="<td class='code required'>";if(g=o.name){g=g.call(q,{hash:{},data:u})}else{g=q.name;g=typeof g===d?g.apply(q):g}p+=c(g)+"</td>\n<td>\n ";g=o["if"].call(q,q.isBody,{hash:{},inverse:n.program(9,e,u),fn:n.program(1,m,u),data:u});if(g||g===0){p+=g}p+="\n</td>\n<td>\n <strong>";if(g=o.description){g=g.call(q,{hash:{},data:u})}else{g=q.description;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+="</strong>\n</td>\n<td>";if(g=o.paramType){g=g.call(q,{hash:{},data:u})}else{g=q.paramType;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+='</td>\n<td><span class="model-signature"></span></td>\n';return p})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.parameter_content_type=b(function(g,l,f,k,j){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);j=j||{};var i="",c,h="function",m=this;function e(r,q){var o="",p;o+="\n ";p=f.each.call(r,r.consumes,{hash:{},inverse:m.noop,fn:m.program(2,d,q),data:q});if(p||p===0){o+=p}o+="\n";return o}function d(r,q){var o="",p;o+='\n <option value="';p=(typeof r===h?r.apply(r):r);if(p||p===0){o+=p}o+='">';p=(typeof r===h?r.apply(r):r);if(p||p===0){o+=p}o+="</option>\n ";return o}function n(p,o){return'\n <option value="application/json">application/json</option>\n'}i+='<label for="parameterContentType"></label>\n<select name="parameterContentType">\n';c=f["if"].call(l,l.consumes,{hash:{},inverse:m.program(4,n,j),fn:m.program(1,e,j),data:j});if(c||c===0){i+=c}i+="\n</select>\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.resource=b(function(g,m,f,l,k){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);k=k||{};var i="",d,p,h="function",j=this.escapeExpression,o=this,n=f.blockHelperMissing;function e(r,q){return" : "}function c(t,s){var q="",r;q+="<li>\n <a href='";if(r=f.url){r=r.call(t,{hash:{},data:s})}else{r=t.url;r=typeof r===h?r.apply(t):r}q+=j(r)+"'>Raw</a>\n </li>";return q}i+="<div class='heading'>\n <h2>\n <a href='#!/";if(d=f.id){d=d.call(m,{hash:{},data:k})}else{d=m.id;d=typeof d===h?d.apply(m):d}i+=j(d)+'\' class="toggleEndpointList" data-id="';if(d=f.id){d=d.call(m,{hash:{},data:k})}else{d=m.id;d=typeof d===h?d.apply(m):d}i+=j(d)+'">';if(d=f.name){d=d.call(m,{hash:{},data:k})}else{d=m.name;d=typeof d===h?d.apply(m):d}i+=j(d)+"</a> ";p={hash:{},inverse:o.noop,fn:o.program(1,e,k),data:k};if(d=f.summary){d=d.call(m,p)}else{d=m.summary;d=typeof d===h?d.apply(m):d}if(!f.summary){d=n.call(m,d,p)}if(d||d===0){i+=d}if(d=f.summary){d=d.call(m,{hash:{},data:k})}else{d=m.summary;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+="\n </h2>\n <ul class='options'>\n <li>\n <a href='#!/";if(d=f.id){d=d.call(m,{hash:{},data:k})}else{d=m.id;d=typeof d===h?d.apply(m):d}i+=j(d)+"' id='endpointListTogger_";if(d=f.id){d=d.call(m,{hash:{},data:k})}else{d=m.id;d=typeof d===h?d.apply(m):d}i+=j(d)+'\' class="toggleEndpointList" data-id="';if(d=f.id){d=d.call(m,{hash:{},data:k})}else{d=m.id;d=typeof d===h?d.apply(m):d}i+=j(d)+'">Show/Hide</a>\n </li>\n <li>\n <a href=\'#\' class="collapseResource" data-id="';if(d=f.id){d=d.call(m,{hash:{},data:k})}else{d=m.id;d=typeof d===h?d.apply(m):d}i+=j(d)+'">\n List Operations\n </a>\n </li>\n <li>\n <a href=\'#\' class="expandResource" data-id=';if(d=f.id){d=d.call(m,{hash:{},data:k})}else{d=m.id;d=typeof d===h?d.apply(m):d}i+=j(d)+">\n Expand Operations\n </a>\n </li>\n ";p={hash:{},inverse:o.noop,fn:o.program(3,c,k),data:k};if(d=f.url){d=d.call(m,p)}else{d=m.url;d=typeof d===h?d.apply(m):d}if(!f.url){d=n.call(m,d,p)}if(d||d===0){i+=d}i+="\n </ul>\n</div>\n<ul class='endpoints' id='";if(d=f.id){d=d.call(m,{hash:{},data:k})}else{d=m.id;d=typeof d===h?d.apply(m):d}i+=j(d)+"_endpoint_list' style='display:none'>\n\n</ul>\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.response_content_type=b(function(g,l,f,k,j){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);j=j||{};var i="",c,h="function",m=this;function e(r,q){var o="",p;o+="\n ";p=f.each.call(r,r.produces,{hash:{},inverse:m.noop,fn:m.program(2,d,q),data:q});if(p||p===0){o+=p}o+="\n";return o}function d(r,q){var o="",p;o+='\n <option value="';p=(typeof r===h?r.apply(r):r);if(p||p===0){o+=p}o+='">';p=(typeof r===h?r.apply(r):r);if(p||p===0){o+=p}o+="</option>\n ";return o}function n(p,o){return'\n <option value="application/json">application/json</option>\n'}i+='<label for="responseContentType"></label>\n<select name="responseContentType">\n';c=f["if"].call(l,l.produces,{hash:{},inverse:m.program(4,n,j),fn:m.program(1,e,j),data:j});if(c||c===0){i+=c}i+="\n</select>\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.signature=b(function(e,k,d,j,i){this.compilerInfo=[4,">= 1.0.0"];d=this.merge(d,e.helpers);i=i||{};var g="",c,f="function",h=this.escapeExpression;g+='<div>\n<ul class="signature-nav">\n <li><a class="description-link" href="#">Model</a></li>\n <li><a class="snippet-link" href="#">Model Schema</a></li>\n</ul>\n<div>\n\n<div class="signature-container">\n <div class="description">\n ';if(c=d.signature){c=c.call(k,{hash:{},data:i})}else{c=k.signature;c=typeof c===f?c.apply(k):c}if(c||c===0){g+=c}g+='\n </div>\n\n <div class="snippet">\n <pre><code>';if(c=d.sampleJSON){c=c.call(k,{hash:{},data:i})}else{c=k.sampleJSON;c=typeof c===f?c.apply(k):c}g+=h(c)+'</code></pre>\n <small class="notice"></small>\n </div>\n</div>\n\n';return g})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.status_code=b(function(e,k,d,j,i){this.compilerInfo=[4,">= 1.0.0"];d=this.merge(d,e.helpers);i=i||{};var g="",c,f="function",h=this.escapeExpression;g+="<td width='15%' class='code'>";if(c=d.code){c=c.call(k,{hash:{},data:i})}else{c=k.code;c=typeof c===f?c.apply(k):c}g+=h(c)+"</td>\n<td>";if(c=d.message){c=c.call(k,{hash:{},data:i})}else{c=k.message;c=typeof c===f?c.apply(k):c}if(c||c===0){g+=c}g+="</td>\n<td width='50%'><span class=\"model-signature\" /></td>";return g})})();(function(){var j,r,u,o,l,k,n,m,i,p,s,q,h,c,g,f,e,d,b,a,x,w,t={}.hasOwnProperty,v=function(B,z){for(var y in z){if(t.call(z,y)){B[y]=z[y]}}function A(){this.constructor=B}A.prototype=z.prototype;B.prototype=new A();B.__super__=z.prototype;return B};s=(function(z){v(y,z);function y(){q=y.__super__.constructor.apply(this,arguments);return q}y.prototype.dom_id="swagger_ui";y.prototype.options=null;y.prototype.api=null;y.prototype.headerView=null;y.prototype.mainView=null;y.prototype.initialize=function(A){var B=this;if(A==null){A={}}if(A.dom_id!=null){this.dom_id=A.dom_id;delete A.dom_id}if($("#"+this.dom_id)==null){$("body").append('<div id="'+this.dom_id+'"></div>')}this.options=A;this.options.success=function(){return B.render()};this.options.progress=function(C){return B.showMessage(C)};this.options.failure=function(C){if(B.api&&B.api.isValid===false){log("not a valid 2.0 spec, loading legacy client");B.api=new SwaggerApi(B.options);return B.api.build()}else{return B.onLoadFailure(C)}};this.headerView=new r({el:$("#header")});return this.headerView.on("update-swagger-ui",function(C){return B.updateSwaggerUi(C)})};y.prototype.updateSwaggerUi=function(A){this.options.url=A.url;return this.load()};y.prototype.load=function(){var B,A;if((A=this.mainView)!=null){A.clear()}B=this.options.url;if(B.indexOf("http")!==0){B=this.buildUrl(window.location.href.toString(),B)}this.options.url=B;this.headerView.update(B);this.api=new SwaggerClient(this.options);return this.api.build()};y.prototype.render=function(){var A=this;this.showMessage("Finished Loading Resource Information. Rendering Swagger UI...");this.mainView=new u({model:this.api,el:$("#"+this.dom_id),swaggerOptions:this.options}).render();this.showMessage();switch(this.options.docExpansion){case"full":Docs.expandOperationsForResource("");break;case"list":Docs.collapseOperationsForResource("")}if(this.options.onComplete){this.options.onComplete(this.api,this)}return setTimeout(function(){return Docs.shebang()},400)};y.prototype.buildUrl=function(C,A){var B,D;log("base is "+C);if(A.indexOf("/")===0){D=C.split("/");C=D[0]+"//"+D[2];return C+A}else{B=C.length;if(C.indexOf("?")>-1){B=Math.min(B,C.indexOf("?"))}if(C.indexOf("#")>-1){B=Math.min(B,C.indexOf("#"))}C=C.substring(0,B);if(C.indexOf("/",C.length-1)!==-1){return C+A}return C+"/"+A}};y.prototype.showMessage=function(A){if(A==null){A=""}$("#message-bar").removeClass("message-fail");$("#message-bar").addClass("message-success");return $("#message-bar").html(A)};y.prototype.onLoadFailure=function(A){var B;if(A==null){A=""}$("#message-bar").removeClass("message-success");$("#message-bar").addClass("message-fail");B=$("#message-bar").html(A);if(this.options.onFailure!=null){this.options.onFailure(A)}return B};return y})(Backbone.Router);window.SwaggerUi=s;r=(function(z){v(y,z);function y(){h=y.__super__.constructor.apply(this,arguments);return h}y.prototype.events={"click #show-pet-store-icon":"showPetStore","click #show-wordnik-dev-icon":"showWordnikDev","click #explore":"showCustom","keyup #input_baseUrl":"showCustomOnKeyup","keyup #input_apiKey":"showCustomOnKeyup"};y.prototype.initialize=function(){};y.prototype.showPetStore=function(A){return this.trigger("update-swagger-ui",{url:"http://petstore.swagger.wordnik.com/api/api-docs"})};y.prototype.showWordnikDev=function(A){return this.trigger("update-swagger-ui",{url:"http://api.wordnik.com/v4/resources.json"})};y.prototype.showCustomOnKeyup=function(A){if(A.keyCode===13){return this.showCustom()}};y.prototype.showCustom=function(A){if(A!=null){A.preventDefault()}return this.trigger("update-swagger-ui",{url:$("#input_baseUrl").val(),apiKey:$("#input_apiKey").val()})};y.prototype.update=function(B,C,A){if(A==null){A=false}$("#input_baseUrl").val(B);if(A){return this.trigger("update-swagger-ui",{url:B})}};return y})(Backbone.View);u=(function(y){var z;v(A,y);function A(){g=A.__super__.constructor.apply(this,arguments);return g}z={alpha:function(C,B){return C.path.localeCompare(B.path)},method:function(C,B){return C.method.localeCompare(B.method)}};A.prototype.initialize=function(B){var C,I,J,E,D,G,H,F;if(B==null){B={}}if(B.swaggerOptions.sorter){E=B.swaggerOptions.sorter;J=z[E];if(this.model.apisArray){F=this.model.apisArray;for(G=0,H=F.length;G<H;G++){I=F[G];I.operationsArray.sort(J)}if(E==="alpha"){this.model.apisArray.sort(J)}}}if(this.model.info&&this.model.info.license&&typeof this.model.info.license==="string"){C=this.model.info.license;D=this.model.info.licenseUrl;this.model.info.license={};this.model.info.license.name=C;this.model.info.license.url=D}if(!this.model.info){this.model.info={}}if(!this.model.info.version){this.model.info.version=this.model.apiVersion}if(this.model.url.indexOf("http://localhost")===-1&&this.model.swaggerVersion===2){return this.model.validatorUrl=this.model.url}};A.prototype.render=function(){var C,H,E,F,D,B,G;$(this.el).html(Handlebars.templates.main(this.model));F={};C=0;G=this.model.apisArray;for(D=0,B=G.length;D<B;D++){E=G[D];H=E.name;while(typeof F[H]!=="undefined"){H=H+"_"+C;C+=1}E.id=H;F[H]=E;this.addResource(E)}return this};A.prototype.addResource=function(C){var B;C.id=C.id.replace(/\s/g,"_");B=new n({model:C,tagName:"li",id:"resource_"+C.id,className:"resource",swaggerOptions:this.options.swaggerOptions});return $("#resources").append(B.render().el)};A.prototype.clear=function(){return $(this.el).html("")};return A})(Backbone.View);n=(function(z){v(y,z);function y(){f=y.__super__.constructor.apply(this,arguments);return f}y.prototype.initialize=function(){if(""===this.model.description){return this.model.description=null}};y.prototype.render=function(){var B,G,D,C,E,A,F;$(this.el).html(Handlebars.templates.resource(this.model));D={};if(this.model.description){this.model.summary=this.model.description}F=this.model.operationsArray;for(E=0,A=F.length;E<A;E++){C=F[E];B=0;G=C.nickname;while(typeof D[G]!=="undefined"){G=G+"_"+B;B+=1}D[G]=C;C.nickname=G;C.parentId=this.model.id;this.addOperation(C)}$(".toggleEndpointList",this.el).click(this.callDocs.bind(this,"toggleEndpointListForResource"));$(".collapseResource",this.el).click(this.callDocs.bind(this,"collapseOperationsForResource"));$(".expandResource",this.el).click(this.callDocs.bind(this,"expandOperationsForResource"));return this};y.prototype.addOperation=function(A){var B;A.number=this.number;B=new o({model:A,tagName:"li",className:"endpoint",swaggerOptions:this.options.swaggerOptions});$(".endpoints",$(this.el)).append(B.render().el);return this.number++};y.prototype.callDocs=function(B,A){A.preventDefault();return Docs[B](A.currentTarget.getAttribute("data-id"))};return y})(Backbone.View);o=(function(z){v(y,z);function y(){e=y.__super__.constructor.apply(this,arguments);return e}y.prototype.invocationUrl=null;y.prototype.events={"submit .sandbox":"submitOperation","click .submit":"submitOperation","click .response_hider":"hideResponse","click .toggleOperation":"toggleOperationContent","mouseenter .api-ic":"mouseEnter","mouseout .api-ic":"mouseExit"};y.prototype.initialize=function(){};y.prototype.mouseEnter=function(F){var D,E,I,B,A,J,G,C,K,H;D=$(F.currentTarget.parentNode).find("#api_information_panel");K=F.pageX;H=F.pageY;J=$(window).scrollLeft();G=$(window).scrollTop();B=J+$(window).width();A=G+$(window).height();C=D.width();E=D.height();if(K+C>B){K=B-C}if(K<J){K=J}if(H+E>A){H=A-E}if(H<G){H=G}I={};I.top=H;I.left=K;D.css(I);return $(F.currentTarget.parentNode).find("#api_information_panel").show()};y.prototype.mouseExit=function(A){return $(A.currentTarget.parentNode).find("#api_information_panel").hide()};y.prototype.render=function(){var D,U,V,T,R,K,J,Q,L,P,W,O,M,I,N,S,H,G,F,C,Y,ab,Z,X,E,B,A,ac,aa;V=true;if(!V){this.model.isReadOnly=true}this.model.description=this.model.description||this.model.notes;if(this.model.description){this.model.description=this.model.description.replace(/(?:\r\n|\r|\n)/g,"<br />")}this.model.oauth=null;if(this.model.authorizations){E=this.model.authorizations;for(T in E){N=E[T];if(T==="oauth2"){if(this.model.oauth===null){this.model.oauth={}}if(this.model.oauth.scopes===void 0){this.model.oauth.scopes=[]}for(H=0,Y=N.length;H<Y;H++){R=N[H];this.model.oauth.scopes.push(R)}}}}if(typeof this.model.responses!=="undefined"){this.model.responseMessages=[];B=this.model.responses;for(D in B){S=B[D];P=null;W=this.model.responses[D].schema;if(W&&W["$ref"]){P=W["$ref"];if(P.indexOf("#/definitions/")===0){P=P.substring("#/definitions/".length)}}this.model.responseMessages.push({code:D,message:S.description,responseModel:P})}}if(typeof this.model.responseMessages==="undefined"){this.model.responseMessages=[]}$(this.el).html(Handlebars.templates.operation(this.model));if(this.model.responseClassSignature&&this.model.responseClassSignature!=="string"){O={sampleJSON:this.model.responseSampleJSON,isParam:false,signature:this.model.responseClassSignature};L=new i({model:O,tagName:"div"});$(".model-signature",$(this.el)).append(L.render().el)}else{this.model.responseClassSignature="string";$(".model-signature",$(this.el)).html(this.model.type)}U={isParam:false};U.consumes=this.model.consumes;U.produces=this.model.produces;A=this.model.parameters;for(G=0,ab=A.length;G<ab;G++){K=A[G];I=K.type||K.dataType;if(typeof I==="undefined"){P=K.schema;if(P&&P["$ref"]){J=P["$ref"];if(J.indexOf("#/definitions/")===0){I=J.substring("#/definitions/".length)}else{I=J}}}if(I&&I.toLowerCase()==="file"){if(!U.consumes){U.consumes="multipart/form-data"}}K.type=I}Q=new m({model:U});$(".response-content-type",$(this.el)).append(Q.render().el);ac=this.model.parameters;for(F=0,Z=ac.length;F<Z;F++){K=ac[F];this.addParameter(K,U.consumes)}aa=this.model.responseMessages;for(C=0,X=aa.length;C<X;C++){M=aa[C];this.addStatusCode(M)}return this};y.prototype.addParameter=function(C,A){var B;C.consumes=A;B=new k({model:C,tagName:"tr",readOnly:this.model.isReadOnly});return $(".operation-params",$(this.el)).append(B.render().el)};y.prototype.addStatusCode=function(B){var A;A=new p({model:B,tagName:"tr"});return $(".operation-status",$(this.el)).append(A.render().el)};y.prototype.submitOperation=function(O){var Q,G,N,D,I,A,J,M,L,K,P,F,C,H,E,B;if(O!=null){O.preventDefault()}G=$(".sandbox",$(this.el));Q=true;G.find("input.required").each(function(){var R=this;$(this).removeClass("error");if(jQuery.trim($(this).val())===""){$(this).addClass("error");$(this).wiggle({callback:function(){return $(R).focus()}});return Q=false}});if(Q){D={};A={parent:this};N=false;H=G.find("input");for(M=0,P=H.length;M<P;M++){I=H[M];if((I.value!=null)&&jQuery.trim(I.value).length>0){D[I.name]=I.value}if(I.type==="file"){N=true}}E=G.find("textarea");for(L=0,F=E.length;L<F;L++){I=E[L];if((I.value!=null)&&jQuery.trim(I.value).length>0){D.body=I.value}}B=G.find("select");for(K=0,C=B.length;K<C;K++){I=B[K];J=this.getSelectedValue(I);if((J!=null)&&jQuery.trim(J).length>0){D[I.name]=J}}A.responseContentType=$("div select[name=responseContentType]",$(this.el)).val();A.requestContentType=$("div select[name=parameterContentType]",$(this.el)).val();$(".response_throbber",$(this.el)).show();if(N){return this.handleFileUpload(D,G)}else{return this.model["do"](D,A,this.showCompleteStatus,this.showErrorStatus,this)}}};y.prototype.success=function(A,B){return B.showCompleteStatus(A)};y.prototype.handleFileUpload=function(R,I){var M,H,C,N,L,K,P,J,G,F,D,Q,U,T,S,E,B,A,V,O=this;E=I.serializeArray();for(J=0,Q=E.length;J<Q;J++){N=E[J];if((N.value!=null)&&jQuery.trim(N.value).length>0){R[N.name]=N.value}}M=new FormData();P=0;B=this.model.parameters;for(G=0,U=B.length;G<U;G++){K=B[G];if(K.paramType==="form"){if(K.type.toLowerCase()!=="file"&&R[K.name]!==void 0){M.append(K.name,R[K.name])}}}C={};A=this.model.parameters;for(F=0,T=A.length;F<T;F++){K=A[F];if(K.paramType==="header"){C[K.name]=R[K.name]}}V=I.find('input[type~="file"]');for(D=0,S=V.length;D<S;D++){H=V[D];if(typeof H.files[0]!=="undefined"){M.append($(H).attr("name"),H.files[0]);P+=1}}this.invocationUrl=this.model.supportHeaderParams()?(C=this.model.getHeaderParams(R),this.model.urlify(R,false)):this.model.urlify(R,true);$(".request_url",$(this.el)).html("<pre></pre>");$(".request_url pre",$(this.el)).text(this.invocationUrl);L={type:this.model.method,url:this.invocationUrl,headers:C,data:M,dataType:"json",contentType:false,processData:false,error:function(X,Y,W){return O.showErrorStatus(O.wrap(X),O)},success:function(W){return O.showResponse(W,O)},complete:function(W){return O.showCompleteStatus(O.wrap(W),O)}};if(window.authorizations){window.authorizations.apply(L)}if(P===0){L.data.append("fake","true")}jQuery.ajax(L);return false};y.prototype.wrap=function(E){var C,F,H,B,G,D,A;H={};F=E.getAllResponseHeaders().split("\r");for(D=0,A=F.length;D<A;D++){B=F[D];C=B.split(":");if(C[0]!==void 0&&C[1]!==void 0){H[C[0].trim()]=C[1].trim()}}G={};G.content={};G.content.data=E.responseText;G.headers=H;G.request={};G.request.url=this.invocationUrl;G.status=E.status;return G};y.prototype.getSelectedValue=function(A){var D,C,F,B,E;if(!A.multiple){return A.value}else{C=[];E=A.options;for(F=0,B=E.length;F<B;F++){D=E[F];if(D.selected){C.push(D.value)}}if(C.length>0){return C.join(",")}else{return null}}};y.prototype.hideResponse=function(A){if(A!=null){A.preventDefault()}$(".response",$(this.el)).slideUp();return $(".response_hider",$(this.el)).fadeOut()};y.prototype.showResponse=function(A){var B;B=JSON.stringify(A,null,"\t").replace(/\n/g,"<br>");return $(".response_body",$(this.el)).html(escape(B))};y.prototype.showErrorStatus=function(B,A){return A.showStatus(B)};y.prototype.showCompleteStatus=function(B,A){return A.showStatus(B)};y.prototype.formatXml=function(H){var D,G,B,I,N,J,C,A,L,M,F,E,K;A=/(>)(<)(\/*)/g;M=/[ ]*(.*)[ ]+\n/g;D=/(<.+>)(.+\n)/g;H=H.replace(A,"$1\n$2$3").replace(M,"$1\n").replace(D,"$1\n$2");C=0;G="";N=H.split("\n");B=0;I="other";L={"single->single":0,"single->closing":-1,"single->opening":0,"single->other":0,"closing->single":0,"closing->closing":-1,"closing->opening":0,"closing->other":0,"opening->single":1,"opening->closing":0,"opening->opening":1,"opening->other":1,"other->single":0,"other->closing":-1,"other->opening":0,"other->other":0};F=function(T){var P,O,R,V,S,Q,U;Q={single:Boolean(T.match(/<.+\/>/)),closing:Boolean(T.match(/<\/.+>/)),opening:Boolean(T.match(/<[^!?].*>/))};S=((function(){var W;W=[];for(R in Q){U=Q[R];if(U){W.push(R)}}return W})())[0];S=S===void 0?"other":S;P=I+"->"+S;I=S;V="";B+=L[P];V=((function(){var X,Y,W;W=[];for(O=X=0,Y=B;0<=Y?X<Y:X>Y;O=0<=Y?++X:--X){W.push(" ")}return W})()).join("");if(P==="opening->closing"){return G=G.substr(0,G.length-1)+T+"\n"}else{return G+=V+T+"\n"}};for(E=0,K=N.length;E<K;E++){J=N[E];F(J)}return G};y.prototype.showStatus=function(F){var C,J,L,I,D,M,A,E,H,G,B;if(F.content===void 0){J=F.data;B=F.url}else{J=F.content.data;B=F.request.url}D=F.headers;L=D&&D["Content-Type"]?D["Content-Type"].split(";")[0].trim():null;if(!J){C=$("<code />").text("no content");E=$('<pre class="json" />').append(C)}else{if(L==="application/json"||/\+json$/.test(L)){M=null;try{M=JSON.stringify(JSON.parse(J),null," ")}catch(K){I=K;M="can't parse JSON. Raw result:\n\n"+J}C=$("<code />").text(M);E=$('<pre class="json" />').append(C)}else{if(L==="application/xml"||/\+xml$/.test(L)){C=$("<code />").text(this.formatXml(J));E=$('<pre class="xml" />').append(C)}else{if(L==="text/html"){C=$("<code />").html(_.escape(J));E=$('<pre class="xml" />').append(C)}else{if(/^image\//.test(L)){E=$("<img>").attr("src",B)}else{C=$("<code />").text(J);E=$('<pre class="json" />').append(C)}}}}}H=E;$(".request_url",$(this.el)).html("<pre></pre>");$(".request_url pre",$(this.el)).text(B);$(".response_code",$(this.el)).html("<pre>"+F.status+"</pre>");$(".response_body",$(this.el)).html(H);$(".response_headers",$(this.el)).html("<pre>"+_.escape(JSON.stringify(F.headers,null," ")).replace(/\n/g,"<br>")+"</pre>");$(".response",$(this.el)).slideDown();$(".response_hider",$(this.el)).show();$(".response_throbber",$(this.el)).hide();G=$(".response_body",$(this.el))[0];A=this.options.swaggerOptions;if(A.highlightSizeThreshold&&F.data.length>A.highlightSizeThreshold){return G}else{return hljs.highlightBlock(G)}};y.prototype.toggleOperationContent=function(){var A;A=$("#"+Docs.escapeResourceName(this.model.parentId)+"_"+this.model.nickname+"_content");if(A.is(":visible")){return Docs.collapseOperation(A)}else{return Docs.expandOperation(A)}};return y})(Backbone.View);p=(function(z){v(y,z);function y(){d=y.__super__.constructor.apply(this,arguments);return d}y.prototype.initialize=function(){};y.prototype.render=function(){var B,A,C;C=this.template();$(this.el).html(C(this.model));if(swaggerUi.api.models.hasOwnProperty(this.model.responseModel)){B={sampleJSON:JSON.stringify(swaggerUi.api.models[this.model.responseModel].createJSONSample(),null,2),isParam:false,signature:swaggerUi.api.models[this.model.responseModel].getMockSignature()};A=new i({model:B,tagName:"div"});$(".model-signature",this.$el).append(A.render().el)}else{$(".model-signature",this.$el).html("")}return this};y.prototype.template=function(){return Handlebars.templates.status_code};return y})(Backbone.View);k=(function(z){v(y,z);function y(){b=y.__super__.constructor.apply(this,arguments);return b}y.prototype.initialize=function(){return Handlebars.registerHelper("isArray",function(B,A){if(B.type.toLowerCase()==="array"||B.allowMultiple){return A.fn(this)}else{return A.inverse(this)}})};y.prototype.render=function(){var A,B,E,C,F,D,I,J,H,G;G=this.model.type||this.model.dataType;if(typeof G==="undefined"){D=this.model.schema;if(D&&D["$ref"]){C=D["$ref"];if(C.indexOf("#/definitions/")===0){G=C.substring("#/definitions/".length)}else{G=C}}}this.model.type=G;this.model.paramType=this.model["in"]||this.model.paramType;if(this.model.paramType==="body"){this.model.isBody=true}if(G&&G.toLowerCase()==="file"){this.model.isFile=true}this.model["default"]=this.model["default"]||this.model.defaultValue;H=this.template();$(this.el).html(H(this.model));I={sampleJSON:this.model.sampleJSON,isParam:true,signature:this.model.signature};if(this.model.sampleJSON){J=new i({model:I,tagName:"div"});$(".model-signature",$(this.el)).append(J.render().el)}else{$(".model-signature",$(this.el)).html(this.model.signature)}B=false;if(this.model.isBody){B=true}A={isParam:B};A.consumes=this.model.consumes;if(B){E=new l({model:A});$(".parameter-content-type",$(this.el)).append(E.render().el)}else{F=new m({model:A});$(".response-content-type",$(this.el)).append(F.render().el)}return this};y.prototype.template=function(){if(this.model.isList){return Handlebars.templates.param_list}else{if(this.options.readOnly){if(this.model.required){return Handlebars.templates.param_readonly_required}else{return Handlebars.templates.param_readonly}}else{if(this.model.required){return Handlebars.templates.param_required}else{return Handlebars.templates.param}}}};return y})(Backbone.View);i=(function(z){v(y,z);function y(){a=y.__super__.constructor.apply(this,arguments);return a}y.prototype.events={"click a.description-link":"switchToDescription","click a.snippet-link":"switchToSnippet","mousedown .snippet":"snippetToTextArea"};y.prototype.initialize=function(){};y.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));this.switchToSnippet();this.isParam=this.model.isParam;if(this.isParam){$(".notice",$(this.el)).text("Click to set as parameter value")}return this};y.prototype.template=function(){return Handlebars.templates.signature};y.prototype.switchToDescription=function(A){if(A!=null){A.preventDefault()}$(".snippet",$(this.el)).hide();$(".description",$(this.el)).show();$(".description-link",$(this.el)).addClass("selected");return $(".snippet-link",$(this.el)).removeClass("selected")};y.prototype.switchToSnippet=function(A){if(A!=null){A.preventDefault()}$(".description",$(this.el)).hide();$(".snippet",$(this.el)).show();$(".snippet-link",$(this.el)).addClass("selected");return $(".description-link",$(this.el)).removeClass("selected")};y.prototype.snippetToTextArea=function(A){var B;if(this.isParam){if(A!=null){A.preventDefault()}B=$("textarea",$(this.el.parentNode.parentNode.parentNode));if($.trim(B.val())===""){return B.val(this.model.sampleJSON)}}};return y})(Backbone.View);j=(function(y){v(z,y);function z(){x=z.__super__.constructor.apply(this,arguments);return x}z.prototype.initialize=function(){};z.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));$("label[for=contentType]",$(this.el)).text("Response Content Type");return this};z.prototype.template=function(){return Handlebars.templates.content_type};return z})(Backbone.View);m=(function(y){v(z,y);function z(){w=z.__super__.constructor.apply(this,arguments);return w}z.prototype.initialize=function(){};z.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));$("label[for=responseContentType]",$(this.el)).text("Response Content Type");return this};z.prototype.template=function(){return Handlebars.templates.response_content_type};return z})(Backbone.View);l=(function(z){v(y,z);function y(){c=y.__super__.constructor.apply(this,arguments);return c}y.prototype.initialize=function(){};y.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));$("label[for=parameterContentType]",$(this.el)).text("Parameter content type:");return this};y.prototype.template=function(){return Handlebars.templates.parameter_content_type};return y})(Backbone.View)}).call(this);
\ No newline at end of file
diff --git a/profiles/killpay/src/main/webapp/lib/underscore-min.js b/profiles/killpay/src/main/webapp/lib/underscore-min.js
new file mode 100644
index 0000000..5a0cb3b
--- /dev/null
+++ b/profiles/killpay/src/main/webapp/lib/underscore-min.js
@@ -0,0 +1,32 @@
+// Underscore.js 1.3.3
+// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
+// Underscore is freely distributable under the MIT license.
+// Portions of Underscore are inspired or borrowed from Prototype,
+// Oliver Steele's Functional, and John Resig's Micro-Templating.
+// For all details and documentation:
+// http://documentcloud.github.com/underscore
+(function(){function r(a,c,d){if(a===c)return 0!==a||1/a==1/c;if(null==a||null==c)return a===c;a._chain&&(a=a._wrapped);c._chain&&(c=c._wrapped);if(a.isEqual&&b.isFunction(a.isEqual))return a.isEqual(c);if(c.isEqual&&b.isFunction(c.isEqual))return c.isEqual(a);var e=l.call(a);if(e!=l.call(c))return!1;switch(e){case "[object String]":return a==""+c;case "[object Number]":return a!=+a?c!=+c:0==a?1/a==1/c:a==+c;case "[object Date]":case "[object Boolean]":return+a==+c;case "[object RegExp]":return a.source==
+c.source&&a.global==c.global&&a.multiline==c.multiline&&a.ignoreCase==c.ignoreCase}if("object"!=typeof a||"object"!=typeof c)return!1;for(var f=d.length;f--;)if(d[f]==a)return!0;d.push(a);var f=0,g=!0;if("[object Array]"==e){if(f=a.length,g=f==c.length)for(;f--&&(g=f in a==f in c&&r(a[f],c[f],d)););}else{if("constructor"in a!="constructor"in c||a.constructor!=c.constructor)return!1;for(var h in a)if(b.has(a,h)&&(f++,!(g=b.has(c,h)&&r(a[h],c[h],d))))break;if(g){for(h in c)if(b.has(c,h)&&!f--)break;
+g=!f}}d.pop();return g}var s=this,I=s._,o={},k=Array.prototype,p=Object.prototype,i=k.slice,J=k.unshift,l=p.toString,K=p.hasOwnProperty,y=k.forEach,z=k.map,A=k.reduce,B=k.reduceRight,C=k.filter,D=k.every,E=k.some,q=k.indexOf,F=k.lastIndexOf,p=Array.isArray,L=Object.keys,t=Function.prototype.bind,b=function(a){return new m(a)};"undefined"!==typeof exports?("undefined"!==typeof module&&module.exports&&(exports=module.exports=b),exports._=b):s._=b;b.VERSION="1.3.3";var j=b.each=b.forEach=function(a,
+c,d){if(a!=null)if(y&&a.forEach===y)a.forEach(c,d);else if(a.length===+a.length)for(var e=0,f=a.length;e<f;e++){if(e in a&&c.call(d,a[e],e,a)===o)break}else for(e in a)if(b.has(a,e)&&c.call(d,a[e],e,a)===o)break};b.map=b.collect=function(a,c,b){var e=[];if(a==null)return e;if(z&&a.map===z)return a.map(c,b);j(a,function(a,g,h){e[e.length]=c.call(b,a,g,h)});if(a.length===+a.length)e.length=a.length;return e};b.reduce=b.foldl=b.inject=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(A&&
+a.reduce===A){e&&(c=b.bind(c,e));return f?a.reduce(c,d):a.reduce(c)}j(a,function(a,b,i){if(f)d=c.call(e,d,a,b,i);else{d=a;f=true}});if(!f)throw new TypeError("Reduce of empty array with no initial value");return d};b.reduceRight=b.foldr=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(B&&a.reduceRight===B){e&&(c=b.bind(c,e));return f?a.reduceRight(c,d):a.reduceRight(c)}var g=b.toArray(a).reverse();e&&!f&&(c=b.bind(c,e));return f?b.reduce(g,c,d,e):b.reduce(g,c)};b.find=b.detect=function(a,
+c,b){var e;G(a,function(a,g,h){if(c.call(b,a,g,h)){e=a;return true}});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(C&&a.filter===C)return a.filter(c,b);j(a,function(a,g,h){c.call(b,a,g,h)&&(e[e.length]=a)});return e};b.reject=function(a,c,b){var e=[];if(a==null)return e;j(a,function(a,g,h){c.call(b,a,g,h)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=true;if(a==null)return e;if(D&&a.every===D)return a.every(c,b);j(a,function(a,g,h){if(!(e=e&&c.call(b,
+a,g,h)))return o});return!!e};var G=b.some=b.any=function(a,c,d){c||(c=b.identity);var e=false;if(a==null)return e;if(E&&a.some===E)return a.some(c,d);j(a,function(a,b,h){if(e||(e=c.call(d,a,b,h)))return o});return!!e};b.include=b.contains=function(a,c){var b=false;if(a==null)return b;if(q&&a.indexOf===q)return a.indexOf(c)!=-1;return b=G(a,function(a){return a===c})};b.invoke=function(a,c){var d=i.call(arguments,2);return b.map(a,function(a){return(b.isFunction(c)?c||a:a[c]).apply(a,d)})};b.pluck=
+function(a,c){return b.map(a,function(a){return a[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a)&&a[0]===+a[0])return Math.max.apply(Math,a);if(!c&&b.isEmpty(a))return-Infinity;var e={computed:-Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a)&&a[0]===+a[0])return Math.min.apply(Math,a);if(!c&&b.isEmpty(a))return Infinity;var e={computed:Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b<e.computed&&
+(e={value:a,computed:b})});return e.value};b.shuffle=function(a){var b=[],d;j(a,function(a,f){d=Math.floor(Math.random()*(f+1));b[f]=b[d];b[d]=a});return b};b.sortBy=function(a,c,d){var e=b.isFunction(c)?c:function(a){return a[c]};return b.pluck(b.map(a,function(a,b,c){return{value:a,criteria:e.call(d,a,b,c)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;return c===void 0?1:d===void 0?-1:c<d?-1:c>d?1:0}),"value")};b.groupBy=function(a,c){var d={},e=b.isFunction(c)?c:function(a){return a[c]};
+j(a,function(a,b){var c=e(a,b);(d[c]||(d[c]=[])).push(a)});return d};b.sortedIndex=function(a,c,d){d||(d=b.identity);for(var e=0,f=a.length;e<f;){var g=e+f>>1;d(a[g])<d(c)?e=g+1:f=g}return e};b.toArray=function(a){return!a?[]:b.isArray(a)||b.isArguments(a)?i.call(a):a.toArray&&b.isFunction(a.toArray)?a.toArray():b.values(a)};b.size=function(a){return b.isArray(a)?a.length:b.keys(a).length};b.first=b.head=b.take=function(a,b,d){return b!=null&&!d?i.call(a,0,b):a[0]};b.initial=function(a,b,d){return i.call(a,
+0,a.length-(b==null||d?1:b))};b.last=function(a,b,d){return b!=null&&!d?i.call(a,Math.max(a.length-b,0)):a[a.length-1]};b.rest=b.tail=function(a,b,d){return i.call(a,b==null||d?1:b)};b.compact=function(a){return b.filter(a,function(a){return!!a})};b.flatten=function(a,c){return b.reduce(a,function(a,e){if(b.isArray(e))return a.concat(c?e:b.flatten(e));a[a.length]=e;return a},[])};b.without=function(a){return b.difference(a,i.call(arguments,1))};b.uniq=b.unique=function(a,c,d){var d=d?b.map(a,d):a,
+e=[];a.length<3&&(c=true);b.reduce(d,function(d,g,h){if(c?b.last(d)!==g||!d.length:!b.include(d,g)){d.push(g);e.push(a[h])}return d},[]);return e};b.union=function(){return b.uniq(b.flatten(arguments,true))};b.intersection=b.intersect=function(a){var c=i.call(arguments,1);return b.filter(b.uniq(a),function(a){return b.every(c,function(c){return b.indexOf(c,a)>=0})})};b.difference=function(a){var c=b.flatten(i.call(arguments,1),true);return b.filter(a,function(a){return!b.include(c,a)})};b.zip=function(){for(var a=
+i.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),e=0;e<c;e++)d[e]=b.pluck(a,""+e);return d};b.indexOf=function(a,c,d){if(a==null)return-1;var e;if(d){d=b.sortedIndex(a,c);return a[d]===c?d:-1}if(q&&a.indexOf===q)return a.indexOf(c);d=0;for(e=a.length;d<e;d++)if(d in a&&a[d]===c)return d;return-1};b.lastIndexOf=function(a,b){if(a==null)return-1;if(F&&a.lastIndexOf===F)return a.lastIndexOf(b);for(var d=a.length;d--;)if(d in a&&a[d]===b)return d;return-1};b.range=function(a,b,d){if(arguments.length<=
+1){b=a||0;a=0}for(var d=arguments[2]||1,e=Math.max(Math.ceil((b-a)/d),0),f=0,g=Array(e);f<e;){g[f++]=a;a=a+d}return g};var H=function(){};b.bind=function(a,c){var d,e;if(a.bind===t&&t)return t.apply(a,i.call(arguments,1));if(!b.isFunction(a))throw new TypeError;e=i.call(arguments,2);return d=function(){if(!(this instanceof d))return a.apply(c,e.concat(i.call(arguments)));H.prototype=a.prototype;var b=new H,g=a.apply(b,e.concat(i.call(arguments)));return Object(g)===g?g:b}};b.bindAll=function(a){var c=
+i.call(arguments,1);c.length==0&&(c=b.functions(a));j(c,function(c){a[c]=b.bind(a[c],a)});return a};b.memoize=function(a,c){var d={};c||(c=b.identity);return function(){var e=c.apply(this,arguments);return b.has(d,e)?d[e]:d[e]=a.apply(this,arguments)}};b.delay=function(a,b){var d=i.call(arguments,2);return setTimeout(function(){return a.apply(null,d)},b)};b.defer=function(a){return b.delay.apply(b,[a,1].concat(i.call(arguments,1)))};b.throttle=function(a,c){var d,e,f,g,h,i,j=b.debounce(function(){h=
+g=false},c);return function(){d=this;e=arguments;f||(f=setTimeout(function(){f=null;h&&a.apply(d,e);j()},c));g?h=true:i=a.apply(d,e);j();g=true;return i}};b.debounce=function(a,b,d){var e;return function(){var f=this,g=arguments;d&&!e&&a.apply(f,g);clearTimeout(e);e=setTimeout(function(){e=null;d||a.apply(f,g)},b)}};b.once=function(a){var b=false,d;return function(){if(b)return d;b=true;return d=a.apply(this,arguments)}};b.wrap=function(a,b){return function(){var d=[a].concat(i.call(arguments,0));
+return b.apply(this,d)}};b.compose=function(){var a=arguments;return function(){for(var b=arguments,d=a.length-1;d>=0;d--)b=[a[d].apply(this,b)];return b[0]}};b.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}};b.keys=L||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var c=[],d;for(d in a)b.has(a,d)&&(c[c.length]=d);return c};b.values=function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&
+c.push(d);return c.sort()};b.extend=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]=b[d]});return a};b.pick=function(a){var c={};j(b.flatten(i.call(arguments,1)),function(b){b in a&&(c[b]=a[b])});return c};b.defaults=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return!b.isObject(a)?a:b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};b.isEqual=function(a,b){return r(a,b,[])};b.isEmpty=
+function(a){if(a==null)return true;if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(b.has(a,c))return false;return true};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=p||function(a){return l.call(a)=="[object Array]"};b.isObject=function(a){return a===Object(a)};b.isArguments=function(a){return l.call(a)=="[object Arguments]"};b.isArguments(arguments)||(b.isArguments=function(a){return!(!a||!b.has(a,"callee"))});b.isFunction=function(a){return l.call(a)=="[object Function]"};
+b.isString=function(a){return l.call(a)=="[object String]"};b.isNumber=function(a){return l.call(a)=="[object Number]"};b.isFinite=function(a){return b.isNumber(a)&&isFinite(a)};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===true||a===false||l.call(a)=="[object Boolean]"};b.isDate=function(a){return l.call(a)=="[object Date]"};b.isRegExp=function(a){return l.call(a)=="[object RegExp]"};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.has=function(a,
+b){return K.call(a,b)};b.noConflict=function(){s._=I;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e<a;e++)b.call(d,e)};b.escape=function(a){return(""+a).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")};b.result=function(a,c){if(a==null)return null;var d=a[c];return b.isFunction(d)?d.call(a):d};b.mixin=function(a){j(b.functions(a),function(c){M(c,b[c]=a[c])})};var N=0;b.uniqueId=
+function(a){var b=N++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var u=/.^/,n={"\\":"\\","'":"'",r:"\r",n:"\n",t:"\t",u2028:"\u2028",u2029:"\u2029"},v;for(v in n)n[n[v]]=v;var O=/\\|'|\r|\n|\t|\u2028|\u2029/g,P=/\\(\\|'|r|n|t|u2028|u2029)/g,w=function(a){return a.replace(P,function(a,b){return n[b]})};b.template=function(a,c,d){d=b.defaults(d||{},b.templateSettings);a="__p+='"+a.replace(O,function(a){return"\\"+n[a]}).replace(d.escape||
+u,function(a,b){return"'+\n_.escape("+w(b)+")+\n'"}).replace(d.interpolate||u,function(a,b){return"'+\n("+w(b)+")+\n'"}).replace(d.evaluate||u,function(a,b){return"';\n"+w(b)+"\n;__p+='"})+"';\n";d.variable||(a="with(obj||{}){\n"+a+"}\n");var a="var __p='';var print=function(){__p+=Array.prototype.join.call(arguments, '')};\n"+a+"return __p;\n",e=new Function(d.variable||"obj","_",a);if(c)return e(c,b);c=function(a){return e.call(this,a,b)};c.source="function("+(d.variable||"obj")+"){\n"+a+"}";return c};
+b.chain=function(a){return b(a).chain()};var m=function(a){this._wrapped=a};b.prototype=m.prototype;var x=function(a,c){return c?b(a).chain():a},M=function(a,c){m.prototype[a]=function(){var a=i.call(arguments);J.call(a,this._wrapped);return x(c.apply(b,a),this._chain)}};b.mixin(b);j("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=k[a];m.prototype[a]=function(){var d=this._wrapped;b.apply(d,arguments);var e=d.length;(a=="shift"||a=="splice")&&e===0&&delete d[0];return x(d,
+this._chain)}});j(["concat","join","slice"],function(a){var b=k[a];m.prototype[a]=function(){return x(b.apply(this._wrapped,arguments),this._chain)}});m.prototype.chain=function(){this._chain=true;return this};m.prototype.value=function(){return this._wrapped}}).call(this);
profiles/pom.xml 2(+1 -1)
diff --git a/profiles/pom.xml b/profiles/pom.xml
index d697060..49d78a7 100644
--- a/profiles/pom.xml
+++ b/profiles/pom.xml
@@ -19,7 +19,7 @@
<parent>
<artifactId>killbill</artifactId>
<groupId>org.kill-bill.billing</groupId>
- <version>0.11.13-SNAPSHOT</version>
+ <version>0.11.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-profiles</artifactId>
subscription/pom.xml 2(+1 -1)
diff --git a/subscription/pom.xml b/subscription/pom.xml
index e87f88b..7254f08 100644
--- a/subscription/pom.xml
+++ b/subscription/pom.xml
@@ -19,7 +19,7 @@
<parent>
<artifactId>killbill</artifactId>
<groupId>org.kill-bill.billing</groupId>
- <version>0.11.13-SNAPSHOT</version>
+ <version>0.11.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-subscription</artifactId>
tenant/pom.xml 2(+1 -1)
diff --git a/tenant/pom.xml b/tenant/pom.xml
index f5c2863..7b4e6f6 100644
--- a/tenant/pom.xml
+++ b/tenant/pom.xml
@@ -19,7 +19,7 @@
<parent>
<artifactId>killbill</artifactId>
<groupId>org.kill-bill.billing</groupId>
- <version>0.11.13-SNAPSHOT</version>
+ <version>0.11.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-tenant</artifactId>
usage/pom.xml 2(+1 -1)
diff --git a/usage/pom.xml b/usage/pom.xml
index 0983572..8c62461 100644
--- a/usage/pom.xml
+++ b/usage/pom.xml
@@ -19,7 +19,7 @@
<parent>
<artifactId>killbill</artifactId>
<groupId>org.kill-bill.billing</groupId>
- <version>0.11.13-SNAPSHOT</version>
+ <version>0.11.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-usage</artifactId>
util/pom.xml 2(+1 -1)
diff --git a/util/pom.xml b/util/pom.xml
index 3d794e9..6be8126 100644
--- a/util/pom.xml
+++ b/util/pom.xml
@@ -12,7 +12,7 @@
<parent>
<artifactId>killbill</artifactId>
<groupId>org.kill-bill.billing</groupId>
- <version>0.11.13-SNAPSHOT</version>
+ <version>0.11.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-util</artifactId>
diff --git a/util/src/main/java/org/killbill/billing/util/config/PaymentConfig.java b/util/src/main/java/org/killbill/billing/util/config/PaymentConfig.java
index 6100e6d..91f75c0 100644
--- a/util/src/main/java/org/killbill/billing/util/config/PaymentConfig.java
+++ b/util/src/main/java/org/killbill/billing/util/config/PaymentConfig.java
@@ -80,6 +80,11 @@ public interface PaymentConfig extends KillbillConfig {
@Description("Rate at which janitor tasks are scheduled")
public TimeSpan getJanitorRunningRate();
+ @Config("org.killbill.payment.control.plugin")
+ @Default("__INVOICE_PAYMENT_CONTROL_PLUGIN__")
+ @Description("Whether the payment subsystem is off")
+ public List<String> getPaymentControlPluginNames();
+
@Config("org.killbill.payment.off")
@Default("false")
@Description("Whether the payment subsystem is off")
diff --git a/util/src/main/java/org/killbill/billing/util/glue/KillbillApiAopModule.java b/util/src/main/java/org/killbill/billing/util/glue/KillbillApiAopModule.java
index cb3d5a6..82f2467 100644
--- a/util/src/main/java/org/killbill/billing/util/glue/KillbillApiAopModule.java
+++ b/util/src/main/java/org/killbill/billing/util/glue/KillbillApiAopModule.java
@@ -17,6 +17,8 @@
package org.killbill.billing.util.glue;
+import java.lang.reflect.Method;
+
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.killbill.billing.KillbillApi;
@@ -25,6 +27,7 @@ import org.killbill.commons.profiling.Profiling.WithProfilingCallback;
import org.killbill.commons.profiling.ProfilingFeature.ProfilingFeatureType;
import com.google.inject.AbstractModule;
+import com.google.inject.matcher.Matcher;
import com.google.inject.matcher.Matchers;
public class KillbillApiAopModule extends AbstractModule {
@@ -33,7 +36,7 @@ public class KillbillApiAopModule extends AbstractModule {
protected void configure() {
bindInterceptor(Matchers.subclassesOf(KillbillApi.class),
- Matchers.any(),
+ Matchers.not(SYNTHETIC_METHOD_MATCHER),
new ProfilingMethodInterceptor());
}
@@ -51,4 +54,21 @@ public class KillbillApiAopModule extends AbstractModule {
});
}
}
+
+ private static final Matcher<Method> SYNTHETIC_METHOD_MATCHER = new Matcher<Method>() {
+ @Override
+ public boolean matches(final Method method) {
+ return method.isSynthetic();
+ }
+
+ @Override
+ public Matcher<Method> and(final Matcher<? super Method> other) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Matcher<Method> or(final Matcher<? super Method> other) {
+ throw new UnsupportedOperationException();
+ }
+ };
}
diff --git a/util/src/test/java/org/killbill/billing/util/dao/TestDateInvestigation.java b/util/src/test/java/org/killbill/billing/util/dao/TestDateInvestigation.java
index e887058..898794c 100644
--- a/util/src/test/java/org/killbill/billing/util/dao/TestDateInvestigation.java
+++ b/util/src/test/java/org/killbill/billing/util/dao/TestDateInvestigation.java
@@ -87,7 +87,7 @@ public class TestDateInvestigation /* extends UtilTestSuiteWithEmbeddedDB */ {
}
- @Test(groups = "slow")
+ @Test(groups = "slow", enabled = false)
public void testWithGMTPlus8() throws SQLException {
final LocalDate date1_1 = new LocalDate(2014, 10, 1, GregorianChronology.getInstance(DATE_TZ_PLUS_8_GMT));
@@ -102,7 +102,7 @@ public class TestDateInvestigation /* extends UtilTestSuiteWithEmbeddedDB */ {
assertEquals(result.getDate2().getZone().toString(), "UTC");
}
- @Test(groups = "slow")
+ @Test(groups = "slow", enabled = false)
public void testWithGMTMinus20() throws SQLException {
final LocalDate date1_1 = new LocalDate(2014, 10, 1, GregorianChronology.getInstance(DATE_TZ_MINUS_20_GMT));
diff --git a/util/src/test/java/org/killbill/billing/util/export/dao/TestDatabaseExportDao.java b/util/src/test/java/org/killbill/billing/util/export/dao/TestDatabaseExportDao.java
index 7fa49c9..0494ed5 100644
--- a/util/src/test/java/org/killbill/billing/util/export/dao/TestDatabaseExportDao.java
+++ b/util/src/test/java/org/killbill/billing/util/export/dao/TestDatabaseExportDao.java
@@ -81,7 +81,7 @@ public class TestDatabaseExportDao extends UtilTestSuiteWithEmbeddedDB {
// Verify new dump
final String newDump = getDump();
// Note: unclear why Jackson would quote the header?
- Assert.assertEquals(newDump, "-- accounts record_id,id,external_key,email,name,first_name_length,currency,\"billing_cycle_day_local\",\"billing_cycle_day_utc\",payment_method_id,time_zone,locale,address1,address2,company_name,city,state_or_province,country,postal_code,phone,migrated,\"is_notified_for_invoices\",created_date,created_by,updated_date,updated_by,tenant_record_id\n" +
+ Assert.assertEquals(newDump, "-- accounts record_id,id,external_key,email,name,first_name_length,currency,billing_cycle_day_local,billing_cycle_day_utc,payment_method_id,time_zone,locale,address1,address2,company_name,city,state_or_province,country,postal_code,phone,migrated,is_notified_for_invoices,created_date,created_by,updated_date,updated_by,tenant_record_id\n" +
String.format("%s,\"%s\",,%s,%s,%s,,,,,,,,,,,,,,,false,%s,\"%s\",%s,\"%s\",%s,%s", internalCallContext.getAccountRecordId(), accountId, accountEmail, accountName, firstNameLength,
isNotifiedForInvoices, "1970-05-24T18:33:02.000+0000", createdBy, "1982-02-18T20:03:42.000+0000", updatedBy, internalCallContext.getTenantRecordId()) + "\n" +
"-- " + tableNameA + " record_id,a_column,account_record_id,tenant_record_id\n" +