/** * Validates the <code>KeyTransport</code> element included in this P-Mode. * <p>When included the element must have at least one child. Also when the <i>RSA-OAEP</i> algorithm is specified * an MGF algorithm must be specified. * * @throws PersistenceException If there is not at least one child element or when no MGF algorithm is specified in * case <i>RSA-OAEP</i> is specified */ @Validate public void validate() throws PersistenceException { // Check at least one child element is included if (Utils.getValue(algorithm, null) == null && Utils.getValue(MGFAlgorithm, null) == null && Utils.getValue(digestAlgorithm, null) == null && Utils.getValue(keyReferenceMethod.referenceMethod, null) == null) throw new PersistenceException("KeyTransport MUST have at least one child element", null); // Check if MGF is specified in case RSA-OAEP is kt algorithm if (WSConstants.KEYTRANSPORT_RSAOEP_XENC11.equalsIgnoreCase(algorithm) && Utils.getValue(MGFAlgorithm, null) == null) throw new PersistenceException("You MUST specify a MGF algorithm when specifying RSA-OAEP as " + "key transport algorithm", null); }
/** * 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); } }
/** * Initialization method used by the Simple XML framework. */ @SuppressWarnings("unused") @Validate private void validate() { /* Validate color. */ if (color != null) { String[] rgb = this.color.split(","); this.colorObject = new Color( Integer.parseInt(rgb[0]), Integer.parseInt(rgb[1]), Integer.parseInt(rgb[2])); } /* Validate last part of name. */ validateName(); /* Create hash code. */ hashCodeValue = bitIdentifier.hashCode() ^ name.hashCode() ^ family.hashCode(); }
/** * Validation method for the read XML information. * * @see org.simpleframework.xml.load.Validate */ @Validate public void validate() { /* Validate color. */ String[] rgb = this.color.split(","); this.colorObject = new Color( Integer.parseInt(rgb[0]), Integer.parseInt(rgb[1]), Integer.parseInt(rgb[2])); /* Validate states. */ if (states != null) { stateStates = new HashMap<String, String[]>(); Iterator<String> iterStr = states.keySet().iterator(); while (iterStr.hasNext()) { String nextStateType = iterStr.next(); String[] stateNames = states.get(nextStateType).split(","); Arrays.sort(stateNames); stateStates.put(nextStateType, stateNames); } } }
@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(Map session) throws IOException { File file = new File(root); if(!file.exists()) { throw new FileNotFoundException("Root path '" +file+ "' does not exist"); } session.put(identifier, file.getAbsolutePath()); }
@Validate public void validate() throws Exception { if(getSeparatedKeys().length==0) throw new Exception("Action must have at least one key: "+keys); if(getNextScene()!=null && getNextDialog()!=null) throw new Exception("An action cannot have both a next dialog and next scene..."); }
@Validate public void validate() throws Exception { if((text==null || text.trim().equals("")) && file==null) throw new Exception("Audio must have either some text or a link to a file"); if((text!=null && (!text.trim().equals(""))) && file!=null) throw new Exception("Audio cannot have both text and a link to a file"); }
@Validate public void validate() throws Exception { if( ! (change.equals(INCREMENT) || change.equals(DECREMENT) || change.equals(SET_TRUE) || change.equals(SET_FALSE) || change.equals(SET_ZERO) || change.equals(SET_VALUE)) ) throw new Exception("Unknown state change: "+change); if(change.equals(SET_VALUE) && getValue()==null) throw new Exception("State-change 'set-value' must have a 'value' attribute"); }
@Validate public void validate() throws Exception { for(Voice v : getVoices()) if(!voiceMap.containsKey(v.getId())) voiceMap.put(v.getId(), v); else throw new Exception("Duplicate voice: "+v.getId()); if(!voiceMap.containsKey(defaultVoiceId)) throw new Exception("Default voice id does not exist: "+defaultVoiceId); }
/** * 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 data read from the XML document by checking that when <code>MaxRetries</code> is supplied * <code>RetryInterval</code> contains positive non zero value;</li></ol> * * @throws Exception When the read XML is not valid */ @Validate public void validate() throws Exception { if (maxRetries > -1) if (retryIntervalDuration <= 0) throw new ValueRequiredException("ReceptionAwareness/RetryInterval must have positive non zero value"); }
/** * 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); }
/** * 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!"); } }
/** * Called after XML setup of SubstanceManager. * Creates a backup of the SubstanceManager initial state. */ @Validate void validate() { familiesBak = new HashSet<SubstanceFamily>(); familiesBak.addAll(families); substancesBak = new HashSet<Substance>(); substancesBak.addAll(substances); subFamilyMergeRulesBak = new Vector<SubFamilyMergeRule>(); subFamilyMergeRulesBak.addAll(subFamilyMergeRules); }
/** * Post-XML read validation. Used to determine the color from the separate RGB components. */ @SuppressWarnings("unused") @Validate private void validate() { /* Validate color. */ if (color != null) { String[] rgb = this.color.split(","); this.colorObject = new Color( Integer.parseInt(rgb[0]), Integer.parseInt(rgb[1]), Integer.parseInt(rgb[2])); } else { this.colorObject = new Color(0, 0, 0); } }
/** * This method initializes the agent names. */ @Validate public void validate() { Iterator<String> iterAgName = agentMap.keySet().iterator(); while (iterAgName.hasNext()) { String agName = iterAgName.next(); AgentPrototype ap = agentMap.get(agName); ap.setName(agName); } }
@SuppressWarnings("unused") @Validate private void validate() { if (conditions == null) conditions = new ArrayList<AgentCondition>(); if (actions == null) actions = new ArrayList<AgentAction>(); }
@Validate public void validate() throws PersistenceException { if(filenameBackgroundProgram != null) { if(!filenameBackgroundProgram.exists()) { String dir = Angerona.getInstance().getActualSimulation().getDirectory(); filenameBackgroundProgram = new File(dir + "/" + filenameBackgroundProgram.getPath()); if(!filenameBackgroundProgram.exists()) throw new PersistenceException("Cannot find background program in '" + filenameBackgroundProgram + "'"); } } }
/** * Checks if the loaded agent instance is valid. * @throws PersistenceException */ @Validate public void validation() throws PersistenceException { if(!(this.cylceScript instanceof CommandSequence)) { throw new PersistenceException("cycle-script is not of type '%s' but of type '%s", CommandSequence.class.getName(), this.cylceScript == null ? "null" : this.cylceScript.getClass().getName()); } }
@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() { return; }
@Validate public void validate(Map map) { validated = true; }
@Validate public void validate() throws Exception { if(lineList.size()==0) throw new Exception("A dialog must have at least one line"); }
@Validate public void validate() throws PersistenceException { List<String> err = new ArrayList<>(); // check if no question is double (id or real-equal)): List<Question> temp = new ArrayList<>(questions); for(int i=0; i<temp.size(); ++i) { Question iQ = temp.get(i); for(int k=i+1; k<temp.size(); ++k) { Question kQ = temp.get(k); // check for duplo id: if(iQ.id == kQ.id) { err.add("The questions '" + iQ.toString() + "' and '" + kQ.toString() + "' share the same id: '" + iQ.id + "'"); // check for equal questions with mismatching ids } else if(Utility.equals(iQ.symbol, kQ.symbol)) { err.add("There exist two versions of questions with the same symbol: '" + iQ.toString() + "' one with 'id=" + iQ.id + "' and the other with id='" + kQ.id + "', questions with same " + "symbol but difference arguments are not supported."); } } } // check if all the behavior and additional information can be referenced for(Question question : questions) { questionMap.put(question.id, question); } for(Behavior behavior : this.allowedBehaviors) { if(!questionMap.keySet().contains(behavior.questionId)) { err.add("The behavior '" + behavior.toString() + "' references not existing question with id='" + behavior.questionId + "'"); } behaviorMap.put(behavior.id, behavior); } for(AdditionalInformation ai : this.additionalInformation) { if(!behaviorMap.keySet().contains(ai.behaviorId)) { err.add("The additional-information: '" + ai.toString() + "' references not existing behavior with id='" + ai.behaviorId + "'"); } } if(!err.isEmpty()) { String out = "Cannot deserialize DefendingSituation:"; for(String line : err) { out += "\n" + line; } throw new PersistenceException(out); } super.validate(); }
/** * 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 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); }
/** * 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"); }