.classpath
.jupiter
.pydevproject
+.idea
target
.metadata/
ASTRAGateway/policyEngineLog.log
XACML-REST/IntegrityMonitor.log
/bin/
*.checkstyle
+*.iml
+*.log
BRMSGateway/logs/
BRMSGateway/sql/
BRMSGateway/src/test/resources/META-INF/generatedCreate.ddl
this.newModel.setUserCreatedBy(userInfo);
String cleanUpFile = null;
- HashMap<String, MSAttributeObject> tempMap = new HashMap<>();
+ Map<String, MSAttributeObject> tempMap = new HashMap<>();
//Need to delete the file
if (importFile.contains(".zip")){
extractFolder(randomID + ".zip");
int currentByte;
byte data[] = new byte[BUFFER];
-
- FileOutputStream fos = new FileOutputStream(destFile);
- BufferedOutputStream dest = new BufferedOutputStream(fos,
- BUFFER);
-
- while ((currentByte = is.read(data, 0, BUFFER)) != -1) {
- dest.write(data, 0, currentByte);
- }
- dest.flush();
- dest.close();
+ try(FileOutputStream fos = new FileOutputStream(destFile);
+ BufferedOutputStream dest = new BufferedOutputStream(fos, BUFFER)) {
+
+ while ((currentByte = is.read(data, 0, BUFFER)) != -1) {
+ dest.write(data, 0, currentByte);
+ }
+ dest.flush();
+ }
is.close();
}
Map<String, String> successMap = new HashMap<>();
MSAttributeObject mainClass = null;
- ArrayList<String> dependency = null;
+ List<String> dependency = null;
String subAttribute = null;
if (!classMap.containsKey(this.newModel.getModelName())){
private String jsonBody;
private Object jsonBodyData;
- private LinkedHashMap<?, ?> serviceTypePolicyName;
- private LinkedHashMap<?, ?> verticaMetrics;
- private LinkedHashMap<?, ?> description;
- private LinkedHashMap<?, ?> attributeFields;
+ private Map<?, ?> serviceTypePolicyName;
+ private Map<?, ?> verticaMetrics;
+ private Map<?, ?> description;
+ private Map<?, ?> attributeFields;
//Safe Policy
private String policyScope;
private String ttlDate;
private Map<String,String> matching;
- private ArrayList<Object> triggerSignatures;
- private ArrayList<Object> symptomSignatures;
+ private List<Object> triggerSignatures;
+ private List<Object> symptomSignatures;
private String logicalConnector;
private String policyStatus;
public String gocServerScope;
//FireWall
private String fwPolicyType;
- private ArrayList<Object> fwattributes;
+ private List<Object> fwattributes;
private String parentForChild;
private String securityZone;
public void setJsonBody(String jsonBody) {
this.jsonBody = jsonBody;
}
- public LinkedHashMap<?, ?> getServiceTypePolicyName() {
+ public Map<?, ?> getServiceTypePolicyName() {
return serviceTypePolicyName;
}
this.serviceTypePolicyName = serviceTypePolicyName;
}
- public LinkedHashMap<?, ?> getVerticaMetrics() {
+ public Map<?, ?> getVerticaMetrics() {
return verticaMetrics;
}
this.verticaMetrics = verticaMetrics;
}
- public LinkedHashMap<?, ?> getDescription() {
+ public Map<?, ?> getDescription() {
return description;
}
- public void setDescription(LinkedHashMap<?, ?> description) {
+ public void setDescription(Map<?, ?> description) {
this.description = description;
}
- public LinkedHashMap<?, ?> getAttributeFields() {
+ public Map<?, ?> getAttributeFields() {
return attributeFields;
}
public void setMatching(Map<String, String> matching) {
this.matching = matching;
}
- public ArrayList<Object> getTriggerSignatures() {
+ public List<Object> getTriggerSignatures() {
return triggerSignatures;
}
public void setTriggerSignatures(ArrayList<Object> triggerSignatures) {
this.triggerSignatures = triggerSignatures;
}
- public ArrayList<Object> getSymptomSignatures() {
+ public List<Object> getSymptomSignatures() {
return symptomSignatures;
}
public void setSymptomSignatures(ArrayList<Object> symptomSignatures) {
public List<String> getBrmsDependency() {
return brmsDependency;
}
- public void setBrmsDependency(ArrayList<String> brmsDependency) {
+ public void setBrmsDependency(List<String> brmsDependency) {
this.brmsDependency = brmsDependency;
}
- public LinkedHashMap<?, ?> getRuleData() {
+ public Map<?, ?> getRuleData() {
return ruleData;
}
public void setRuleData(LinkedHashMap<?, ?> ruleData) {
this.ruleData = ruleData;
}
- public LinkedHashMap<?, ?> getRuleListData() {
+ public Map<?, ?> getRuleListData() {
return ruleListData;
}
public void setRuleListData(LinkedHashMap<?, ?> ruleListData) {
public void setFwPolicyType(String fwPolicyType) {
this.fwPolicyType = fwPolicyType;
}
- public ArrayList<Object> getFwattributes() {
+ public List<Object> getFwattributes() {
return fwattributes;
}
public void setFwattributes(ArrayList<Object> fwattributes) {
public class XACMLRest {
private static final Log logger = LogFactory.getLog(XACMLRest.class);
private static Properties restProperties = new Properties();
-
+
+ private XACMLRest(){
+ // Empty constructor
+ }
/**
* This must be called during servlet initialization. It sets up the xacml.?.properties
* file as a system property. If the System property is already set, then it does not
Enumeration<String> params = config.getInitParameterNames();
while (params.hasMoreElements()) {
String param = params.nextElement();
- if (! param.equals("XACML_PROPERTIES_NAME")) {
+ if (! "XACML_PROPERTIES_NAME".equals(param)) {
String value = config.getInitParameter(param);
- //logger.info(param + "=" + config.getInitParameter(param));
PolicyLogger.info(param + "=" + config.getInitParameter(param));
restProperties.setProperty(param, value);
}
public static void dumpRequest(HttpServletRequest request) {
if (logger.isDebugEnabled()) {
// special-case for receiving heartbeat - don't need to repeatedly output all of the information in multiple lines
- if (request.getMethod().equals("GET") && "hb".equals(request.getParameter("type")) ) {
- //logger.debug("GET type=hb : heartbeat received");
+ if ("GET".equals(request.getMethod()) && "hb".equals(request.getParameter("type")) ) {
PolicyLogger.debug("GET type=hb : heartbeat received");
return;
}
logger.debug(element + ":" + request.getAttribute(element));
}
logger.debug("ContextPath: " + request.getContextPath());
- if (request.getMethod().equals("PUT") || request.getMethod().equals("POST")) {
+ if ("PUT".equals(request.getMethod()) || "POST".equals(request.getMethod())) {
// POST and PUT are allowed to have parameters in the content, but in our usage the parameters are always in the Query string.
// More importantly, there are cases where the POST and PUT content is NOT parameters (e.g. it might contain a Policy file).
// Unfortunately the request.getParameterMap method reads the content to see if there are any parameters,
this.name = value;
}
+ @Override
public boolean equals(Object obj){
if(obj == null){
return false;
}
return false;
}
-
- public int hashCode() {
+ @Override
+ public int hashCode() {
return Integer.valueOf(name.charAt(0)+(name.charAt(1)));
}
{
if(members==null)
{
- members= new ArrayList<AddressMembersJson>();
+ members= new ArrayList<>();
}
return this.members;
}
public void setType(String type) {
this.type = type;
}
-
- /*public String getValue() {
- return value;
- }
- public void setValue(String value) {
- this.value = value;
- }*/
}
package org.onap.policy.rest.adapter;
-import java.util.ArrayList;
+import java.util.List;
public class AutoPushTabAdapter {
- private ArrayList<Object> pdpDatas;
- private ArrayList<Object> policyDatas;
- public ArrayList<Object> getPdpDatas() {
+ private List<Object> pdpDatas;
+ private List<Object> policyDatas;
+ public List<Object> getPdpDatas() {
return pdpDatas;
}
- public void setPdpDatas(ArrayList<Object> pdpDatas) {
+ public void setPdpDatas(List<Object> pdpDatas) {
this.pdpDatas = pdpDatas;
}
- public ArrayList<Object> getPolicyDatas() {
+ public List<Object> getPolicyDatas() {
return policyDatas;
}
- public void setPolicyDatas(ArrayList<Object> policyDatas) {
+ public void setPolicyDatas(List<Object> policyDatas) {
this.policyDatas = policyDatas;
}
}
public static final String CLPM_UIFIELD_GEOLINK = "Geo Link";
public static final String CLPM_UIJSON_GEOLINK = "geoLink";
+
+ private ClosedLoopPerformanceMetrics() {
+ // Empty constructor
+ }
}
public static final String CLFAULT_UIFIELD_POLICY_STATUS_INACTIVE = "InActive";
public static final String CLFAULT_UIJSON_POLICY_STATUS_INACTIVE = "INACTIVE";
+ private ClosedLoopPolicy(){
+ // Empty constructor
+ }
}
package org.onap.policy.rest.adapter;
-import java.util.ArrayList;
+import java.util.List;
public class GridData {
- private ArrayList<Object> attributes;
- private ArrayList<Object> transportProtocols;
- private ArrayList<Object> appProtocols;
+ private List<Object> attributes;
+ private List<Object> transportProtocols;
+ private List<Object> appProtocols;
- public ArrayList<Object> getAttributes() {
+ public List<Object> getAttributes() {
return attributes;
}
- public void setAttributes(ArrayList<Object> attributes) {
+ public void setAttributes(List<Object> attributes) {
this.attributes = attributes;
}
- public ArrayList<Object> getAppProtocols() {
+ public List<Object> getAppProtocols() {
return appProtocols;
}
- public void setAppProtocols(ArrayList<Object> appProtocols) {
+ public void setAppProtocols(List<Object> appProtocols) {
this.appProtocols = appProtocols;
}
- public ArrayList<Object> getTransportProtocols() {
+ public List<Object> getTransportProtocols() {
return transportProtocols;
}
- public void setTransportProtocols(ArrayList<Object> transportProtocols) {
+ public void setTransportProtocols(List<Object> transportProtocols) {
this.transportProtocols = transportProtocols;
}
}
package org.onap.policy.rest.adapter;
-import java.util.ArrayList;
+import java.util.List;
public class PolicyExportAdapter {
- private ArrayList<Object> policyDatas;
+ private List<Object> policyDatas;
- public ArrayList<Object> getPolicyDatas() {
+ public List<Object> getPolicyDatas() {
return policyDatas;
}
- public void setPolicyDatas(ArrayList<Object> policyDatas) {
+ public void setPolicyDatas(List<Object> policyDatas) {
this.policyDatas = policyDatas;
}
}
private Object jsonBodyData;
private String dirPath;
private String configBodyPath;
- private ArrayList<Object> attributes;
- private ArrayList<Object> settings;
- private ArrayList<Object> ruleAlgorithmschoices;
+ private List<Object> attributes;
+ private List<Object> settings;
+ private List<Object> ruleAlgorithmschoices;
- private LinkedHashMap<?, ?> serviceTypePolicyName;
+ private Map<?, ?> serviceTypePolicyName;
- private LinkedHashMap<?, ?> verticaMetrics;
- private LinkedHashMap<?, ?> description;
- private LinkedHashMap<?, ?> attributeFields;
+ private Map<?, ?> verticaMetrics;
+ private Map<?, ?> description;
+ private Map<?, ?> attributeFields;
//ClosedLoop
private String clearTimeOut;
//FireWall
private String fwPolicyType;
- private ArrayList<Object> fwattributes;
+ private List<Object> fwattributes;
private String parentForChild;
private String securityZone;
private String ttlDate;
private Map<String,String> matching;
- private ArrayList<Object> triggerSignatures;
- private ArrayList<Object> symptomSignatures;
+ private List<Object> triggerSignatures;
+ private List<Object> symptomSignatures;
private String logicalConnector;
private String policyStatus;
private String gocServerScope;
private String supressionType;
- public ArrayList<Object> getTriggerSignatures() {
+ public List<Object> getTriggerSignatures() {
return triggerSignatures;
}
- public void setTriggerSignatures(ArrayList<Object> triggerSignatures) {
+ public void setTriggerSignatures(List<Object> triggerSignatures) {
this.triggerSignatures = triggerSignatures;
}
- public ArrayList<Object> getSymptomSignatures() {
+ public List<Object> getSymptomSignatures() {
return symptomSignatures;
}
- public void setSymptomSignatures(ArrayList<Object> symptomSignatures) {
+ public void setSymptomSignatures(List<Object> symptomSignatures) {
this.symptomSignatures = symptomSignatures;
}
public String getLogicalConnector() {
public void setConfigBodyPath(String configBodyPath) {
this.configBodyPath = configBodyPath;
}
- public ArrayList<Object> getAttributes() {
+ public List<Object> getAttributes() {
return attributes;
}
- public void setAttributes(ArrayList<Object> attributes) {
+ public void setAttributes(List<Object> attributes) {
this.attributes = attributes;
}
- public ArrayList<Object> getSettings() {
+ public List<Object> getSettings() {
return settings;
}
- public void setSettings(ArrayList<Object> settings) {
+ public void setSettings(List<Object> settings) {
this.settings = settings;
}
- public ArrayList<Object> getRuleAlgorithmschoices() {
+ public List<Object> getRuleAlgorithmschoices() {
return ruleAlgorithmschoices;
}
- public void setRuleAlgorithmschoices(ArrayList<Object> ruleAlgorithmschoices) {
+ public void setRuleAlgorithmschoices(List<Object> ruleAlgorithmschoices) {
this.ruleAlgorithmschoices = ruleAlgorithmschoices;
}
- public LinkedHashMap<?, ?> getServiceTypePolicyName() {
+ public Map<?, ?> getServiceTypePolicyName() {
return serviceTypePolicyName;
}
- public void setServiceTypePolicyName(LinkedHashMap<?, ?> serviceTypePolicyName) {
+ public void setServiceTypePolicyName(Map<?, ?> serviceTypePolicyName) {
this.serviceTypePolicyName = serviceTypePolicyName;
}
- public LinkedHashMap<?, ?> getVerticaMetrics() {
+ public Map<?, ?> getVerticaMetrics() {
return verticaMetrics;
}
- public void setVerticaMetrics(LinkedHashMap<?, ?> verticaMetrics) {
+ public void setVerticaMetrics(Map<?, ?> verticaMetrics) {
this.verticaMetrics = verticaMetrics;
}
- public LinkedHashMap<?, ?> getDescription() {
+ public Map<?, ?> getDescription() {
return description;
}
public void setDescription(LinkedHashMap<?, ?> description) {
this.description = description;
}
- public LinkedHashMap<?, ?> getAttributeFields() {
+ public Map<?, ?> getAttributeFields() {
return attributeFields;
}
public void setAttributeFields(LinkedHashMap<?, ?> attributeFields) {
public void setFwPolicyType(String fwPolicyType) {
this.fwPolicyType = fwPolicyType;
}
- public ArrayList<Object> getFwattributes() {
+ public List<Object> getFwattributes() {
return fwattributes;
}
- public void setFwattributes(ArrayList<Object> fwattributes) {
+ public void setFwattributes(List<Object> fwattributes) {
this.fwattributes = fwattributes;
}
public String getParentForChild() {
{
if(members==null)
{
- members= new ArrayList<AddressMembers>();
+ members= new ArrayList<>();
}
return this.members;
}
{
this.members = members;
}
- /*public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }*/
-
}
package org.onap.policy.rest.adapter;
-import java.util.ArrayList;
import java.util.List;
public class RainyDayParams {
private String vnfType;
private String bbid;
private String workstep;
- private ArrayList<Object> treatmentTableChoices;
+ private List<Object> treatmentTableChoices;
private List<String> errorcode;
private List<String> treatment;
/**
* @return the treatmentTableChoices
*/
- public ArrayList<Object> getTreatmentTableChoices() {
+ public List<Object> getTreatmentTableChoices() {
return treatmentTableChoices;
}
/**
* @param treatmentTableChoices the treatmentTableChoices to set
*/
- public void setTreatmentTableChoices(ArrayList<Object> treatmentTableChoices) {
+ public void setTreatmentTableChoices(List<Object> treatmentTableChoices) {
this.treatmentTableChoices = treatmentTableChoices;
}
/**
public void setName(String value) {
this.name = value;
}
-
+
+ @Override
public boolean equals(Object obj){
if(obj == null){
return false;
}
return false;
}
-
- public int hashCode() {
+
+ @Override
+ public int hashCode() {
return Integer.valueOf(name.charAt(0)+(name.charAt(1)));
}
{
if(members==null)
{
- members= new ArrayList<ServiceMembers>();
+ members= new ArrayList<>();
}
return this.members;
}
public void setName(String value) {
this.name = value;
}
-
+
+ @Override
public boolean equals(Object obj){
if(obj == null){
return false;
}
return false;
}
-
- public int hashCode() {
+
+ @Override
+ public int hashCode() {
if(name!=null){
return Integer.valueOf(name.charAt(0)+(name.charAt(1)));
}else{
return 0;
}
- }
+ }
public String getDescription() {
public List<String> getFromZones() {
if (fromZones==null)
{
- fromZones= new ArrayList<String>();
+ fromZones= new ArrayList<>();
}
return fromZones;
}
public List<String> getToZones() {
if (toZones==null)
{
- toZones= new ArrayList<String>();
+ toZones= new ArrayList<>();
}
return toZones;
}
{
if(sourceList==null)
{
- sourceList= new ArrayList<AddressJson>();
+ sourceList= new ArrayList<>();
}
return this.sourceList;
}
{
if(destinationList==null)
{
- destinationList= new ArrayList<AddressJson>();
+ destinationList= new ArrayList<>();
}
return this.destinationList;
}
public List<ServicesJson> getSourceServices() {
if(sourceServices==null)
{
- sourceServices= new ArrayList<ServicesJson>();
+ sourceServices= new ArrayList<>();
}
return this.sourceServices;
}
public Set<ServicesJson> getDestServices() {
if(destServices==null)
{
- destServices= new HashSet<ServicesJson>();
+ destServices= new HashSet<>();
}
return this.destServices;
}
public Set<Object> getServiceGroups() {
if(serviceGroups==null)
{
- serviceGroups= new HashSet<Object>();
+ serviceGroups= new HashSet<>();
}
return this.serviceGroups;
}
public Set<Object> getAddressGroups() {
if(addressGroups==null)
{
- addressGroups= new HashSet<Object>();
+ addressGroups= new HashSet<>();
}
return this.addressGroups;
}
if(firewallRuleList==null)
{
- firewallRuleList= new ArrayList<Term>();
+ firewallRuleList= new ArrayList<>();
}
return this.firewallRuleList;
}
public class VendorSpecificData {
- private List<IdMap> idMap= new ArrayList<IdMap>();
+ private List<IdMap> idMap= new ArrayList<>();
public List<IdMap> getIdMap() {
return idMap;
private static final long serialVersionUID = -6162444281003852781L;
public PolicyDBException() {
+ // Empty constructor
}
public PolicyDBException(String message) {
private boolean deleted = false;
public ActionBodyEntity() {
+ //An empty constructor
}
@PrePersist
return actionBodyId;
}
/**
- * @param configurationDataId the configurationDataId to set
+ * @param name the configuration body name to set
*/
public void setActionBodyName(String name) {
this.actionBodyName = name;
return actionBody;
}
/**
- * @param configBody the configBody to set
+ * @param body the configBody to set
*/
public void setActionBody(String body) {
this.actionBody = body;
return false;
}
- return (
- actionBodyId == ((ActionBodyEntity) obj).actionBodyId &&
+ return actionBodyId == ((ActionBodyEntity) obj).actionBodyId &&
actionBodyName.equals(((ActionBodyEntity) obj).actionBodyName) &&
version == ((ActionBodyEntity) obj).version &&
actionBody.equals(((ActionBodyEntity) obj).actionBody) &&
createdDate.equals(((ActionBodyEntity) obj).createdDate) &&
modifiedBy.equals(((ActionBodyEntity) obj).modifiedBy) &&
modifiedDate.equals(((ActionBodyEntity) obj).modifiedDate) &&
- deleted == ((ActionBodyEntity) obj).deleted
- );
+ deleted == ((ActionBodyEntity) obj).deleted;
}
}
@Column(name="description")
private String description;
-/*
- @Temporal(TemporalType.TIMESTAMP)
- @Column(name="modified_date", nullable=false)
- private Date modifiedDate;*/
public ActionList() {
-
+ //An empty constructor
}
public ActionList(String string, String userid) {
this(domain);
}
public ActionList(String domain) {
-
+ //An empty constructor
}
@PrePersist
public void prePersist() {
-
+ //An empty function
}
@PreUpdate
public void preUpdate() {
+ //An empty function
}
public String getActionName() {
return this.actionName;
private static Log logger = LogFactory.getLog(ActionPolicyDict.class);
public ActionPolicyDict() {
-
+ //An empty constructor
}
public ActionPolicyDict(String string, String userid) {
public void preUpdate() {
this.modifiedDate = new Date();
try {
- this.userModifiedBy =XacmlAdminAuthorization.getUserId();;
+ this.userModifiedBy =XacmlAdminAuthorization.getUserId();
} catch (Exception e) {
logger.error("Exception caused While adding Modified by Role"+e);
- //PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "ActionPolicyDict", "Exception caused While adding Modified by Role");
}
}
public int getId() {
private String description;
public AddressGroup() {
-
+ //An empty constructor
}
public AddressGroup(String string, String userid) {
this(domain);
}
public AddressGroup(String domain) {
-
+ //An empty constructor
}
@PrePersist
public void prePersist() {
-
+ //An empty function
}
@PreUpdate
public void preUpdate() {
+ //An empty function
}
public Attribute() {
+ //An empty constructor
}
public Attribute(String domain) {
public String getXacmlId() {
return this.xacmlId;
}
-
-/* @Transient
- public Identifier getXacmlIdentifier() {
- return new IdentifierImpl(this.xacmlId);
- }*/
+
public void setXacmlId(String xacmlId) {
this.xacmlId = xacmlId;
@Transient
public boolean isDesignator() {
- return (this.isDesignator == '1');
+ return this.isDesignator == '1';
}
@Transient
private Obadvice obadvice;
public AttributeAssignment() {
+ //An empty constructor
}
public int getId() {
}
public BRMSParamTemplate(){
+ //An empty constructor
}
public BRMSParamTemplate(String userid){
-
+ //An empty constructor
}
@PrePersist
@Transient
public boolean isStandard() {
- return (this.isStandard == Category.STANDARD);
+ return this.isStandard == Category.STANDARD;
}
@Transient
public boolean isCustom() {
- return (this.isStandard == Category.CUSTOM);
+ return this.isStandard == Category.CUSTOM;
}
@Transient
private static Log LOGGER = LogFactory.getLog(ClosedLoopD2Services.class);
public ClosedLoopD2Services(){
-
+ //An empty constructor
}
public ClosedLoopD2Services(String string, String userid) {
private static Log LOGGER = LogFactory.getLog(ClosedLoopSite.class);
public ClosedLoopSite(){
-
+ //An empty constructor
}
public ClosedLoopSite(String string, String userid) {
private String yaml;
public ClosedLoops() {
-
+ //An empty constructor
}
public int getId() {
private boolean deleted = false;
public ConfigurationDataEntity() {
+ //An empty constructor
}
@PrePersist
return false;
}
- return (
- configurationDataId == ((ConfigurationDataEntity) obj).configurationDataId &&
+ return configurationDataId == ((ConfigurationDataEntity) obj).configurationDataId &&
configurationName.equals(((ConfigurationDataEntity) obj).configurationName) &&
version == ((ConfigurationDataEntity) obj).version &&
configType.equals(((ConfigurationDataEntity) obj).configType) &&
description.equals(((ConfigurationDataEntity) obj).description) &&
modifiedBy.equals(((ConfigurationDataEntity) obj).modifiedBy) &&
modifiedDate.equals(((ConfigurationDataEntity) obj).modifiedDate) &&
- deleted == ((ConfigurationDataEntity) obj).deleted
- );
+ deleted == ((ConfigurationDataEntity) obj).deleted;
}
}
private Set<Attribute> attributes = new HashSet<>();
public ConstraintType() {
-
+ //An empty constructor
}
public ConstraintType(String constraintType) {
private Attribute attribute;
public ConstraintValue() {
+ //An empty constructor
}
public ConstraintValue(String property, String value) {
public DCAEUsers() {
-
+ //An empty constructor
}
public DCAEUsers(String string, String userid) {
this(domain);
}
public DCAEUsers(String domain) {
-
+ //An empty constructor
}
@PrePersist
public void prePersist() {
-
+ //An empty function
}
@PreUpdate
public void preUpdate() {
+ //An empty function
}
public DCAEuuid() {
-
+ //An empty constructor
}
public DCAEuuid(String string, String userid) {
this(domain);
}
public DCAEuuid(String domain) {
-
+ //An empty constructor
}
@PrePersist
public void prePersist() {
-
+ //An empty function
}
@PreUpdate
public void preUpdate() {
+ //An empty function
}
public String getDescription() {
@Column(name="lock_key")
private int lock_key = 1;
public DatabaseLockEntity(){
-
+ //An empty constructor
}
public int getKey(){
return lock_key;
@Transient
public boolean isStandard() {
- return (this.isStandard == Datatype.STANDARD);
+ return this.isStandard == Datatype.STANDARD;
}
@Transient
public boolean isCustom() {
- return (this.isStandard == Datatype.CUSTOM);
+ return this.isStandard == Datatype.CUSTOM;
}
@Transient
+ ", xacmlId=" + xacmlId + ", shortName=" + shortName
+ ", attributes=" + attributes + ", functions=" + functions
+ ", arguments=" + arguments + "]";
-
- //return "Datatype [shortName=" + shortName + "]";
}
}
}
public DecisionSettings() {
+ //An empty constructor
}
public DecisionSettings(String domain) {
public void preUpdate() {
this.modifiedDate = new Date();
try {
- this.userModifiedBy = XacmlAdminAuthorization.getUserId();;
+ this.userModifiedBy = XacmlAdminAuthorization.getUserId();
} catch (Exception e) {
PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "DecisionSettings", "Exception caused While adding Modified by Role");
}
public String getXacmlId() {
return this.xacmlId;
}
-
-/* @Transient
- public Identifier getXacmlIdentifier() {
- return new IdentifierImpl(this.xacmlId);
- }*/
public void setXacmlId(String xacmlId) {
this.xacmlId = xacmlId;
private static Log LOGGER = LogFactory.getLog(DescriptiveScope.class);
public DescriptiveScope(){
-
+ //An empty constructor
}
public DescriptiveScope(String string, String userid) {
private static Log LOGGER = LogFactory.getLog(FWTag.class);
public FWTag(){
-
+ //An empty constructor
}
public FWTag(String string, String userid) {
private static Log logger = LogFactory.getLog(FWTagPicker.class);
public FWTagPicker(){
-
+ //An empty constructor
}
public FWTagPicker(String string, String userid) {
@Column(name="serviceList")
private String serviceList;
-
-/* @Temporal(TemporalType.TIMESTAMP)
- @Column(name="created_date", updatable=false)
- private Date createdDate;
-
- @Temporal(TemporalType.TIMESTAMP)
- @Column(name="modified_date", nullable=false)
- private Date modifiedDate;
-
- @ManyToOne(optional = false)
- @JoinColumn(name="created_by")
- private UserInfo userCreatedBy;
-
- @ManyToOne(optional = false)
- @JoinColumn(name="modified_by")
- private UserInfo userModifiedBy;*/
public int getId() {
return this.id;
public void setServiceList(String serviceList) {
this.serviceList = serviceList;
}
-
-
- /*public UserInfo getUserCreatedBy() {
- return userCreatedBy;
- }
-
- public void setUserCreatedBy(UserInfo userCreatedBy) {
- this.userCreatedBy = userCreatedBy;
- }
-
- public UserInfo getUserModifiedBy() {
- return userModifiedBy;
- }
-
- public void setUserModifiedBy(UserInfo userModifiedBy) {
- this.userModifiedBy = userModifiedBy;
- }*/
public FirewallDictionaryList() {
-
+ //An empty constructor
}
public FirewallDictionaryList(String string, String userid) {
this.parentItemName = domain;
}
- /*@PrePersist
- public void prePersist() {
- Date date = new Date();
- this.createdDate = date;
- this.modifiedDate = date;
- auditLogger.debug("Added New Term Name: "+this.parentItemName+" by "+this.userCreatedBy);
-
- }
- @PreUpdate
- public void preUpdate() {
- this.modifiedDate = new Date();
- try {
- this.userModifiedBy =XacmlAdminAuthorization.getUserId();;
- } catch (Exception e) {
- PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "TermList", "Exception caused While adding Modified by Role");
- }
- auditLogger.debug("Updated Term Name: "+this.parentItemName+" by "+this.userModifiedBy);
- }
-*/
}
private Datatype datatypeBean;
public FunctionArgument() {
+ //An empty constructor
}
public FunctionArgument(final FunctionArgument argument) {
private List<FunctionArgument> functionArguments;
public FunctionDefinition() {
+ //An empty constructor
}
public int getId() {
private String description;
public GroupPolicyScopeList() {
-
+ //An empty constructor
}
public GroupPolicyScopeList(String string, String userid) {
this(domain);
}
public GroupPolicyScopeList(String domain) {
-
+ //An empty constructor
}
@PrePersist
public void prePersist() {
-
+ //An empty function
}
@PreUpdate
public void preUpdate() {
+ //An empty function
}
public GroupServiceList() {
-
+ //An empty constructor
}
public GroupServiceList(String string, String userid) {
this(domain);
}
public GroupServiceList(String domain) {
-
+ //An empty constructor
}
@PrePersist
public void prePersist() {
-
+ //An empty function
}
@PreUpdate
public void preUpdate() {
+ //An empty function
}
public MicroServiceAttribute() {
-
+ //An empty constructor
}
public MicroServiceAttribute(String string, String userid) {
this(domain);
}
public MicroServiceAttribute(String domain) {
-
+ //An empty constructor
}
@PrePersist
public void prePersist() {
-
+ //An empty function
}
@PreUpdate
public void preUpdate() {
+ //An empty function
}
public MicroServiceConfigName() {
-
+ //An empty constructor
}
public MicroServiceConfigName(String string, String userid) {
this(domain);
}
public MicroServiceConfigName(String domain) {
-
+ //An empty constructor
}
@PrePersist
public void prePersist() {
-
+ //An empty function
}
@PreUpdate
public void preUpdate() {
+ //An empty function
}
public MicroServiceLocation() {
-
+ //An empty constructor
}
public MicroServiceLocation(String string, String userid) {
this(domain);
}
public MicroServiceLocation(String domain) {
-
+ //An empty constructor
}
@PrePersist
public void prePersist() {
-
+ //An empty function
}
@PreUpdate
public void preUpdate() {
+ //An empty function
}
}
public MicroServiceModels(){
+ //An empty constructor
}
public MicroServiceModels(String userid){
-
+ //An empty constructor
}
public String getAttributes() {
@Column(name="type", nullable=false)
private String type;
-
- /*
- @Lob
- @Column(name="expression", nullable=false)
- private byte[] expression;
- */
//bi-directional many-to-one association to Obadvice
@ManyToOne
}
public OnapName() {
-
+ //An empty constructor
}
public OnapName(String string, String userid) {
private static Log LOGGER = LogFactory.getLog(PEPOptions.class);
public PEPOptions(){
-
+ //An empty constructor
}
public PEPOptions(String string, String userid) {
private PIPConfiguration pipconfiguration;
public PIPConfigParam() {
+ //An empty constructor
}
public PIPConfigParam(String param) {
@Transient
public boolean isRequired() {
- return (this.required == '1');
+ return this.required == '1';
}
@Transient
private Set<PIPResolver> pipresolvers = new HashSet<>();
public PIPConfiguration() {
+ //An empty constructor
}
public PIPConfiguration(PIPConfiguration config, String user) {
@Transient
public boolean isReadOnly() {
- return (this.readOnly == '1');
+ return this.readOnly == '1';
}
@Transient
@Transient
public boolean requiresResolvers() {
- return (this.requiresResolvers == '1');
+ return this.requiresResolvers == '1';
}
@Transient
//
// Go through each property
//
- for (Object name : properties.keySet()) {
- if (name.toString().startsWith(id) == false) {
+ for (Object nme : properties.keySet()) {
+ if (nme.toString().startsWith(id) == false) {
continue;
}
- if (name.equals(id + ".classname")) {
+ if (nme.equals(id + ".classname")) {
//
// We already saved this
//
- } else if (name.equals(id + "." + StdConfigurableEngine.PROP_NAME)) {
- this.name = properties.getProperty(name.toString());
- } else if (name.equals(id + "." + StdConfigurableEngine.PROP_DESCRIPTION)) {
- this.description = properties.getProperty(name.toString());
- } else if (name.equals(id + "." + StdConfigurableEngine.PROP_ISSUER)) {
- this.issuer = properties.getProperty(name.toString());
- } else if (name.equals(id + ".resolvers")) {
+ } else if (nme.equals(id + "." + StdConfigurableEngine.PROP_NAME)) {
+ this.name = properties.getProperty(nme.toString());
+ } else if (nme.equals(id + "." + StdConfigurableEngine.PROP_DESCRIPTION)) {
+ this.description = properties.getProperty(nme.toString());
+ } else if (nme.equals(id + "." + StdConfigurableEngine.PROP_ISSUER)) {
+ this.issuer = properties.getProperty(nme.toString());
+ } else if (nme.equals(id + ".resolvers")) {
//
// It has resolvers, make sure this is set to true if
// it has been already.
// Parse the resolvers
//
Collection<PIPResolver> resolvers = PIPResolver.importResolvers(id + ".resolver",
- properties.getProperty(name.toString()),
+ properties.getProperty(nme.toString()),
properties,"super-admin"
);
for (PIPResolver resolver : resolvers) {
this.addPipresolver(resolver);
}
- } else if (name.toString().startsWith(id + ".resolver")) {
+ } else if (nme.toString().startsWith(id + ".resolver")) {
//
// Ignore, the PIPResolver will parse these values
//
//
// Config Parameter
//
- this.addPipconfigParam(new PIPConfigParam(name.toString().substring(id.length() + 1),
- properties.getProperty(name.toString())));
+ this.addPipconfigParam(new PIPConfigParam(nme.toString().substring(id.length() + 1),
+ properties.getProperty(nme.toString())));
}
}
//
Iterator<PIPResolver> iter = this.pipresolvers.iterator();
while (iter.hasNext()) {
PIPResolver resolver = iter.next();
- String id = Integer.toString(resolver.getId());
- Map<String, String> resolverMap = resolver.getConfiguration(prefix + "resolver." + id);
+ String idd = Integer.toString(resolver.getId());
+ Map<String, String> resolverMap = resolver.getConfiguration(prefix + "resolver." + idd);
map.putAll(resolverMap);
- ids.add(id);
+ ids.add(idd);
}
- if (ids.size() > 0) {
+ if (!ids.isEmpty()) {
map.put(prefix + "resolvers", Joiner.on(',').join(ids));
}
return map;
Iterator<PIPResolver> iter = this.pipresolvers.iterator();
while (iter.hasNext()) {
PIPResolver resolver = iter.next();
- String id = Integer.toString(resolver.getId());
- resolver.generateProperties(props, prefix + "resolver." + id);
- ids.add(id);
+ String idd = Integer.toString(resolver.getId());
+ resolver.generateProperties(props, prefix + "resolver." + idd);
+ ids.add(idd);
}
- if (ids.size() > 0) {
+ if (!ids.isEmpty()) {
props.setProperty(prefix + "resolvers", Joiner.on(',').join(ids));
}
return props;
private Set<PIPResolverParam> pipresolverParams = new HashSet<>();
public PIPResolver() {
+ //An empty constructor
}
public PIPResolver(String prefix, Properties properties, String user) throws PIPException {
@Transient
public boolean isReadOnly() {
- return (this.readOnly == '1');
+ return this.readOnly == '1';
}
@Transient
//
// Go through each property
//
- for (Object name : properties.keySet()) {
- if (name.toString().startsWith(prefix) == false) {
+ for (Object nme : properties.keySet()) {
+ if (nme.toString().startsWith(prefix) == false) {
continue;
}
- if (name.equals(prefix + ".classname")) {
+ if (nme.equals(prefix + ".classname")) {
//
// We already saved this
//
- } else if (name.equals(prefix + "." + StdConfigurableEngine.PROP_NAME)) {
- this.name = properties.getProperty(name.toString());
- } else if (name.equals(prefix + "." + StdConfigurableEngine.PROP_DESCRIPTION)) {
- this.description = properties.getProperty(name.toString());
- } else if (name.equals(prefix + "." + StdConfigurableEngine.PROP_ISSUER)) {
- this.issuer = properties.getProperty(name.toString());
+ } else if (nme.equals(prefix + "." + StdConfigurableEngine.PROP_NAME)) {
+ this.name = properties.getProperty(nme.toString());
+ } else if (nme.equals(prefix + "." + StdConfigurableEngine.PROP_DESCRIPTION)) {
+ this.description = properties.getProperty(nme.toString());
+ } else if (nme.equals(prefix + "." + StdConfigurableEngine.PROP_ISSUER)) {
+ this.issuer = properties.getProperty(nme.toString());
} else {
- this.addPipresolverParam(new PIPResolverParam(name.toString().substring(prefix.length() + 1),
- properties.getProperty(name.toString())));
+ this.addPipresolverParam(new PIPResolverParam(nme.toString().substring(prefix.length() + 1),
+ properties.getProperty(nme.toString())));
}
}
}
@Transient
public Map<String, String> getConfiguration(String prefix) {
+ String pref = prefix;
Map<String, String> map = new HashMap<>();
if (prefix.endsWith(".") == false) {
- prefix = prefix + ".";
+ pref = prefix + ".";
}
- map.put(prefix + "classname", this.classname);
- map.put(prefix + "name", this.name);
+ map.put(pref + "classname", this.classname);
+ map.put(pref + "name", this.name);
if (this.description != null) {
- map.put(prefix + "description", this.description);
+ map.put(pref + "description", this.description);
}
if (this.issuer != null && this.issuer.isEmpty() != false) {
- map.put(prefix + "issuer", this.issuer);
+ map.put(pref + "issuer", this.issuer);
}
for (PIPResolverParam param : this.pipresolverParams) {
- map.put(prefix + param.getParamName(), param.getParamValue());
+ map.put(pref + param.getParamName(), param.getParamValue());
}
return map;
}
@Transient
public void generateProperties(Properties props, String prefix) {
+ String pref = prefix;
if (prefix.endsWith(".") == false) {
- prefix = prefix + ".";
+ pref = prefix + ".";
}
- props.setProperty(prefix + "classname", this.classname);
- props.setProperty(prefix + "name", this.name);
+ props.setProperty(pref + "classname", this.classname);
+ props.setProperty(pref + "name", this.name);
if (this.description != null) {
- props.setProperty(prefix + "description", this.description);
+ props.setProperty(pref + "description", this.description);
}
if (this.issuer != null && this.issuer.isEmpty() != false) {
- props.setProperty(prefix + "issuer", this.issuer);
+ props.setProperty(pref + "issuer", this.issuer);
}
for (PIPResolverParam param : this.pipresolverParams) {
- props.setProperty(prefix + param.getParamName(), param.getParamValue());
+ props.setProperty(pref + param.getParamName(), param.getParamValue());
}
}
private PIPResolver pipresolver;
public PIPResolverParam() {
+ // Empty constructor
}
public PIPResolverParam(String name) {
private Set<PIPConfiguration> pipconfigurations;
public PIPType() {
+ // Empty constructor
}
public int getId() {
@Transient
public boolean isStandard() {
- return (this.isStandard == PolicyAlgorithms.STANDARD);
+ return this.isStandard == PolicyAlgorithms.STANDARD;
}
@Transient
public boolean isCustom() {
- return (this.isStandard == PolicyAlgorithms.CUSTOM);
+ return this.isStandard == PolicyAlgorithms.CUSTOM;
}
public String getXacmlId() {
@JoinColumn(name="modified_by")
private UserInfo userModifiedBy;
- public PolicyEditorScopes() {
+ public PolicyEditorScopes() {
+ // Empty constructor
}
public PolicyEditorScopes(String string, String userid) {
PolicyEntity p = (PolicyEntity) obj;
- return (
- policyId == p.policyId &&
+ return policyId == p.policyId &&
policyName.equals(p.policyName) &&
scope.equals(p.scope) &&
version == p.version &&
description.equals(p.description) &&
modifiedBy.equals(p.modifiedBy) &&
modifiedDate.equals(p.modifiedDate) &&
- deleted == p.deleted
- );
+ deleted == p.deleted;
}
private String role;
public PolicyRoles() {
+ // Empty constructor
}
public int getId() {
private String description ;
public PolicyScopeClosedLoop() {
-
+ // Empty constructor
}
public PolicyScopeClosedLoop(String string, String userid) {
this(domain);
}
public PolicyScopeClosedLoop(String domain) {
-
+ // Empty constructor
}
@PrePersist
public void prePersist() {
-
+ // Empty function
}
@PreUpdate
public void preUpdate() {
+ // Empty function
}
private String description ;
public PolicyScopeResource() {
-
+ // Empty constructor
}
public PolicyScopeResource(String string, String userid) {
this(domain);
}
public PolicyScopeResource(String domain) {
-
+ // Empty constructor
}
@PrePersist
public void prePersist() {
-
+ // Empty function
}
@PreUpdate
public void preUpdate() {
+ // Empty function
}
private String description ;
public PolicyScopeService() {
-
+ // Empty constructor
}
public PolicyScopeService(String string, String userid) {
this(domain);
}
public PolicyScopeService(String domain) {
-
+ // Empty constructor
}
@PrePersist
public void prePersist() {
-
+ // Empty function
}
@PreUpdate
public void preUpdate() {
+ // Empty function
}
private String description ;
public PolicyScopeType() {
-
+ // Empty constructor
}
public PolicyScopeType(String string, String userid) {
this(domain);
}
public PolicyScopeType(String domain) {
-
+ // Empty constructor
}
@PrePersist
public void prePersist() {
-
+ // Empty function
}
@PreUpdate
public void preUpdate() {
+ // Empty function
}
private String PolicyScore;
public PolicyScore() {
-
+ // Empty constructor
}
public PolicyScore(String pName, String pScore) {
}
public PolicyScore(String domain) {
-
+ // Empty constructor
}
public int getId() {
package org.onap.policy.rest.jpa;
import java.io.Serializable;
-//import java.sql.Clob;
import java.sql.Timestamp;
import java.util.Date;
import java.util.Objects;
}
public PolicyVersion(){
-
+ // Empty constructor
}
@PrePersist
@PreUpdate
public void preUpdate() {
this.modifiedDate = new Date();
- /*
- * The modifiedBy must be set via the setModifiedBy() method since PolicyVersion
- * has been moved to XACML-REST module for access from the XACML-PAP-REST module
-
- String userid = ((XacmlAdminUI) UI.getCurrent()).getLoginUserId();
- this.modifiedBy =userid;
- *
- */
}
public int getId() {
PolicyVersion p = (PolicyVersion) obj;
- return (
- id == p.id &&
+ return id == p.id &&
policyName.equals(p.policyName) &&
activeVersion == p.activeVersion &&
higherVersion == p.higherVersion &&
createdDate.equals(p.createdDate) &&
createdBy.equals(p.createdBy) &&
modifiedDate.equals(p.modifiedDate) &&
- modifiedBy.equals(p.modifiedBy)
- );
+ modifiedBy.equals(p.modifiedBy);
}
}
private Date modifiedDate;*/
public PortList() {
-
+ // Empty constructor
}
public PortList(String string, String userid) {
this(domain);
}
public PortList(String domain) {
-
+ // Empty constructor
}
@PrePersist
public void prePersist() {
-
+ // Empty function
}
@PreUpdate
public void preUpdate() {
+ // Empty function
}
@Column(name="pl_value", nullable=false)
private String prefixListValue;
-/*
- @Temporal(TemporalType.TIMESTAMP)
- @Column(name="modified_date", nullable=false)
- private Date modifiedDate;*/
public PrefixList() {
-
+ // Empty constructor
}
public PrefixList(String string, String userid) {
this(domain);
}
public PrefixList(String domain) {
-
+ // Empty constructor
}
@PrePersist
public void prePersist() {
-
+ // Empty function
}
@PreUpdate
public void preUpdate() {
+ // Empty function
}
public String getPrefixListName() {
return this.prefixListName;
@Column(name="description")
private String description;
-/*
- @Temporal(TemporalType.TIMESTAMP)
- @Column(name="modified_date", nullable=false)
- private Date modifiedDate;*/
public ProtocolList() {
-
+ // Empty constructor
}
public ProtocolList(String string, String userid) {
this(domain);
}
public ProtocolList(String domain) {
-
+ // Empty constructor
}
@PrePersist
public void prePersist() {
-
+ // Empty function
}
@PreUpdate
public void preUpdate() {
+ // Empty function
}
public String getProtocolName() {
return this.protocolName;
private String treatments;
public RainyDayTreatments() {
-
+ // Empty constructor
}
public int getId() {
public RemoteCatalogValues() {
-
+ // Empty constructor
}
public RemoteCatalogValues(String string, String userid) {
this(domain);
}
public RemoteCatalogValues(String domain) {
-
+ // Empty constructor
}
@PrePersist
public void prePersist() {
-
+ // Empty function
}
@PreUpdate
public void preUpdate() {
+ // Empty function
}
public String getValue() {
private static Log LOGGER = LogFactory.getLog(RiskType.class);
public RiskType() {
-
+ // Empty constructor
}
public RiskType(String string, String userid) {
@Transient
public boolean isStandard() {
- return (this.isStandard == RuleAlgorithms.STANDARD);
+ return this.isStandard == RuleAlgorithms.STANDARD;
}
@Transient
public boolean isCustom() {
- return (this.isStandard == RuleAlgorithms.CUSTOM);
+ return this.isStandard == RuleAlgorithms.CUSTOM;
}
public String getXacmlId() {
this.riskType = riskType;
}
public SafePolicyWarning() {
-
+ // Empty constructor
}
public SafePolicyWarning(String string, String userid) {
this(domain);
}
public SafePolicyWarning(String domain) {
-
+ // Empty constructor
}
@PrePersist
public void prePersist() {
-
+ // Empty function
}
@PreUpdate
public void preUpdate() {
+ // Empty function
}
public SecurityZone() {
-
+ // Empty constructor
}
public SecurityZone(String string, String userid) {
this(domain);
}
public SecurityZone(String domain) {
-
+ // Empty constructor
}
@PrePersist
public void prePersist() {
-
+ // Empty function
}
@PreUpdate
public void preUpdate() {
+ // Empty function
}
@Column(name="ports")
private String servicePorts;
-
-
-
-/*
- @Temporal(TemporalType.TIMESTAMP)
- @Column(name="modified_date", nullable=false)
- private Date modifiedDate;*/
public ServiceList() {
-
+ // Empty constructor
}
public ServiceList(String string, String userid) {
this(domain);
}
public ServiceList(String domain) {
-
+ // Empty constructor
}
@PrePersist
public void prePersist() {
-
+ // Empty function
}
@PreUpdate
public void preUpdate() {
+ // Empty function
}
private static Log LOGGER = LogFactory.getLog(TermList.class);
public TermList() {
-
+ // Empty constructor
}
private static final Log auditLogger = LogFactory
public VMType() {
-
+ // Empty constructor
}
public VMType(String string, String userid) {
this(domain);
}
public VMType(String domain) {
-
+ // Empty constructor
}
@PrePersist
public void prePersist() {
-
+ // Empty function
}
@PreUpdate
public void preUpdate() {
+ // Empty function
}
public String getDescription() {
private static Log LOGGER = LogFactory.getLog(VNFType.class);
public VNFType() {
-
+ // Empty constructor
}
public String getVnftype() {
private static Log LOGGER = LogFactory.getLog(VSCLAction.class);
public VSCLAction() {
-
+ // Empty constructor
}
public VSCLAction(String string, String userid) {
private static Log LOGGER = LogFactory.getLog(VarbindDictionary.class);
public VarbindDictionary() {
-
+ // Empty constructor
}
public VarbindDictionary(String string, String userid) {
return false;
}
- return(id == ((WatchPolicyNotificationTable)obj).id &&
+ return id == ((WatchPolicyNotificationTable)obj).id &&
policyName.equals(((WatchPolicyNotificationTable)obj).policyName) &&
- loginIds.equals(((WatchPolicyNotificationTable)obj).loginIds)
- );
+ loginIds.equals(((WatchPolicyNotificationTable)obj).loginIds);
}
public Zone() {
-
+ // Empty constructor
}
public Zone(String string, String userid) {
this(domain);
}
public Zone(String domain) {
-
+ // Empty constructor
}
@PrePersist
public void prePersist() {
-
+ // Empty function
}
@PreUpdate
public void preUpdate() {
+ // Empty function
}
public class MSAttributeObject {
private String className;
- private HashMap<String, String> attribute = new HashMap<>();
- private HashMap<String, String> refAttribute = new HashMap<>();
- private HashMap<String, Object> subClass = new HashMap<>();
+ private Map<String, String> attribute = new HashMap<>();
+ private Map<String, String> refAttribute = new HashMap<>();
+ private Map<String, Object> subClass = new HashMap<>();
private String dependency;
- private HashMap<String, String> enumType = new HashMap<>();
- private HashMap<String, String> matchingSet = new HashMap<>();
+ private Map<String, String> enumType = new HashMap<>();
+ private Map<String, String> matchingSet = new HashMap<>();
private boolean policyTempalate;
public Map<String, String> getRefAttribute() {
return refAttribute;
}
- public void setRefAttribute(HashMap<String, String> refAttribute) {
+ public void setRefAttribute(Map<String, String> refAttribute) {
this.refAttribute = refAttribute;
}
public String getClassName() {
public Map<String, String> getAttribute() {
return attribute;
}
- public void setAttribute(HashMap<String, String> attribute) {
+ public void setAttribute(Map<String, String> attribute) {
this.attribute = attribute;
}
- public HashMap<String, String> getEnumType() {
+ public Map<String, String> getEnumType() {
return enumType;
}
- public void setEnumType(HashMap<String, String> enumType) {
+ public void setEnumType(Map<String, String> enumType) {
this.enumType = enumType;
}
public void addAttribute(String key, String value){
public void addAllRefAttribute(Map<String, String> map){
this.refAttribute.putAll(map);
}
- public HashMap<String, Object> getSubClass() {
+ public Map<String, Object> getSubClass() {
return subClass;
}
- public void setSubClass(HashMap<String, Object> subClass) {
+ public void setSubClass(Map<String, Object> subClass) {
this.subClass = subClass;
}
- public void addAllSubClass(HashMap<String, Object> subClass){
+ public void addAllSubClass(Map<String, Object> subClass){
this.subClass.putAll(subClass);
}
public String getDependency() {
public void addSingleEnum(String key, String value){
this.enumType.put(key, value);
}
- public HashMap<String, String> getMatchingSet() {
+ public Map<String, String> getMatchingSet() {
return matchingSet;
}
- public void setMatchingSet(HashMap<String, String> matchingSet) {
+ public void setMatchingSet(Map<String, String> matchingSet) {
this.matchingSet = matchingSet;
}
public void addMatchingSet(String key, String value){
this.matchingSet.put(key, value);
}
- public void addMatchingSet(HashMap<String, String> matchingSet){
+ public void addMatchingSet(Map<String, String> matchingSet){
this.matchingSet.putAll(matchingSet);
}
public boolean isPolicyTempalate() {
};
- public HashMap<String, MSAttributeObject> processEpackage(String file, MODEL_TYPE model){
+ public Map<String, MSAttributeObject> processEpackage(String file, MODEL_TYPE model){
if (model == MODEL_TYPE.XMI ){
processXMIEpackage(file);
}
private void processXMIEpackage(String xmiFile){
EPackage root = getEpackage(xmiFile);
TreeIterator<EObject> treeItr = root.eAllContents();
- String className = null;
- String returnValue = null;
+ String className;
+ String returnValue;
// Pulling out dependency from file
while (treeItr.hasNext()) {
private void UpdateMatching(HashMap<String, String> tempAttribute, String key) {
- Map<String, MSAttributeObject> newClass = null;
-
- newClass = classMap;
+ Map<String, MSAttributeObject> newClass = classMap;
for (Entry<String, MSAttributeObject> updateClass : newClass.entrySet()){
- HashMap<String, String> valueMap = updateClass.getValue().getMatchingSet();
+ Map<String, String> valueMap = updateClass.getValue().getMatchingSet();
String keymap = updateClass.getKey();
if (valueMap.containsKey(key)){
- HashMap<String, String> modifyMap = classMap.get(keymap).getMatchingSet();
+ Map<String, String> modifyMap = classMap.get(keymap).getMatchingSet();
modifyMap.remove(key);
modifyMap.putAll(tempAttribute);
classMap.get(keymap).setMatchingSet(modifyMap);
m.put("xmi", new XMIResourceFactoryImpl());
Resource resource = resSet.getResource(URI.createFileURI(xmiFile), true);
try {
- resource.load(Collections.EMPTY_MAP);
+ resource.load(Collections.emptyMap());
} catch (IOException e) {
logger.error("Error loading Encore Resource for new Model" + e);
}
public void getAttributes(String className, String dependency, EPackage root) {
List<String> dpendList = new ArrayList<>();
if (dependency!=null){
- dpendList = new ArrayList<String>(Arrays.asList(dependency.split(",")));
+ dpendList = new ArrayList<>(Arrays.asList(dependency.split(",")));
}
MSAttributeObject msAttributeObject = new MSAttributeObject();
msAttributeObject.setClassName(className);
String extendClass = getSubTypes(root, className);
- HashMap<String, String> returnRefList = getRefAttributeList(root, className, extendClass);
- HashMap<String, String> returnAttributeList = getAttributeList(root, className, extendClass);
- HashMap<String, Object> returnSubList = getSubAttributeList(root, className, extendClass);
+ Map<String, String> returnRefList = getRefAttributeList(root, className, extendClass);
+ Map<String, String> returnAttributeList = getAttributeList(root, className, extendClass);
+ Map<String, Object> returnSubList = getSubAttributeList(root, className, extendClass);
HashMap<String, String> returnAnnotation = getAnnotation(root, className, extendClass);
msAttributeObject.setAttribute(returnAttributeList);
msAttributeObject.setRefAttribute(returnRefList);
boolean requiredAttribute = false;
boolean requiredMatchAttribute = false;
HashMap<String, String> annotationSet = new HashMap<>();
- String matching = null;
- String range = null;
- String dictionary = null;
+ String matching;
+ String range;
+ String dictionary;
// Pulling out dependency from file
while (treeItr.hasNext()) {
if (requiredAttribute){
if (obj instanceof EStructuralFeature) {
EStructuralFeature eStrucClassifier = (EStructuralFeature) obj;
- if (eStrucClassifier.getEAnnotations().size() != 0) {
+ if (!eStrucClassifier.getEAnnotations().isEmpty()) {
matching = annotationValue(eStrucClassifier, ANNOTATION_TYPE.MATCHING, policy);
if (matching!=null){
annotationSet.put(eStrucClassifier.getName(), matching);
} else if (requiredMatchAttribute){
if (obj instanceof EStructuralFeature) {
EStructuralFeature eStrucClassifier = (EStructuralFeature) obj;
- if (eStrucClassifier.getEAnnotations().size() != 0) {
+ if (!eStrucClassifier.getEAnnotations().isEmpty()) {
matching = annotationValue(eStrucClassifier, ANNOTATION_TYPE.MATCHING, policy);
if (matching!=null){
if (obj instanceof EReference){
return annotationSet;
}
- private HashMap<String, Object> getSubAttributeList(EPackage root, String className , String superClass) {
+ private Map<String, Object> getSubAttributeList(EPackage root, String className , String superClass) {
TreeIterator<EObject> treeItr = root.eAllContents();
boolean requiredAttribute = false;
- HashMap<String, Object> subAttribute = new HashMap<String, Object>();
+ Map<String, Object> subAttribute = new HashMap<>();
int rollingCount = 0;
int processClass = 0;
- boolean annotation = false;
+ boolean annotation;
// Pulling out dependency from file
while (treeItr.hasNext() && rollingCount < 2) {
if (requiredAttribute) {
if (obj instanceof EStructuralFeature) {
EStructuralFeature eStrucClassifier = (EStructuralFeature) obj;
- if (eStrucClassifier.getEAnnotations().size() != 0) {
+ if (!eStrucClassifier.getEAnnotations().isEmpty()) {
annotation = annotationTest(eStrucClassifier, configuration, onap);
if (annotation && obj instanceof EReference) {
EClass refType = ((EReference) obj).getEReferenceType();
return ":required-false";
}
- public JSONObject buildJavaObject(HashMap<String, String> map, String attributeType){
+ public JSONObject buildJavaObject(Map<String, String> map){
JSONObject returnValue = new JSONObject(map);
}
- public HashMap<String, String> getRefAttributeList(EPackage root, String className, String superClass){
+ public Map<String, String> getRefAttributeList(EPackage root, String className, String superClass){
TreeIterator<EObject> treeItr = root.eAllContents();
boolean requiredAttribute = false;
HashMap<String, String> refAttribute = new HashMap<>();
int rollingCount = 0;
int processClass = 0;
- boolean annotation = false;
+ boolean annotation;
// Pulling out dependency from file
while (treeItr.hasNext()) {
EObject obj = treeItr.next();
if (requiredAttribute) {
if (obj instanceof EStructuralFeature) {
EStructuralFeature eStrucClassifier = (EStructuralFeature) obj;
- if (eStrucClassifier.getEAnnotations().size() != 0) {
+ if (!eStrucClassifier.getEAnnotations().isEmpty()) {
annotation = annotationTest(eStrucClassifier, configuration, onap);
if ( annotation && obj instanceof EReference) {
EClass refType = ((EReference) obj).getEReferenceType();
}
private boolean annotationTest(EStructuralFeature eStrucClassifier, String annotation, String type) {
- String annotationType = null;
- EAnnotation eAnnotation = null;
- String onapType = null;
- String onapValue = null;
+ String annotationType;
+ EAnnotation eAnnotation;
+ String onapType;
+ String onapValue;
EList<EAnnotation> value = eStrucClassifier.getEAnnotations();
private String annotationValue(EStructuralFeature eStrucClassifier, ANNOTATION_TYPE annotation, String type) {
- String annotationType = null;
- EAnnotation eAnnotation = null;
- String onapType = null;
+ String annotationType;
+ EAnnotation eAnnotation;
+ String onapType;
String onapValue = null;
EList<EAnnotation> value = eStrucClassifier.getEAnnotations();
return returnSubTypes;
}
- public HashMap<String, String> getAttributeList(EPackage root, String className, String superClass){
+ public Map<String, String> getAttributeList(EPackage root, String className, String superClass){
TreeIterator<EObject> treeItr = root.eAllContents();
boolean requiredAttribute = false;
HashMap<String, String> refAttribute = new HashMap<>();
- boolean annotation = false;
- boolean dictionaryTest = false;
- String defaultValue = null;
- String eType = null;
+ boolean annotation;
+ boolean dictionaryTest;
+ String defaultValue;
+ String eType;
// Pulling out dependency from file
while (treeItr.hasNext()) {
if (requiredAttribute){
if (obj instanceof EStructuralFeature) {
EStructuralFeature eStrucClassifier = (EStructuralFeature) obj;
- if (eStrucClassifier.getEAnnotations().size() != 0) {
+ if (!eStrucClassifier.getEAnnotations().isEmpty()) {
annotation = annotationTest(eStrucClassifier, configuration, onap);
dictionaryTest = annotationTest(eStrucClassifier, dictionary, policy);
EClassifier refType = ((EStructuralFeature) obj).getEType();
return returnValue;
}
- public Map<String, String> buildSubList(HashMap<String, String> subClassAttributes, HashMap<String, MSAttributeObject> classMap, String className){
+ public Map<String, String> buildSubList(Map<String, String> subClassAttributes, Map<String, MSAttributeObject> classMap, String className){
Map<String, String> missingValues = new HashMap<>();
- Map<String, String> workingMap = new HashMap<>();
+ Map<String, String> workingMap;
boolean enumType;
for ( Entry<String, String> map : classMap.get(className).getRefAttribute().entrySet()){
return missingValues;
}
- public Map<String, HashMap<String, String>> recursiveReference(HashMap<String, MSAttributeObject> classMap, String className){
+ public Map<String, Map<String, String>> recursiveReference(Map<String, MSAttributeObject> classMap, String className){
- Map<String, HashMap<String, String>> returnObject = new HashMap<>();
- HashMap<String, String> returnClass = getRefclass(classMap, className);
+ Map<String, Map<String, String>> returnObject = new HashMap<>();
+ Map<String, String> returnClass = getRefclass(classMap, className);
returnObject.put(className, returnClass);
for (Entry<String, String> reAttribute :returnClass.entrySet()){
if (reAttribute.getValue().split(":")[1].contains("MANY")){
}
- public String createJson(HashMap<String, Object> subClassAttributes, HashMap<String, MSAttributeObject> classMap, String className) {
+ public String createJson(Map<String, Object> subClassAttributes, Map<String, MSAttributeObject> classMap, String className) {
boolean enumType;
- Map<String, HashMap<String, String>> myObject = new HashMap<>();
+ Map<String, Map<String, String>> myObject = new HashMap<>();
for ( Entry<String, String> map : classMap.get(className).getRefAttribute().entrySet()){
String value = map.getValue().split(":")[0];
if (value!=null){
enumType = classMap.get(className).getEnumType().containsKey(value);
if (!enumType){
if (map.getValue().split(":")[1].contains("MANY")){
- Map<String, HashMap<String, String>> testRecursive = recursiveReference(classMap, map.getValue().split(":")[0] );
+ Map<String, Map<String, String>> testRecursive = recursiveReference(classMap, map.getValue().split(":")[0] );
myObject.putAll(testRecursive);
}
}
return json;
}
- public HashMap<String, String> getRefclass(HashMap<String, MSAttributeObject> classMap, String className){
+ public Map<String, String> getRefclass(Map<String, MSAttributeObject> classMap, String className){
HashMap<String, String> missingValues = new HashMap<>();
if (classMap.get(className).getAttribute()!=null || !classMap.get(className).getAttribute().isEmpty()){
return missingValues;
}
- public String createSubAttributes(ArrayList<String> dependency, HashMap<String, MSAttributeObject> classMap, String modelName) {
+ public String createSubAttributes(List<String> dependency, Map<String, MSAttributeObject> classMap, String modelName) {
HashMap <String, Object> workingMap = new HashMap<>();
- MSAttributeObject tempObject = new MSAttributeObject();
+ MSAttributeObject tempObject;
if (dependency!=null){
- if (dependency.size()==0){
+ if (dependency.isEmpty()){
return "{}";
}
dependency.add(modelName);
return returnValue;
}
- public ArrayList<String> getFullDependencyList(ArrayList<String> dependency, HashMap<String,MSAttributeObject > classMap) {
+ public List<String> getFullDependencyList(List<String> dependency, Map<String,MSAttributeObject > classMap) {
ArrayList<String> returnList = new ArrayList<>();
- ArrayList<String> workingList = new ArrayList<>();
+ ArrayList<String> workingList;
returnList.addAll(dependency);
for (String element : dependency ){
if (classMap.containsKey(element)){
MSAttributeObject value = classMap.get(element);
String rawValue = StringUtils.replaceEach(value.getDependency(), new String[]{"[", "]"}, new String[]{"", ""});
- workingList = new ArrayList<String>(Arrays.asList(rawValue.split(",")));
+ workingList = new ArrayList<>(Arrays.asList(rawValue.split(",")));
for(String depend : workingList){
if (!returnList.contains(depend) && !depend.isEmpty()){
returnList.add(depend.trim());
/*
* This is an empty constructor
*/
- public PolicyValidation(){}
+ public PolicyValidation(){
+ // Empty constructor
+ }
public StringBuilder validatePolicy(PolicyRestAdapter policyData) throws IOException{
String configBodyData = policyData.getConfigBodyData();
String configType = policyData.getConfigType();
if (configType != null) {
- if (configType.equals("JSON")) {
+ if ("JSON".equals(configType)) {
if (!PolicyUtils.isJSONValid(configBodyData)) {
responseString.append("Config Body: JSON Content is not valid" + "<br>");
valid = false;
}
- } else if (configType.equals("XML")) {
+ } else if ("XML".equals(configType)) {
if (!PolicyUtils.isXMLValid(configBodyData)) {
responseString.append("Config Body: XML Content data is not valid" + "<br>");
valid = false;
}
- } else if (configType.equals("PROPERTIES")) {
+ } else if ("PROPERTIES".equals(configType)) {
if (!PolicyUtils.isPropValid(configBodyData)||configBodyData.equals("")) {
responseString.append("Config Body: Property data is not valid" + "<br>");
valid = false;
if(!Strings.isNullOrEmpty(policyData.getServiceType())){
pullJsonKeyPairs((JsonNode) policyData.getPolicyJSON());
- String service = null;
- String version = null;
+ String service;
+ String version;
if (policyData.getServiceType().contains("-v")){
service = policyData.getServiceType().split("-v")[0];
version = policyData.getServiceType().split("-v")[1];
}
protected String emailValidation(String email, String response){
+ String res = response;
if(email != null){
String validateEmail = PolicyUtils.validateEmailAddress(email.replace("\"", ""));
if(!validateEmail.contains(SUCCESS)){
- response += "<b>Email</b>:<i>" + validateEmail + HTML_ITALICS_LNBREAK;
- }else{
+ res += "<b>Email</b>:<i>" + validateEmail + HTML_ITALICS_LNBREAK;
+ }
+ else {
return SUCCESS;
}
}
- return response;
+ return res;
}
private MicroServiceModels getAttributeObject(String name, String version) {
JsonNode root = mapper.readTree(request.getReader());
policyData = mapper.readValue(root.get("policyData").toString(), PolicyRestAdapter.class);
- JsonObject json = null;
+ JsonObject json;
json = stringToJsonObject(root.toString());
if(json != null){
} else if("Action".equals(parameters.getPolicyClass().toString())){
- ArrayList<Object> ruleAlgorithmChoices = new ArrayList<Object>();
+ ArrayList<Object> ruleAlgorithmChoices = new ArrayList<>();
List<String> dynamicLabelRuleAlgorithms = parameters.getDynamicRuleAlgorithmLabels();
List<String> dynamicFieldFunctionRuleAlgorithms = parameters.getDynamicRuleAlgorithmFunctions();
List<String> dynamicFieldOneRuleAlgorithms = parameters.getDynamicRuleAlgorithmField1();
List<String> dyrnamicFieldTwoRuleAlgorithms = parameters.getDynamicRuleAlgorithmField2();
- if (dynamicLabelRuleAlgorithms != null && dynamicLabelRuleAlgorithms.size() > 0) {
+ if (dynamicLabelRuleAlgorithms != null && !dynamicLabelRuleAlgorithms.isEmpty()) {
int i = dynamicLabelRuleAlgorithms.size() - 1;
for (String labelAttr : dynamicLabelRuleAlgorithms) {
}
- private JsonObject stringToJsonObject(String value)
- throws JsonException, IllegalStateException {
-
- try{
- JsonReader jsonReader = Json.createReader(new StringReader(value));
- JsonObject object = jsonReader.readObject();
- jsonReader.close();
- return object;
+ private JsonObject stringToJsonObject(String value) {
+
+ try(JsonReader jsonReader = Json.createReader(new StringReader(value))){
+ return jsonReader.readObject();
} catch(JsonException| IllegalStateException e){
LOGGER.info(XACMLErrorConstants.ERROR_DATA_ISSUE+ "Improper JSON format... may or may not cause issues in validating the policy: " + value, e);
return null;
import com.att.research.xacml.util.XACMLProperties;
+/**
+ * What is not good about this class is that once a value has been set for pdpProperties path
+ * you cannot change it. That may be ok for a highly controlled production environment in which
+ * nothing changes, but not a very good implementation.
+ *
+ * The reset() method has been added to assist with the above problem in order to
+ * acquire >80% JUnit code coverage.
+ *
+ * This static class doesn't really check a PDP, it simply loads a properties file and tried
+ * to ensure that a valid URL exists for a PDP along with user/password.
+ *
+ */
public class CheckPDP {
private static Path pdpPath = null;
private static Long oldModified = null;
public static Map<String, String> getPdpMap() {
return pdpMap;
}
+
+ private static void reset() {
+ pdpPath = null;
+ oldModified = null;
+ pdpMap = null;
+ }
public static boolean validateID(String id) {
// ReadFile
LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e);
return false;
}
+ if (pdpMap == null) {
+ return false;
+ }
// Check ID
return pdpMap.containsKey(id);
}
}
if (pdpPath == null) {
pdpPath = Paths.get(pdpFile);
- if (!pdpPath.toFile().exists()) {
+ if (!pdpPath.toString().endsWith(".properties") || !pdpPath.toFile().exists()) {
LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "File doesn't exist in the specified Path : " + pdpPath.toString());
-
- }
- if (pdpPath.toString().endsWith(".properties")) {
- readProps();
- } else {
- LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Not a .properties file " + pdpFile);
+ CheckPDP.reset();
+ return;
}
+ readProps();
}
// Check if File is updated recently
else {
for (String propKey : sorted) {
loadPDPProperties(propKey, pdpProp);
}
- if (pdpMap == null || pdpMap.isEmpty()) {
- LOGGER.debug(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Cannot Proceed without PDP_URLs");
- }
in.close();
} catch (IOException e) {
LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e);
}
+ if (pdpMap == null || pdpMap.isEmpty()) {
+ LOGGER.debug(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Cannot Proceed without PDP_URLs");
+ CheckPDP.reset();
+ }
}
private static void loadPDPProperties(String propKey, Properties pdpProp){
private static final Logger LOGGER = FlexLogger.getLogger(PolicyAdapter.class);
public void configure(PolicyRestAdapter policyAdapter, PolicyEntity entity) {
- String policyNameValue;
- String configPolicyName = null ;
if(extendedOptions(policyAdapter, entity)){
return;
}
+ String policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf('_'));
+ String configPolicyName = null ;
if(policyAdapter.getPolicyName().startsWith("Config_PM")){
- policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf('_'));
configPolicyName = "ClosedLoop_PM";
}else if(policyAdapter.getPolicyName().startsWith("Config_Fault")){
- policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf('_'));
configPolicyName = "ClosedLoop_Fault";
}else if(policyAdapter.getPolicyName().startsWith("Config_FW")){
- policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf('_'));
configPolicyName = "Firewall Config";
}else if(policyAdapter.getPolicyName().startsWith("Config_BRMS_Raw")){
- policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf('_'));
configPolicyName = "BRMS_Raw";
}else if(policyAdapter.getPolicyName().startsWith("Config_BRMS_Param")){
- policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf('_'));
configPolicyName = "BRMS_Param";
}else if(policyAdapter.getPolicyName().startsWith("Config_MS")){
- policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf('_'));
configPolicyName = "Micro Service";
}else if(policyAdapter.getPolicyName().startsWith("Action") || policyAdapter.getPolicyName().startsWith("Decision") ){
- policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf('_'));
+ // No configPolicyName is applicable
}else{
- policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf('_'));
configPolicyName = "Base";
}
if (policyNameValue != null) {
}
if("Action".equalsIgnoreCase(policyAdapter.getPolicyType())){
- ActionPolicyController actionController = new ActionPolicyController();
- actionController.prePopulateActionPolicyData(policyAdapter, entity);
+ new ActionPolicyController().prePopulateActionPolicyData(policyAdapter, entity);
}
if("Decision".equalsIgnoreCase(policyAdapter.getPolicyType())){
- DecisionPolicyController decisionController = new DecisionPolicyController();
- decisionController.prePopulateDecisionPolicyData(policyAdapter, entity);
+ new DecisionPolicyController().prePopulateDecisionPolicyData(policyAdapter, entity);
}
if("Config".equalsIgnoreCase(policyAdapter.getPolicyType())){
if("Base".equalsIgnoreCase(policyAdapter.getConfigPolicyType())){
- CreatePolicyController baseController = new CreatePolicyController();
- baseController.prePopulateBaseConfigPolicyData(policyAdapter, entity);
+ new CreatePolicyController().prePopulateBaseConfigPolicyData(policyAdapter, entity);
}
else if("BRMS_Raw".equalsIgnoreCase(policyAdapter.getConfigPolicyType())){
- CreateBRMSRawController brmsController = new CreateBRMSRawController();
- brmsController.prePopulateBRMSRawPolicyData(policyAdapter, entity);
+ new CreateBRMSRawController().prePopulateBRMSRawPolicyData(policyAdapter, entity);
}
else if("BRMS_Param".equalsIgnoreCase(policyAdapter.getConfigPolicyType())){
- CreateBRMSParamController paramController = new CreateBRMSParamController();
- paramController.prePopulateBRMSParamPolicyData(policyAdapter, entity);
+ new CreateBRMSParamController().prePopulateBRMSParamPolicyData(policyAdapter, entity);
}
else if("ClosedLoop_Fault".equalsIgnoreCase(policyAdapter.getConfigPolicyType())){
- CreateClosedLoopFaultController newFaultTemplate = new CreateClosedLoopFaultController();
- newFaultTemplate.prePopulateClosedLoopFaultPolicyData(policyAdapter, entity);
+ new CreateClosedLoopFaultController().prePopulateClosedLoopFaultPolicyData(policyAdapter, entity);
}
else if("ClosedLoop_PM".equalsIgnoreCase(policyAdapter.getConfigPolicyType())){
- CreateClosedLoopPMController pmController = new CreateClosedLoopPMController();
- pmController.prePopulateClosedLoopPMPolicyData(policyAdapter, entity);
+ new CreateClosedLoopPMController().prePopulateClosedLoopPMPolicyData(policyAdapter, entity);
}
else if("Micro Service".equalsIgnoreCase(policyAdapter.getConfigPolicyType())){
- CreateDcaeMicroServiceController msController = new CreateDcaeMicroServiceController();
- msController.prePopulateDCAEMSPolicyData(policyAdapter, entity);
+ new CreateDcaeMicroServiceController().prePopulateDCAEMSPolicyData(policyAdapter, entity);
}
else if("Firewall Config".equalsIgnoreCase(policyAdapter.getConfigPolicyType())){
- CreateFirewallController firewallController = new CreateFirewallController();
- firewallController.prePopulateFWPolicyData(policyAdapter, entity);
+ new CreateFirewallController().prePopulateFWPolicyData(policyAdapter, entity);
}
}
}
}
return null;
}
-
-
}
import org.onap.policy.components.HumanPolicyComponent;
import org.onap.policy.controller.PolicyController;
import org.onap.policy.controller.PolicyExportAndImportController;
-import org.onap.policy.model.Roles;
import org.onap.policy.rest.XACMLRest;
import org.onap.policy.rest.XACMLRestProperties;
import org.onap.policy.rest.adapter.PolicyRestAdapter;
import org.onap.policy.rest.jpa.PolicyVersion;
import org.onap.policy.rest.jpa.UserInfo;
import org.onap.policy.utils.PolicyUtils;
+import org.onap.policy.utils.UserUtils.Pair;
import org.onap.policy.xacml.api.XACMLErrorConstants;
import org.onap.policy.xacml.util.XACMLPolicyScanner;
import org.onap.portalsdk.core.web.support.UserUtils;
}
private JSONObject searchPolicyList(JSONObject params, HttpServletRequest request) {
- Set<String> scopes = null;
- List<String> roles = null;
+ Set<String> scopes;
+ List<String> roles;
List<Object> policyData = new ArrayList<>();
JSONArray policyList = null;
if(params.has("policyList")){
try {
//Get the Login Id of the User from Request
String userId = UserUtils.getUserSession(request).getOrgUserId();
- //Check if the Role and Scope Size are Null get the values from db.
List<Object> userRoles = controller.getRoles(userId);
- roles = new ArrayList<>();
- scopes = new HashSet<>();
- for(Object role: userRoles){
- Roles userRole = (Roles) role;
- roles.add(userRole.getRole());
- if(userRole.getScope() != null){
- if(userRole.getScope().contains(",")){
- String[] multipleScopes = userRole.getScope().split(",");
- for(int i =0; i < multipleScopes.length; i++){
- scopes.add(multipleScopes[i]);
- }
- }else{
- scopes.add(userRole.getScope());
- }
- }
- }
+ Pair<Set<String>, List<String>> pair = org.onap.policy.utils.UserUtils.checkRoleAndScope(userRoles);
+ roles = pair.u;
+ scopes = pair.t;
if (roles.contains(ADMIN) || roles.contains(EDITOR) || roles.contains(GUEST) ) {
if(scopes.isEmpty()){
return error("No Scopes has been Assigned to the User. Please, Contact Super-Admin");
policyName = removeExtension.substring(0, removeExtension.lastIndexOf('.'));
}
- String activePolicy = null;
+ String activePolicy;
PolicyController controller = getPolicyControllerInstance();
if(params.toString().contains("activeVersion")){
String activeVersion = params.getString("activeVersion");
//Get the Login Id of the User from Request
String testUserID = getTestUserId();
String userId = testUserID != null ? testUserID : UserUtils.getUserSession(request).getOrgUserId();
- //Check if the Role and Scope Size are Null get the values from db.
List<Object> userRoles = controller.getRoles(userId);
- roles = new ArrayList<>();
- scopes = new HashSet<>();
- for(Object role: userRoles){
- Roles userRole = (Roles) role;
- roles.add(userRole.getRole());
- if(userRole.getScope() != null){
- if(userRole.getScope().contains(",")){
- String[] multipleScopes = userRole.getScope().split(",");
- for(int i =0; i < multipleScopes.length; i++){
- scopes.add(multipleScopes[i]);
- }
- }else{
- scopes.add(userRole.getScope());
- }
- }
- }
+ Pair<Set<String>, List<String>> pair = org.onap.policy.utils.UserUtils.checkRoleAndScope(userRoles);
+ roles = pair.u;
+ scopes = pair.t;
List<JSONObject> resultList = new ArrayList<>();
boolean onlyFolders = params.getBoolean("onlyFolders");
}
private List<Object> queryPolicyEditorScopes(String scopeName){
- String scopeNamequery = "";
+ String scopeNamequery;
SimpleBindings params = new SimpleBindings();
if(scopeName == null){
scopeNamequery = "from PolicyEditorScopes";
params.put("scopeName", scopeName + "%");
}
PolicyController controller = getPolicyControllerInstance();
- List<Object> scopesList = null;
+ List<Object> scopesList;
if(PolicyController.isjUnit()){
scopesList = controller.getDataByQuery(scopeNamequery, null);
}else{
SimpleBindings params = new SimpleBindings();
params.put("scopeName", scopeName + "%");
- List<Object> activePolicies = null;
- List<Object> scopesList = null;
+ List<Object> activePolicies;
+ List<Object> scopesList;
if(PolicyController.isjUnit()){
activePolicies = controller.getDataByQuery(query, null);
scopesList = controller.getDataByQuery(scopeNamequery, null);
}
}
}
- String scopeNameCheck = null;
+ String scopeNameCheck;
for (Object list : activePolicies) {
PolicyVersion policy = (PolicyVersion) list;
String scopeNameValue = policy.getPolicyName().substring(0, policy.getPolicyName().lastIndexOf(File.separator));
private JSONObject policyRename(String oldPath, String newPath, String userId) throws ServletException {
try {
- PolicyEntity entity = null;
+ PolicyEntity entity;
PolicyController controller = getPolicyControllerInstance();
String policyVersionName = newPath.replace(".xml", "");
private JSONObject cloneRecord(String newpolicyName, String oldScope, String removeoldPolicyExtension, String newScope, String removenewPolicyExtension, PolicyEntity entity, String userId) throws ServletException{
FileWriter fw = null;
- String queryEntityName = null;
+ String queryEntityName;
PolicyController controller = getPolicyControllerInstance();
PolicyEntity cloneEntity = new PolicyEntity();
cloneEntity.setPolicyName(newpolicyName);
path = path.substring(path.indexOf('/')+1);
String policyNamewithExtension = path.replace("/", File.separator);
String policyVersionName = policyNamewithExtension.replace(".xml", "");
- String query = "";
+ String query;
SimpleBindings policyParams = new SimpleBindings();
if(path.endsWith(".xml")){
policyNamewithoutExtension = policyVersionName.substring(0, policyVersionName.lastIndexOf('.'));
SimpleBindings peParams = new SimpleBindings();
peParams.put("split_1", split[1]);
peParams.put("split_0", split[0]);
- List<Object> queryData = null;
+ List<Object> queryData;
if(PolicyController.isjUnit()){
queryData = controller.getDataByQuery(query, null);
}else{
}
}
if(sendFlag){
- AnnotationConfigApplicationContext ctx = null;
- try {
+ try (AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext()) {
to = list.getLoginIds()+"@"+PolicyController.getSmtpEmailExtension();
to = to.trim();
- ctx = new AnnotationConfigApplicationContext();
ctx.register(PolicyNotificationMail.class);
ctx.refresh();
JavaMailSenderImpl mailSender = ctx.getBean(JavaMailSenderImpl.class);
mailMsg.setSubject(subject);
mailMsg.setText(message);
mailSender.send(mimeMessage);
- if(mode.equalsIgnoreCase("Rename") || mode.contains("Delete") || mode.contains("Move")){
+ if("Rename".equalsIgnoreCase(mode) || mode.contains("Delete") || mode.contains("Move")){
policyNotificationDao.delete(watch);
}
} catch (Exception e) {
policyLogger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW+"Exception Occured in Policy Notification" +e);
- }finally{
- if(ctx != null){
- ctx.close();
- }
}
}
}
if(policyData.getConfigPolicyType() != null){
if("ClosedLoop_Fault".equalsIgnoreCase(policyData.getConfigPolicyType())){
- CreateClosedLoopFaultController faultController = new CreateClosedLoopFaultController();
- policyData = faultController.setDataToPolicyRestAdapter(policyData, root);
+ policyData = new CreateClosedLoopFaultController().setDataToPolicyRestAdapter(policyData, root);
}else if("Firewall Config".equalsIgnoreCase(policyData.getConfigPolicyType())){
- CreateFirewallController fwController = new CreateFirewallController();
- policyData = fwController.setDataToPolicyRestAdapter(policyData);
+ policyData = new CreateFirewallController().setDataToPolicyRestAdapter(policyData);
}else if("Micro Service".equalsIgnoreCase(policyData.getConfigPolicyType())){
- CreateDcaeMicroServiceController msController = new CreateDcaeMicroServiceController();
- policyData = msController.setDataToPolicyRestAdapter(policyData, root);
+ policyData = new CreateDcaeMicroServiceController().setDataToPolicyRestAdapter(policyData, root);
}
}
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
-import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.nio.file.Path;
}
private static String processPolicy() {
- if (LOGGER.isTraceEnabled())
+ if (LOGGER.isTraceEnabled()) {
LOGGER.trace("ENTER");
-
- FileInputStream pIS = null;
- try {
- pIS = new FileInputStream(policyFile);
+ }
+ try (FileInputStream pIS = new FileInputStream(policyFile)){
Object policy = XACMLPolicyScanner.readPolicy(pIS);
if (policy == null)
throw new IllegalArgumentException("Policy File " + policyFile.getName() +
": " + e.getMessage();
LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + msg, e);
throw new IllegalArgumentException(msg);
- } finally {
- if (pIS != null) {
- try {
- pIS.close();
- } catch (IOException e) {
- LOGGER.warn(e.getMessage(), e);
- }
- }
}
}
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import javax.xml.bind.JAXBElement;
AttributeValueType attributeValue = (AttributeValueType) attributeAssignmentExpression
.getExpression().getValue();
if (attributeID.equals(PERFORMER_ATTRIBUTEID)) {
- for (String key : performer.keySet()) {
- String keyValue = performer.get(key);
+ for ( Entry<String, String> entry: performer.entrySet()) {
+ String key = entry.getKey();
+ String keyValue = entry.getValue();
if (keyValue.equals(attributeValue.getContent().get(0))) {
policyAdapter.setActionPerformer(key);
}
ruleMap.put("id", "A" + (index + 1));
// Populate combo box
Map<String, String> dropDownMap = PolicyController.getDropDownMap();
- for (String key : dropDownMap.keySet()) {
- String keyValue = dropDownMap.get(key);
- if (keyValue.equals(actionApply.getFunctionId())) {
- ruleMap.put("dynamicRuleAlgorithmCombo", key);
+ for ( Entry<String, String> entry : dropDownMap.entrySet()) {
+ if (entry.getValue().equals(actionApply.getFunctionId())) {
+ ruleMap.put("dynamicRuleAlgorithmCombo", entry.getKey());
}
}
// Populate the key and value fields
CreateBRMSParamController.commonClassDao = commonClassDao;
}
- public CreateBRMSParamController(){}
+ public CreateBRMSParamController(){
+ // Empty constructor
+ }
protected PolicyRestAdapter policyAdapter = null;
private HashMap<String, String> dynamicLayoutMap;
String[] components = params.toString().split(":");
String caption = "";
for (int i = 0; i < components.length; i++) {
- String type = "";
+ String type;
if (i == 0) {
caption = components[i];
}
String[] components = params.toString().split("\\);");
if(components!= null && components.length > 0){
for (int i = 0; i < components.length; i++) {
- String value = null;
+ String value;
components[i] = components[i]+")";
String caption = components[i].substring(0,
components[i].indexOf('('));
policyData.setEditPolicy(true);
}
- String body = "";
+ String body;
body = "/* Autogenerated Code Please Don't change/remove this comment section. This is for the UI purpose. \n\t " +
brmsTemplateVlaue + policyData.getRuleName() + "%$> \n */ \n";
AttributeDesignatorType designator = match.getAttributeDesignator();
String attributeId = designator.getAttributeId();
- if (attributeId.equals("RiskType")){
+ if ("RiskType".equals(attributeId)){
policyAdapter.setRiskType(value);
}
- if (attributeId.equals("RiskLevel")){
+ if ("RiskLevel".equals(attributeId)){
policyAdapter.setRiskLevel(value);
}
- if (attributeId.equals("guard")){
+ if ("guard".equals(attributeId)){
policyAdapter.setGuard(value);
}
- if (attributeId.equals("TTLDate") && !value.contains("NA")){
+ if ("TTLDate".equals(attributeId) && !value.contains("NA")){
PolicyController controller = new PolicyController();
String newDate = controller.convertDate(value);
policyAdapter.setTtlDate(newDate);
CreateClosedLoopFaultController.commonclassdao = commonclassdao;
}
- public CreateClosedLoopFaultController(){}
+ public CreateClosedLoopFaultController(){
+ // Empty constructor
+ }
public PolicyRestAdapter setDataToPolicyRestAdapter(PolicyRestAdapter policyData, JsonNode root){
try{
TrapDatas trapDatas = (TrapDatas) object;
ArrayList<Object> attributeList = new ArrayList<>();
// Read the Trap
- if(!trap.equals("nill")){
+ if(! "nill".equals(trap)){
try{
if(trap.startsWith("Trap")){
- if(trap.equals("Trap1")){
+ if("Trap1".equals(trap)){
attributeList = trapDatas.getTrap1();
- }else if(trap.equals("Trap2")){
+ }else if("Trap2".equals(trap)){
attributeList = trapDatas.getTrap2();
- }else if(trap.equals("Trap3")){
+ }else if("Trap3".equals(trap)){
attributeList = trapDatas.getTrap3();
- }else if(trap.equals("Trap4")){
+ }else if("Trap4".equals(trap)){
attributeList = trapDatas.getTrap4();
- }else if(trap.equals("Trap5")){
+ }else if("Trap5".equals(trap)){
attributeList = trapDatas.getTrap5();
- }else if(trap.equals("Trap6")){
+ }else if("Trap6".equals(trap)){
attributeList = trapDatas.getTrap6();
}
}else{
if(trap.startsWith("Fault")){
- if(trap.equals("Fault1")){
+ if("Fault1".equals(trap)){
attributeList = trapDatas.getTrap1();
- }else if(trap.equals("Fault2")){
+ }else if("Fault2".equals(trap)){
attributeList = trapDatas.getTrap2();
- }else if(trap.equals("Fault3")){
+ }else if("Fault3".equals(trap)){
attributeList = trapDatas.getTrap3();
- }else if(trap.equals("Fault4")){
+ }else if("Fault4".equals(trap)){
attributeList = trapDatas.getTrap4();
- }else if(trap.equals("Fault5")){
+ }else if("Fault5".equals(trap)){
attributeList = trapDatas.getTrap5();
- }else if(trap.equals("Fault6")){
+ }else if("Fault6".equals(trap)){
attributeList = trapDatas.getTrap6();
}
}
String attributeId = designator.getAttributeId();
// First match in the target is OnapName, so set that value.
- if (attributeId.equals("ONAPName")) {
+ if ("ONAPName".equals(attributeId)) {
policyAdapter.setOnapName(value);
OnapName onapName = new OnapName();
onapName.setOnapName(value);
policyAdapter.setOnapNameField(onapName);
}
- if (attributeId.equals("RiskType")){
+ if ("RiskType".equals(attributeId)){
policyAdapter.setRiskType(value);
}
- if (attributeId.equals("RiskLevel")){
+ if ("RiskLevel".equals(attributeId)){
policyAdapter.setRiskLevel(value);
}
- if (attributeId.equals("guard")){
+ if ("guard".equals(attributeId)){
policyAdapter.setGuard(value);
}
- if (attributeId.equals("TTLDate") && !value.contains("NA")){
+ if ("TTLDate".equals(attributeId) && !value.contains("NA")){
PolicyController controller = new PolicyController();
String newDate = controller.convertDate(value);
policyAdapter.setTtlDate(newDate);
ObjectMapper mapper = new ObjectMapper();
try {
ClosedLoopFaultBody closedLoopBody = mapper.readValue(entity.getConfigurationData().getConfigBody(), ClosedLoopFaultBody.class);
- if(closedLoopBody.getClosedLoopPolicyStatus().equalsIgnoreCase("ACTIVE")){
+ if("ACTIVE".equalsIgnoreCase(closedLoopBody.getClosedLoopPolicyStatus())){
closedLoopBody.setClosedLoopPolicyStatus("Active");
}else{
closedLoopBody.setClosedLoopPolicyStatus("InActive");
CreateDcaeMicroServiceController.commonClassDao = commonClassDao;
}
- public CreateDcaeMicroServiceController(){}
+ public CreateDcaeMicroServiceController(){
+ // Empty Constructor
+ }
protected PolicyRestAdapter policyAdapter = null;
private int priorityCount;
return settings;
}
- public Map<String, String> load(byte[] source) throws IOException {
+ public Map<String, String> load(byte[] source) {
Yaml yaml = new Yaml();
@SuppressWarnings("unchecked")
Map<Object, Object> yamlMap = (Map<Object, Object>) yaml.load(Arrays.toString(source));
Iterator<String> itr=keys.iterator();
while(itr.hasNext()){
String key= itr.next();
- if((!("type").equals(key) ||("required").equals(key)))
+ if(!("type").equals(key) ||("required").equals(key))
{
String value= keyValues.get(key);
//The "." in the value determines if its a string or a user defined type.
}
- if(keyValues.get("type").equalsIgnoreCase(LIST)){
- if(constraints == null || constraints.isEmpty()){
+ if(keyValues.get("type").equalsIgnoreCase(LIST) &&
+ (constraints == null || constraints.isEmpty()) ) {
referenceStringBuilder.append(keySetString+"=MANY-true"+",");
- }
}
}else{
//User defined Datatype.
JsonNodeFactory nodeFactory = JsonNodeFactory.instance;
ObjectNode node = nodeFactory.objectNode();
String prevKey = null;
- String presKey = null;
- for(String key: element.keySet()){
+ String presKey;
+ for(Entry<String, String> entry: element.entrySet()){
+ String key = entry.getKey();
+ String value = entry.getValue();
if(key.contains(".")){
presKey = key.substring(0,key.indexOf('.'));
}else if(key.contains("@")){
nodeKey = key.substring(0,key.indexOf('.'));
}
if(nodeKey.equals(key.substring(0,key.indexOf('.')))){
- node.put(key.substring(key.indexOf('.')+1), element.get(key));
+ node.put(key.substring(key.indexOf('.')+1), value);
}else{
if(node.size()!=0){
if(nodeKey.contains("@")){
if(nodeKey.contains("@")){
arryKey = nodeKey.substring(0,nodeKey.indexOf('@'));
}
- node.put(key.substring(key.indexOf('.')+1), element.get(key));
+ node.put(key.substring(key.indexOf('.')+1), value);
}
- }else if(node.size()!=0){
- if(nodeKey.contains("@")){
- if(arryKey==null){
- arryKey = nodeKey.substring(0,nodeKey.indexOf('@'));
- }
- if(nodeKey.endsWith("@0")){
- isArray = true;
- jsonArray = new JSONArray();
- }
- if(jsonArray != null && arryKey.equals(nodeKey.substring(0,nodeKey.indexOf('@')))){
- jsonArray.put(decodeContent(node));
- }
- jsonResult.put(arryKey, jsonArray);
- jsonArray = new JSONArray();
- arryKey = nodeKey.substring(0,nodeKey.indexOf('@'));
- }else{
- isArray = false;
- jsonResult.put(nodeKey, decodeContent(node));
- }
- node = nodeFactory.objectNode();
- if(key.contains("@")){
- isArray = true;
- if(key.endsWith("@0")|| jsonArray==null){
+ }else {
+ if(node.size()!=0){
+ if(nodeKey.contains("@")){
+ if(arryKey==null){
+ arryKey = nodeKey.substring(0,nodeKey.indexOf('@'));
+ }
+ if(nodeKey.endsWith("@0")){
+ isArray = true;
+ jsonArray = new JSONArray();
+ }
+ if(jsonArray != null && arryKey.equals(nodeKey.substring(0,nodeKey.indexOf('@')))){
+ jsonArray.put(decodeContent(node));
+ }
+ jsonResult.put(arryKey, jsonArray);
jsonArray = new JSONArray();
- }
- }else if(!key.contains("@")){
- isArray = false;
- }
- if(isArray){
- if(oldValue==null){
- oldValue = key.substring(0,key.indexOf('@'));
- }
- if(oldValue!=prevKey){
- oldValue = key.substring(0,key.indexOf('@'));
- }
- if(oldValue.equals(key.substring(0,key.indexOf('@')))){
- jsonArray.put(element.get(key));
+ arryKey = nodeKey.substring(0,nodeKey.indexOf('@'));
}else{
- jsonResult.put(oldValue, jsonArray);
- jsonArray = new JSONArray();
+ isArray = false;
+ jsonResult.put(nodeKey, decodeContent(node));
}
- oldValue = key.substring(0,key.indexOf('@'));
- }else{
- jsonResult.put(key, element.get(key));
+ node = nodeFactory.objectNode();
}
- }else{
if(key.contains("@")){
isArray = true;
if(key.endsWith("@0")|| jsonArray==null){
oldValue = key.substring(0,key.indexOf('@'));
}
if(oldValue.equals(key.substring(0,key.indexOf('@')))){
- jsonArray.put(element.get(key));
+ jsonArray.put(value);
}else{
jsonResult.put(oldValue, jsonArray);
jsonArray = new JSONArray();
}
oldValue = key.substring(0,key.indexOf('@'));
}else{
- jsonResult.put(key, element.get(key));
+ jsonResult.put(key, value);
}
}
}
List<Object> list = new ArrayList<>();
PrintWriter out = response.getWriter();
String responseString = mapper.writeValueAsString(returnModel);
- JSONObject j = null;
+ JSONObject j;
if("".equals(allManyTrueKeys)){
j = new JSONObject("{dcaeModelData: " + responseString + ",jsonValue: " + jsonModel + "}");
}else{
for (Entry<String, String> keySet : attributeMap.entrySet()){
array = new JSONArray();
String value = keySet.getValue();
- if (keySet.getValue().split("MANY-")[1].equalsIgnoreCase("true")){
+ if ("true".equalsIgnoreCase(keySet.getValue().split("MANY-")[1])){
array.put(value);
object.put(keySet.getKey().trim(), array);
}else {
array = new JSONArray();
String value = keySet.getValue().split(":")[0];
if (gsonObject.containsKey(value)){
- if (keySet.getValue().split("MANY-")[1].equalsIgnoreCase("true")){
+ if ("true".equalsIgnoreCase(keySet.getValue().split("MANY-")[1])){
array.put(recursiveReference(value, gsonObject, enumAttribute));
object.put(keySet.getKey().trim(), array);
}else {
object.put(keySet.getKey().trim(), recursiveReference(value, gsonObject, enumAttribute));
}
}else {
- if (keySet.getValue().split("MANY-")[1].equalsIgnoreCase("true")){
+ if ("true".equalsIgnoreCase(keySet.getValue().split("MANY-")[1])){
array.put(value.trim());
object.put(keySet.getKey().trim(), array);
}else {
String[] splitValue = m.getValue().split(":");
array = new JSONArray();
if (subAttributeMap.containsKey(splitValue[0])){
- if (m.getValue().split("MANY-")[1].equalsIgnoreCase("true")){
+ if ("true".equalsIgnoreCase(m.getValue().split("MANY-")[1])){
array.put(recursiveReference(splitValue[0], subAttributeMap, enumAttribute));
object.put(m.getKey().trim(), array);
}else {
object.put(m.getKey().trim(), recursiveReference(splitValue[0], subAttributeMap, enumAttribute));
}
} else{
- if (m.getValue().split("MANY-")[1].equalsIgnoreCase("true")){
+ if ("true".equalsIgnoreCase(m.getValue().split("MANY-")[1])){
array.put(splitValue[0].trim());
object.put(m.getKey().trim(), array);
}else {
if(referAttributes != null){
String[] referAarray = referAttributes.split(",");
- String []element= null;
+ String []element;
for(int i=0; i<referAarray.length; i++){
element = referAarray[i].split("=");
if(element.length > 1 && element[1].contains("MANY-true")){
AttributeDesignatorType designator = match.getAttributeDesignator();
String attributeId = designator.getAttributeId();
// First match in the target is OnapName, so set that value.
- if (attributeId.equals("ONAPName")) {
+ if ("ONAPName".equals(attributeId)) {
policyAdapter.setOnapName(value);
}
- if (attributeId.equals("ConfigName")){
+ if ("ConfigName".equals(attributeId)){
policyAdapter.setConfigName(value);
}
- if (attributeId.equals("uuid")){
+ if ("uuid".equals(attributeId)){
policyAdapter.setUuid(value);
}
- if (attributeId.equals("location")){
+ if ("location".equals(attributeId)){
policyAdapter.setLocation(value);
}
- if (attributeId.equals("RiskType")){
+ if ("RiskType".equals(attributeId)){
policyAdapter.setRiskType(value);
}
- if (attributeId.equals("RiskLevel")){
+ if ("RiskLevel".equals(attributeId)){
policyAdapter.setRiskLevel(value);
}
- if (attributeId.equals("guard")){
+ if ("guard".equals(attributeId)){
policyAdapter.setGuard(value);
}
- if (attributeId.equals("TTLDate") && !value.contains("NA")){
+ if ("TTLDate".equals(attributeId) && !value.contains("NA")){
PolicyController controller = new PolicyController();
String newDate = controller.convertDate(value);
policyAdapter.setTtlDate(newDate);
if(value instanceof LinkedHashMap<?, ?>){
LinkedHashMap<String, Object> secondObjec = new LinkedHashMap<>();
readRecursivlyJSONContent((LinkedHashMap<String, ?>) value, secondObjec);
- for(String objKey: secondObjec.keySet()){
- data.put(key+"." +objKey, secondObjec.get(objKey));
+ for( Entry<String, Object> entry : secondObjec.entrySet()){
+ data.put(key+"." + entry.getKey(), entry.getValue());
}
}else if(value instanceof ArrayList){
ArrayList<?> jsonArrayVal = (ArrayList<?>)value;
if(arrayvalue instanceof LinkedHashMap<?, ?>){
LinkedHashMap<String, Object> newData = new LinkedHashMap<>();
readRecursivlyJSONContent((LinkedHashMap<String, ?>) arrayvalue, newData);
- for(String objKey: newData.keySet()){
- data.put(key+"@"+i+"." +objKey, newData.get(objKey));
+ for(Entry<String, Object> entry: newData.entrySet()){
+ data.put(key+"@"+i+"." +entry.getKey(), entry.getValue());
}
}else if(arrayvalue instanceof ArrayList){
ArrayList<?> jsonArrayVal1 = (ArrayList<?>)value;
//Convert the map values and set into JSON body
public Map<String, String> convertMap(Map<String, String> attributesMap, Map<String, String> attributesRefMap) {
Map<String, String> attribute = new HashMap<>();
- StringBuilder temp = null;
+ StringBuilder temp;
String key;
String value;
for (Entry<String, String> entry : attributesMap.entrySet()) {
File file = new File(this.newFile);
fileList.add(file);
}
- String modelType= "";
+ String modelType;
if(! yml){
modelType="xmi";
//Process Main Model file first
int BUFFER = 2048;
File file = new File(zipFile);
- ZipFile zip = null;
- try {
- zip = new ZipFile(file);
+ try (ZipFile zip = new ZipFile(file)) {
String newPath = "model" + File.separator + zipFile.substring(0, zipFile.length() - 4);
this.directory = "model" + File.separator + zipFile.substring(0, zipFile.length() - 4);
checkZipDirectory(this.directory);
if (!entry.isDirectory()){
BufferedInputStream is = new BufferedInputStream(zip.getInputStream(entry));
int currentByte;
- byte data[] = new byte[BUFFER];
- FileOutputStream fos = new FileOutputStream(destFile);
- BufferedOutputStream dest = new BufferedOutputStream(fos, BUFFER);
- while ((currentByte = is.read(data, 0, BUFFER)) != -1) {
- dest.write(data, 0, currentByte);
+ byte[] data = new byte[BUFFER];
+ try (FileOutputStream fos = new FileOutputStream(destFile);
+ BufferedOutputStream dest = new BufferedOutputStream(fos, BUFFER)) {
+ while ((currentByte = is.read(data, 0, BUFFER)) != -1) {
+ dest.write(data, 0, currentByte);
+ }
+ dest.flush();
+ } catch (IOException e) {
+ LOGGER.error("Failed to write zip contents to {}" + destFile + e);
+ //
+ // PLD should I throw e?
+ //
+ throw e;
}
- dest.flush();
- dest.close();
- is.close();
}
if (currentEntry.endsWith(".zip")){
}
} catch (IOException e) {
LOGGER.error("Failed to unzip model file " + zipFile, e);
- }finally{
- try {
- if(zip != null)
- zip.close();
- } catch (IOException e) {
- LOGGER.error("Exception Occured While closing zipfile " + e);
- }
}
}
private void retreiveDependency(String workingFile, Boolean modelClass) {
MSModelUtils utils = new MSModelUtils(PolicyController.getMsOnapName(), PolicyController.getMsPolicyName());
- HashMap<String, MSAttributeObject> tempMap;
+ Map<String, MSAttributeObject> tempMap;
tempMap = utils.processEpackage(workingFile, MODEL_TYPE.XMI);
public PolicyRestAdapter setDataToPolicyRestAdapter(PolicyRestAdapter policyData){
- String jsonBody="";
+ String jsonBody;
termCollectorList = new ArrayList <>();
tagCollectorList = new ArrayList <>();
if(! policyData.getAttributes().isEmpty()){
}
}
jsonBody = constructJson(policyData);
- if (jsonBody != null && !jsonBody.equalsIgnoreCase("")) {
+ if (jsonBody != null && ! "".equalsIgnoreCase(jsonBody)) {
policyData.setJsonBody(jsonBody);
} else {
policyData.setJsonBody("{}");
}
private List<String> mapping(String expandableList) {
- String value = null;
- String desc = null;
+ String value;
+ String desc;
List <String> valueDesc= new ArrayList<>();
List<Object> prefixListData = commonClassDao.getData(PrefixList.class);
for (int i = 0; i< prefixListData.size(); i++) {
TermCollector tc1=null;
try {
//Json conversion.
- String data=null;
+ String data;
SecurityZone jpaSecurityZone;
data = entity.getConfigurationData().getConfigBody();
tc1 = mapper.readValue(data, TermCollector.class);
policyLogger.error("Exception Caused while Retriving the JSON body data" +e);
}
- Map<String, String> termTagMap=null;
+ Map<String, String> termTagMap;
if(tc1 != null){
for(int i=0;i<tc1.getFirewallRuleList().size();i++){
termTagMap = new HashMap <>();
if (("guard").equals(attributeId)){
policyAdapter.setGuard(value);
}
- if (attributeId.equals("TTLDate") && !value.contains("NA")){
+ if ("TTLDate".equals(attributeId) && !value.contains("NA")){
PolicyController controller = new PolicyController();
String newDate = controller.convertDate(value);
policyAdapter.setTtlDate(newDate);
}
}
TermList jpaTermList;
- String ruleSrcList=null;
- String ruleDestList=null;
- String ruleSrcPort=null;
- String ruleDestPort=null;
- String ruleAction=null;
- List <String> valueDesc= new ArrayList<>();
- StringBuffer displayString = new StringBuffer();
+ String ruleSrcList;
+ String ruleDestList;
+ String ruleSrcPort;
+ String ruleDestPort;
+ String ruleAction;
+ List <String> valueDesc;
+ StringBuilder displayString = new StringBuilder();
for (String id : termCollectorList) {
List<Object> tmList = commonClassDao.getDataById(TermList.class, "termName", id);
jpaTermList = (TermList) tmList.get(0);
if(srcList.startsWith(GROUP)){
AddressGroup ag;
ag= mappingAddressGroup(srcList);
- displayString.append("\n\t"+"Group has :"+ag.getPrefixList()+"\n");
- for(String groupItems:ag.getPrefixList().split(",")){
- valueDesc=mapping(groupItems);
- displayString.append("\n\t"+"Name: "+groupItems);
- if(!valueDesc.isEmpty()){
- displayString.append("\n\t"+"Description: "+valueDesc.get(1));
- displayString.append("\n\t"+"Value: "+valueDesc.get(0));
+ displayString.append("\n\t"+"Group has :"+(ag != null ? ag.getPrefixList() : "") +"\n");
+ if (ag != null) {
+ for(String groupItems:ag.getPrefixList().split(",")){
+ valueDesc=mapping(groupItems);
+ displayString.append("\n\t"+"Name: "+groupItems);
+ if(!valueDesc.isEmpty()){
+ displayString.append("\n\t"+"Description: "+valueDesc.get(1));
+ displayString.append("\n\t"+"Value: "+valueDesc.get(0));
+ }
+ displayString.append("\n");
}
- displayString.append("\n");
}
}else{
if(!srcList.equals(ANY)){
displayString.append("\n");
}
ruleDestList= jpaTermList.getDestIPList();
- if ( ruleDestList!= null && (!ruleDestList.isEmpty())&& !ruleDestList.equals("null")){
+ if ( ruleDestList!= null && (!ruleDestList.isEmpty())&& ! "null".equals(ruleDestList)){
displayString.append("Destination IP List: " + jpaTermList.getDestIPList());
displayString.append(" ; \t\n");
for(String destList:ruleDestList.split(",")){
if(destList.startsWith(GROUP)){
AddressGroup ag;
ag= mappingAddressGroup(destList);
- displayString.append("\n\t"+"Group has :"+ag.getPrefixList()+"\n");
- for(String groupItems:ag.getPrefixList().split(",")){
- valueDesc=mapping(groupItems);
- displayString.append("\n\t"+"Name: "+groupItems);
- displayString.append("\n\t"+"Description: "+valueDesc.get(1));
- displayString.append("\n\t"+"Value: "+valueDesc.get(0));
- displayString.append("\n\t");
+ displayString.append("\n\t"+"Group has :"+ (ag != null ? ag.getPrefixList() : "") +"\n");
+ if (ag != null) {
+ for(String groupItems:ag.getPrefixList().split(",")){
+ valueDesc=mapping(groupItems);
+ displayString.append("\n\t"+"Name: "+groupItems);
+ displayString.append("\n\t"+"Description: "+valueDesc.get(1));
+ displayString.append("\n\t"+"Value: "+valueDesc.get(0));
+ displayString.append("\n\t");
+ }
}
}else{
if(!destList.equals(ANY)){
}
ruleSrcPort=jpaTermList.getSrcPortList();
- if ( ruleSrcPort!= null && (!ruleSrcPort.isEmpty())&& !ruleSrcPort.equals("null")) {
+ if ( ruleSrcPort!= null && (!ruleSrcPort.isEmpty())&& !"null".equals(ruleSrcPort)) {
displayString.append("\n"+"Source Port List:"
+ ruleSrcPort);
displayString.append(" ; \t\n");
}
ruleDestPort= jpaTermList.getDestPortList();
- if (ruleDestPort != null && (!ruleDestPort.isEmpty())&& !ruleDestPort.equals("null")) {
+ if (ruleDestPort != null && (!ruleDestPort.isEmpty())&& !"null".equals(ruleDestPort)) {
displayString.append("\n"+"Destination Port List:"
+ ruleDestPort);
displayString.append(" ; \t\n");
if(destServices.startsWith(GROUP)){
GroupServiceList sg;
sg= mappingServiceGroup(destServices);
- displayString.append("\n\t"+"Service Group has :"+sg.getServiceList()+"\n");
- for(String groupItems:sg.getServiceList().split(",")){
- ServiceList sl;
- sl= mappingServiceList(groupItems);
- displayString.append("\n\t"+"Name: "+
- sl.getServiceName());
- displayString.append("\n\t"+"Description: "+
- sl.getServiceDescription());
- displayString.append("\n\t"+"Transport-Protocol: "+
- sl.getServiceTransProtocol());
- displayString.append("\n\t"+"Ports: "+
- sl.getServicePorts());
- displayString.append("\n");
+ displayString.append("\n\t"+"Service Group has :"+ (sg != null ? sg.getServiceList() : "") +"\n");
+ if (sg != null) {
+ for(String groupItems:sg.getServiceList().split(",")){
+ ServiceList sl;
+ sl= mappingServiceList(groupItems);
+ displayString.append("\n\t"+"Name: "+
+ sl.getServiceName());
+ displayString.append("\n\t"+"Description: "+
+ sl.getServiceDescription());
+ displayString.append("\n\t"+"Transport-Protocol: "+
+ sl.getServiceTransProtocol());
+ displayString.append("\n\t"+"Ports: "+
+ sl.getServicePorts());
+ displayString.append("\n");
+ }
}
}
else{
}
//ExpandableServicesList
if((srcPort_map!=null) && (destPort_map!=null)){
- String servicesCollateString = (srcPort_map.get(tl) + "," + destPort_map.get(tl));
+ String servicesCollateString = srcPort_map.get(tl) + "," + destPort_map.get(tl);
expandableServicesList.add(servicesCollateString);
}else if (srcPort_map!=null){
expandableServicesList.add(srcPort_map.get(tl));
//ExpandablePrefixIPList
if ((srcIP_map!=null) && (destIP_map!=null))
{
- String collateString = (srcIP_map.get(tl) + "," + destIP_map
- .get(tl));
+ String collateString = srcIP_map.get(tl) + "," + destIP_map
+ .get(tl);
expandablePrefixIPList.add(collateString);
}
else if(srcIP_map!=null){
Set<AddressGroupJson> addrGroupArray= new HashSet<>();
Set<AddressMembers> addrArray= new HashSet<> ();
- ServiceGroupJson targetSg= null;
- AddressGroupJson addressSg=null;
- ServiceListJson targetAny= null;
- ServiceListJson targetAnyTcp=null;
- ServiceListJson targetAnyUdp=null;
+ ServiceGroupJson targetSg;
+ AddressGroupJson addressSg;
+ ServiceListJson targetAny;
+ ServiceListJson targetAnyTcp;
+ ServiceListJson targetAnyUdp;
for(String serviceList:expandableServicesList){
for(String t: serviceList.split(",")){
- if((!t.startsWith(GROUP))){
+ if(!t.startsWith(GROUP)){
if(!t.equals(ANY)){
ServiceList sl;
targetSl= new ServiceListJson();
Set<PrefixIPList> prefixIPList = new HashSet<>();
for(String prefixList:expandablePrefixIPList){
for(String prefixIP: prefixList.split(",")){
- if((!prefixIP.startsWith(GROUP))){
+ if(!prefixIP.startsWith(GROUP)){
if(!prefixIP.equals(ANY)){
List<AddressMembers> addMembersList= new ArrayList<>();
List<String> valueDesc;
AttributeDesignatorType designator = match.getAttributeDesignator();
String attributeId = designator.getAttributeId();
// First match in the target is OnapName, so set that value.
- if (attributeId.equals("ONAPName")) {
+ if ("ONAPName".equals(attributeId)) {
policyAdapter.setOnapName(value);
}
- if (attributeId.equals("RiskType")){
+ if ("RiskType".equals(attributeId)){
policyAdapter.setRiskType(value);
}
- if (attributeId.equals("RiskLevel")){
+ if ("RiskLevel".equals(attributeId)){
policyAdapter.setRiskLevel(value);
}
- if (attributeId.equals("guard")){
+ if ("guard".equals(attributeId)){
policyAdapter.setGuard(value);
}
- if (attributeId.equals("TTLDate") && !value.contains("NA")){
+ if ("TTLDate".equals(attributeId) && !value.contains("NA")){
PolicyController controller = new PolicyController();
String newDate = controller.convertDate(value);
policyAdapter.setTtlDate(newDate);
}
- if (attributeId.equals("ConfigName")){
+ if ("ConfigName".equals(attributeId)){
policyAdapter.setConfigName(value);
}
// After Onap and Config it is optional to have attributes, so
policyLogger.debug("Create an RMI connector client and connect it to the JMX connector server");
HashMap map = null;
- JMXConnector jmxConnection;
- try {
- jmxConnection = JMXConnectorFactory.newJMXConnector(createConnectionURL(host, port), map);
+ try (JMXConnector jmxConnection = JMXConnectorFactory.newJMXConnector(createConnectionURL(host, port), map)){
jmxConnection.connect();
Object o = jmxConnection.getMBeanServerConnection().getAttribute(new ObjectName("PdpRest:type=PdpRestMonitor"), jmxAttribute);
- jmxConnection.close();
policyLogger.debug("pdpEvaluationNA value retreived: " + o);
return (long) o;
} catch (MalformedURLException e) {
*/
private void addPolicyToTable() {
policyActivityData = new ArrayList<>();
- String policyID = null;
- int policyFireCount = 0;
+ String policyID;
+ int policyFireCount;
Map<String, String> policyMap = new HashMap<>();
- Object policyList = null;
+ Object policyList;
//get list of policy
for (PDPGroup group : this.pdpConatiner.getGroups()){
for (String policyKeyValue : splitPolicy){
policyID = urnPolicyID(policyKeyValue);
policyFireCount = countPolicyID(policyKeyValue);
- if (policyID != null ){
- if (policyMap.containsKey(policyID)){
- JSONObject object = new JSONObject();
- object.put("policyId", policyMap.get(policyID));
- object.put("fireCount", policyFireCount);
- object.put("system", pdp.getId());
- policyActivityData.add(object);
- }
+ if (policyID != null && policyMap.containsKey(policyID)){
+ JSONObject object = new JSONObject();
+ object.put("policyId", policyMap.get(policyID));
+ object.put("fireCount", policyFireCount);
+ object.put("system", pdp.getId());
+ policyActivityData.add(object);
}
}
}else {
private Object getPolicy(String host, int port, String jmxAttribute){
policyLogger.debug("Create an RMI connector client and connect it to the JMX connector server for Policy: " + host);
HashMap map = null;
- JMXConnector jmxConnection;
- try {
- jmxConnection = JMXConnectorFactory.newJMXConnector(createConnectionURL(host, port), map);
+ try (JMXConnector jmxConnection = JMXConnectorFactory.newJMXConnector(createConnectionURL(host, port), map)) {
jmxConnection.connect();
Object o = jmxConnection.getMBeanServerConnection().getAttribute(new ObjectName("PdpRest:type=PdpRestMonitor"), "policyMap");
- jmxConnection.close();
policyLogger.debug("policyMap value retreived: " + o);
return o;
} catch (MalformedURLException e) {
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import javax.xml.bind.JAXBElement;
AttributeDesignatorType designator = match.getAttributeDesignator();
String attributeId = designator.getAttributeId();
// First match in the target is OnapName, so set that value.
- if (attributeId.equals("ONAPName")) {
+ if ("ONAPName".equals(attributeId)) {
policyAdapter.setOnapName(value);
}
// Component attributes are saved under Target here we are fetching them back.
if(!attributeList.isEmpty()) {
for(int i=0; i<attributeList.size() ; i++){
Map<String, String> map = (Map<String,String>)attributeList.get(i);
- if(map.get("key").equals("WorkStep")){
+ if("WorkStep".equals(map.get("key"))){
rainydayParams.setWorkstep(map.get("value"));
rainy=true;
- }else if(map.get("key").equals("BB_ID")){
+ }else if("BB_ID".equals(map.get("key"))){
rainydayParams.setBbid(map.get("value"));
rainy=true;
- }else if(map.get("key").equals("ServiceType")){
+ }else if("ServiceType".equals(map.get("key"))){
rainydayParams.setServiceType(map.get("value"));
rainy=true;
- }else if(map.get("key").equals("VNFType")){
+ }else if("VNFType".equals(map.get("key"))){
rainydayParams.setVnfType(map.get("value"));
rainy=true;
}
// get the condition data under the rule for rule Algorithms.
if(((RuleType) object).getEffect().equals(EffectType.DENY)) {
if(((RuleType) object).getAdviceExpressions()!=null){
- if(((RuleType) object).getAdviceExpressions().getAdviceExpression().get(0).getAdviceId().equalsIgnoreCase("AAF")){
+ if("AAF".equalsIgnoreCase(((RuleType) object).getAdviceExpressions().getAdviceExpression().get(0).getAdviceId())){
policyAdapter.setRuleProvider("AAF");
break;
- }else if(((RuleType) object).getAdviceExpressions().getAdviceExpression().get(0).getAdviceId().equalsIgnoreCase("GUARD_YAML")){
+ }else if("GUARD_YAML".equalsIgnoreCase(((RuleType) object).getAdviceExpressions().getAdviceExpression().get(0).getAdviceId())){
policyAdapter.setRuleProvider("GUARD_YAML");
- }else if(((RuleType) object).getAdviceExpressions().getAdviceExpression().get(0).getAdviceId().equalsIgnoreCase("GUARD_BL_YAML")){
+ }else if("GUARD_BL_YAML".equalsIgnoreCase(((RuleType) object).getAdviceExpressions().getAdviceExpression().get(0).getAdviceId())){
policyAdapter.setRuleProvider("GUARD_BL_YAML");
}
}else{
ApplyType decisionApply = (ApplyType) condition.getExpression().getValue();
decisionApply = (ApplyType) decisionApply.getExpression().get(0).getValue();
ruleAlgoirthmTracker = new LinkedList<>();
- if(policyAdapter.getRuleProvider()!=null && (policyAdapter.getRuleProvider().equals("GUARD_YAML")||(policyAdapter.getRuleProvider().equals("GUARD_BL_YAML")))){
+ if(policyAdapter.getRuleProvider()!=null && ("GUARD_YAML".equals(policyAdapter.getRuleProvider())||(policyAdapter.getRuleProvider().equals("GUARD_BL_YAML")))){
YAMLParams yamlParams = new YAMLParams();
for(int i=0; i<attributeList.size() ; i++){
Map<String, String> map = (Map<String,String>)attributeList.get(i);
yamlParams.setClname(map.get("value"));
}
}
- ApplyType apply = ((ApplyType)((ApplyType)decisionApply.getExpression().get(0).getValue()).getExpression().get(0).getValue());
+ ApplyType apply = (ApplyType)((ApplyType)decisionApply.getExpression().get(0).getValue()).getExpression().get(0).getValue();
yamlParams.setGuardActiveStart(((AttributeValueType)apply.getExpression().get(1).getValue()).getContent().get(0).toString());
yamlParams.setGuardActiveEnd(((AttributeValueType)apply.getExpression().get(2).getValue()).getContent().get(0).toString());
- if(policyAdapter.getRuleProvider().equals("GUARD_BL_YAML")){
+ if("GUARD_BL_YAML".equals(policyAdapter.getRuleProvider())){
apply = (ApplyType)((ApplyType)((ApplyType)decisionApply.getExpression().get(0).getValue()).getExpression().get(1).getValue()).getExpression().get(2).getValue();
Iterator<JAXBElement<?>> attributes = apply.getExpression().iterator();
List<String> blackList = new ArrayList<>();
prePopulateDecisionCompoundRuleAlgorithm(index, decisionApply);
policyAdapter.setRuleAlgorithmschoices(ruleAlgorithmList);
}
- } else if(policyAdapter.getRuleProvider()!=null && policyAdapter.getRuleProvider().equals("Rainy_Day")&& ((RuleType) object).getEffect().equals(EffectType.PERMIT)) {
+ } else if(policyAdapter.getRuleProvider()!=null && "Rainy_Day".equals(policyAdapter.getRuleProvider())&& ((RuleType) object).getEffect().equals(EffectType.PERMIT)) {
TargetType ruleTarget = ((RuleType) object).getTarget();
AdviceExpressionsType adviceExpression = ((RuleType) object).getAdviceExpressions();
Map<String, String> ruleMap = new HashMap<>();
ruleMap.put("id", "A" + (index +1));
Map<String, String> dropDownMap = PolicyController.getDropDownMap();
- for (String key : dropDownMap.keySet()) {
- String keyValue = dropDownMap.get(key);
- if (keyValue.equals(decisionApply.getFunctionId())) {
- ruleMap.put("dynamicRuleAlgorithmCombo", key);
+ for (Entry<String, String> entry : dropDownMap.entrySet()) {
+ if (entry.getValue().equals(decisionApply.getFunctionId())) {
+ ruleMap.put("dynamicRuleAlgorithmCombo", entry.getKey());
}
}
// Populate the key and value fields
- if (((jaxbDecisionTypes.get(0).getValue()) instanceof AttributeValueType)) {
+ if ((jaxbDecisionTypes.get(0).getValue() instanceof AttributeValueType)) {
ApplyType innerDecisionApply = (ApplyType) jaxbDecisionTypes.get(1).getValue();
List<JAXBElement<?>> jaxbInnerDecisionTypes = innerDecisionApply.getExpression();
if (jaxbInnerDecisionTypes.get(0).getValue() instanceof AttributeDesignatorType) {
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.model.PDPGroupContainer;
-import org.onap.policy.model.Roles;
+import org.onap.policy.utils.UserUtils.Pair;
import org.onap.policy.xacml.api.XACMLErrorConstants;
import org.onap.policy.xacml.api.pap.OnapPDPGroup;
import org.onap.policy.xacml.api.pap.PAPPolicyEngine;
try {
PolicyController controller = getPolicyControllerInstance();
Set<PDPPolicy> filteredPolicies = new HashSet<>();
- Set<String> scopes = null;
- List<String> roles = null;
+ Set<String> scopes;
+ List<String> roles;
String userId = isJunit() ? "Test" : UserUtils.getUserSession(request).getOrgUserId();
List<Object> userRoles = controller.getRoles(userId);
- roles = new ArrayList<>();
- scopes = new HashSet<>();
- for(Object role: userRoles){
- Roles userRole = (Roles) role;
- roles.add(userRole.getRole());
- if(userRole.getScope() != null){
- if(userRole.getScope().contains(",")){
- String[] multipleScopes = userRole.getScope().split(",");
- for(int i =0; i < multipleScopes.length; i++){
- scopes.add(multipleScopes[i]);
- }
- }else{
- scopes.add(userRole.getScope());
- }
- }
- }
+ Pair<Set<String>, List<String>> pair = org.onap.policy.utils.UserUtils.checkRoleAndScope(userRoles);
+ roles = pair.u;
+ scopes = pair.t;
+
if(!junit&& controller.getPapEngine()==null){
setPAPEngine(request);
}
this.groups.addAll(this.getGroupsData());
}
}else{
- if(!userRoles.isEmpty()){
- if(!scopes.isEmpty()){
- this.groups.addAll(controller.getPapEngine().getOnapPDPGroups());
- List<OnapPDPGroup> tempGroups = new ArrayList<>();
- if(!groups.isEmpty()){
- Iterator<OnapPDPGroup> pdpGroup = groups.iterator();
- while(pdpGroup.hasNext()){
- OnapPDPGroup group = pdpGroup.next();
- Set<PDPPolicy> policies = group.getPolicies();
- for(PDPPolicy policy : policies){
- for(String scope : scopes){
- scope = scope.replace(File.separator, ".");
- String policyName = policy.getId();
- if(policyName.contains(".Config_")){
- policyName = policyName.substring(0, policyName.lastIndexOf(".Config_"));
- }else if(policyName.contains(".Action_")){
- policyName = policyName.substring(0, policyName.lastIndexOf(".Action_"));
- }else if(policyName.contains(".Decision_")){
- policyName = policyName.substring(0, policyName.lastIndexOf(".Decision_"));
- }
- if(policyName.startsWith(scope)){
- filteredPolicies.add(policy);
- }
+ if(!userRoles.isEmpty() && !scopes.isEmpty()){
+ this.groups.addAll(controller.getPapEngine().getOnapPDPGroups());
+ List<OnapPDPGroup> tempGroups = new ArrayList<>();
+ if(!groups.isEmpty()){
+ Iterator<OnapPDPGroup> pdpGroup = groups.iterator();
+ while(pdpGroup.hasNext()){
+ OnapPDPGroup group = pdpGroup.next();
+ Set<PDPPolicy> policies = group.getPolicies();
+ for(PDPPolicy policy : policies){
+ for(String scope : scopes){
+ scope = scope.replace(File.separator, ".");
+ String policyName = policy.getId();
+ if(policyName.contains(".Config_")){
+ policyName = policyName.substring(0, policyName.lastIndexOf(".Config_"));
+ }else if(policyName.contains(".Action_")){
+ policyName = policyName.substring(0, policyName.lastIndexOf(".Action_"));
+ }else if(policyName.contains(".Decision_")){
+ policyName = policyName.substring(0, policyName.lastIndexOf(".Decision_"));
+ }
+ if(policyName.startsWith(scope)){
+ filteredPolicies.add(policy);
}
}
- pdpGroup.remove();
- StdPDPGroup newGroup = (StdPDPGroup) group;
- newGroup.setPolicies(filteredPolicies);
- tempGroups.add(newGroup);
- }
- groups.clear();
- groups = tempGroups;
- }
+ }
+ pdpGroup.remove();
+ StdPDPGroup newGroup = (StdPDPGroup) group;
+ newGroup.setPolicies(filteredPolicies);
+ tempGroups.add(newGroup);
+ }
+ groups.clear();
+ groups = tempGroups;
}
}
}
policyLogger.info("*****************************************************************************************************************************");
StdPDPGroup pdpGroupData = mapper.readValue(root.get("pdpGroupData").toString(), StdPDPGroup.class);
- if(pdpGroupData.getName().equals("Default")) {
+ if("Default".equals(pdpGroupData.getName())) {
throw new UnsupportedOperationException("You can't remove the Default Group.");
}else{
this.container.removeGroup(pdpGroupData, null);
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Properties;
import javax.annotation.PostConstruct;
}
public PolicyController() {
+ // Empty constructor
}
@PostConstruct
//Initialize the FunctionDefinition table at Server Start up
Map<Datatype, List<FunctionDefinition>> functionMap = getFunctionDatatypeMap();
- for (Datatype id : functionMap.keySet()) {
- List<FunctionDefinition> functionDefinations = functionMap.get(id);
+ for ( Entry<Datatype, List<FunctionDefinition>> entry : functionMap.entrySet()) {
+ List<FunctionDefinition> functionDefinations = entry.getValue();
for (FunctionDefinition functionDef : functionDefinations) {
dropDownMap.put(functionDef.getShortname(),functionDef.getXacmlid());
}
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import org.json.JSONObject;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
-import org.onap.policy.model.Roles;
import org.onap.policy.rest.adapter.PolicyExportAdapter;
import org.onap.policy.rest.dao.CommonClassDao;
import org.onap.policy.rest.jpa.ActionBodyEntity;
import org.onap.policy.rest.jpa.PolicyEntity;
import org.onap.policy.rest.jpa.PolicyVersion;
import org.onap.policy.rest.jpa.UserInfo;
+import org.onap.policy.utils.UserUtils.Pair;
import org.onap.policy.xacml.api.XACMLErrorConstants;
import org.onap.portalsdk.core.controller.RestrictedBaseController;
import org.onap.portalsdk.core.web.support.UserUtils;
PolicyExportAndImportController.commonClassDao = commonClassDao;
}
- public PolicyExportAndImportController(){}
+ public PolicyExportAndImportController(){
+ // Empty constructor
+ }
@RequestMapping(value={"/policy_download/exportPolicy.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
public void exportPolicy(HttpServletRequest request, HttpServletResponse response) throws IOException{
try{
- String file = null;
+ String file;
selectedPolicy = new ArrayList<>();
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
boolean configExists = false;
boolean actionExists = false;
String configName = null;
- String scope = null;
- boolean finalColumn = false;
+ String scope;
+ boolean finalColumn;
PolicyController controller = policyController != null ? getPolicyController() : new PolicyController();
String userId = UserUtils.getUserSession(request).getOrgUserId();
UserInfo userInfo = (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginId", userId);
- //Check if the Role and Scope Size are Null get the values from db.
List<Object> userRoles = controller.getRoles(userId);
- roles = new ArrayList<>();
- scopes = new HashSet<>();
- for(Object role: userRoles){
- Roles userRole = (Roles) role;
- roles.add(userRole.getRole());
- if(userRole.getScope() != null){
- if(userRole.getScope().contains(",")){
- String[] multipleScopes = userRole.getScope().split(",");
- for(int i =0; i < multipleScopes.length; i++){
- scopes.add(multipleScopes[i]);
- }
- }else{
- scopes.add(userRole.getScope());
- }
- }
- }
+ Pair<Set<String>, List<String>> pair = org.onap.policy.utils.UserUtils.checkRoleAndScope(userRoles);
+ roles = pair.u;
+ scopes = pair.t;
+
FileInputStream excelFile = new FileInputStream(new File(file));
workbook = new HSSFWorkbook(excelFile);
Sheet datatypeSheet = workbook.getSheetAt(0);
Iterator<Cell> cellIterator = currentRow.cellIterator();
while (cellIterator.hasNext()) {
Cell cell = cellIterator.next();
- if (getCellHeaderName(cell).equalsIgnoreCase("policyName")) {
+ if ("policyName".equalsIgnoreCase(getCellHeaderName(cell))) {
policyEntity.setPolicyName(cell.getStringCellValue());
}
- if (getCellHeaderName(cell).equalsIgnoreCase("scope")) {
+ if ("scope".equalsIgnoreCase(getCellHeaderName(cell))) {
policyEntity.setScope(cell.getStringCellValue());
}
- if (getCellHeaderName(cell).equalsIgnoreCase("policyData")) {
+ if ("policyData".equalsIgnoreCase(getCellHeaderName(cell))) {
policyEntity.setPolicyData(cell.getStringCellValue());
}
- if (getCellHeaderName(cell).equalsIgnoreCase("description")) {
+ if ("description".equalsIgnoreCase(getCellHeaderName(cell))) {
policyEntity.setDescription(cell.getStringCellValue());
}
- if (getCellHeaderName(cell).equalsIgnoreCase("configurationbody")) {
+ if ("configurationbody".equalsIgnoreCase(getCellHeaderName(cell))) {
if(policyEntity.getPolicyName().contains("Config_")){
configExists = true;
configurationDataEntity.setConfigBody(cell.getStringCellValue());
actionBodyEntity.setActionBody(cell.getStringCellValue());
}
}
- if (getCellHeaderName(cell).equalsIgnoreCase("configurationName")) {
+ if ("configurationName".equalsIgnoreCase(getCellHeaderName(cell))) {
finalColumn = true;
configName = cell.getStringCellValue();
if(policyEntity.getPolicyName().contains("Config_")){
}
if (roles.contains(ADMIN) || roles.contains(EDITOR)) {
if(scopes.isEmpty()){
- //return error("No Scopes has been Assigned to the User. Please, Contact Super-Admin");
+ logger.error("No Scopes has been Assigned to the User. Please, Contact Super-Admin");
}else{
//1. if Role contains admin, then check if parent scope has role admin, if not don't create a scope and add to list.
if(roles.contains(ADMIN)){
package org.onap.policy.daoImp;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
@Override
public List<Object> checkExistingGroupListforUpdate(String arg0, String arg1) {
- return null;
+ return Collections.emptyList();
}
}
public boolean isSupported(Object itemId) {
- return (itemId instanceof OnapPDPGroup);
+ return itemId instanceof OnapPDPGroup;
}
public synchronized void refreshGroups() {
if (this.policies.isEmpty()) {
return false;
}
- return (itemId.equals(this.policies.get(0)));
+ return itemId.equals(this.policies.get(0));
}
@Override
if (this.policies.isEmpty()) {
return false;
}
- return (itemId.equals(this.policies.get(this.policies.size() - 1)));
+ return itemId.equals(this.policies.get(this.policies.size() - 1));
}
@Override
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Map;
+import java.util.Map.Entry;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
connection.setUseCaches(false);
// add hard-coded headers
- for (String headerName : hardCodedHeaderMap.keySet()) {
- connection.addRequestProperty(headerName, hardCodedHeaderMap.get(headerName));
+ for (Entry<String, String> entry : hardCodedHeaderMap.entrySet()) {
+ connection.addRequestProperty(entry.getKey(), entry.getValue());
}
-
-
if (jsonBody != null){
connection.setDoInput(true);
--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.policy.utils;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.onap.policy.controller.PolicyController;
+import org.onap.policy.model.Roles;
+
+public final class UserUtils {
+
+ private UserUtils () {
+ // Empty Constructor
+ }
+
+ public static class Pair<T, U> {
+ public final T t;
+ public final U u;
+
+ public Pair (T t, U u) {
+ this.t = t;
+ this.u = u;
+ }
+ }
+
+ public static Pair<Set<String>, List<String>> checkRoleAndScope(List<Object> userRoles) {
+ Set<String> scopes;
+ List<String> roles;
+ //Check if the Role and Scope Size are Null get the values from db.
+// List<Object> userRoles = ;
+ roles = new ArrayList<>();
+ scopes = new HashSet<>();
+ for(Object role: userRoles){
+ Roles userRole = (Roles) role;
+ roles.add(userRole.getRole());
+ if(userRole.getScope() != null){
+ if(userRole.getScope().contains(",")){
+ String[] multipleScopes = userRole.getScope().split(",");
+ for(int i =0; i < multipleScopes.length; i++){
+ scopes.add(multipleScopes[i]);
+ }
+ }else{
+ scopes.add(userRole.getScope());
+ }
+ }
+ }
+ return new Pair<>(scopes, roles);
+ }
+
+}
}
Base64.Encoder encoder = Base64.getEncoder();
String encoding = encoder.encodeToString((XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_USERID)+":"+XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_PASS)).getBytes(StandardCharsets.UTF_8));
- HttpURLConnection connection = null;
+ HttpURLConnection connection;
UUID requestID = UUID.randomUUID();
URL url;
try {
public static boolean notifyPapOfDelete(String policyToDelete){
Base64.Encoder encoder = Base64.getEncoder();
String encoding = encoder.encodeToString((XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_USERID)+":"+XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_PASS)).getBytes(StandardCharsets.UTF_8));
- HttpURLConnection connection = null;
+ HttpURLConnection connection;
UUID requestID = UUID.randomUUID();
String papUrl = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_URL);
if(papUrl == null){
}
Base64.Encoder encoder = Base64.getEncoder();
String encoding = encoder.encodeToString((XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_USERID)+":"+XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_PASS)).getBytes(StandardCharsets.UTF_8));
- HttpURLConnection connection = null;
+ HttpURLConnection connection;
UUID requestID = UUID.randomUUID();
URL url;
try {
*/
package org.onap.policy.admin;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.File;
+import org.junit.FixMethodOrder;
import org.junit.Test;
+import org.junit.runners.MethodSorters;
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class CheckPDPTest {
@Test
- public final void testCheckPDP() {
+ public final void test1NoPropertySet() {
+ try {
+ System.clearProperty("xacml.rest.pdp.idfile");
+ assertFalse(CheckPDP.validateID("http://localhost:8082/pdp/"));
+
+ System.setProperty("xacml.rest.pdp.idfile", new File(".").getCanonicalPath() + File.separator + "src"+ File.separator + "test" + File.separator + "resources" + File.separator + "idonotexist.properties");
+ assertFalse(CheckPDP.validateID("http://localhost:8082/pdp/"));
+
+ System.setProperty("xacml.rest.pdp.idfile", new File(".").getCanonicalPath() + File.separator + "src"+ File.separator + "test" + File.separator + "resources" + File.separator + "doesnothaveproperties.atall");
+ assertFalse(CheckPDP.validateID("http://localhost:8082/pdp/"));
+
+ System.setProperty("xacml.rest.pdp.idfile", new File(".").getCanonicalPath() + File.separator + "src"+ File.separator + "test" + File.separator + "resources" + File.separator + "testbad.properties");
+ assertFalse(CheckPDP.validateID("http://localhost:8082/pdp/"));
+
+ System.setProperty("xacml.rest.pdp.idfile", new File(".").getCanonicalPath() + File.separator + "src"+ File.separator + "test" + File.separator + "resources" + File.separator + "empty.properties");
+ assertFalse(CheckPDP.validateID("http://localhost:8082/pdp/"));
+
+ System.setProperty("xacml.rest.pdp.idfile", new File(".").getCanonicalPath() + File.separator + "src"+ File.separator + "test" + File.separator + "resources" + File.separator + "testnotenoughvalues.properties");
+ assertFalse(CheckPDP.validateID("http://localhost:8082/pdp/"));
+
+ assertNull(CheckPDP.getPdpMap());
+ assertNull(CheckPDP.getEncoding("http://localhost:8082/pdp/"));
+
+ } catch (Exception e) {
+ fail("Error occured in CheckPDP test");
+ }
+ }
+
+ @Test
+ public final void test2CheckPDP() {
try {
System.setProperty("xacml.rest.pdp.idfile", new File(".").getCanonicalPath() + File.separator + "src"+ File.separator + "test" + File.separator + "resources" + File.separator + "test.properties");
- CheckPDP.validateID("http://localhost:8082/pdp/");
+ assertTrue(CheckPDP.validateID("http://localhost:8082/pdp/"));
assertTrue(CheckPDP.getPdpMap().containsKey("http://localhost:8082/pdp/"));
assertTrue(CheckPDP.getEncoding("http://localhost:8082/pdp/").equals("dGVzdHBkcDphbHBoYTQ1Ng=="));
} catch (Exception e) {
--- /dev/null
+###
+# ============LICENSE_START=======================================================
+# ONAP Policy Engine
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# ================================================================================
+# 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.
+# ============LICENSE_END=========================================================
+###
+
+# Purposefully empty
\ No newline at end of file
###
PDP_URL=http://localhost:8082/pdp/, testpdp, alpha456;http://localhost:8081/pdp/, testpdp, alpha456
+WHAT=
--- /dev/null
+###
+# ============LICENSE_START=======================================================
+# ONAP Policy Engine
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# ================================================================================
+# 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.
+# ============LICENSE_END=========================================================
+###
+
+BADPDP_URL=http://localhost:8082/pdp/, testpdp, alpha456;http://localhost:8081/pdp/, testpdp, alpha456
--- /dev/null
+###
+# ============LICENSE_START=======================================================
+# ONAP Policy Engine
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# ================================================================================
+# 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.
+# ============LICENSE_END=========================================================
+###
+
+PDP_URL=http://localhost:8082/pdp/, testpdp;http://localhost:8081/pdp/, alpha456