Skip to content

Commit

Permalink
Merge branch 'dev_core'
Browse files Browse the repository at this point in the history
  • Loading branch information
maybeec committed Mar 16, 2018
2 parents 7f83309 + f83d5ec commit 59699bc
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cobigen-documentation/tools-cobigen.wiki
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,19 @@ public interface InputInterpreter {
public Object read(String type, Path path, Charset inputCharset, Object... additionalArguments)
throws InputReaderException;

/**
* Reads the content at a path via the first fitting {@link InputReader} and returns a CobiGen compliant
* input
* @param path
* the {@link Path} to the object. Can also point to a folder
* @param inputCharset
* of the input to be used
* @param additionalArguments
* depending on the InputReader implementation
* @return Object that is a valid input or null if the file cannot be read by any InputReader
* @throws InputReaderException
* if the Path cannot be read
*/
public Object read(Path path, Charset inputCharset, Object... additionalArguments) throws InputReaderException;

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.capgemini.cobigen.api.exception;


/** Exception to indicate that an InputReader encountered a problem while parsing input content. */
public class InputReaderException extends CobiGenRuntimeException {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
package com.capgemini.cobigen.impl.exceptions;

import com.capgemini.cobigen.api.exception.CobiGenRuntimeException;
package com.capgemini.cobigen.api.exception;

/**
* States that any logic has been triggered, which is currently not supported.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public class PluginNotAvailableException extends InvalidConfigurationException {
* the plugin type searched for
*/
public PluginNotAvailableException(String component, String plugintype) {
super("The Plug-in with type " + plugintype + " did not serve any " + component
super((plugintype != null ? "The Plug-in with type " + plugintype + " did not serve any "
: "There is no plug-in serving ") + component
+ ". Please make sure, that you installed all necessary plug-ins and there is no typo in "
+ "type='...' values of all triggers in your context configuration as well as there are no typos "
+ "in your templates configuration's mergeStrategy='...' values.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
import com.capgemini.cobigen.api.constants.BackupPolicy;
import com.capgemini.cobigen.api.exception.CobiGenRuntimeException;
import com.capgemini.cobigen.api.exception.InvalidConfigurationException;
import com.capgemini.cobigen.api.exception.NotYetSupportedException;
import com.capgemini.cobigen.impl.exceptions.BackupFailedException;
import com.capgemini.cobigen.impl.exceptions.NotYetSupportedException;
import com.capgemini.cobigen.impl.util.ExceptionUtil;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import org.dozer.DozerBeanMapper;

import com.capgemini.cobigen.api.constants.ConfigurationConstants;
import com.capgemini.cobigen.api.exception.NotYetSupportedException;
import com.capgemini.cobigen.impl.config.ContextConfiguration;
import com.capgemini.cobigen.impl.config.constant.ContextConfigurationVersion;
import com.capgemini.cobigen.impl.exceptions.NotYetSupportedException;

/**
* This class encompasses all logic for legacy context configuration detection and upgrading these to the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import org.dozer.DozerBeanMapper;

import com.capgemini.cobigen.api.constants.ConfigurationConstants;
import com.capgemini.cobigen.api.exception.NotYetSupportedException;
import com.capgemini.cobigen.impl.config.constant.TemplatesConfigurationVersion;
import com.capgemini.cobigen.impl.config.entity.io.TemplatesConfiguration;
import com.capgemini.cobigen.impl.exceptions.NotYetSupportedException;

/**
* This class encompasses all logic for legacy templates configuration detection and upgrading these to the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import org.slf4j.LoggerFactory;

import com.capgemini.cobigen.api.exception.InvalidConfigurationException;
import com.capgemini.cobigen.api.exception.NotYetSupportedException;
import com.capgemini.cobigen.impl.config.constant.ContextConfigurationVersion;
import com.capgemini.cobigen.impl.config.constant.TemplatesConfigurationVersion;
import com.capgemini.cobigen.impl.exceptions.NotYetSupportedException;

/**
* The version validator checks the compatibility of CobiGen and its configuration files
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.capgemini.cobigen.impl.extension;

import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
Expand Down Expand Up @@ -143,4 +145,13 @@ public static TriggerInterpreter getTriggerInterpreter(String triggerType) {
return triggerInterpreter;
}

/**
* Returns a {@link Map} of all {@link TriggerInterpreter} keys.
*
* @return all {@link TriggerInterpreter} keys as a set of strings.
*/
public static Set<String> getTriggerInterpreterKeySet() {
return new HashSet<>(registeredTriggerInterpreter.keySet());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ public Object read(String type, Path path, Charset inputCharset, Object... addit
return inputInterpreter.read(type, path, inputCharset, additionalArguments);
}

@Override
public Object read(Path path, Charset inputCharset, Object... additionalArguments) throws InputReaderException {
return inputInterpreter.read(path, inputCharset, additionalArguments);
}

@Override
public List<IncrementTo> getMatchingIncrements(Object matcherInput) throws InvalidConfigurationException {
return configurationInterpreter.getMatchingIncrements(matcherInput);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,8 @@ private Map<File, File> generate(TemplateTo template, TriggerInterpreter trigger
if (merger != null) {
mergeResult = merger.merge(tmpOriginalFile, patch, targetCharset);
} else {
throw new PluginNotAvailableException(trigger.getType(),
"merge strategy '" + templateEty.getMergeStrategy() + "'");
throw new PluginNotAvailableException(
"merge strategy '" + templateEty.getMergeStrategy() + "'", null);
}

if (mergeResult != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import javax.inject.Inject;

Expand Down Expand Up @@ -57,6 +58,19 @@ public Object read(String type, Path path, Charset inputCharset, Object... addit
return getInputReader(type).read(path, inputCharset, additionalArguments);
}

@Override
public Object read(Path path, Charset inputCharset, Object... additionalArguments) throws InputReaderException {
Set<String> keySet = PluginRegistry.getTriggerInterpreterKeySet();
for (String s : keySet) {
try {
return getInputReader(s).read(path, inputCharset, additionalArguments);
} catch (InputReaderException e) {
// nothing to do.
}
}
return null;
}

/**
* @param type
* of the input
Expand Down
2 changes: 1 addition & 1 deletion cobigen/cobigen-core-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</parent>

<properties>
<cobigencore.version>4.2.0</cobigencore.version>
<cobigencore.version>4.2.1-SNAPSHOT</cobigencore.version>
</properties>

<modules>
Expand Down

0 comments on commit 59699bc

Please sign in to comment.