@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."); } }
/** * 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); }
/** * 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); }
/** * This is used to determine if two annotations are equals based * on the attributes of the annotation. The comparison done can * ignore specific attributes, for instance the name attribute. * * @param proxy this is the annotation the invocation was made on * @param list this is the parameters provided to the invocation * * @return this returns true if the annotations are equals */ private boolean equals(Object proxy, Object[] list) throws Throwable { Annotation left = (Annotation) proxy; Annotation right = (Annotation) list[0]; if(left.annotationType() != right.annotationType()) { throw new PersistenceException("Annotation %s is not the same as %s", left, right); } return comparer.equals(left, right); }
/** * This is used to close the session on the thread local. If the * session still has references to it then the reference count * is decreased and the session remains open. This ensures that * we can make recursive calls in to the <code>Persister</code> * and still use the same session object. */ public void close() throws Exception { Reference session = local.get(); if(session == null) { throw new PersistenceException("Session does not exist"); } int reference = session.clear(); if(reference == 0) { local.remove(); } }
/** * This is used to close the session on the thread local. If the * session still has references to it then the reference count * is decreased and the session remains open. This ensures that * we can make recursive calls in to the <code>Persister</code> * and still use the same session object. */ public void close() throws Exception { Reference session = local.get(); if(session == null) { throw new PersistenceException("Session does not exist"); } int reference = session.clear(); if(reference == 0) { local.remove(); } }
/** * This is used to close the session on the thread local. If the * session still has references to it then the reference count * is decreased and the session remains open. This ensures that * we can make recursive calls in to the <code>Persister</code> * and still use the same session object. */ public void close() throws Exception { Reference session = local.get(); if(session == null) { throw new PersistenceException("Session does not exist"); } int reference = session.clear(); if(reference == 0) { local.remove(); } }
/** * This is used to determine if two annotations are equals based * on the attributes of the annotation. The comparison done can * ignore specific attributes, for instance the name attribute. * * @param proxy this is the annotation the invocation was made on * @param list this is the parameters provided to the invocation * * @return this returns true if the annotations are equals */ private boolean equals(Object proxy, Object[] list) throws Throwable { Annotation left = (Annotation) proxy; Annotation right = (Annotation) list[0]; if(left.annotationType() != right.annotationType()) { throw new PersistenceException("Annotation %s is not the same as %s", left, right); } return comparer.equals(left, right); }
/** * This <code>read</code> method will extract the text value from * the node and replace any template variables before converting * it to a primitive value. This uses the <code>Context</code> * object used for this instance of serialization to replace all * template variables with values from the context filter. * * @param node this is the node to be converted to a primitive * @param value this is the original primitive value used * * @return this returns the primitive that has been deserialized * * @throws Exception if value is not null an exception is thrown */ public Object read(InputNode node, Object value) throws Exception{ if(value != null) { throw new PersistenceException("Can not read existing %s for %s", expect, type); } return read(node); }
/** * 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"); }
/** * This is used to instantiate the object using a constructor that * takes deserialized objects as arguments. The object that have * been deserialized can be taken from the <code>Criteria</code> * object which contains the deserialized values. * * @param criteria this contains the criteria to be used * * @return this returns the object that has been instantiated */ public Object getInstance(Criteria criteria) throws Exception { Creator creator = getCreator(criteria); if(creator == null) { throw new PersistenceException("Constructor not matched for %s", detail); } return creator.getInstance(criteria); }
/** * This is used to instantiate the object using a constructor that * takes deserialized objects as arguments. The object that have * been deserialized can be taken from the <code>Criteria</code> * object which contains the deserialized values. * * @param criteria this contains the criteria to be used * * @return this returns the object that has been instantiated */ public Object getInstance(Criteria criteria) throws Exception { Creator creator = getCreator(criteria); if(creator == null) { throw new PersistenceException("Constructor not matched for %s", detail); } return creator.getInstance(criteria); }
/** * 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!"); } }
/** * This is used to instantiate the object using a constructor that * takes deserialized objects as arguments. The object that have * been deserialized can be taken from the <code>Criteria</code> * object which contains the deserialized values. * * @param criteria this contains the criteria to be used * * @return this returns the object that has been instantiated */ public Object getInstance(Criteria criteria) throws Exception { Creator creator = getCreator(criteria); if(creator == null) { throw new PersistenceException("Constructor not matched for %s", detail); } return creator.getInstance(criteria); }
/** * This <code>read</code> method will perform a read using the * provided object with the repeater. Reading with this method * ensures that any additional XML elements within the source * will be added to the value. * * @param node this is the node that contains the extra data * * @return this will return the original deserialized object */ public Object read(InputNode node, Object value) throws Exception { Position line = node.getPosition(); String name = node.getName(); if(reader instanceof Repeater) { Repeater repeat = (Repeater) reader; return repeat.read(node, value); } throw new PersistenceException("Element '%s' is already used with %s at %s", name, label, line); }
/** * This <code>read</code> method will perform a read using the * provided object with the repeater. Reading with this method * ensures that any additional XML elements within the source * will be added to the value. * * @param node this is the node that contains the extra data * * @return this will return the original deserialized object */ public boolean validate(InputNode node) throws Exception { Position line = node.getPosition(); String name = node.getName(); if(reader instanceof Repeater) { Repeater repeat = (Repeater) reader; return repeat.validate(node); } throw new PersistenceException("Element '%s' declared twice at %s", name, line); }
/** * This <code>read</code> method will perform a read using the * provided object with the repeater. Reading with this method * ensures that any additional XML elements within the source * will be added to the value. * * @param node this is the node that contains the extra data * * @return this will return the original deserialized object */ public Object read(InputNode node, Object value) throws Exception { Position line = node.getPosition(); String name = node.getName(); if(reader instanceof Repeater) { Repeater repeat = (Repeater) reader; return repeat.read(node, value); } throw new PersistenceException("Element '%s' is already used with %s at %s", name, label, line); }
/** * This <code>validate</code> method is used to perform validation * of the provided node object using a delegate converter. This is * typically another <code>Composite</code> converter, or if the * node is an attribute a <code>Primitive</code> converter. If this * fails validation then an exception is thrown to report the issue. * * @param node this is the node that contains the contact value * @param label this is the label used to create the converter */ private void validate(InputNode node, Label label) throws Exception { Converter reader = label.getConverter(context); Position line = node.getPosition(); Class expect = type.getType(); boolean valid = reader.validate(node); if(valid == false) { throw new PersistenceException("Invalid value for %s in %s at %s", label, expect, line); } criteria.set(label, null); }