### Be careful, this must be in one line only ###
-SPRING_APPLICATION_JSON={"spring.datasource.cldsdb.url":"jdbc:mariadb:sequential://db:3306/cldsdb4?autoReconnect=true&connectTimeout=10000&socketTimeout=10000&retriesAllDown=3","org.onap.clamp.config.files.cldsPolicyConfig":"classpath:/clds/clds-policy-config.properties","org.onap.clamp.config.files.sdcController":"classpath:/clds/sdc-controllers-config.json"}
\ No newline at end of file
+SPRING_APPLICATION_JSON={"spring.datasource.cldsdb.url":"jdbc:mariadb:sequential://db:3306/cldsdb4?autoReconnect=true&connectTimeout=10000&socketTimeout=10000&retriesAllDown=3","clamp.config.files.sdcController":"classpath:/clds/sdc-controllers-config.json","clamp.config.files.cldsPolicyConfig":"classpath:/clds/clds-policy-config.properties"}
\ No newline at end of file
protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
protected static final String POLICY_MSTYPE_PROPERTY_NAME = "policy.ms.type";
protected static final String POLICY_ONAPNAME_PROPERTY_NAME = "policy.onap.name";
- @Value("${org.onap.clamp.config.files.cldsPolicyConfig:'classpath:/clds/clds-policy-config.properties'}")
+ @Value("${clamp.config.files.cldsPolicyConfig:'classpath:/clds/clds-policy-config.properties'}")
protected String cldsPolicyConfigFile;
@Autowired
protected ApplicationContext appContext;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import org.apache.commons.io.IOUtils;
import org.onap.clamp.clds.exception.CldsUsersException;
import org.onap.clamp.clds.service.CldsUser;
public class CldsUserJsonDecoder {
+
/**
* This method decodes the JSON file provided to a CldsUser Array. The
* stream is closed after this call, this is not possible to reuse it.
* JSON file
*/
public static CldsUser[] decodeJson(InputStream cldsUsersFile) {
+ try {
+ return decodeJson(IOUtils.toString(cldsUsersFile, StandardCharsets.UTF_8.name()));
+ } catch (IOException e) {
+ throw new CldsUsersException("Exception occurred during the decoding of the clds-users.json", e);
+ }
+ }
+
+ public static CldsUser[] decodeJson(String cldsUsersString) {
try {
// the ObjectMapper readValue method closes the stream no need to do
// it
- return new ObjectMapper().readValue(cldsUsersFile, CldsUser[].class);
+ return new ObjectMapper().readValue(cldsUsersString, CldsUser[].class);
} catch (IOException e) {
throw new CldsUsersException("Exception occurred during the decoding of the clds-users.json", e);
}
/**
* The file name that will be loaded by Spring.
*/
- @Value("${org.onap.clamp.config.files.sdcController:'classpath:/clds/sdc-controllers-config.json'}")
+ @Value("${clamp.config.files.sdcController:'classpath:/clds/sdc-controllers-config.json'}")
protected String sdcControllerFile;
/**
* The root of the JSON.
import java.io.IOException;
+import org.onap.clamp.clds.config.ClampProperties;
import org.onap.clamp.clds.config.CldsUserJsonDecoder;
import org.onap.clamp.clds.exception.CldsUsersException;
import org.onap.clamp.clds.service.CldsUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
/**
* This class is used to enable the HTTP authentication to login. It requires a
* specific JSON file containing the user definition
- * (classpath:etc/config/clds/clds-users.json).
+ * (classpath:clds/clds-users.json).
*/
@Configuration
@EnableWebSecurity
protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsSecurityConfigUsers.class);
protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
@Autowired
- private ApplicationContext appContext;
- @Value("${org.onap.clamp.config.files.cldsUsers:'classpath:etc/config/clds/clds-users.json'}")
- private String cldsUsersFile;
+ private ClampProperties refProp;
@Value("${clamp.config.security.permission.type.cl:permission-type-cl}")
private String cldsPersmissionTypeCl;
@Value("${CLDS_PERMISSION_INSTANCE:dev}")
CldsUser[] usersList = loadUsers();
// no users defined
if (null == usersList) {
- logger.warn("No users defined. Users should be defined under " + cldsUsersFile);
+ logger.warn("No users defined. Users should be defined under clds-users.json");
return;
}
for (CldsUser user : usersList) {
* CldsUser.
*
* @return The array of CldsUser
+ * @throws IOException
+ * In case of the file is not found
*/
- private CldsUser[] loadUsers() {
- try {
- logger.info("Load from clds-users.properties");
- return CldsUserJsonDecoder.decodeJson(appContext.getResource(cldsUsersFile).getInputStream());
- } catch (IOException e) {
- logger.error("Unable to decode the User Json file", e);
- throw new CldsUsersException("Load from clds-users.properties", e);
- }
+ private CldsUser[] loadUsers() throws IOException {
+ logger.info("Load from clds-users.properties");
+ return CldsUserJsonDecoder.decodeJson(refProp.getFileContent("files.cldsUsers"));
}
}
throw new CldsConfigException(e.getMessage(), e);
}
// refresh model info from db (get fresh event info)
- CldsModel retreivedModel = CldsModel.retrieve(cldsDao, modelName, false);
+ CldsModel retrievedModel = CldsModel.retrieve(cldsDao, modelName, false);
if (!isTest && (actionCd.equalsIgnoreCase(CldsEvent.ACTION_SUBMIT)
|| actionCd.equalsIgnoreCase(CldsEvent.ACTION_RESUBMIT)
|| actionCd.equalsIgnoreCase(CldsEvent.ACTION_SUBMITDCAE))) {
// To verify inventory status and modify model status to distribute
- dcaeInventoryServices.setEventInventory(retreivedModel, getUserId());
- retreivedModel.save(cldsDao, getUserId());
+ dcaeInventoryServices.setEventInventory(retrievedModel, getUserId());
+ retrievedModel.save(cldsDao, getUserId());
}
// audit log
LoggingUtils.setTimeContext(startTime, new Date());
LoggingUtils.setResponseContext("0", "Process model action success", this.getClass().getName());
auditLogger.info("Process model action completed");
- return retreivedModel;
+ return retrievedModel;
}
/**
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public CldsModel unDeployModel(@PathParam("action") String action, @PathParam("modelName") String modelName,
- @QueryParam("test") String test, CldsModel model) throws IOException {
+ @QueryParam("test") String test, CldsModel model) {
Date startTime = new Date();
LoggingUtils.setRequestContext("CldsService: Undeploy model", getPrincipalName());
String operationStatusUndeployUrl = dcaeDispatcherServices.deleteExistingDeployment(model.getDeploymentId(),
async.max.pool.size=20\r
async.queue.capacity=500\r
\r
-org.onap.clamp.config.files.cldsPolicyConfig=classpath:/clds/clds-policy-config.properties\r
-org.onap.clamp.config.files.cldsUsers=classpath:/clds/clds-users.json\r
+clamp.config.files.cldsPolicyConfig=classpath:/clds/clds-policy-config.properties\r
+clamp.config.files.cldsUsers=classpath:/clds/clds-users.json\r
clamp.config.files.globalProperties=classpath:/clds/templates/globalProperties.json\r
-org.onap.clamp.config.files.sdcController=classpath:/clds/sdc-controllers-config.json\r
+clamp.config.files.sdcController=classpath:/clds/sdc-controllers-config.json\r
\r
# Properties for Clamp\r
# DCAE request build properties\r
async.max.pool.size=20\r
async.queue.capacity=500\r
\r
-org.onap.clamp.config.files.cldsPolicyConfig=classpath:/clds/clds-policy-config.properties\r
-org.onap.clamp.config.files.cldsUsers=classpath:/clds/clds-users.json\r
+clamp.config.files.cldsPolicyConfig=classpath:/clds/clds-policy-config.properties\r
+clamp.config.files.cldsUsers=classpath:/clds/clds-users.json\r
clamp.config.files.globalProperties=classpath:/clds/templates/globalProperties.json\r
-org.onap.clamp.config.files.sdcController=classpath:/clds/sdc-controllers-config.json\r
+clamp.config.files.sdcController=classpath:/clds/sdc-controllers-config.json\r
\r
# Properties for Clamp\r
# DCAE request build properties\r