use of com.buschmais.jqassistant.commandline.CliConfigurationException in project jqa-commandline-tool by jQAssistant.
the class AbstractStoreTask method withStandardOptions.
@Override
public final void withStandardOptions(CommandLine options, PropertiesConfigBuilder propertiesConfigBuilder) throws CliConfigurationException {
StoreConfiguration.StoreConfigurationBuilder builder = StoreConfiguration.builder();
String storeUri = getOptionValue(options, CMDLINE_OPTION_STORE_URI);
String storeDirectory = getOptionValue(options, CMDLINE_OPTION_S);
if (storeUri != null && storeDirectory != null) {
throw new CliConfigurationException("Expecting either parameter '" + CMDLINE_OPTION_STORE_DIRECTORY + "' or '" + CMDLINE_OPTION_STORE_URI + "'.");
}
if (storeUri != null) {
try {
builder.uri(new URI(storeUri));
} catch (URISyntaxException e) {
throw new CliConfigurationException("Cannot parse URI " + storeUri, e);
}
builder.username(getOptionValue(options, CMDLINE_OPTION_STORE_USERNAME));
builder.password(getOptionValue(options, CMDLINE_OPTION_STORE_PASSWORD));
builder.encryption(getOptionValue(options, CMDLINE_OPTION_STORE_ENCRYPTION));
builder.trustStrategy(getOptionValue(options, CMDLINE_OPTION_STORE_TRUST_STRATEGY));
builder.trustCertificate(getOptionValue(options, CMDLINE_OPTION_STORE_TRUST_CERITFICATE));
} else {
String directoryName = OptionHelper.coalesce(storeDirectory, DEFAULT_STORE_DIRECTORY);
File directory = new File(directoryName);
directory.getParentFile().mkdirs();
builder.uri(directory.toURI());
}
builder.embedded(getEmbeddedNeo4jConfiguration(options));
this.storeConfiguration = builder.build();
}
use of com.buschmais.jqassistant.commandline.CliConfigurationException in project jqa-commandline-tool by jQAssistant.
the class AbstractAnalyzeTask method withOptions.
@Override
public void withOptions(CommandLine options, PropertiesConfigBuilder propertiesConfigBuilder) throws CliConfigurationException {
String rulesUrl = getOptionValue(options, CMDLINE_OPTION_RULESURL, null);
if (rulesUrl != null) {
try {
this.rulesUrl = new URL(rulesUrl);
} catch (MalformedURLException e) {
throw new CliConfigurationException("'" + rulesUrl + "' is not a valid URL.", e);
}
}
ruleDirectory = getOptionValue(options, CMDLINE_OPTION_R, Task.DEFAULT_RULE_DIRECTORY);
groupIds = getOptionValues(options, CMDLINE_OPTION_GROUPS, Collections.<String>emptyList());
constraintIds = getOptionValues(options, CMDLINE_OPTION_CONSTRAINTS, Collections.<String>emptyList());
conceptIds = getOptionValues(options, CMDLINE_OPTION_CONCEPTS, Collections.<String>emptyList());
RuleConfiguration.RuleConfigurationBuilder ruleConfigurationBuilder = RuleConfiguration.builder();
String defaultGroupSeverityValue = getOptionValue(options, CMDLINE_OPTION_DEFAULT_GROUP_SEVERITY);
if (defaultGroupSeverityValue != null) {
ruleConfigurationBuilder.defaultGroupSeverity(getSeverity(defaultGroupSeverityValue));
}
String defaultConceptSeverityValue = getOptionValue(options, CMDLINE_OPTION_DEFAULT_CONCEPT_SEVERITY);
if (defaultConceptSeverityValue != null) {
ruleConfigurationBuilder.defaultConceptSeverity(getSeverity(defaultConceptSeverityValue));
}
String defaultConstraintSeverityValue = getOptionValue(options, CMDLINE_OPTION_DEFAULT_CONSTRAINT_SEVERITY);
if (defaultConstraintSeverityValue != null) {
ruleConfigurationBuilder.defaultConstraintSeverity(getSeverity(defaultConstraintSeverityValue));
}
ruleConfiguration = ruleConfigurationBuilder.build();
}
use of com.buschmais.jqassistant.commandline.CliConfigurationException in project jqa-commandline-tool by jQAssistant.
the class ScanTask method executeTask.
@Override
protected void executeTask(Configuration configuration, Store store) throws CliExecutionException {
ScannerContext scannerContext = new ScannerContextImpl(store, new File(DEFAULT_OUTPUT_DIRECTORY));
if (configuration.scan().reset()) {
store.reset();
}
for (ScopeHelper.ScopedResource scopedResource : files) {
String fileName = scopedResource.getResource();
String scopeName = scopedResource.getScopeName();
File file = new File(fileName);
String absolutePath = file.getAbsolutePath();
if (!file.exists()) {
LOGGER.info(absolutePath + "' does not exist, skipping scan.");
} else {
scan(configuration, scannerContext, file, file.getAbsolutePath(), scopeName);
}
}
for (ScopeHelper.ScopedResource scopedResource : urls) {
String uri = scopedResource.getResource();
String scopeName = scopedResource.getScopeName();
try {
scan(configuration, scannerContext, new URI(uri), uri, scopeName);
} catch (URISyntaxException e) {
throw new CliConfigurationException("Cannot parse URI " + uri, e);
}
}
}
use of com.buschmais.jqassistant.commandline.CliConfigurationException in project jqa-commandline-tool by jQAssistant.
the class AbstractAnalyzeTask method configure.
@Override
public void configure(CommandLine options, ConfigurationBuilder configurationBuilder) throws CliConfigurationException {
super.configure(options, configurationBuilder);
String rulesUrl = getOptionValue(options, CMDLINE_OPTION_RULESURL, null);
if (rulesUrl != null) {
try {
this.rulesUrl = new URL(rulesUrl);
} catch (MalformedURLException e) {
throw new CliConfigurationException("'" + rulesUrl + "' is not a valid URL.", e);
}
}
ruleDirectory = getOptionValue(options, CMDLINE_OPTION_R, Task.DEFAULT_RULE_DIRECTORY);
configurationBuilder.with(Analyze.class, Analyze.GROUPS, getOptionValues(options, CMDLINE_OPTION_GROUPS, Collections.<String>emptyList()));
configurationBuilder.with(Analyze.class, Analyze.CONSTRAINTS, getOptionValues(options, CMDLINE_OPTION_CONSTRAINTS, Collections.<String>emptyList()));
configurationBuilder.with(Analyze.class, Analyze.CONCEPTS, getOptionValues(options, CMDLINE_OPTION_CONCEPTS, Collections.<String>emptyList()));
try {
configurationBuilder.with(Rule.class, Rule.DEFAULT_CONCEPT_SEVERITY, Severity.fromValue(getOptionValue(options, CMDLINE_OPTION_DEFAULT_CONCEPT_SEVERITY)));
configurationBuilder.with(Rule.class, Rule.DEFAULT_CONSTRAINT_SEVERITY, Severity.fromValue(getOptionValue(options, CMDLINE_OPTION_DEFAULT_CONSTRAINT_SEVERITY)));
configurationBuilder.with(Rule.class, Rule.DEFAULT_GROUP_SEVERITY, Severity.fromValue(getOptionValue(options, CMDLINE_OPTION_DEFAULT_GROUP_SEVERITY)));
} catch (RuleException e) {
throw new CliConfigurationException("Cannot convert severity.", e);
}
}
use of com.buschmais.jqassistant.commandline.CliConfigurationException in project jqa-commandline-tool by jQAssistant.
the class AbstractStoreTask method configure.
@Override
public void configure(CommandLine options, ConfigurationBuilder configurationBuilder) throws CliConfigurationException {
String storeUri = getOptionValue(options, CMDLINE_OPTION_STORE_URI);
String storeDirectory = getOptionValue(options, CMDLINE_OPTION_S);
if (storeUri != null && storeDirectory != null) {
throw new CliConfigurationException("Expecting either parameter '" + CMDLINE_OPTION_STORE_DIRECTORY + "' or '" + CMDLINE_OPTION_STORE_URI + "'.");
}
if (storeUri != null) {
URI uri;
try {
uri = new URI(storeUri);
} catch (URISyntaxException e) {
throw new CliConfigurationException("Cannot parse URI " + storeUri, e);
}
configurationBuilder.with(com.buschmais.jqassistant.core.store.api.configuration.Store.class, com.buschmais.jqassistant.core.store.api.configuration.Store.URI, uri);
configurationBuilder.with(Remote.class, Remote.USERNAME, getOptionValue(options, CMDLINE_OPTION_STORE_USERNAME));
configurationBuilder.with(Remote.class, Remote.PASSWORD, getOptionValue(options, CMDLINE_OPTION_STORE_PASSWORD));
configurationBuilder.with(Remote.class, Remote.ENCRYPTION, getOptionValue(options, CMDLINE_OPTION_STORE_ENCRYPTION));
configurationBuilder.with(Remote.class, Remote.TRUST_STRATEGY, getOptionValue(options, CMDLINE_OPTION_STORE_TRUST_STRATEGY));
configurationBuilder.with(Remote.class, Remote.TRUST_CERTIFICATE, getOptionValue(options, CMDLINE_OPTION_STORE_TRUST_CERITFICATE));
} else if (storeDirectory != null) {
File directory = new File(storeDirectory);
directory.getParentFile().mkdirs();
configurationBuilder.with(com.buschmais.jqassistant.core.store.api.configuration.Store.class, com.buschmais.jqassistant.core.store.api.configuration.Store.URI, directory.toURI());
}
configurationBuilder.with(Embedded.class, Embedded.CONNECTOR_ENABLED, isConnectorRequired());
configurationBuilder.with(Embedded.class, Embedded.LISTEN_ADDRESS, getOptionValue(options, CMDLINE_OPTION_EMBEDDED_LISTEN_ADDRESS));
configurationBuilder.with(Embedded.class, Embedded.HTTP_PORT, getOptionValue(options, CMDLINE_OPTION_EMBEDDED_HTTP_PORT));
configurationBuilder.with(Embedded.class, Embedded.BOLT_PORT, getOptionValue(options, CMDLINE_OPTION_EMBEDDED_BOLT_PORT));
}
Aggregations