Skip to content
This repository has been archived by the owner on Oct 28, 2022. It is now read-only.

Commit

Permalink
Using CollectionValidator and ValidationAdvice classes instead of inc…
Browse files Browse the repository at this point in the history
…lude into the generated project
  • Loading branch information
jcagarcia committed Feb 9, 2017
1 parent 858728b commit eab17dc
Show file tree
Hide file tree
Showing 9 changed files with 5 additions and 214 deletions.
Expand Up @@ -67,7 +67,7 @@ public class DtoOperationsImpl implements DtoOperations {
protected final static Logger LOGGER = HandlerUtils.getLogger(DtoOperationsImpl.class);

private static final Property SPRINGLETS_VERSION_PROPERTY = new Property("springlets.version",
"1.1.0.RELEASE");
"1.2.0.BUILD-SNAPSHOT");
private static final Dependency SPRINGLETS_CONTEXT_DEPENDENCY = new Dependency("io.springlets",
"springlets-context", "${springlets.version}");

Expand Down
Expand Up @@ -109,7 +109,7 @@ public class JpaOperationsImpl implements JpaOperations {
private ServiceInstaceManager serviceManager = new ServiceInstaceManager();

private static final Property SPRINGLETS_VERSION_PROPERTY = new Property("springlets.version",
"1.1.0.RELEASE");
"1.2.0.BUILD-SNAPSHOT");
private static final Dependency SPRINGLETS_DATA_JPA_STARTER = new Dependency("io.springlets",
"springlets-data-jpa", "${springlets.version}");
private static final Dependency SPRINGLETS_DATA_COMMONS_STARTER = new Dependency("io.springlets",
Expand Down
Expand Up @@ -54,7 +54,7 @@ public class JpaAuditOperationsImpl implements JpaAuditOperations {
private ServiceInstaceManager serviceInstaceManager = new ServiceInstaceManager();

private static final Property SPRINGLETS_VERSION_PROPERTY = new Property("springlets.version",
"1.1.0.RELEASE");
"1.2.0.BUILD-SNAPSHOT");
private static final Dependency SPRINGLETS_DATA_JPA_STARTER = new Dependency("io.springlets",
"springlets-boot-starter-data-jpa", "${springlets.version}");

Expand Down
Expand Up @@ -31,7 +31,7 @@
public class SpringletsJpaSecurityProvider implements SecurityProvider {

private static final Property SPRINGLETS_VERSION_PROPERTY = new Property("springlets.version",
"1.1.0.RELEASE");
"1.2.0.BUILD-SNAPSHOT");

private static final Dependency SPRINGLETS_SECURITY_AUTHENTICATION_STARTER = new Dependency(
"io.springlets", "springlets-boot-starter-authentication", "${springlets.version}");
Expand Down
Expand Up @@ -108,7 +108,7 @@ public class ControllerOperationsImpl implements ControllerOperations {
"org.springframework.boot.jackson.JsonObjectDeserializer");

private static final Property SPRINGLETS_VERSION_PROPERTY = new Property("springlets.version",
"1.1.0.RELEASE");
"1.2.0.BUILD-SNAPSHOT");
private static final Dependency SPRINGLETS_WEB_STARTER = new Dependency("io.springlets",
"springlets-boot-starter-web", "${springlets.version}");
private static final Property TRACEE_PROPERTY = new Property("tracee.version", "1.1.2");
Expand Down Expand Up @@ -231,12 +231,6 @@ public void setup(Pom module, boolean usesDefaultModule) {
// Create JSON configuration class
createDomainModelModule(module);

// Create Roo Validator classes
createClassFromTemplate(module, "CollectionValidator-template._java", "CollectionValidator",
"validation");
createClassFromTemplate(module, "ValidatorAdvice-template._java", "ValidatorAdvice",
"validation");

// Adding spring.jackson.serialization.indent-output property
getApplicationConfigService().addProperty(module.getModuleName(),
"spring.jackson.serialization.indent-output", "true", "dev", true);
Expand Down Expand Up @@ -788,63 +782,6 @@ private AnnotationMetadataBuilder getRooDetailAnnotation(final String relationFi
return annotationDetail;
}

/**
* Creates a class from a template
*
* @param module
* the Pom related to modeule where the class should be created
* @param templateName
* the String with the template name
* @param className
* the String with the class name to create
* @param packageLastElement
* the String (optional) with the last element of the package,
* which will be appended to module artifactId. If null, package
* will be module artifactId
*/
public void createClassFromTemplate(Pom module, String templateName, String className,
String packageLastElement) {

// Set package
String packageName = null;
if (StringUtils.isNotBlank(packageLastElement)) {
packageName =
String.format("%s.%s", getTypeLocationService().getTopLevelPackageForModule(module),
packageLastElement);
} else {
packageName = module.getGroupId();
}

// Include implementation of Validator from template
final JavaType type =
new JavaType(String.format("%s.%s", packageName, className), module.getModuleName());
Validate.notNull(type.getModule(),
"ERROR: Module name is required to generate a valid JavaType");
final String identifier =
getPathResolver().getCanonicalPath(type.getModule(), Path.SRC_MAIN_JAVA, type);
InputStream inputStream = null;

// Check first if file exists
if (!getFileManager().exists(identifier)) {
try {

// Use defined template
inputStream = FileUtils.getInputStream(getClass(), templateName);
String input = IOUtils.toString(inputStream);

// Replacing package
input = input.replace("__PACKAGE__", packageName);

// Creating CollectionValidator
getFileManager().createOrUpdateTextFileIfRequired(identifier, input, true);
} catch (final IOException e) {
throw new IllegalStateException(String.format("Unable to create '%s'", identifier), e);
} finally {
IOUtils.closeQuietly(inputStream);
}
}
}

/**
* This method gets all implementations of ControllerMVCResponseService
* interface to be able to locate all installed ControllerMVCResponseService
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit eab17dc

Please sign in to comment.