private synchronized DefaultPrice[] getZeroPrice(StandaloneCatalog root) { Currency[] currencies = root.getCurrentSupportedCurrencies(); DefaultPrice[] zeroPrice = new DefaultPrice[currencies.length]; for (int i = 0; i < currencies.length; i++) { zeroPrice[i] = new DefaultPrice(); zeroPrice[i].setCurrency(currencies[i]); zeroPrice[i].setValue(new BigDecimal(0)); } return zeroPrice; }
@Override public ValidationErrors validate(StandaloneCatalog catalog, ValidationErrors errors) { Currency[] supportedCurrencies = catalog.getCurrentSupportedCurrencies(); for (Price p : prices) { Currency currency = p.getCurrency(); if (!currencyIsSupported(currency, supportedCurrencies)) { errors.add( "Unsupported currency: " + currency, catalog.getCatalogURI(), this.getClass(), ""); } try { if (p.getValue().doubleValue() < 0.0) { errors.add( "Negative value for price in currency: " + currency, catalog.getCatalogURI(), this.getClass(), ""); } } catch (CurrencyValueNull e) { // No currency => nothing to check, ignore exception } } return errors; }