return single;
}
+ public void includeProfile(String profile) {
+ this.load(profile, true);
+ }
+
+ public void excludeProfile(String profile) {
+ this.load(profile, false);
+ }
public void add(String productVersion, String paramName, String paramValue) {
}
private void load() {
+ this.load(this.profileName, true);
+ }
+
+ private void load(String profileName, boolean include) {
List<OnapCommandParamEntity> params= new ArrayList<>();
try {
- params = this.loadParamFromCache(this.profileName);
+ params = this.loadParamFromCache(profileName);
} catch (OnapCommandLoadProfileFailed e) {
throw new RuntimeException(e); // NOSONAR
}
for (OnapCommandParamEntity p : params) {
- this.add(p.getProduct(), p.getName(), p.getValue());
+ if (include) {
+ this.add(p.getProduct(), p.getName(), p.getValue());
+ } else {
+ this.remove(p.getProduct(), p.getName());
+ }
}
}
paramCache.remove(this.getEnabledProductVersion(), paramName);
}
- public void setProfile(String profileName) {
+ public void setProfile(String profileName, List<String> includes, List<String> excludes) {
this.paramCache.setProfile(profileName);
+
+ for (String profile: includes) {
+ this.paramCache.includeProfile(profile);
+ }
+
+ for (String profile: excludes) {
+ this.paramCache.excludeProfile(profile);
+ }
}
public List<String> getUserProfiles() {
import java.io.File;
import java.net.URL;
+import java.util.ArrayList;
import org.junit.Before;
import org.junit.Test;
@Test
public void testProfile() throws OnapCommandException {
try {
- OnapCommandRegistrar.getRegistrar().setProfile("test12312");
+ OnapCommandRegistrar.getRegistrar().setProfile("test234", new ArrayList<String>(), new ArrayList<String>());
OnapCommandRegistrar.getRegistrar().addParamCache("a", "b");
OnapCommandRegistrar.getRegistrar().getParamCache();
OnapCommandRegistrar.getRegistrar().removeParamCache("a");
if ((args.size() == 2) && (this.getLongOption(OnapCliConstants.PARAM_PROFILE_LONG).equals(args.get(0))
|| this.getShortOption(OnapCliConstants.PARAM_PROFILE_SHORT).equals(args.get(0)))) {
- OnapCommandRegistrar.getRegistrar().setProfile(args.get(1));
+ OnapCommandRegistrar.getRegistrar().setProfile(
+ args.get(1),
+ new ArrayList<String>(),
+ new ArrayList<String>());
//Make space of interactive mode
this.args = new ArrayList<>();
}