src/org/ohmage/domain/Observer.java
public static JsonParser validateSchema(
				final String schema)
				throws DomainException {
			
			Context context = Context.enter();
			try {
				Scriptable scope = context.initStandardObjects();
				Function concordiaConstructor =
					context.compileFunction(
						scope, 
						JS_SCHEMA, 
						"Concordia.js", 
						1, 
						null);
				
				concordiaConstructor.construct(
					context, 
					scope, 
					new Object[] { schema });
			}
			catch(JavaScriptException e) {
				throw new DomainException(
					ErrorCode.OBSERVER_INVALID_STREAM_DEFINITION,
					"The schema is invalid: " + e.getMessage(),
					e);
			}
			catch(RhinoException e) {
				throw new DomainException(
					ErrorCode.OBSERVER_INVALID_STREAM_DEFINITION, 
					"A stream definition is not valid JSON.");
			}
			finally {
				Context.exit();
			}
			
			try {
				return JSON_FACTORY.createJsonParser(schema);
			}
			catch(JsonParseException e) {
				throw new DomainException(
					"Validation succeeded, but the schema could not be parsed as JSON.",
					e);
			}
			catch(IOException e) {
				throw new DomainException(
					"Could not read the string value.",
					e);
			}
		}
/**
		 * Validates that a schema used to defined a stream is valid.
		 * 
		 * @param schema The stream's schema.
		 * 
		 * @return The schema if it was valid.
		 * 
		 * @throws DomainException The schema was not valid.
		 */
Validates that a schema used to defined a stream is valid.

@param schema The stream's schema.

@return The schema if it was valid.

@throws DomainException The schema was not valid.
Validates that a schema used to defined a stream is valid . @param schema The stream ' s schema . @return The schema if it was valid . @throws DomainException The schema was not valid .
public static JsonParser validateSchema(
				final String schema)
				throws DomainException {
			Context context = Context.enter();
			try {
				Scriptable scope = context.initStandardObjects();
				Function concordiaConstructor =
					context.compileFunction(
						scope, 
						JS_SCHEMA, 
						"Concordia.js", 
						1, 
						null);
				concordiaConstructor.construct(
					context, 
					scope, 
					new Object[] { schema });
			}
			catch(JavaScriptException e) {
				throw new DomainException(
					ErrorCode.OBSERVER_INVALID_STREAM_DEFINITION,
					"The schema is invalid: " + e.getMessage(),
					e);
			}
			catch(RhinoException e) {
				throw new DomainException(
					ErrorCode.OBSERVER_INVALID_STREAM_DEFINITION, 
					"A stream definition is not valid JSON.");
			}
			finally {
				Context.exit();
			}
			try {
				return JSON_FACTORY.createJsonParser(schema);
			}
			catch(JsonParseException e) {
				throw new DomainException(
					"Validation succeeded, but the schema could not be parsed as JSON.",
					e);
			}
			catch(IOException e) {
				throw new DomainException(
					"Could not read the string value.",
					e);
			}
		}
public static JsonParser validateSchema ( final String schema ) throws DomainException { Context context = Context . enter ( ) ; try { Scriptable scope = context . initStandardObjects ( ) ; Function concordiaConstructor = context . compileFunction ( scope , JS_SCHEMA , "Concordia.js" , 1 , null ) ; concordiaConstructor . construct ( context , scope , new Object [ ] { schema } ) ; } catch ( JavaScriptException e ) { throw new DomainException ( ErrorCode . OBSERVER_INVALID_STREAM_DEFINITION , "The schema is invalid: " + e . getMessage ( ) , e ) ; } catch ( RhinoException e ) { throw new DomainException ( ErrorCode . OBSERVER_INVALID_STREAM_DEFINITION , "A stream definition is not valid JSON." ) ; } finally { Context . exit ( ) ; } try { return JSON_FACTORY . createJsonParser ( schema ) ; } catch ( JsonParseException e ) { throw new DomainException ( "Validation succeeded, but the schema could not be parsed as JSON." , e ) ; } catch ( IOException e ) { throw new DomainException ( "Could not read the string value." , e ) ; } }
Validates that a schema used to defined a stream is valid.
Validates that a schema used to defined a stream is valid .