@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); }
/** * 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 <code>read</code> method will read the XML element from the * provided node. This checks to ensure that the deserialized type * is the same as the entry type provided. If the types are not * the same then an exception is thrown. This is done to ensure * each node in the collection contain the same root annotation. * * @param node this is the XML element that is to be deserialized * @param expect this is the type expected of the deserialized type * * @return this returns the item to attach to the object contact */ private Object read(InputNode node, Class expect) throws Exception { Object item = root.read(node, expect); Class result = item.getClass(); Class actual = entry.getType(); if(!actual.isAssignableFrom(result)) { throw new PersistenceException("Entry %s does not match %s for %s", result, entry, type); } return item; }
/** * 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 method is used to read the key value from the node. The * value read from the node is resolved using the template filter. * If the key value can not be found according to the annotation * attributes then an exception is thrown. * * @param node this is the node to read the key value from * @param value this is the value to deserialize in to * * @return this returns the value deserialized from the node * * @throws Exception if value is not null an exception is thrown */ public Object read(InputNode node, Object value) throws Exception { Class expect = type.getType(); if(value != null) { throw new PersistenceException("Can not read key of %s for %s", expect, entry); } return read(node); }