container/components/components/src/main/java/org/mobicents/slee/container/component/validator/ProfileSpecificationComponentValidator.java
boolean validateDescriptor() {

		boolean passed = true;
		String errorBuffer = new String("");

		if (!this.component.isSlee11()) {
			return passed;
			// there is not much we can do for those oldies.
		}

		try {
			HashSet<String> collatorAlliases = new HashSet<String>();
			ProfileSpecificationDescriptorImpl desc = this.component
					.getDescriptor();
			for (CollatorDescriptor mc : desc.getCollators()) {
				if (collatorAlliases.contains(mc.getCollatorAlias())) {
					passed = false;
					errorBuffer = appendToBuffer(
							"Profile specification declares collator alias twice: "
									+ mc.getCollatorAlias(), "3.3.7",
							errorBuffer);
				} else {
					collatorAlliases.add(mc.getCollatorAlias());
				}
			}

			// double deifnition of refs is allowed.
			Map<String, ProfileCMPFieldDescriptor> cmpName2Field = new HashMap<String, ProfileCMPFieldDescriptor>();
			for (ProfileCMPFieldDescriptor c : desc.getProfileCMPInterface().getCmpFields()) {

				if (!Character.isLowerCase(c.getCmpFieldName().charAt(0))) {
					passed = false;
					errorBuffer = appendToBuffer(
							"Profile specification declares wrong cmp field name, first char is not lower case, field: "
									+ c.getCmpFieldName(), "3.3.7", errorBuffer);
				}

				if (cmpName2Field.containsKey(c.getCmpFieldName())) {
					passed = false;
					errorBuffer = appendToBuffer(
							"Profile specification declares cmp field twice: "
									+ c.getCmpFieldName(), "3.3.7", errorBuffer);
				} else {
					cmpName2Field.put(c.getCmpFieldName(), c);
				}

				if (c.getUniqueCollatorRef() != null
						&& !collatorAlliases.contains(c.getUniqueCollatorRef())) {
					passed = false;
					errorBuffer = appendToBuffer(
							"Profile specification declares cmp field: "
									+ c.getCmpFieldName()
									+ ", with wrong collator reference: "
									+ c.getUniqueCollatorRef(), "3.3.7",
							errorBuffer);
				}

				for (IndexHintDescriptor indexHint : c.getIndexHints()) {
					if (indexHint.getCollatorRef() != null
							&& !collatorAlliases.contains(indexHint
									.getCollatorRef())) {
						passed = false;
						errorBuffer = appendToBuffer(
								"Profile specification declares cmp field: "
										+ c.getCmpFieldName()
										+ ", with index hint declaring wrong collator reference: "
										+ c.getUniqueCollatorRef(), "3.3.7",
								errorBuffer);
					}
				}

			}

			Set<String> queriesNames = new HashSet<String>();
			for (QueryDescriptor mq : desc.getQueryElements()) {

				if (queriesNames.contains(mq.getName())) {
					passed = false;
					errorBuffer = appendToBuffer(
							"Profile specification declares queries with the same name: "
									+ mq.getName(), "3.3.7", errorBuffer);
				} else {

					// FIXME: all declaredparameters have to be used in
					// expressions?
					HashSet<String> decalredParameters = new HashSet<String>();
					HashSet<String> usedParameters = new HashSet<String>();
					for (QueryParameterDescriptor mqp : mq.getQueryParameters()) {
						if (decalredParameters.contains(mqp.getName())) {
							passed = false;
							errorBuffer = appendToBuffer(
									"Profile specification declares query parameter twice, parameter name: "
											+ mqp.getName() + ", in query: "
											+ mq.getName(), "3.3.7",
									errorBuffer);
						} else {
							decalredParameters.add(mqp.getName());
						}

					}

					if (!validateExpression(mq.getName(), mq
							.getQueryExpression(), usedParameters,
							cmpName2Field.keySet(), collatorAlliases)) {
						passed = false;
					}

					if (!usedParameters.containsAll(decalredParameters)
							&& !decalredParameters.containsAll(usedParameters)) {
						passed = false;
						decalredParameters.retainAll(usedParameters);
						errorBuffer = appendToBuffer(
								"Profile specification declares query parameter that are not used, in query: "
										+ mq.getName()
										+ ", not used parameters: "
										+ Arrays.toString(decalredParameters
												.toArray()), "3.3.7",
								errorBuffer);
					}

				}

			}

			// FIXME: this should be here or not?
			if (!validateEnvEntries()) {
				passed = false;
			}

		} finally {

			if (!passed) {
				if(logger.isEnabledFor(Level.ERROR))
					logger.error(errorBuffer);
				//System.err.println(errorBuffer);
			}

		}

		return passed;

	}
boolean validateDescriptor() {

		boolean passed = true;
		String errorBuffer = new String("");

		if (!this.component.isSlee11()) {
			return passed;
			// there is not much we can do for those oldies.
		}

		try {
			HashSet<String> collatorAlliases = new HashSet<String>();
			ProfileSpecificationDescriptorImpl desc = this.component
					.getDescriptor();
			for (CollatorDescriptor mc : desc.getCollators()) {
				if (collatorAlliases.contains(mc.getCollatorAlias())) {
					passed = false;
					errorBuffer = appendToBuffer(
							"Profile specification declares collator alias twice: "
									+ mc.getCollatorAlias(), "3.3.7",
							errorBuffer);
				} else {
					collatorAlliases.add(mc.getCollatorAlias());
				}
			}

			// double deifnition of refs is allowed.
			Map<String, ProfileCMPFieldDescriptor> cmpName2Field = new HashMap<String, ProfileCMPFieldDescriptor>();
			for (ProfileCMPFieldDescriptor c : desc.getProfileCMPInterface().getCmpFields()) {

				if (!Character.isLowerCase(c.getCmpFieldName().charAt(0))) {
					passed = false;
					errorBuffer = appendToBuffer(
							"Profile specification declares wrong cmp field name, first char is not lower case, field: "
									+ c.getCmpFieldName(), "3.3.7", errorBuffer);
				}

				if (cmpName2Field.containsKey(c.getCmpFieldName())) {
					passed = false;
					errorBuffer = appendToBuffer(
							"Profile specification declares cmp field twice: "
									+ c.getCmpFieldName(), "3.3.7", errorBuffer);
				} else {
					cmpName2Field.put(c.getCmpFieldName(), c);
				}

				if (c.getUniqueCollatorRef() != null
						&& !collatorAlliases.contains(c.getUniqueCollatorRef())) {
					passed = false;
					errorBuffer = appendToBuffer(
							"Profile specification declares cmp field: "
									+ c.getCmpFieldName()
									+ ", with wrong collator reference: "
									+ c.getUniqueCollatorRef(), "3.3.7",
							errorBuffer);
				}

				for (IndexHintDescriptor indexHint : c.getIndexHints()) {
					if (indexHint.getCollatorRef() != null
							&& !collatorAlliases.contains(indexHint
									.getCollatorRef())) {
						passed = false;
						errorBuffer = appendToBuffer(
								"Profile specification declares cmp field: "
										+ c.getCmpFieldName()
										+ ", with index hint declaring wrong collator reference: "
										+ c.getUniqueCollatorRef(), "3.3.7",
								errorBuffer);
					}
				}

			}

			Set<String> queriesNames = new HashSet<String>();
			for (QueryDescriptor mq : desc.getQueryElements()) {

				if (queriesNames.contains(mq.getName())) {
					passed = false;
					errorBuffer = appendToBuffer(
							"Profile specification declares queries with the same name: "
									+ mq.getName(), "3.3.7", errorBuffer);
				} else {

					// FIXME: all declaredparameters have to be used in
					// expressions?
					HashSet<String> decalredParameters = new HashSet<String>();
					HashSet<String> usedParameters = new HashSet<String>();
					for (QueryParameterDescriptor mqp : mq.getQueryParameters()) {
						if (decalredParameters.contains(mqp.getName())) {
							passed = false;
							errorBuffer = appendToBuffer(
									"Profile specification declares query parameter twice, parameter name: "
											+ mqp.getName() + ", in query: "
											+ mq.getName(), "3.3.7",
									errorBuffer);
						} else {
							decalredParameters.add(mqp.getName());
						}

					}

					if (!validateExpression(mq.getName(), mq
							.getQueryExpression(), usedParameters,
							cmpName2Field.keySet(), collatorAlliases)) {
						passed = false;
					}

					if (!usedParameters.containsAll(decalredParameters)
							&& !decalredParameters.containsAll(usedParameters)) {
						passed = false;
						decalredParameters.retainAll(usedParameters);
						errorBuffer = appendToBuffer(
								"Profile specification declares query parameter that are not used, in query: "
										+ mq.getName()
										+ ", not used parameters: "
										+ Arrays.toString(decalredParameters
												.toArray()), "3.3.7",
								errorBuffer);
					}

				}

			}

			// FIXME: this should be here or not?
			if (!validateEnvEntries()) {
				passed = false;
			}

		} finally {

			if (!passed) {
				if(logger.isEnabledFor(Level.ERROR))
					logger.error(errorBuffer);
				//System.err.println(errorBuffer);
			}

		}

		return passed;

	}
boolean validateDescriptor ( ) { boolean passed = true ; String errorBuffer = new String ( "" ) ; if ( ! this . component . isSlee11 ( ) ) { return passed ; // there is not much we can do for those oldies.
 } try { HashSet < String > collatorAlliases = new HashSet < String > ( ) ; ProfileSpecificationDescriptorImpl desc = this . component . getDescriptor ( ) ; for ( CollatorDescriptor mc : desc . getCollators ( ) ) { if ( collatorAlliases . contains ( mc . getCollatorAlias ( ) ) ) { passed = false ; errorBuffer = appendToBuffer ( "Profile specification declares collator alias twice: " + mc . getCollatorAlias ( ) , "3.3.7" , errorBuffer ) ; } else { collatorAlliases . add ( mc . getCollatorAlias ( ) ) ; } } // double deifnition of refs is allowed.
 Map < String , ProfileCMPFieldDescriptor > cmpName2Field = new HashMap < String , ProfileCMPFieldDescriptor > ( ) ; for ( ProfileCMPFieldDescriptor c : desc . getProfileCMPInterface ( ) . getCmpFields ( ) ) { if ( ! Character . isLowerCase ( c . getCmpFieldName ( ) . charAt ( 0 ) ) ) { passed = false ; errorBuffer = appendToBuffer ( "Profile specification declares wrong cmp field name, first char is not lower case, field: " + c . getCmpFieldName ( ) , "3.3.7" , errorBuffer ) ; } if ( cmpName2Field . containsKey ( c . getCmpFieldName ( ) ) ) { passed = false ; errorBuffer = appendToBuffer ( "Profile specification declares cmp field twice: " + c . getCmpFieldName ( ) , "3.3.7" , errorBuffer ) ; } else { cmpName2Field . put ( c . getCmpFieldName ( ) , c ) ; } if ( c . getUniqueCollatorRef ( ) != null && ! collatorAlliases . contains ( c . getUniqueCollatorRef ( ) ) ) { passed = false ; errorBuffer = appendToBuffer ( "Profile specification declares cmp field: " + c . getCmpFieldName ( ) + ", with wrong collator reference: " + c . getUniqueCollatorRef ( ) , "3.3.7" , errorBuffer ) ; } for ( IndexHintDescriptor indexHint : c . getIndexHints ( ) ) { if ( indexHint . getCollatorRef ( ) != null && ! collatorAlliases . contains ( indexHint . getCollatorRef ( ) ) ) { passed = false ; errorBuffer = appendToBuffer ( "Profile specification declares cmp field: " + c . getCmpFieldName ( ) + ", with index hint declaring wrong collator reference: " + c . getUniqueCollatorRef ( ) , "3.3.7" , errorBuffer ) ; } } } Set < String > queriesNames = new HashSet < String > ( ) ; for ( QueryDescriptor mq : desc . getQueryElements ( ) ) { if ( queriesNames . contains ( mq . getName ( ) ) ) { passed = false ; errorBuffer = appendToBuffer ( "Profile specification declares queries with the same name: " + mq . getName ( ) , "3.3.7" , errorBuffer ) ; } else { // FIXME: all declaredparameters have to be used in
 // expressions?
 HashSet < String > decalredParameters = new HashSet < String > ( ) ; HashSet < String > usedParameters = new HashSet < String > ( ) ; for ( QueryParameterDescriptor mqp : mq . getQueryParameters ( ) ) { if ( decalredParameters . contains ( mqp . getName ( ) ) ) { passed = false ; errorBuffer = appendToBuffer ( "Profile specification declares query parameter twice, parameter name: " + mqp . getName ( ) + ", in query: " + mq . getName ( ) , "3.3.7" , errorBuffer ) ; } else { decalredParameters . add ( mqp . getName ( ) ) ; } } if ( ! validateExpression ( mq . getName ( ) , mq . getQueryExpression ( ) , usedParameters , cmpName2Field . keySet ( ) , collatorAlliases ) ) { passed = false ; } if ( ! usedParameters . containsAll ( decalredParameters ) && ! decalredParameters . containsAll ( usedParameters ) ) { passed = false ; decalredParameters . retainAll ( usedParameters ) ; errorBuffer = appendToBuffer ( "Profile specification declares query parameter that are not used, in query: " + mq . getName ( ) + ", not used parameters: " + Arrays . toString ( decalredParameters . toArray ( ) ) , "3.3.7" , errorBuffer ) ; } } } // FIXME: this should be here or not?
 if ( ! validateEnvEntries ( ) ) { passed = false ; } } finally { if ( ! passed ) { if ( logger . isEnabledFor ( Level . ERROR ) ) logger . error ( errorBuffer ) ; //System.err.println(errorBuffer);
 } } return passed ; }
Validated descriptor against some basic constraints: all references are
correct, some fields are declaredproperly, no double definitions, if
proper elements are present - for instance some elements exclude others.

@return
Validated descriptor against some basic constraints : all references are correct some fields are declaredproperly no double definitions if proper elements are present - for instance some elements exclude others .