X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=POLICY-SDK-APP%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fcontroller%2FPolicyController.java;h=ae473f34fc06d241f90280d1d6014486174da02a;hb=9450c8d0102b9188933b5d26193df754a70a7157;hp=321dc72d2c5e978c889f77cc8297ea19ba122bc5;hpb=d7776329d495746091724b61c357e93f9e2031a6;p=policy%2Fengine.git diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyController.java index 321dc72d2..ae473f34f 100644 --- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyController.java +++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyController.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP Policy Engine * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-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. @@ -29,6 +29,7 @@ import java.util.ArrayList; 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; @@ -43,8 +44,8 @@ import org.onap.policy.admin.RESTfulPAPEngine; 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.rest.XACMLRestProperties; -import org.onap.policy.rest.XacmlAdminAuthorization; import org.onap.policy.rest.dao.CommonClassDao; import org.onap.policy.rest.jpa.Datatype; import org.onap.policy.rest.jpa.FunctionDefinition; @@ -53,10 +54,9 @@ import org.onap.policy.rest.jpa.PolicyVersion; import org.onap.policy.rest.jpa.UserInfo; import org.onap.policy.xacml.api.XACMLErrorConstants; import org.onap.policy.xacml.api.pap.PAPPolicyEngine; -import org.openecomp.policy.model.Roles; -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; -import org.openecomp.portalsdk.core.web.support.JsonMessage; -import org.openecomp.portalsdk.core.web.support.UserUtils; +import org.onap.portalsdk.core.controller.RestrictedBaseController; +import org.onap.portalsdk.core.web.support.JsonMessage; +import org.onap.portalsdk.core.web.support.UserUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; @@ -74,10 +74,6 @@ public class PolicyController extends RestrictedBaseController { private static final Logger policyLogger = FlexLogger.getLogger(PolicyController.class); private static CommonClassDao commonClassDao; - - // Our authorization object - // - XacmlAdminAuthorization authorizer = new XacmlAdminAuthorization(); // // The PAP Engine // @@ -144,6 +140,9 @@ public class PolicyController extends RestrictedBaseController { private static String configHome; private static String actionHome; + //File upload size + private static long fileSizeLimit; + private static boolean jUnit = false; @@ -161,6 +160,7 @@ public class PolicyController extends RestrictedBaseController { } public PolicyController() { + // Empty constructor } @PostConstruct @@ -176,6 +176,8 @@ public class PolicyController extends RestrictedBaseController { } // load a properties file prop.load(input); + //file upload size limit property + setFileSizeLimit(prop.getProperty("file.size.limit")); //pap url setPapUrl(prop.getProperty("xacml.rest.pap.url")); // get the property values @@ -203,7 +205,12 @@ public class PolicyController extends RestrictedBaseController { setAutoPushPDPGroup(prop.getProperty("xacml.autopush.pdpGroup")); //Micro Service Properties setMsOnapName(prop.getProperty("xacml.policy.msOnapName")); + if(getMsOnapName() == null){ + setMsOnapName(prop.getProperty("xacml.policy.msEcompName")); + } + policyLogger.info("getMsOnapName => " + getMsOnapName()); setMsPolicyName(prop.getProperty("xacml.policy.msPolicyName")); + policyLogger.info("setMsPolicyName => " + getMsPolicyName()); //WebApp directories setConfigHome(prop.getProperty("xacml.rest.config.webapps") + "Config"); setActionHome(prop.getProperty("xacml.rest.config.webapps") + "Action"); @@ -231,8 +238,8 @@ public class PolicyController extends RestrictedBaseController { //Initialize the FunctionDefinition table at Server Start up Map> functionMap = getFunctionDatatypeMap(); - for (Datatype id : functionMap.keySet()) { - List functionDefinations = functionMap.get(id); + for ( Entry> entry : functionMap.entrySet()) { + List functionDefinations = entry.getValue(); for (FunctionDefinition functionDef : functionDefinations) { dropDownMap.put(functionDef.getShortname(),functionDef.getXacmlid()); } @@ -437,7 +444,7 @@ public class PolicyController extends RestrictedBaseController { for(Object entity : policyEntity){ PolicyEntity pEntity = (PolicyEntity) entity; String removeExtension = pEntity.getPolicyName().replace(".xml", ""); - String version = removeExtension.substring(removeExtension.lastIndexOf(".")+1); + String version = removeExtension.substring(removeExtension.lastIndexOf('.')+1); av.add(version); } if(policyName.contains("/")){ @@ -475,14 +482,6 @@ public class PolicyController extends RestrictedBaseController { PolicyController.commonClassDao = commonClassDao; } - public XacmlAdminAuthorization getAuthorizer() { - return authorizer; - } - - public void setAuthorizer(XacmlAdminAuthorization authorizer) { - this.authorizer = authorizer; - } - public static Map> getMapDatatype2Function() { return mapDatatype2Function; } @@ -711,6 +710,19 @@ public class PolicyController extends RestrictedBaseController { return file; } + public static void setFileSizeLimit(String uploadSize) { + //Default size limit is 30MB + if (uploadSize == null || uploadSize.isEmpty()) { + fileSizeLimit = 30000000; + } + else { + fileSizeLimit = Long.parseLong(uploadSize); + } + } + + public static long getFileSizeLimit() { + return fileSizeLimit; + } public String convertDate(String dateTTL) { String formateDate = null; if(dateTTL.contains("-")){