/** * Validate if all required fields are present. * * @throws StorageException Thrown if the validation failed due to missing field values. */ @Validate public final void validateRequiredFields() throws StorageException { logger.log(Level.FINE, "Validating required fields"); try { Field[] elementFields = ReflectionUtil.getAllFieldsWithAnnotation(this.getClass(), Element.class); for (Field field : elementFields) { field.setAccessible(true); if (field.getAnnotation(Element.class).required() && field.get(this) == null) { logger.log(Level.WARNING, "Missing mandatory field {0}#{1}", new Object[] { this.getClass().getSimpleName(), field.getName() }); throw new StorageException("Missing mandatory field " + this.getClass().getSimpleName() + "#" + field.getName()); } } } catch (IllegalAccessException e) { throw new RuntimeException("IllegalAccessException when validating required fields: ", e); } }
@Validate public void validate() throws StorageException { if (baz != null && !baz.equalsIgnoreCase("baz")) { throw new StorageException("Only allowed value for baz field is 'baz'"); } } }
@Validate private void validate() throws PersistenceException{ if (commands == null || commands.length != COMMANDS_COUNT) throw new PersistenceException("There must be always " + COMMANDS_COUNT + " commands in a configuration."); } }
@Validate public void validate() throws ParseException { this.name = ValidationUtils .validateCaseInsensitiveNameAttribute(ATTRIBUTE_PARENT_NAME, "name", name); }
@Validate public void validate() throws ParseException { this.name = ValidationUtils .validateCaseInsensitiveNameAttribute(ATTRIBUTE_PARENT_NAME, "name", name); }
/** * Validates the read data for the <code>PartInfo</code> element. * <p>If the payload is or should be contained in the SOAP body or as an attachment the location of the payload * document must be specified. * * @throws PersistenceException When the payload is contained in either SOAP body or attachment but no location is * specified */ @Validate public void validate() throws PersistenceException { if (!"external".equalsIgnoreCase(this.containment) && (location == null || location.isEmpty())) throw new PersistenceException("location attributed is required for containment type " + containment, (Object[]) null); }
/** * Validates the read XML structure. The only restriction is that <i>Address</i> must be specified when the * </i>AddActorOrRoleAttribute</i> is set. * * @throws PersistenceException When no URL is provided for <i>Address</i> when the * </i>AddActorOrRoleAttribute</i> is set. */ @Validate public void validate() throws PersistenceException { if (shouldshouldAddActorOrRoleAttribute != null && (address == null || address.isEmpty())) throw new PersistenceException("Address must be specified if AddActorOrRoleAttribute is set"); }
/** * Validates the read XML data to ensure that there is at most one UsernameToken child element. This only element * should have no <code>target</code> attribute specified or with value <i>"ebms"</i> because the sub-channel * authentication and authorization can only use the security header targeted to this role. * * @throws PersistenceException When the read XML document contains more than 1 UsernameToken element */ @Override @Validate public void validate() throws PersistenceException { if (usernameTokens == null) return; else if (usernameTokens.size() > 1) throw new PersistenceException("There shall be only one UsernameToken element for PullRequestFlow", null); }
/** * Validates the data read from the XML document. The validation for now only checks whether an URL is specified * when the response pattern is set to CALLBACK * * @throws PersistenceException When no URL is provided when the reply pattern is set to CALLBACK */ @Validate public void validate() throws PersistenceException { if (getPattern() == ReplyPattern.CALLBACK && (to == null || to.isEmpty())) throw new PersistenceException("You must specify the URL where to sent errors when setting" + " reply pattern to CALLBACK", null); }
/** * Checks that the trading partner configuration included in the P-Mode XML document includes at least a PartyId or * security configuration. * * @throws PersistenceException When neither PartyId or security configuration is included in the XML document */ @Validate public void validate() throws PersistenceException { if (Utils.isNullOrEmpty(partyIds) && securityConfig == null) throw new PersistenceException("Either one or more PartyIds or the security configuration must be included"); }
/** * Performs additional checks to ensure that the read XML document is valid according to the XSD. * <p>Because a general definition is used for reading both the default and specific pullers there is no check * on the number of P-Modes referenced by the pullers when the XML is deserialized. Therefor this method performs * checks:<ol> * <li>There are no referenced P-Modes for the default puller</li> * <li>There is at least one reference P-Mode for each specific puller</li> * </ol> * * @throws PersistenceException When the read XML fails one of the checks */ @Validate private void validate() throws PersistenceException { // Default puller should have no PModes associated with it if(defaultPuller.pmodes != null && !defaultPuller.pmodes.isEmpty()) throw new PersistenceException("The default puller should not specify specific PModes!"); // A specific puller must specifiy at least one PMode if(pullers != null) { for(final PullerConfig p : pullers) if(p.pmodes == null || p.pmodes.isEmpty()) throw new PersistenceException("Specific puller must reference at least one PMode!"); } }
/** * Validates the read configuration. At the moment this validation only checks that each parameter is named. * * @throws PersistenceException When a parameter included in the XML document has no name. */ @Validate public void validate() throws PersistenceException { if (!Utils.isNullOrEmpty(parameters)) { for (final String name : parameters.keySet()) if (Utils.isNullOrEmpty(name)) throw new PersistenceException("Each parameter in the configuration must be named!"); } }
/** * Validates the read XML data to ensure that there are at most two UsernameToken child elements and that each * has its own target. * * @throws PersistenceException When the read XML document contains more than 2 UsernameToken elements or the * specified UsernameToken elements have the same target */ @Validate public void validate() throws PersistenceException { if (usernameTokens == null) return; if (usernameTokens.size() > 2) throw new PersistenceException("There may not be more than 2 UsernameToken elements", null); else if (usernameTokens.size() == 2) { // Compare the target attribute value of both elements final int c = Utils.compareStrings(usernameTokens.get(0).target, usernameTokens.get(1).target); if (c == -1 || c == 0) // The targets are equal throw new PersistenceException("You must specify separate targets for the UsernameToken elements!", null); } }
@Validate public void convertToClasses() throws PersistenceException {
@Validate public void validate() throws ParseException { this.company = ValidationUtils .validateNotHavingUnderscore(ValidationUtils.validateCaseSensitiveNameAttribute( ATTRIBUTE_PARENT_NAME, "company", company), "The company parameter can't contain underscores. It is connected with the way the Version API reads companies. Underscores have been stripped."); this.name = ValidationUtils .validateCaseSensitiveNameAttribute(ATTRIBUTE_PARENT_NAME, "name", name); this.project = ValidationUtils .validateCaseSensitiveNameAttribute(ATTRIBUTE_PARENT_NAME, "project", project); }
@Validate public void validate() throws ParseException { this.company = ValidationUtils .validateNotHavingUnderscore(ValidationUtils.validateCaseSensitiveNameAttribute( ATTRIBUTE_PARENT_NAME, "company", company), "The company parameter can't contain underscores. It is connected with the way the Version API reads companies. Underscores have been stripped."); this.name = ValidationUtils .validateCaseSensitiveNameAttribute(ATTRIBUTE_PARENT_NAME, "name", name); this.project = ValidationUtils .validateCaseSensitiveNameAttribute(ATTRIBUTE_PARENT_NAME, "project", project); }
/** * Validates the data read from the XML document by checking that when <code>MaxRetries</code> is supplied * <code>RetryInterval</code> contains positive non zero value. * * @throws Exception When the read XML is not valid */ @Validate public void validate() throws Exception { if (maxRetries > -1) if (fixedInterval <= 0) throw new ValueRequiredException( "ReceptionAwareness/RetryInterval must have positive non zero value if MaxRetries is set"); else if (!Utils.isNullOrEmpty(flexibleIntervalsText)) throw new ElementException("Invalid combination of MaxRetries and WaitIntervals settings"); // Create the array of intervals and check also that the specified intervals are valid calculateIntervals(); }