You are viewing a plain text version of this content. The canonical link for it is here.
Posted to imperius-commits@incubator.apache.org by ke...@apache.org on 2008/01/11 18:57:14 UTC
svn commit: r611261 [33/43] - in /incubator/imperius/trunk: ./
imperius-javaspl/ imperius-javaspl/src/main/java/org/apache/imperius/javaspl/
imperius-splcore/
imperius-splcore/src/main/antlr/org/apache/imperius/spl/parser/compiler/
imperius-splcore/src...
Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/statements/impl/PolicyGroup.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/statements/impl/PolicyGroup.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/statements/impl/PolicyGroup.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/statements/impl/PolicyGroup.java Fri Jan 11 10:56:30 2008
@@ -1,191 +1,191 @@
-/*
- * Licensed 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.
- */
-//
-
-/**
- * @author Neeraj Joshi <jn...@us.ibm.com>
- *
- */
-package org.apache.imperius.spl.parser.statements.impl;
-
-import java.util.logging.Logger;
-
-import org.apache.imperius.spl.external.Actuator;
-import org.apache.imperius.spl.external.DataCollector;
-import org.apache.imperius.spl.parser.compiler.symboltable.SPLSymbolTable;
-import org.apache.imperius.spl.parser.exceptions.SPLException;
-import org.apache.imperius.spl.parser.statements.PolicyStatement;
-import org.apache.imperius.util.SPLLogger;
-
-
-public class PolicyGroup implements PolicyStatement
-{
-
- private String assocName = "CIM_Component";
- private String role1="GroupComponent";
- private String role2="PartComponent";
- private String auditloggerString = "";
-
-
- private SPLPolicy cimPolicy;
- private int priority;
- private SPLSymbolTable symTab;
- private static Logger logger = SPLLogger.getSPLLogger().getLogger();
- private static final String sourceClass="PolicyGroup";
-
-
-
- public PolicyGroup(String assocName,String role1,String role2,SPLPolicy c,String priority, SPLSymbolTable sTab)
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "PolicyGroup");
-
- if(!assocName.equals(""))
- this.assocName = assocName;
- if(!role1.equals(""))
- this.role1 = role1;
- if(!role2.equals(""))
- this.role2 = role2;
-
- this.cimPolicy = c;
- this.priority = Integer.parseInt(priority);
- this.symTab = sTab;
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "PolicyGroup");
-
-
- }
-
-
- public String getAssocName() {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getAssocName");
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getAssocName");
-
- return assocName;
- }
-
-
- public void setAssocName(String assocName) {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setAssocName");
-
- this.assocName = assocName;
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setAssocName");
-
- }
-
-
- public SPLPolicy getCimPolicy() {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getCimPolicy");
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getCimPolicy");
-
- return cimPolicy;
- }
-
-
- public void setCimPolicy(SPLPolicy cimPolicy) {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setCimPolicy");
-
- this.cimPolicy = cimPolicy;
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setCimPolicy");
-
- }
-
-
- public int getPriority() {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getPriority");
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getPriority");
-
- return priority;
- }
-
-
- public void setPriority(int priority) {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setPriority");
-
- this.priority = priority;
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setPriority");
-
- }
-
-
- public String getRole1() {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getRole1");
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getRole1");
-
- return role1;
- }
-
-
- public void setRole1(String role1) {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setRole1");
-
- this.role1 = role1;
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setRole1");
-
- }
-
-
- public String getRole2() {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getRole2");
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getRole2");
-
- return role2;
- }
-
-
- public void setRole2(String role2) {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setRole2");
-
- this.role2 = role2;
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setRole2");
-
- }
-
- public int evaluate(DataCollector dc,Actuator ac) throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
- this.auditloggerString="";
- int result = SPLPolicy.POLICY_EVALUATION_FAILED;
- //System.out.println("Policy Gp::evaluate::symTab.getInstance().getCimObjectName() "+symTab.getAnchorClassList());
-// Map classToInstanceMap = null;
-// Iterator it = classToInstanceMap.keySet().iterator();
-// Object instance = null;
-// while(it.hasNext())
-// {
-// String key = (String)it.next();
-// instance = classToInstanceMap.get(key);
-// }
- String anchorClassName=(String)symTab.getAnchorClassList().get(0);
- System.out.println("-----------"+"Starting Evaluation of Policy Group"+"-----------");
-
- this.auditloggerString+="-----------"+"Starting Evaluation of Policy Group"+"-----------"+"\n";
- result = cimPolicy.evaluate(dc,ac,anchorClassName,symTab.getDefaultQualifier(),symTab.getInstance(anchorClassName),assocName,role1,role2);
- this.auditloggerString+=cimPolicy.getAuditLogString();
- this.auditloggerString+="-----------"+"Completed Evaluation of Policy Group"+"-----------"+"\n";
- System.out.println("-----------"+"Completed Evaluation of Policy Group"+"-----------");
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- return result;
- }
-
-
- public String getAuditLogString() {
-
- return this.auditloggerString;
- }
-}
+/*
+ * Licensed 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.
+ */
+//
+
+/**
+ * @author Neeraj Joshi <jn...@us.ibm.com>
+ *
+ */
+package org.apache.imperius.spl.parser.statements.impl;
+
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.Actuator;
+import org.apache.imperius.spl.external.DataCollector;
+import org.apache.imperius.spl.parser.compiler.symboltable.SPLSymbolTable;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.statements.PolicyStatement;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class PolicyGroup implements PolicyStatement
+{
+
+ private String assocName = "CIM_Component";
+ private String role1="GroupComponent";
+ private String role2="PartComponent";
+ private String auditloggerString = "";
+
+
+ private SPLPolicy cimPolicy;
+ private int priority;
+ private SPLSymbolTable symTab;
+ private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+ private static final String sourceClass="PolicyGroup";
+
+
+
+ public PolicyGroup(String assocName,String role1,String role2,SPLPolicy c,String priority, SPLSymbolTable sTab)
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "PolicyGroup");
+
+ if(!assocName.equals(""))
+ this.assocName = assocName;
+ if(!role1.equals(""))
+ this.role1 = role1;
+ if(!role2.equals(""))
+ this.role2 = role2;
+
+ this.cimPolicy = c;
+ this.priority = Integer.parseInt(priority);
+ this.symTab = sTab;
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "PolicyGroup");
+
+
+ }
+
+
+ public String getAssocName() {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getAssocName");
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getAssocName");
+
+ return assocName;
+ }
+
+
+ public void setAssocName(String assocName) {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setAssocName");
+
+ this.assocName = assocName;
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setAssocName");
+
+ }
+
+
+ public SPLPolicy getCimPolicy() {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getCimPolicy");
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getCimPolicy");
+
+ return cimPolicy;
+ }
+
+
+ public void setCimPolicy(SPLPolicy cimPolicy) {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setCimPolicy");
+
+ this.cimPolicy = cimPolicy;
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setCimPolicy");
+
+ }
+
+
+ public int getPriority() {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getPriority");
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getPriority");
+
+ return priority;
+ }
+
+
+ public void setPriority(int priority) {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setPriority");
+
+ this.priority = priority;
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setPriority");
+
+ }
+
+
+ public String getRole1() {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getRole1");
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getRole1");
+
+ return role1;
+ }
+
+
+ public void setRole1(String role1) {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setRole1");
+
+ this.role1 = role1;
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setRole1");
+
+ }
+
+
+ public String getRole2() {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getRole2");
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getRole2");
+
+ return role2;
+ }
+
+
+ public void setRole2(String role2) {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setRole2");
+
+ this.role2 = role2;
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setRole2");
+
+ }
+
+ public int evaluate(DataCollector dc,Actuator ac) throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+ this.auditloggerString="";
+ int result = SPLPolicy.POLICY_EVALUATION_FAILED;
+ //System.out.println("Policy Gp::evaluate::symTab.getInstance().getCimObjectName() "+symTab.getAnchorClassList());
+// Map classToInstanceMap = null;
+// Iterator it = classToInstanceMap.keySet().iterator();
+// Object instance = null;
+// while(it.hasNext())
+// {
+// String key = (String)it.next();
+// instance = classToInstanceMap.get(key);
+// }
+ String anchorClassName=(String)symTab.getAnchorClassList().get(0);
+ System.out.println("-----------"+"Starting Evaluation of Policy Group"+"-----------");
+
+ this.auditloggerString+="-----------"+"Starting Evaluation of Policy Group"+"-----------"+"\n";
+ result = cimPolicy.evaluate(dc,ac,anchorClassName,symTab.getDefaultQualifier(),symTab.getInstance(anchorClassName),assocName,role1,role2);
+ this.auditloggerString+=cimPolicy.getAuditLogString();
+ this.auditloggerString+="-----------"+"Completed Evaluation of Policy Group"+"-----------"+"\n";
+ System.out.println("-----------"+"Completed Evaluation of Policy Group"+"-----------");
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ return result;
+ }
+
+
+ public String getAuditLogString() {
+
+ return this.auditloggerString;
+ }
+}
Propchange: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/statements/impl/PolicyGroup.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/statements/impl/PolicyInfo.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/statements/impl/PolicyInfo.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/statements/impl/PolicyInfo.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/statements/impl/PolicyInfo.java Fri Jan 11 10:56:30 2008
@@ -1,85 +1,85 @@
-/*
- * Licensed 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.
- */
-//
-
-/**
- * @author Prashant Baliga <pr...@in.ibm.com>
- *
- */
-
-package org.apache.imperius.spl.parser.statements.impl;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.apache.imperius.spl.parser.compiler.symboltable.AnchorData;
-import org.apache.imperius.spl.parser.compiler.symboltable.SPLSymbolTable;
-import org.apache.imperius.util.SPLLogger;
-
-public class PolicyInfo {
-
- private List importStmtList=null;
- private static Logger logger = SPLLogger.getSPLLogger().getLogger();
-
- private static String sourceClass = "PolicyInfo";
-
-
- public PolicyInfo(List importStmtList){
- this.importStmtList=importStmtList;
- }
-
- public Map getClassQualifierMap(){
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+"createInstance");
-
- Map classQualifier=new HashMap();
- Iterator it=importStmtList.iterator();
- while(it.hasNext())
- {
-
- if(logger.isLoggable(Level.FINE))
- logger.fine(Thread.currentThread().getName()+" 1Creating SPL Policy instance :"+importStmtList);
-
- ImportStatement importStmt=(ImportStatement)it.next();
- if(logger.isLoggable(Level.FINE))
- logger.fine(Thread.currentThread().getName()+" 2Creating SPL Policy instance :"+importStmt);
-
- SPLSymbolTable symtab=importStmt.getSymTab();
- if(logger.isLoggable(Level.FINE))
- logger.fine(Thread.currentThread().getName()+" 3Creating SPL Policy instance :"+symtab);
-
- AnchorData anchor=symtab.getAnchorData();
- if(logger.isLoggable(Level.FINE))
- logger.fine(Thread.currentThread().getName()+" 4Creating SPL Policy instance :"+anchor);
-
- List classes=anchor.getAnchorClassList();
- if(logger.isLoggable(Level.FINE))
- logger.fine(Thread.currentThread().getName()+" 5Creating SPL Policy instance :"+classes);
-
- Iterator classIt=classes.iterator();
- while(classIt.hasNext()){
- String classname=(String)classIt.next();
- String qualifier=anchor.getQualifierForClass(classname);
- classQualifier.put(classname, qualifier);
- }
- }
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+"createInstance");
-
- return classQualifier;
- }
-
-}
+/*
+ * Licensed 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.
+ */
+//
+
+/**
+ * @author Prashant Baliga <pr...@in.ibm.com>
+ *
+ */
+
+package org.apache.imperius.spl.parser.statements.impl;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.parser.compiler.symboltable.AnchorData;
+import org.apache.imperius.spl.parser.compiler.symboltable.SPLSymbolTable;
+import org.apache.imperius.util.SPLLogger;
+
+public class PolicyInfo {
+
+ private List importStmtList=null;
+ private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+
+ private static String sourceClass = "PolicyInfo";
+
+
+ public PolicyInfo(List importStmtList){
+ this.importStmtList=importStmtList;
+ }
+
+ public Map getClassQualifierMap(){
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+"createInstance");
+
+ Map classQualifier=new HashMap();
+ Iterator it=importStmtList.iterator();
+ while(it.hasNext())
+ {
+
+ if(logger.isLoggable(Level.FINE))
+ logger.fine(Thread.currentThread().getName()+" 1Creating SPL Policy instance :"+importStmtList);
+
+ ImportStatement importStmt=(ImportStatement)it.next();
+ if(logger.isLoggable(Level.FINE))
+ logger.fine(Thread.currentThread().getName()+" 2Creating SPL Policy instance :"+importStmt);
+
+ SPLSymbolTable symtab=importStmt.getSymTab();
+ if(logger.isLoggable(Level.FINE))
+ logger.fine(Thread.currentThread().getName()+" 3Creating SPL Policy instance :"+symtab);
+
+ AnchorData anchor=symtab.getAnchorData();
+ if(logger.isLoggable(Level.FINE))
+ logger.fine(Thread.currentThread().getName()+" 4Creating SPL Policy instance :"+anchor);
+
+ List classes=anchor.getAnchorClassList();
+ if(logger.isLoggable(Level.FINE))
+ logger.fine(Thread.currentThread().getName()+" 5Creating SPL Policy instance :"+classes);
+
+ Iterator classIt=classes.iterator();
+ while(classIt.hasNext()){
+ String classname=(String)classIt.next();
+ String qualifier=anchor.getQualifierForClass(classname);
+ classQualifier.put(classname, qualifier);
+ }
+ }
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+"createInstance");
+
+ return classQualifier;
+ }
+
+}
Propchange: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/statements/impl/PolicyInfo.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/statements/impl/SPLPolicy.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/statements/impl/SPLPolicy.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/statements/impl/SPLPolicy.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/statements/impl/SPLPolicy.java Fri Jan 11 10:56:30 2008
@@ -1,554 +1,554 @@
-/*
- * Licensed 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.
- */
-//
-
-/**
- * @author Neeraj Joshi <jn...@us.ibm.com>
- *
- */
-package org.apache.imperius.spl.parser.statements.impl;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.apache.imperius.spl.external.Actuator;
-import org.apache.imperius.spl.external.DataCollector;
-import org.apache.imperius.spl.external.InstanceInfo;
-import org.apache.imperius.spl.parser.compiler.symboltable.SPLSymbolTable;
-import org.apache.imperius.spl.parser.exceptions.SPLException;
-import org.apache.imperius.spl.parser.statements.PolicyStatement;
-import org.apache.imperius.util.SPLLogger;
-
-
-public class SPLPolicy
-{
- private List _importStmtList;
- private StrategyStatement _strgyStmt;
- private DeclarationStatement _declaration;
- private ArrayList _policyList;
- private SPLSymbolTable _symTab;
- public static final int POLICY_EVALUATED_SUCCESSFULLY = 1;
- public static final int POLICY_NOT_EVALUATED = 0;
- public static final int POLICY_EVALUATION_FAILED = -1;
- private static Logger logger = SPLLogger.getSPLLogger().getLogger();
- private String auditloggerString = "";
-
- private static final String sourceClass="SPLPolicy";
-
-
-
- public SPLPolicy(List importStatementList, StrategyStatement s,DeclarationStatement decl,ArrayList pList, SPLSymbolTable symTab2)
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "SPLPolicy");
-
-
- this._importStmtList = importStatementList;
- this._strgyStmt = s;
- this._declaration = decl;
- this._policyList = sortPoliciesByPriority(pList);
-
- this._symTab = symTab2;
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "SPLPolicy");
-
- }
-
- private ArrayList sortPoliciesByPriority(ArrayList list)
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "sortPoliciesByPriority");
-
-
- for(int i=0; i<list.size(); i++)
- {
- for(int j=i+1; j<list.size()-1; j++)
- {
- PolicyStatement pStatement = (PolicyStatement)list.get(i);
- PolicyStatement pStatementNext = (PolicyStatement)list.get(j);
- if(pStatement.getPriority() < pStatementNext.getPriority())
- {
- PolicyStatement temp = pStatement;
- pStatement = pStatementNext;
- pStatementNext = temp;
-
-
- }
-
-
-
- }
- }
-
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "sortPoliciesByPriority");
- return list;
- }
-
-
-
- private int _evaluatePolicies(Map instanceMap,
- DataCollector dc,
- Actuator ac)
- throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluatePolicies");
-
- // Iterate over the List of maps
- int result = POLICY_EVALUATED_SUCCESSFULLY;
- Iterator instanceMapKeyIt = instanceMap.keySet().iterator();
- System.out.println("Iterating over all instances of Anchor class");
-
- while(instanceMapKeyIt.hasNext())
- {
-
- String className = (String)instanceMapKeyIt.next();
- List instancesForClass = (List)instanceMap.get(className);
- Iterator instancesForClassIt = instancesForClass.iterator();
- if(logger.isLoggable(Level.FINE))
- logger.fine(Thread.currentThread().getName()+" iterating over instances ");
-// System.out.println(">>>>>>>>>>>"+"Starting policy Evaluation"+"<<<<<<<<<<<");
-// auditloggerString+=">>>>>>>>>>>"+"Starting policy Evaluation"+"<<<<<<<<<<<"+"\n";
- int instanceCount=1;
- while(instancesForClassIt.hasNext())
- {
- System.out.println("+++++++++++"+"Evaluating policy against instance "+instanceCount+"+++++++++++");
- auditloggerString+="+++++++++++"+"Evaluating policy against instance "+instanceCount+"+++++++++++"+"\n";
-
-
- InstanceInfo instanceOfClass = (InstanceInfo)instancesForClassIt.next();
- String instanceName = instanceOfClass.getInstanceName();
- Object instance = instanceOfClass.getInstance();
- Map instanceSymbolMap = instanceOfClass.getInstanceSymbolsMap();
- // populate the symboltable with information from the map
- _symTab.populateInstanceValuesForInstance(className, instanceName,instance, instanceSymbolMap);
- }
- }
- //evaluate the declaration to populate the values for the constants
-
- if(_declaration != null)
- {
- _declaration.evaluate();
- }
- // iterate over all the policies
- for(int j=0; j<_policyList.size();j++)
- {
-
- System.out.println("***********"+"evaluating sub policy number "+(j+1)+"***********");
- auditloggerString+="***********"+"evaluating sub policy number "+(j+1)+"***********"+"\n";
- PolicyStatement pStatement = (PolicyStatement)_policyList.get(j);
- // evaluate each policy
- int result1 = pStatement.evaluate(dc,ac);
- auditloggerString+=pStatement.getAuditLogString();
-
- if(result1 == POLICY_EVALUATION_FAILED) // report failure even if a single policy fails
- {
- result = result1;
- System.out.println(" "+"SPLPolicy evaluation failed ");
- auditloggerString+=" "+"SPLPolicy evaluation failed "+"\n";
-
- logger.severe(Thread.currentThread().getName()+"SPLPolicy evaluation failed return value="+result);
-
-
- }
- else
- {
- System.out.println(" "+"SPLPolicy evaluation successful ");
- auditloggerString+=" "+"SPLPolicy evaluation successful "+"\n";
- }
- // if strategy is to execute first applicable and if the policy has been evaluated
- // terminate
-
- if(_strgyStmt.getStrategy().equals("Execute_First_Applicable"))
- {
- if(result1 == POLICY_EVALUATED_SUCCESSFULLY || result1 == POLICY_EVALUATION_FAILED)
- {
- System.out.println("***********"+"completed evaluation of sub policy number "+(j+1)+"***********");
- auditloggerString+="***********"+"completed evaluation of sub policy number "+(j+1)+"***********"+"\n";
-
- break;
- }
- }
-
- System.out.println("***********"+"completed evaluation of sub policy number "+(j+1)+"***********");
- auditloggerString+="***********"+"completed evaluation of sub policy number "+(j+1)+"***********"+"\n";
-
- }
-
-
- if(logger.isLoggable(Level.FINE))
- logger.fine(Thread.currentThread().getName()+"SPLPolicy EvaluatePolicies return value="+result);
-
- if(logger.isLoggable(Level.FINE))
- logger.fine(Thread.currentThread().getName()+auditloggerString);
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluatePolicies");
-
- return result;
- }
-
-
-
- public DeclarationStatement getDeclarationStatement() {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getDeclarationStatement");
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getDeclarationStatement");
-
- return _declaration;
- }
-
- public void setDeclList(DeclarationStatement decl) {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setDeclList");
-
- this._declaration = decl;
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setDeclList");
-
- }
-
- public List getImportStmtList() {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getImportStmt");
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getImportStmt");
-
- return _importStmtList;
- }
-
- public void setImportStmtList(List importStmtList) {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setImportStmt");
-
- this._importStmtList = importStmtList;
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setImportStmt");
-
- }
-
- public ArrayList getPolicyList() {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getPolicyList");
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getPolicyList");
-
- return _policyList;
- }
-
- public void setPolicyList(ArrayList policyList) {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setPolicyList");
-
- this._policyList = policyList;
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setPolicyList");
-
- }
-
- public StrategyStatement getStrgyStmt() {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getStrgyStmt");
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getStrgyStmt");
-
- return _strgyStmt;
- }
-
- public void setStrgyStmt(StrategyStatement strgyStmt) {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setStrgyStmt");
-
- this._strgyStmt = strgyStmt;
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setStrgyStmt");
-
- }
-
- public DeclarationStatement getDeclaration() {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getDeclaration");
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getDeclaration");
-
- return _declaration;
- }
-
- public void setDeclaration(DeclarationStatement declaration) {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setDeclaration");
- this._declaration = declaration;
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setDeclaration");
-
-
- }
-
- public SPLSymbolTable getSymTab() {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getSymTab");
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getSymTab");
-
- return _symTab;
- }
-
- public void setSymTab(SPLSymbolTable symTab) {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setSymTab");
- this._symTab = symTab;
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setSymTab");
-
-
- }
-
- public int evaluate(DataCollector dc, Actuator ac,
- String anchorClassName,String anchornamespace,
- Object anchorInstance, String assocName, String role1,
- String role2) throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
- this.auditloggerString="";
-
- int result = POLICY_EVALUATED_SUCCESSFULLY;
- System.out.println("cimObjectName "+anchorClassName+" "+anchornamespace+" "+anchorInstance.toString());
- //Map keys=this.symTab.getInstance().getMapOfKeys();
- ImportStatement imp=(ImportStatement)this._importStmtList.get(0);
- InstanceInfo ii=(InstanceInfo)imp.getImportInstanceInfoList().get(0);
- String targetclassnm = ii.getInstanceName();
- List targetClassInstances = dc.getAssociatedInstanceReferences(anchorInstance, anchornamespace, targetclassnm, assocName, role1, role2);
-
- Iterator it=targetClassInstances.iterator();
- System.out.println(">>>>>>>>>>>"+"Policy Group Evaluation - number of associated instances :"+targetClassInstances.size()+"<<<<<<<<<<<");
-
- auditloggerString+=">>>>>>>>>>>"+"Policy Group Evaluation - number of associated instances :"+targetClassInstances.size()+"<<<<<<<<<<<"+"\n";
-
- while(it.hasNext()){
- Object inst=it.next();
- InstanceInfo iinfo=new InstanceInfo(targetclassnm,inst);
- List instanceInfoList=new ArrayList();
- instanceInfoList.add(iinfo);
-
- Map objMap=new HashMap();
- objMap.put(targetclassnm, instanceInfoList);
- result = evaluate(dc,ac,objMap);
-
- }
-// System.out.println(">>>>>>>>>>>"+"policy evaluation complete, result :"+result+"<<<<<<<<<<<");
-// auditloggerString+=">>>>>>>>>>>"+"policy evaluation complete, result :"+result+"<<<<<<<<<<<"+"\n";
-
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- return result;
- }
-
-
- public int evaluate(DataCollector dc, Actuator ac, Map iMap) throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate2");
- this.auditloggerString="";
- if (logger.isLoggable(Level.FINE))
- logger.fine(Thread.currentThread().getName()+"evaluating policy against instances cimPolicy");
- Map instanceMap = _buildInstanceMap(iMap,dc);
-
-
- int result = POLICY_EVALUATION_FAILED;
- if(!instanceMap.isEmpty())
- {
- if (logger.isLoggable(Level.FINE))
- {
- logger.fine(Thread.currentThread().getName()+
- "number of instances passed in for evaluation is "+instanceMap.size());
- }
- System.out.println(">>>>>>>>>>>"+"number of instances passed in for evaluation is :"+instanceMap.size()+"<<<<<<<<<<<");
-
- auditloggerString+=">>>>>>>>>>>"+"number of instances passed in for evaluation is :"+instanceMap.size()+"<<<<<<<<<<<"+"\n";
-
-
- result = _evaluatePolicies(instanceMap,dc,ac);
-
- System.out.println(">>>>>>>>>>>"+"policy evaluation complete, result :"+result+"<<<<<<<<<<<");
- auditloggerString+=">>>>>>>>>>>"+"policy evaluation complete, result :"+result+"<<<<<<<<<<<"+"\n";
-
-
- }
- else
- {
-
- logger.warning(Thread.currentThread().getName()+" "+"No valid instances for policy evaluation");
- //throw new SPLException("Out of the Instances that were passed in for Evaluation, none have passed the filter");
- }
- if (logger.isLoggable(Level.FINE))
- logger.fine(Thread.currentThread().getName()+"result of evaluation is "+result);
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate2");
-
- return result;
- }
-
- /**
- * This method filters out instances passed to the evaluate method
- * that are not present in the import statement of the policy and builds
- * the InstanceMap that is used internally
- * @param instanceMap
- * @return
- * @throws ClassNotFoundException
- */
-
- private Map _buildInstanceMap(Map iMap,DataCollector dc) throws SPLException
- {
- Map instMap = new HashMap();
- try
- {
- Iterator instNameIt = iMap.keySet().iterator();
- while(instNameIt.hasNext())
- {
- String instanceName = (String)instNameIt.next();
- Object instance = iMap.get(instanceName);
- // String instanceClassName = instance.getClass().getName();
- Iterator importIt = _importStmtList.iterator();
- while(importIt.hasNext())
- {
- ImportStatement importStmt = (ImportStatement)importIt.next();
- String anchorClassName = importStmt.getAnchorClassName();
- Class anchorClass = Class.forName(anchorClassName);
-
- // check if class of the passed instance has been imported
- if(anchorClass.isInstance(instance))
- {
-
- List instanceList = importStmt.getImportInstanceInfoList();
- Iterator instanceListIt = instanceList.iterator();
- // iterate over all the instances of this class to see if
- // there is a match
- while(instanceListIt.hasNext())
- {
- InstanceInfo iInfo = (InstanceInfo)instanceListIt.next();
- if(iInfo.getInstanceName().equals(instanceName))
- {
- InstanceInfo instanceInfo = new InstanceInfo(instanceName,instance);
-
- String qualifier = _symTab.getQualifierForClass(anchorClassName);
- Map symbolsForInstance = dc.getSymbolsForInstance(anchorClassName,
- qualifier,
- instance);
- instanceInfo.setInstanceSymbolsMap(symbolsForInstance);
- if(instMap.containsKey(anchorClassName))
- {
- List instanceInfoList = (List)instMap.get(anchorClassName);
- instanceInfoList.add(instanceInfo);
-
- }
- else
- {
- List instanceInfoList = new ArrayList();
- instanceInfoList.add(instanceInfo);
- instMap.put(anchorClassName, instanceInfoList);
-
- }
-
- }
- }
- }
-
- }
- }
- }
- catch(ClassNotFoundException cnef)
- {
- throw new SPLException(cnef.getMessage());
- }
- return instMap;
-
- }
-
-
-
-
- public String getAuditLogString() {
-
- return this.auditloggerString;
- }
-
- private boolean _instancesPassImportFilter(DataCollector dc,Object instance)
- {
- return true;
- /*logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "instanceFilterByCOP");
- String classnm=this.importStmt.getClassName();
- String namespc=this.importStmt.getNameSpace();
-
- String copShouldStartWith=this.getSymTab().getAnchor();
- //System.out.println("cop Should contain : "+copShouldStartWith);
- //System.out.println("cop is : "+cop);
- if(cop.toString().indexOf(copShouldStartWith) != -1)
- {
- try
- {
- Map instMap=dc.getInstanceMap(classnm, namespc, cop.toString());
- symTab.populateSymbolTableWithInstanceValues(instMap);
- Expression importFilterExpression = importStmt.getExpr();
- if(importFilterExpression != null)
- {
- if (logger.isLoggable(Level.FINE))
- logger.fine(Thread.currentThread().getName()+"importFilterExpression != null");
- // filter the List of Maps based on the import statement filter expression
- Boolean filterResult = (Boolean)importFilterExpression.evaluate();
- if(filterResult.booleanValue())
- {
- if (logger.isLoggable(Level.FINE))
- logger.fine(Thread.currentThread().getName()+"filterResult.booleanValue() = true");
- return true;
- }
- else
- {
- if (logger.isLoggable(Level.FINE))
- logger.fine(Thread.currentThread().getName()+"filterResult.booleanValue() = false");
- return false;
- }
- }
- else
- {
- // no filtering required
- return true;
- }
-
- }
- catch(SPLException e)
- {
- logger.severe(e.getMessage());
- }
-
-
-
- //System.out.println("passed the filter");
-
- }
- //System.out.println("did not passed the filter");
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "instanceFilterByCOP");
-
- return false;*/
- }
-
- /* private List filterInstancesByImportFilter(List instSymbolMaps, Expression importFilterExpression) throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "filterInstancesByImportFilter");
-
- List filteredList = new ArrayList();
- Iterator listIt = instSymbolMaps.iterator();
- while(listIt.hasNext())
- {
- Map instSymbols = (Map)listIt.next();
- symTab.populateSymbolTableWithInstanceValues(instSymbols);
- Boolean filterResult = (Boolean)importFilterExpression.evaluate();
- if(filterResult.booleanValue())
- {
- filteredList.add(instSymbols);
- }
- }
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "filterInstancesByImportFilter");
-
- return filteredList;
- }*/
-
-
-
-
-}
+/*
+ * Licensed 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.
+ */
+//
+
+/**
+ * @author Neeraj Joshi <jn...@us.ibm.com>
+ *
+ */
+package org.apache.imperius.spl.parser.statements.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.Actuator;
+import org.apache.imperius.spl.external.DataCollector;
+import org.apache.imperius.spl.external.InstanceInfo;
+import org.apache.imperius.spl.parser.compiler.symboltable.SPLSymbolTable;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.statements.PolicyStatement;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class SPLPolicy
+{
+ private List _importStmtList;
+ private StrategyStatement _strgyStmt;
+ private DeclarationStatement _declaration;
+ private ArrayList _policyList;
+ private SPLSymbolTable _symTab;
+ public static final int POLICY_EVALUATED_SUCCESSFULLY = 1;
+ public static final int POLICY_NOT_EVALUATED = 0;
+ public static final int POLICY_EVALUATION_FAILED = -1;
+ private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+ private String auditloggerString = "";
+
+ private static final String sourceClass="SPLPolicy";
+
+
+
+ public SPLPolicy(List importStatementList, StrategyStatement s,DeclarationStatement decl,ArrayList pList, SPLSymbolTable symTab2)
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "SPLPolicy");
+
+
+ this._importStmtList = importStatementList;
+ this._strgyStmt = s;
+ this._declaration = decl;
+ this._policyList = sortPoliciesByPriority(pList);
+
+ this._symTab = symTab2;
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "SPLPolicy");
+
+ }
+
+ private ArrayList sortPoliciesByPriority(ArrayList list)
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "sortPoliciesByPriority");
+
+
+ for(int i=0; i<list.size(); i++)
+ {
+ for(int j=i+1; j<list.size()-1; j++)
+ {
+ PolicyStatement pStatement = (PolicyStatement)list.get(i);
+ PolicyStatement pStatementNext = (PolicyStatement)list.get(j);
+ if(pStatement.getPriority() < pStatementNext.getPriority())
+ {
+ PolicyStatement temp = pStatement;
+ pStatement = pStatementNext;
+ pStatementNext = temp;
+
+
+ }
+
+
+
+ }
+ }
+
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "sortPoliciesByPriority");
+ return list;
+ }
+
+
+
+ private int _evaluatePolicies(Map instanceMap,
+ DataCollector dc,
+ Actuator ac)
+ throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluatePolicies");
+
+ // Iterate over the List of maps
+ int result = POLICY_EVALUATED_SUCCESSFULLY;
+ Iterator instanceMapKeyIt = instanceMap.keySet().iterator();
+ System.out.println("Iterating over all instances of Anchor class");
+
+ while(instanceMapKeyIt.hasNext())
+ {
+
+ String className = (String)instanceMapKeyIt.next();
+ List instancesForClass = (List)instanceMap.get(className);
+ Iterator instancesForClassIt = instancesForClass.iterator();
+ if(logger.isLoggable(Level.FINE))
+ logger.fine(Thread.currentThread().getName()+" iterating over instances ");
+// System.out.println(">>>>>>>>>>>"+"Starting policy Evaluation"+"<<<<<<<<<<<");
+// auditloggerString+=">>>>>>>>>>>"+"Starting policy Evaluation"+"<<<<<<<<<<<"+"\n";
+ int instanceCount=1;
+ while(instancesForClassIt.hasNext())
+ {
+ System.out.println("+++++++++++"+"Evaluating policy against instance "+instanceCount+"+++++++++++");
+ auditloggerString+="+++++++++++"+"Evaluating policy against instance "+instanceCount+"+++++++++++"+"\n";
+
+
+ InstanceInfo instanceOfClass = (InstanceInfo)instancesForClassIt.next();
+ String instanceName = instanceOfClass.getInstanceName();
+ Object instance = instanceOfClass.getInstance();
+ Map instanceSymbolMap = instanceOfClass.getInstanceSymbolsMap();
+ // populate the symboltable with information from the map
+ _symTab.populateInstanceValuesForInstance(className, instanceName,instance, instanceSymbolMap);
+ }
+ }
+ //evaluate the declaration to populate the values for the constants
+
+ if(_declaration != null)
+ {
+ _declaration.evaluate();
+ }
+ // iterate over all the policies
+ for(int j=0; j<_policyList.size();j++)
+ {
+
+ System.out.println("***********"+"evaluating sub policy number "+(j+1)+"***********");
+ auditloggerString+="***********"+"evaluating sub policy number "+(j+1)+"***********"+"\n";
+ PolicyStatement pStatement = (PolicyStatement)_policyList.get(j);
+ // evaluate each policy
+ int result1 = pStatement.evaluate(dc,ac);
+ auditloggerString+=pStatement.getAuditLogString();
+
+ if(result1 == POLICY_EVALUATION_FAILED) // report failure even if a single policy fails
+ {
+ result = result1;
+ System.out.println(" "+"SPLPolicy evaluation failed ");
+ auditloggerString+=" "+"SPLPolicy evaluation failed "+"\n";
+
+ logger.severe(Thread.currentThread().getName()+"SPLPolicy evaluation failed return value="+result);
+
+
+ }
+ else
+ {
+ System.out.println(" "+"SPLPolicy evaluation successful ");
+ auditloggerString+=" "+"SPLPolicy evaluation successful "+"\n";
+ }
+ // if strategy is to execute first applicable and if the policy has been evaluated
+ // terminate
+
+ if(_strgyStmt.getStrategy().equals("Execute_First_Applicable"))
+ {
+ if(result1 == POLICY_EVALUATED_SUCCESSFULLY || result1 == POLICY_EVALUATION_FAILED)
+ {
+ System.out.println("***********"+"completed evaluation of sub policy number "+(j+1)+"***********");
+ auditloggerString+="***********"+"completed evaluation of sub policy number "+(j+1)+"***********"+"\n";
+
+ break;
+ }
+ }
+
+ System.out.println("***********"+"completed evaluation of sub policy number "+(j+1)+"***********");
+ auditloggerString+="***********"+"completed evaluation of sub policy number "+(j+1)+"***********"+"\n";
+
+ }
+
+
+ if(logger.isLoggable(Level.FINE))
+ logger.fine(Thread.currentThread().getName()+"SPLPolicy EvaluatePolicies return value="+result);
+
+ if(logger.isLoggable(Level.FINE))
+ logger.fine(Thread.currentThread().getName()+auditloggerString);
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluatePolicies");
+
+ return result;
+ }
+
+
+
+ public DeclarationStatement getDeclarationStatement() {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getDeclarationStatement");
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getDeclarationStatement");
+
+ return _declaration;
+ }
+
+ public void setDeclList(DeclarationStatement decl) {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setDeclList");
+
+ this._declaration = decl;
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setDeclList");
+
+ }
+
+ public List getImportStmtList() {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getImportStmt");
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getImportStmt");
+
+ return _importStmtList;
+ }
+
+ public void setImportStmtList(List importStmtList) {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setImportStmt");
+
+ this._importStmtList = importStmtList;
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setImportStmt");
+
+ }
+
+ public ArrayList getPolicyList() {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getPolicyList");
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getPolicyList");
+
+ return _policyList;
+ }
+
+ public void setPolicyList(ArrayList policyList) {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setPolicyList");
+
+ this._policyList = policyList;
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setPolicyList");
+
+ }
+
+ public StrategyStatement getStrgyStmt() {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getStrgyStmt");
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getStrgyStmt");
+
+ return _strgyStmt;
+ }
+
+ public void setStrgyStmt(StrategyStatement strgyStmt) {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setStrgyStmt");
+
+ this._strgyStmt = strgyStmt;
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setStrgyStmt");
+
+ }
+
+ public DeclarationStatement getDeclaration() {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getDeclaration");
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getDeclaration");
+
+ return _declaration;
+ }
+
+ public void setDeclaration(DeclarationStatement declaration) {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setDeclaration");
+ this._declaration = declaration;
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setDeclaration");
+
+
+ }
+
+ public SPLSymbolTable getSymTab() {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getSymTab");
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getSymTab");
+
+ return _symTab;
+ }
+
+ public void setSymTab(SPLSymbolTable symTab) {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setSymTab");
+ this._symTab = symTab;
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setSymTab");
+
+
+ }
+
+ public int evaluate(DataCollector dc, Actuator ac,
+ String anchorClassName,String anchornamespace,
+ Object anchorInstance, String assocName, String role1,
+ String role2) throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+ this.auditloggerString="";
+
+ int result = POLICY_EVALUATED_SUCCESSFULLY;
+ System.out.println("cimObjectName "+anchorClassName+" "+anchornamespace+" "+anchorInstance.toString());
+ //Map keys=this.symTab.getInstance().getMapOfKeys();
+ ImportStatement imp=(ImportStatement)this._importStmtList.get(0);
+ InstanceInfo ii=(InstanceInfo)imp.getImportInstanceInfoList().get(0);
+ String targetclassnm = ii.getInstanceName();
+ List targetClassInstances = dc.getAssociatedInstanceReferences(anchorInstance, anchornamespace, targetclassnm, assocName, role1, role2);
+
+ Iterator it=targetClassInstances.iterator();
+ System.out.println(">>>>>>>>>>>"+"Policy Group Evaluation - number of associated instances :"+targetClassInstances.size()+"<<<<<<<<<<<");
+
+ auditloggerString+=">>>>>>>>>>>"+"Policy Group Evaluation - number of associated instances :"+targetClassInstances.size()+"<<<<<<<<<<<"+"\n";
+
+ while(it.hasNext()){
+ Object inst=it.next();
+ InstanceInfo iinfo=new InstanceInfo(targetclassnm,inst);
+ List instanceInfoList=new ArrayList();
+ instanceInfoList.add(iinfo);
+
+ Map objMap=new HashMap();
+ objMap.put(targetclassnm, instanceInfoList);
+ result = evaluate(dc,ac,objMap);
+
+ }
+// System.out.println(">>>>>>>>>>>"+"policy evaluation complete, result :"+result+"<<<<<<<<<<<");
+// auditloggerString+=">>>>>>>>>>>"+"policy evaluation complete, result :"+result+"<<<<<<<<<<<"+"\n";
+
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ return result;
+ }
+
+
+ public int evaluate(DataCollector dc, Actuator ac, Map iMap) throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate2");
+ this.auditloggerString="";
+ if (logger.isLoggable(Level.FINE))
+ logger.fine(Thread.currentThread().getName()+"evaluating policy against instances cimPolicy");
+ Map instanceMap = _buildInstanceMap(iMap,dc);
+
+
+ int result = POLICY_EVALUATION_FAILED;
+ if(!instanceMap.isEmpty())
+ {
+ if (logger.isLoggable(Level.FINE))
+ {
+ logger.fine(Thread.currentThread().getName()+
+ "number of instances passed in for evaluation is "+instanceMap.size());
+ }
+ System.out.println(">>>>>>>>>>>"+"number of instances passed in for evaluation is :"+instanceMap.size()+"<<<<<<<<<<<");
+
+ auditloggerString+=">>>>>>>>>>>"+"number of instances passed in for evaluation is :"+instanceMap.size()+"<<<<<<<<<<<"+"\n";
+
+
+ result = _evaluatePolicies(instanceMap,dc,ac);
+
+ System.out.println(">>>>>>>>>>>"+"policy evaluation complete, result :"+result+"<<<<<<<<<<<");
+ auditloggerString+=">>>>>>>>>>>"+"policy evaluation complete, result :"+result+"<<<<<<<<<<<"+"\n";
+
+
+ }
+ else
+ {
+
+ logger.warning(Thread.currentThread().getName()+" "+"No valid instances for policy evaluation");
+ //throw new SPLException("Out of the Instances that were passed in for Evaluation, none have passed the filter");
+ }
+ if (logger.isLoggable(Level.FINE))
+ logger.fine(Thread.currentThread().getName()+"result of evaluation is "+result);
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate2");
+
+ return result;
+ }
+
+ /**
+ * This method filters out instances passed to the evaluate method
+ * that are not present in the import statement of the policy and builds
+ * the InstanceMap that is used internally
+ * @param instanceMap
+ * @return
+ * @throws ClassNotFoundException
+ */
+
+ private Map _buildInstanceMap(Map iMap,DataCollector dc) throws SPLException
+ {
+ Map instMap = new HashMap();
+ try
+ {
+ Iterator instNameIt = iMap.keySet().iterator();
+ while(instNameIt.hasNext())
+ {
+ String instanceName = (String)instNameIt.next();
+ Object instance = iMap.get(instanceName);
+ // String instanceClassName = instance.getClass().getName();
+ Iterator importIt = _importStmtList.iterator();
+ while(importIt.hasNext())
+ {
+ ImportStatement importStmt = (ImportStatement)importIt.next();
+ String anchorClassName = importStmt.getAnchorClassName();
+ Class anchorClass = Class.forName(anchorClassName);
+
+ // check if class of the passed instance has been imported
+ if(anchorClass.isInstance(instance))
+ {
+
+ List instanceList = importStmt.getImportInstanceInfoList();
+ Iterator instanceListIt = instanceList.iterator();
+ // iterate over all the instances of this class to see if
+ // there is a match
+ while(instanceListIt.hasNext())
+ {
+ InstanceInfo iInfo = (InstanceInfo)instanceListIt.next();
+ if(iInfo.getInstanceName().equals(instanceName))
+ {
+ InstanceInfo instanceInfo = new InstanceInfo(instanceName,instance);
+
+ String qualifier = _symTab.getQualifierForClass(anchorClassName);
+ Map symbolsForInstance = dc.getSymbolsForInstance(anchorClassName,
+ qualifier,
+ instance);
+ instanceInfo.setInstanceSymbolsMap(symbolsForInstance);
+ if(instMap.containsKey(anchorClassName))
+ {
+ List instanceInfoList = (List)instMap.get(anchorClassName);
+ instanceInfoList.add(instanceInfo);
+
+ }
+ else
+ {
+ List instanceInfoList = new ArrayList();
+ instanceInfoList.add(instanceInfo);
+ instMap.put(anchorClassName, instanceInfoList);
+
+ }
+
+ }
+ }
+ }
+
+ }
+ }
+ }
+ catch(ClassNotFoundException cnef)
+ {
+ throw new SPLException(cnef.getMessage());
+ }
+ return instMap;
+
+ }
+
+
+
+
+ public String getAuditLogString() {
+
+ return this.auditloggerString;
+ }
+
+ private boolean _instancesPassImportFilter(DataCollector dc,Object instance)
+ {
+ return true;
+ /*logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "instanceFilterByCOP");
+ String classnm=this.importStmt.getClassName();
+ String namespc=this.importStmt.getNameSpace();
+
+ String copShouldStartWith=this.getSymTab().getAnchor();
+ //System.out.println("cop Should contain : "+copShouldStartWith);
+ //System.out.println("cop is : "+cop);
+ if(cop.toString().indexOf(copShouldStartWith) != -1)
+ {
+ try
+ {
+ Map instMap=dc.getInstanceMap(classnm, namespc, cop.toString());
+ symTab.populateSymbolTableWithInstanceValues(instMap);
+ Expression importFilterExpression = importStmt.getExpr();
+ if(importFilterExpression != null)
+ {
+ if (logger.isLoggable(Level.FINE))
+ logger.fine(Thread.currentThread().getName()+"importFilterExpression != null");
+ // filter the List of Maps based on the import statement filter expression
+ Boolean filterResult = (Boolean)importFilterExpression.evaluate();
+ if(filterResult.booleanValue())
+ {
+ if (logger.isLoggable(Level.FINE))
+ logger.fine(Thread.currentThread().getName()+"filterResult.booleanValue() = true");
+ return true;
+ }
+ else
+ {
+ if (logger.isLoggable(Level.FINE))
+ logger.fine(Thread.currentThread().getName()+"filterResult.booleanValue() = false");
+ return false;
+ }
+ }
+ else
+ {
+ // no filtering required
+ return true;
+ }
+
+ }
+ catch(SPLException e)
+ {
+ logger.severe(e.getMessage());
+ }
+
+
+
+ //System.out.println("passed the filter");
+
+ }
+ //System.out.println("did not passed the filter");
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "instanceFilterByCOP");
+
+ return false;*/
+ }
+
+ /* private List filterInstancesByImportFilter(List instSymbolMaps, Expression importFilterExpression) throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "filterInstancesByImportFilter");
+
+ List filteredList = new ArrayList();
+ Iterator listIt = instSymbolMaps.iterator();
+ while(listIt.hasNext())
+ {
+ Map instSymbols = (Map)listIt.next();
+ symTab.populateSymbolTableWithInstanceValues(instSymbols);
+ Boolean filterResult = (Boolean)importFilterExpression.evaluate();
+ if(filterResult.booleanValue())
+ {
+ filteredList.add(instSymbols);
+ }
+ }
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "filterInstancesByImportFilter");
+
+ return filteredList;
+ }*/
+
+
+
+
+}
Propchange: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/statements/impl/SPLPolicy.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/statements/impl/StrategyStatement.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/statements/impl/StrategyStatement.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/statements/impl/StrategyStatement.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/statements/impl/StrategyStatement.java Fri Jan 11 10:56:30 2008
@@ -1,58 +1,58 @@
-/*
- * Licensed 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.
- */
-//
-
-/**
- * @author Neeraj Joshi <jn...@us.ibm.com>
- *
- */
-package org.apache.imperius.spl.parser.statements.impl;
-
-import java.util.logging.Logger;
-
-import org.apache.imperius.util.SPLLogger;
-
-
-public class StrategyStatement
-{
- private String strategy;
- private static Logger logger = SPLLogger.getSPLLogger().getLogger();
- private static final String sourceClass="StrategyStatement";
-
-
- public String getStrategy() {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getStrategy");
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getStrategy");
-
- return strategy;
- }
-
- public void setStrategy(String strategy) {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setStrategy");
-
- this.strategy = strategy;
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setStrategy");
-
- }
-
- public StrategyStatement(String st)
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "StrategyStatement");
-
- strategy = st;
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "StrategyStatement");
-
- }
-}
+/*
+ * Licensed 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.
+ */
+//
+
+/**
+ * @author Neeraj Joshi <jn...@us.ibm.com>
+ *
+ */
+package org.apache.imperius.spl.parser.statements.impl;
+
+import java.util.logging.Logger;
+
+import org.apache.imperius.util.SPLLogger;
+
+
+public class StrategyStatement
+{
+ private String strategy;
+ private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+ private static final String sourceClass="StrategyStatement";
+
+
+ public String getStrategy() {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getStrategy");
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getStrategy");
+
+ return strategy;
+ }
+
+ public void setStrategy(String strategy) {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setStrategy");
+
+ this.strategy = strategy;
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setStrategy");
+
+ }
+
+ public StrategyStatement(String st)
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "StrategyStatement");
+
+ strategy = st;
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "StrategyStatement");
+
+ }
+}
Propchange: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/statements/impl/StrategyStatement.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/util/ActuatorFactory.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/util/ActuatorFactory.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/util/ActuatorFactory.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/util/ActuatorFactory.java Fri Jan 11 10:56:30 2008
@@ -1,41 +1,41 @@
-/*
- * Licensed 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.
- */
-//
-
-/**
- * @author Prashant Baliga <pr...@in.ibm.com>
- *
- */
-
-package org.apache.imperius.spl.parser.util;
-
-import org.apache.imperius.spl.external.Actuator;
-
-public class ActuatorFactory
-{
- private static Actuator _actuator;
-
- public static void registerActuator(Actuator ac)
- {
- _actuator = ac;
- }
-
- public static Actuator getActuator()
- {
- return _actuator;
- }
-
-
-
-}
+/*
+ * Licensed 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.
+ */
+//
+
+/**
+ * @author Prashant Baliga <pr...@in.ibm.com>
+ *
+ */
+
+package org.apache.imperius.spl.parser.util;
+
+import org.apache.imperius.spl.external.Actuator;
+
+public class ActuatorFactory
+{
+ private static Actuator _actuator;
+
+ public static void registerActuator(Actuator ac)
+ {
+ _actuator = ac;
+ }
+
+ public static Actuator getActuator()
+ {
+ return _actuator;
+ }
+
+
+
+}
Propchange: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/util/ActuatorFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/util/DataCollectorFactory.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/util/DataCollectorFactory.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/util/DataCollectorFactory.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/util/DataCollectorFactory.java Fri Jan 11 10:56:30 2008
@@ -1,39 +1,39 @@
-/*
- * Licensed 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.
- */
-//
-
-/**
- * @author Prashant Baliga <pr...@in.ibm.com>
- *
- */
-
-package org.apache.imperius.spl.parser.util;
-
-import org.apache.imperius.spl.external.DataCollector;
-
-public class DataCollectorFactory
-{
- private static DataCollector _dataCollector;
-
- public static void registerDataCollector(DataCollector dc)
- {
- _dataCollector = dc;
- }
-
- public static DataCollector getDataCollector()
- {
- return _dataCollector;
- }
-
-}
+/*
+ * Licensed 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.
+ */
+//
+
+/**
+ * @author Prashant Baliga <pr...@in.ibm.com>
+ *
+ */
+
+package org.apache.imperius.spl.parser.util;
+
+import org.apache.imperius.spl.external.DataCollector;
+
+public class DataCollectorFactory
+{
+ private static DataCollector _dataCollector;
+
+ public static void registerDataCollector(DataCollector dc)
+ {
+ _dataCollector = dc;
+ }
+
+ public static DataCollector getDataCollector()
+ {
+ return _dataCollector;
+ }
+
+}
Propchange: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/util/DataCollectorFactory.java
------------------------------------------------------------------------------
svn:eol-style = native