killbill-uncached

Merge with upstream

6/16/2012 3:22:10 AM

Details

diff --git a/catalog/src/main/java/com/ning/billing/catalog/DefaultCatalogService.java b/catalog/src/main/java/com/ning/billing/catalog/DefaultCatalogService.java
index 11a42c7..9685457 100644
--- a/catalog/src/main/java/com/ning/billing/catalog/DefaultCatalogService.java
+++ b/catalog/src/main/java/com/ning/billing/catalog/DefaultCatalogService.java
@@ -54,7 +54,6 @@ public class DefaultCatalogService implements KillbillService, Provider<Catalog>
                 final String url = config.getCatalogURI();
                 catalog = loader.load(url);
 
-                //catalog = XMLLoader.getObjectFromProperty(config.getCatalogURI(), Catalog.class);
                 isInitialized = true;
             } catch (Exception e) {
                 throw new ServiceException(e);
diff --git a/jaxrs/src/main/java/com/ning/billing/jaxrs/json/CatalogJsonSimple.java b/jaxrs/src/main/java/com/ning/billing/jaxrs/json/CatalogJsonSimple.java
new file mode 100644
index 0000000..3a8e86f
--- /dev/null
+++ b/jaxrs/src/main/java/com/ning/billing/jaxrs/json/CatalogJsonSimple.java
@@ -0,0 +1,193 @@
+/* 
+ * Copyright 2010-2011 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.
+ */
+package com.ning.billing.jaxrs.json;
+
+import java.math.BigDecimal;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+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.google.common.collect.Lists;
+import com.ning.billing.catalog.api.CatalogApiException;
+import com.ning.billing.catalog.api.Plan;
+import com.ning.billing.catalog.api.PlanPhase;
+import com.ning.billing.catalog.api.Price;
+import com.ning.billing.catalog.api.Product;
+import com.ning.billing.catalog.api.StaticCatalog;
+
+@JsonAutoDetect(fieldVisibility=JsonAutoDetect.Visibility.ANY)
+public class CatalogJsonSimple {
+    
+    private final ProductJson [] products;
+    
+    public CatalogJsonSimple(StaticCatalog catalog) throws CatalogApiException {
+
+        Map<String, ProductJson> productMap = new HashMap<String, CatalogJsonSimple.ProductJson>();
+
+        Plan [] plans = catalog.getCurrentPlans();
+        for (Plan plan : plans) {
+
+            Product product = plan.getProduct();
+            ProductJson jProduct = productMap.get(product.getName());
+            if (jProduct == null) {
+                jProduct = new ProductJson(product.getCategory().toString(),
+                        product.getName(),
+                        toProductNames(product.getIncluded()), toProductNames(product.getAvailable()));
+                productMap.put(product.getName(), jProduct);
+            }
+
+            int i = 0 ;
+            PhaseJson [] phases = new PhaseJson[plan.getAllPhases().length];
+            for (PlanPhase phase : plan.getAllPhases()) {
+
+                Map<String, BigDecimal> prices = new HashMap<String, BigDecimal>();
+                if (phase.getRecurringPrice() != null) {
+                    for (Price cur : phase.getRecurringPrice().getPrices()) {
+                        prices.put(cur.getCurrency().toString(), cur.getValue());
+                    }
+                }
+                PhaseJson jPhase = new PhaseJson(phase.getPhaseType().toString(), prices);
+                phases[i++] = jPhase;
+            }
+            PlanJson jPlan = new PlanJson(plan.getName(), phases); 
+            jProduct.addPlan(jPlan);
+        }
+        products = productMap.values().toArray(new ProductJson[productMap.values().size()]);
+    }
+    
+    private Collection<String> toProductNames(Product [] in) {
+        return Collections2.transform(Lists.newArrayList(in), new Function<Product, String>() {
+            public String apply(Product input) {
+                return input.getName();
+            }
+        });
+    }
+    
+    @JsonCreator
+    public CatalogJsonSimple(@JsonProperty("products")  ProductJson[] products) {
+        super();
+        this.products = products;
+    }
+    
+    
+
+    public ProductJson[] getProducts() {
+        return products;
+    }
+
+
+    @JsonAutoDetect(fieldVisibility=JsonAutoDetect.Visibility.ANY)
+    public static class ProductJson {
+
+        private final String type;
+        private final String name;
+        private final String [] included;
+        private final String [] available;
+        private final List<PlanJson> plans;
+        
+
+        @JsonCreator
+        public ProductJson(@JsonProperty("type") String type,
+                @JsonProperty("name") String name,
+                @JsonProperty("plans") List<PlanJson> plans,
+                @JsonProperty("included") Collection<String> included,
+                @JsonProperty("available") Collection<String> available) {
+            super();
+            this.type = type;
+            this.name = name;
+            this.included = included.toArray(new String[included.size()]);
+            this.available = available.toArray(new String[available.size()]);
+            this.plans = plans;
+        }
+
+        public ProductJson(String type, String name, Collection<String> included, Collection<String> available) {
+            this(type, name, new LinkedList<CatalogJsonSimple.PlanJson>(), included, available);
+        }
+
+        public void addPlan(PlanJson plan) {
+            plans.add(plan);
+        }
+        
+        public String getType() {
+            return type;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public List<PlanJson> getPlans() {
+            return plans;
+        }
+        
+        public String[] getIncluded() {
+            return included;
+        }
+
+        public String[] getAvailable() {
+            return available;
+        }
+    }
+    
+    @JsonAutoDetect(fieldVisibility=JsonAutoDetect.Visibility.ANY)
+    public static class PlanJson {
+
+        private final String name;
+        private final PhaseJson [] phases;
+        
+        @JsonCreator
+        public PlanJson(@JsonProperty("name") String name,
+                @JsonProperty("phases") PhaseJson[] phases) {
+            super();
+            this.name = name;
+            this.phases = phases;
+        }
+        public String getName() {
+            return name;
+        }
+        public PhaseJson[] getPhases() {
+            return phases;
+        }
+    }
+
+    @JsonAutoDetect(fieldVisibility=JsonAutoDetect.Visibility.ANY)
+    public static class PhaseJson {
+
+        private final String type;
+        private final Map<String, BigDecimal> prices;
+        
+        @JsonCreator
+        public PhaseJson(@JsonProperty("type") String type,
+                @JsonProperty("prices") Map<String, BigDecimal> prices) {
+            super();
+            this.type = type;
+            this.prices = prices;
+        }
+        public String getType() {
+            return type;
+        }
+        public Map<String, BigDecimal> getPrices() {
+            return prices;
+        }
+    }
+}
diff --git a/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/CatalogResource.java b/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/CatalogResource.java
index ebd36e1..3941dc6 100644
--- a/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/CatalogResource.java
+++ b/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/CatalogResource.java
@@ -22,15 +22,22 @@ import javax.ws.rs.Produces;
 import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response.Status;
+
+import org.joda.time.DateTime;
+
 import java.util.ArrayList;
 import java.util.List;
 
+import com.google.common.base.Joiner;
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
 import com.ning.billing.catalog.api.CatalogApiException;
 import com.ning.billing.catalog.api.CatalogService;
 import com.ning.billing.catalog.api.Listing;
+import com.ning.billing.catalog.api.Plan;
+import com.ning.billing.catalog.api.Product;
 import com.ning.billing.catalog.api.StaticCatalog;
+import com.ning.billing.jaxrs.json.CatalogJsonSimple;
 import com.ning.billing.jaxrs.json.PlanDetailJason;
 import com.ning.billing.util.config.XMLWriter;
 
@@ -81,4 +88,15 @@ public class CatalogResource implements JaxrsResource {
         }
         return Response.status(Status.OK).entity(details).build();
     }
+
+    @GET
+    @Path("/simpleCatalog")
+    @Produces(APPLICATION_JSON)
+    public Response getSimpleCatalog() throws CatalogApiException {
+
+        StaticCatalog catalog  = catalogService.getCurrentCatalog();
+        
+        CatalogJsonSimple json = new CatalogJsonSimple(catalog);
+        return Response.status(Status.OK).entity(json).build();            
+    }
 }
diff --git a/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/SubscriptionResource.java b/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/SubscriptionResource.java
index 8f3c93e..fe79b2a 100644
--- a/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/SubscriptionResource.java
+++ b/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/SubscriptionResource.java
@@ -83,8 +83,8 @@ public class SubscriptionResource extends JaxRsResourceBase {
 
     @Inject
     public SubscriptionResource(final JaxrsUriBuilder uriBuilder, final EntitlementUserApi entitlementApi,
-                                final Context context, final KillbillEventHandler killbillHandler,
-                                final TagUserApi tagUserApi, final TagHelper tagHelper, final CustomFieldUserApi customFieldUserApi) {
+            final Context context, final KillbillEventHandler killbillHandler,
+            final TagUserApi tagUserApi, final TagHelper tagHelper, final CustomFieldUserApi customFieldUserApi) {
         super(uriBuilder, tagUserApi, tagHelper, customFieldUserApi);
         this.uriBuilder = uriBuilder;
         this.entitlementApi = entitlementApi;
@@ -116,12 +116,12 @@ public class SubscriptionResource extends JaxRsResourceBase {
     @Consumes(APPLICATION_JSON)
     @Produces(APPLICATION_JSON)
     public Response createSubscription(final SubscriptionJsonNoEvents subscription,
-                                       @QueryParam(QUERY_REQUESTED_DT) final String requestedDate,
-                                       @QueryParam(QUERY_CALL_COMPLETION) @DefaultValue("false") final Boolean callCompletion,
-                                       @QueryParam(QUERY_CALL_TIMEOUT) @DefaultValue("3") final long timeoutSec,
-                                       @HeaderParam(HDR_CREATED_BY) final String createdBy,
-                                       @HeaderParam(HDR_REASON) final String reason,
-                                       @HeaderParam(HDR_COMMENT) final String comment) {
+            @QueryParam(QUERY_REQUESTED_DT) final String requestedDate,
+            @QueryParam(QUERY_CALL_COMPLETION) @DefaultValue("false") final Boolean callCompletion,
+            @QueryParam(QUERY_CALL_TIMEOUT) @DefaultValue("3") final long timeoutSec,
+            @HeaderParam(HDR_CREATED_BY) final String createdBy,
+            @HeaderParam(HDR_REASON) final String reason,
+            @HeaderParam(HDR_COMMENT) final String comment) {
 
 
         final SubscriptionCallCompletionCallback<Subscription> callback = new SubscriptionCallCompletionCallback<Subscription>() {
@@ -132,8 +132,8 @@ public class SubscriptionResource extends JaxRsResourceBase {
                 final UUID uuid = UUID.fromString(subscription.getBundleId());
 
                 final PlanPhaseSpecifier spec = new PlanPhaseSpecifier(subscription.getProductName(),
-                                                                 ProductCategory.valueOf(subscription.getProductCategory()),
-                                                                 BillingPeriod.valueOf(subscription.getBillingPeriod()), subscription.getPriceList(), null);
+                        ProductCategory.valueOf(subscription.getProductCategory()),
+                        BillingPeriod.valueOf(subscription.getBillingPeriod()), subscription.getPriceList(), null);
                 return entitlementApi.createSubscription(uuid, spec, inputDate, ctx);
             }
 
@@ -156,13 +156,13 @@ public class SubscriptionResource extends JaxRsResourceBase {
     @Consumes(APPLICATION_JSON)
     @Path("/{subscriptionId:" + UUID_PATTERN + "}")
     public Response changeSubscriptionPlan(final SubscriptionJsonNoEvents subscription,
-                                           @PathParam("subscriptionId") final String subscriptionId,
-                                           @QueryParam(QUERY_REQUESTED_DT) final String requestedDate,
-                                           @QueryParam(QUERY_CALL_COMPLETION) @DefaultValue("false") final Boolean callCompletion,
-                                           @QueryParam(QUERY_CALL_TIMEOUT) @DefaultValue("3") final long timeoutSec,
-                                           @HeaderParam(HDR_CREATED_BY) final String createdBy,
-                                           @HeaderParam(HDR_REASON) final String reason,
-                                           @HeaderParam(HDR_COMMENT) final String comment) {
+            @PathParam("subscriptionId") final String subscriptionId,
+            @QueryParam(QUERY_REQUESTED_DT) final String requestedDate,
+            @QueryParam(QUERY_CALL_COMPLETION) @DefaultValue("false") final Boolean callCompletion,
+            @QueryParam(QUERY_CALL_TIMEOUT) @DefaultValue("3") final long timeoutSec,
+            @HeaderParam(HDR_CREATED_BY) final String createdBy,
+            @HeaderParam(HDR_REASON) final String reason,
+            @HeaderParam(HDR_COMMENT) final String comment) {
 
         final SubscriptionCallCompletionCallback<Response> callback = new SubscriptionCallCompletionCallback<Response>() {
 
@@ -170,8 +170,8 @@ public class SubscriptionResource extends JaxRsResourceBase {
 
             @Override
             public Response doOperation(final CallContext ctx)
-                    throws EntitlementUserApiException, InterruptedException,
-                    TimeoutException {
+            throws EntitlementUserApiException, InterruptedException,
+            TimeoutException {
                 try {
                     final UUID uuid = UUID.fromString(subscriptionId);
                     final Subscription current = entitlementApi.getSubscriptionFromId(uuid);
@@ -213,9 +213,9 @@ public class SubscriptionResource extends JaxRsResourceBase {
     @Path("/{subscriptionId:" + UUID_PATTERN + "}/uncancel")
     @Produces(APPLICATION_JSON)
     public Response uncancelSubscriptionPlan(@PathParam("subscriptionId") final String subscriptionId,
-                                             @HeaderParam(HDR_CREATED_BY) final String createdBy,
-                                             @HeaderParam(HDR_REASON) final String reason,
-                                             @HeaderParam(HDR_COMMENT) final String comment) {
+            @HeaderParam(HDR_CREATED_BY) final String createdBy,
+            @HeaderParam(HDR_REASON) final String reason,
+            @HeaderParam(HDR_COMMENT) final String comment) {
         try {
             final UUID uuid = UUID.fromString(subscriptionId);
             final Subscription current = entitlementApi.getSubscriptionFromId(uuid);
@@ -236,12 +236,12 @@ public class SubscriptionResource extends JaxRsResourceBase {
     @Path("/{subscriptionId:" + UUID_PATTERN + "}")
     @Produces(APPLICATION_JSON)
     public Response cancelSubscriptionPlan(@PathParam("subscriptionId") final String subscriptionId,
-                                           @QueryParam(QUERY_REQUESTED_DT) final String requestedDate,
-                                           @QueryParam(QUERY_CALL_COMPLETION) @DefaultValue("false") final Boolean callCompletion,
-                                           @QueryParam(QUERY_CALL_TIMEOUT) @DefaultValue("5") final long timeoutSec,
-                                           @HeaderParam(HDR_CREATED_BY) final String createdBy,
-                                           @HeaderParam(HDR_REASON) final String reason,
-                                           @HeaderParam(HDR_COMMENT) final String comment) {
+            @QueryParam(QUERY_REQUESTED_DT) final String requestedDate,
+            @QueryParam(QUERY_CALL_COMPLETION) @DefaultValue("false") final Boolean callCompletion,
+            @QueryParam(QUERY_CALL_TIMEOUT) @DefaultValue("5") final long timeoutSec,
+            @HeaderParam(HDR_CREATED_BY) final String createdBy,
+            @HeaderParam(HDR_REASON) final String reason,
+            @HeaderParam(HDR_COMMENT) final String comment) {
 
         final SubscriptionCallCompletionCallback<Response> callback = new SubscriptionCallCompletionCallback<Response>() {
 
@@ -249,8 +249,8 @@ public class SubscriptionResource extends JaxRsResourceBase {
 
             @Override
             public Response doOperation(final CallContext ctx)
-                    throws EntitlementUserApiException, InterruptedException,
-                    TimeoutException {
+            throws EntitlementUserApiException, InterruptedException,
+            TimeoutException {
                 try {
                     final UUID uuid = UUID.fromString(subscriptionId);
 
@@ -289,34 +289,34 @@ public class SubscriptionResource extends JaxRsResourceBase {
         }
 
         @Override
-        public void onSubscriptionTransition(final SubscriptionEvent curEvent) {
-            log.debug(String.format("Got event SubscriptionTransition token = %s, type = %s, remaining = %d ",
-                                    curEvent.getUserToken(), curEvent.getTransitionType(), curEvent.getRemainingEventsForUserOperation()));
+        public void onSubscriptionTransition(SubscriptionEvent curEvent) {
+            log.info(String.format("Got event SubscriptionTransition token = %s, type = %s, remaining = %d ", 
+                    curEvent.getUserToken(), curEvent.getTransitionType(),  curEvent.getRemainingEventsForUserOperation())); 
         }
 
         @Override
         public void onEmptyInvoice(final EmptyInvoiceEvent curEvent) {
-            log.debug(String.format("Got event EmptyInvoiceNotification token = %s ", curEvent.getUserToken()));
+            log.info(String.format("Got event EmptyInvoiceNotification token = %s ", curEvent.getUserToken())); 
             notifyForCompletion();
         }
 
         @Override
-        public void onInvoiceCreation(final InvoiceCreationEvent curEvent) {
-            log.debug(String.format("Got event InvoiceCreationNotification token = %s ", curEvent.getUserToken()));
+        public void onInvoiceCreation(InvoiceCreationEvent curEvent) {
+            log.info(String.format("Got event InvoiceCreationNotification token = %s ", curEvent.getUserToken())); 
             if (curEvent.getAmountOwed().compareTo(BigDecimal.ZERO) <= 0) {
                 notifyForCompletion();
             }
         }
 
         @Override
-        public void onPaymentInfo(final PaymentInfoEvent curEvent) {
-            log.debug(String.format("Got event PaymentInfo token = %s ", curEvent.getUserToken()));
+        public void onPaymentInfo(PaymentInfoEvent curEvent) {
+            log.info(String.format("Got event PaymentInfo token = %s ", curEvent.getUserToken()));  
             notifyForCompletion();
         }
 
         @Override
-        public void onPaymentError(final PaymentErrorEvent curEvent) {
-            log.debug(String.format("Got event PaymentError token = %s ", curEvent.getUserToken()));
+        public void onPaymentError(PaymentErrorEvent curEvent) {
+            log.info(String.format("Got event PaymentError token = %s ", curEvent.getUserToken())); 
             notifyForCompletion();
         }
     }
@@ -332,11 +332,11 @@ public class SubscriptionResource extends JaxRsResourceBase {
     private class SubscriptionCallCompletion<T> {
 
         public Response withSynchronization(final SubscriptionCallCompletionCallback<T> callback,
-                                            final long timeoutSec,
-                                            final boolean callCompletion,
-                                            final String createdBy,
-                                            final String reason,
-                                            final String comment) {
+                final long timeoutSec,
+                final boolean callCompletion,
+                final String createdBy,
+                final String reason,
+                final String comment) {
 
             final CallContext ctx = context.createContext(createdBy, reason, comment);
             final CompletionUserRequestSubscription waiter = callCompletion ? new CompletionUserRequestSubscription(ctx.getUserToken()) : null;
@@ -376,12 +376,12 @@ public class SubscriptionResource extends JaxRsResourceBase {
     @Consumes(APPLICATION_JSON)
     @Produces(APPLICATION_JSON)
     public Response createCustomFields(@PathParam(ID_PARAM_NAME) final String id,
-                                       final List<CustomFieldJson> customFields,
-                                       @HeaderParam(HDR_CREATED_BY) final String createdBy,
-                                       @HeaderParam(HDR_REASON) final String reason,
-                                       @HeaderParam(HDR_COMMENT) final String comment) {
+            final List<CustomFieldJson> customFields,
+            @HeaderParam(HDR_CREATED_BY) final String createdBy,
+            @HeaderParam(HDR_REASON) final String reason,
+            @HeaderParam(HDR_COMMENT) final String comment) {
         return super.createCustomFields(UUID.fromString(id), customFields,
-                                        context.createContext(createdBy, reason, comment));
+                context.createContext(createdBy, reason, comment));
     }
 
     @DELETE
@@ -389,12 +389,12 @@ public class SubscriptionResource extends JaxRsResourceBase {
     @Consumes(APPLICATION_JSON)
     @Produces(APPLICATION_JSON)
     public Response deleteCustomFields(@PathParam(ID_PARAM_NAME) final String id,
-                                       @QueryParam(QUERY_CUSTOM_FIELDS) final String customFieldList,
-                                       @HeaderParam(HDR_CREATED_BY) final String createdBy,
-                                       @HeaderParam(HDR_REASON) final String reason,
-                                       @HeaderParam(HDR_COMMENT) final String comment) {
+            @QueryParam(QUERY_CUSTOM_FIELDS) final String customFieldList,
+            @HeaderParam(HDR_CREATED_BY) final String createdBy,
+            @HeaderParam(HDR_REASON) final String reason,
+            @HeaderParam(HDR_COMMENT) final String comment) {
         return super.deleteCustomFields(UUID.fromString(id), customFieldList,
-                                        context.createContext(createdBy, reason, comment));
+                context.createContext(createdBy, reason, comment));
     }
 
     @GET
@@ -409,12 +409,12 @@ public class SubscriptionResource extends JaxRsResourceBase {
     @Consumes(APPLICATION_JSON)
     @Produces(APPLICATION_JSON)
     public Response createTags(@PathParam(ID_PARAM_NAME) final String id,
-                               @QueryParam(QUERY_TAGS) final String tagList,
-                               @HeaderParam(HDR_CREATED_BY) final String createdBy,
-                               @HeaderParam(HDR_REASON) final String reason,
-                               @HeaderParam(HDR_COMMENT) final String comment) {
+            @QueryParam(QUERY_TAGS) final String tagList,
+            @HeaderParam(HDR_CREATED_BY) final String createdBy,
+            @HeaderParam(HDR_REASON) final String reason,
+            @HeaderParam(HDR_COMMENT) final String comment) {
         return super.createTags(UUID.fromString(id), tagList,
-                                context.createContext(createdBy, reason, comment));
+                context.createContext(createdBy, reason, comment));
     }
 
     @DELETE
@@ -422,13 +422,13 @@ public class SubscriptionResource extends JaxRsResourceBase {
     @Consumes(APPLICATION_JSON)
     @Produces(APPLICATION_JSON)
     public Response deleteTags(@PathParam(ID_PARAM_NAME) final String id,
-                               @QueryParam(QUERY_TAGS) final String tagList,
-                               @HeaderParam(HDR_CREATED_BY) final String createdBy,
-                               @HeaderParam(HDR_REASON) final String reason,
-                               @HeaderParam(HDR_COMMENT) final String comment) {
+            @QueryParam(QUERY_TAGS) final String tagList,
+            @HeaderParam(HDR_CREATED_BY) final String createdBy,
+            @HeaderParam(HDR_REASON) final String reason,
+            @HeaderParam(HDR_COMMENT) final String comment) {
 
         return super.deleteTags(UUID.fromString(id), tagList,
-                                context.createContext(createdBy, reason, comment));
+                context.createContext(createdBy, reason, comment));
     }
 
     @Override
diff --git a/jaxrs/src/main/java/com/ning/billing/jaxrs/util/KillbillEventHandler.java b/jaxrs/src/main/java/com/ning/billing/jaxrs/util/KillbillEventHandler.java
index 1c46e37..a16694e 100644
--- a/jaxrs/src/main/java/com/ning/billing/jaxrs/util/KillbillEventHandler.java
+++ b/jaxrs/src/main/java/com/ning/billing/jaxrs/util/KillbillEventHandler.java
@@ -52,8 +52,8 @@ public class KillbillEventHandler {
     }
 
     /*
-    * IRS event handler for killbill entitlement events
-    */
+     * Killbill server event handler
+     */
     @Subscribe
     public void handleEntitlementevents(final BusEvent event) {
         final List<CompletionUserRequestNotifier> runningWaiters = new ArrayList<CompletionUserRequestNotifier>();
diff --git a/server/src/test/java/com/ning/billing/jaxrs/TestAccount.java b/server/src/test/java/com/ning/billing/jaxrs/TestAccount.java
index 2345464..49895e2 100644
--- a/server/src/test/java/com/ning/billing/jaxrs/TestAccount.java
+++ b/server/src/test/java/com/ning/billing/jaxrs/TestAccount.java
@@ -234,7 +234,7 @@ public class TestAccount extends TestJaxrsBase {
     @Test(groups = "slow", enabled = true)
     public void testAccountPayments() throws Exception {
 
-        clock.setTime(new DateTime(2012, 4, 25, 0, 3, 42, 0));
+        //clock.setTime(new DateTime(2012, 4, 25, 0, 3, 42, 0));
 
         final AccountJson accountJson = createAccountWithDefaultPaymentMethod("ermenehildo", "shtyrgfhwe", "ermenehildo@yahoo.com");
         assertNotNull(accountJson);
diff --git a/server/src/test/java/com/ning/billing/jaxrs/TestJaxrsBase.java b/server/src/test/java/com/ning/billing/jaxrs/TestJaxrsBase.java
index f9a4060..e9dfa5d 100644
--- a/server/src/test/java/com/ning/billing/jaxrs/TestJaxrsBase.java
+++ b/server/src/test/java/com/ning/billing/jaxrs/TestJaxrsBase.java
@@ -134,14 +134,17 @@ public class TestJaxrsBase {
             throw new RuntimeException(e);
         }
 
-        // Use the full path for the catalog
+        /*
         final String catalogURI = System.getProperty("killbill.catalog.uri");
+        System.setProperty("killbill.catalog.uri", Resources.getResource(catalogURI).toExternalForm());
+
         if (catalogURI != null) {
             try {
-                System.setProperty("killbill.catalog.uri", Resources.getResource(catalogURI).toExternalForm());
+                
             } catch (IllegalArgumentException ignored) {
             }
         }
+        */
     }
 
     public static class TestKillbillGuiceListener extends KillbillGuiceListener {
diff --git a/util/src/main/java/com/ning/billing/util/config/UriAccessor.java b/util/src/main/java/com/ning/billing/util/config/UriAccessor.java
index 802bd1d..118f0df 100644
--- a/util/src/main/java/com/ning/billing/util/config/UriAccessor.java
+++ b/util/src/main/java/com/ning/billing/util/config/UriAccessor.java
@@ -24,33 +24,45 @@ import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.Scanner;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.io.Resources;
+
 public class UriAccessor {
+
+    private final static Logger log = LoggerFactory.getLogger(UriAccessor.class);
+
     private static final String URI_SCHEME_FOR_CLASSPATH = "jar";
     private static final String URI_SCHEME_FOR_FILE = "file";
 
-    public static InputStream accessUri(final String uri) throws IOException, URISyntaxException {
+    public static InputStream accessUri(String uri)  throws IOException, URISyntaxException {
         return accessUri(new URI(uri));
     }
 
-    public static InputStream accessUri(final URI uri) throws IOException {
-        final String scheme = uri.getScheme();
+    public static InputStream accessUri(URI uri) throws IOException, URISyntaxException {
+        String scheme = uri.getScheme();
         URL url = null;
-        if (scheme.equals(URI_SCHEME_FOR_CLASSPATH)) {
+        if (scheme == null) {
+            uri = new URI(Resources.getResource(uri.toString()).toExternalForm());
+        } else if (scheme.equals(URI_SCHEME_FOR_CLASSPATH)) {
             return UriAccessor.class.getResourceAsStream(uri.getPath());
         } else if (scheme.equals(URI_SCHEME_FOR_FILE) &&
                 !uri.getSchemeSpecificPart().startsWith("/")) { // interpret URIs of this form as relative path uris
             url = new File(uri.getSchemeSpecificPart()).toURI().toURL();
+        } else {
+            throw new RuntimeException("");
         }
         url = uri.toURL();
         return url.openConnection().getInputStream();
     }
 
-    public static String accessUriAsString(final String uri) throws IOException, URISyntaxException {
+    public static String accessUriAsString(String uri)  throws IOException, URISyntaxException {
         return accessUriAsString(new URI(uri));
     }
 
-    public static String accessUriAsString(final URI uri) throws IOException {
-        final InputStream stream = accessUri(uri);
+    public static String accessUriAsString(URI uri) throws IOException,  URISyntaxException {
+        InputStream stream = accessUri(uri);
         return new Scanner(stream).useDelimiter("\\A").next();
     }
 }