public static void main(final String[] args) throws Exception { if (args.length != 1) { System.err.println("Usage: <catalog filepath>"); System.exit(0); } File file = new File(args[0]); if(!file.exists()) { System.err.println("Error: '" + args[0] + "' does not exist"); } StandaloneCatalog catalog = XMLLoader.getObjectFromUri(file.toURI(), StandaloneCatalog.class); if (catalog != null) { System.out.println("Success: Catalog loads!"); } }
final StandaloneCatalog catalog = XMLLoader.getObjectFromUri(u, StandaloneCatalog.class); result.add(catalog);
@Test(groups = "fast") public void test() throws Exception { final URI uri = new URI(Resources.getResource("WeaponsHireSmall.xml").toExternalForm()); final StandaloneCatalog catalog = XMLLoader.getObjectFromUri(uri, StandaloneCatalog.class); Assert.assertNotNull(catalog); final PlanRules rules = catalog.getPlanRules(); final PlanSpecifier specifier = new PlanSpecifier("Laser-Scope", ProductCategory.ADD_ON, BillingPeriod.MONTHLY, "DEFAULT"); final PlanAlignmentCreate alignment = rules.getPlanCreateAlignment(specifier, catalog); Assert.assertEquals(alignment, PlanAlignmentCreate.START_OF_SUBSCRIPTION); final PlanSpecifier specifier2 = new PlanSpecifier("Extra-Ammo", ProductCategory.ADD_ON, BillingPeriod.MONTHLY, "DEFAULT"); final PlanAlignmentCreate alignment2 = rules.getPlanCreateAlignment(specifier2, catalog); Assert.assertEquals(alignment2, PlanAlignmentCreate.START_OF_BUNDLE); } }
@LifecycleHandlerType(LifecycleLevel.LOAD_CATALOG) public synchronized void loadConfig() throws ServiceException { if (!isConfigLoaded) { try { final URI u = new URI(properties.getConfigURI()); overdueConfig = XMLLoader.getObjectFromUri(u, OverdueConfig.class); // File not found? if (overdueConfig == null) { log.warn("Unable to load the overdue config from " + properties.getConfigURI()); overdueConfig = new OverdueConfig(); } isConfigLoaded = true; } catch (final URISyntaxException e) { overdueConfig = new OverdueConfig(); } catch (final IllegalArgumentException e) { overdueConfig = new OverdueConfig(); } catch (final Exception e) { throw new ServiceException(e); } factory.setOverdueConfig(overdueConfig); ((DefaultOverdueUserApi) userApi).setOverdueConfig(overdueConfig); } }