axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From manj...@apache.org
Subject svn commit: r548908 - in /webservices/axis2/trunk/c/neethi: include/neethi_util.h src/util.c
Date Wed, 20 Jun 2007 03:18:38 GMT
Author: manjula
Date: Tue Jun 19 20:18:37 2007
New Revision: 548908

URL: http://svn.apache.org/viewvc?view=rev&rev=548908
Log:
Adding util to create policy from file and om.

Added:
    webservices/axis2/trunk/c/neethi/include/neethi_util.h
    webservices/axis2/trunk/c/neethi/src/util.c

Added: webservices/axis2/trunk/c/neethi/include/neethi_util.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/neethi/include/neethi_util.h?view=auto&rev=548908
==============================================================================
--- webservices/axis2/trunk/c/neethi/include/neethi_util.h (added)
+++ webservices/axis2/trunk/c/neethi/include/neethi_util.h Tue Jun 19 20:18:37 2007
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef NEETHI_UTIL_H
+#define NEETHI_UTIL_H
+
+
+/**
+  * @file neethi_util.h
+  * @policy creation utilities 
+  */
+
+#include <axis2_defines.h>
+#include <axutil_env.h>
+#include <neethi_includes.h>
+#include <neethi_policy.h>
+#include <neethi_engine.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+    AXIS2_EXTERN neethi_policy_t *AXIS2_CALL
+    neethi_util_create_policy_from_file(
+            const axutil_env_t *env,
+            axis2_char_t *file_name);
+    
+    AXIS2_EXTERN neethi_policy_t *AXIS2_CALL
+    neethi_util_create_policy_from_om(
+        const axutil_env_t *env,
+        axiom_node_t *root_node);
+
+
+
+    /** @} */
+#ifdef __cplusplus
+}
+#endif
+
+#endif                          /* NEETHI_UTIL_H */

Added: webservices/axis2/trunk/c/neethi/src/util.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/neethi/src/util.c?view=auto&rev=548908
==============================================================================
--- webservices/axis2/trunk/c/neethi/src/util.c (added)
+++ webservices/axis2/trunk/c/neethi/src/util.c Tue Jun 19 20:18:37 2007
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+
+#include <neethi_util.h>
+
+
+
+AXIS2_EXTERN neethi_policy_t *AXIS2_CALL 
+neethi_util_create_policy_from_file(
+        const axutil_env_t *env,
+        axis2_char_t *file_name)
+{
+
+    axiom_xml_reader_t *reader = NULL;
+    axiom_stax_builder_t *builder = NULL;
+    axiom_document_t *document = NULL;
+    axiom_node_t *root_node = NULL;
+
+
+    reader = axiom_xml_reader_create_for_file(env, file_name, NULL);
+
+    if (!reader)
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_CREATING_XML_STREAM_READER,
+                AXIS2_FAILURE);
+        return NULL;
+    }
+
+    builder = axiom_stax_builder_create(env, reader);
+    if(!builder)
+    {
+        axiom_xml_reader_free(reader, env);
+        return NULL;
+    }
+    document = axiom_stax_builder_get_document(builder, env);
+
+    if(!document)
+    {
+        axiom_stax_builder_free(builder, env);
+        return NULL;
+    }
+
+    root_node = axiom_document_build_all(document, env);
+    if(!root_node)
+    {
+        axiom_stax_builder_free(builder, env);
+        return NULL;
+    }   
+
+    return neethi_util_create_policy_from_om(env, root_node);
+     
+}
+
+
+AXIS2_EXTERN neethi_policy_t *AXIS2_CALL
+neethi_util_create_policy_from_om(
+        const axutil_env_t *env,
+        axiom_node_t *root_node)
+{
+
+    axiom_element_t *root_ele = NULL;    
+
+    if(axiom_node_get_node_type(root_node, env) == AXIOM_ELEMENT)
+    {
+        root_ele = (axiom_element_t *)axiom_node_get_data_element(root_node, env);
+        if(root_ele)
+        {
+            neethi_policy_t *neethi_policy = NULL;
+            neethi_policy = neethi_engine_get_policy(env, root_node, root_ele);
+            if(!neethi_policy)
+            {
+                return NULL;
+            }
+            return neethi_policy;
+        }
+        else return NULL;
+    }
+    else return NULL;
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message