Commit 1f3d7936 authored by Jeroen Hoffman's avatar Jeroen Hoffman

ESSENTIALS-1005 Merge master to bugfix branch

parents f0ffdf80 a61b56a4
......@@ -8,44 +8,6 @@ Please use the Hippo Essentials feedback form to inform us if you encounter any
suggestions for improvements.
```
# Prerequisites
* Java 8
* Maven 3.x
* Git (http://git-scm.com)
* NodeJS (http://nodejs.org/) 5.x.x
* Node Package Manager (http://npmjs.org)
* Grunt (http://gruntjs.org)
Grunt can be installed with Node Package Manager:
```shell
sudo npm install -g grunt-cli
```
## Windows specific preparation instructions
You can automate the installation of NodeJS and NPM using [Chocolatey package manager]
(https://chocolatey.org).
The package for Node.js can be installed using (this will also install NPM):
C:\> choco install nodejs.install
__Note:__ Due to a [bug] (http://jira.codehaus.org/browse/MEXEC-137) in the exec-maven-plugin the Maven build of the
API module will fail as the exec-maven-plugin is unable to find the __grunt__ command. To fix this, do
the following:
* open folder `C:\Users\USER\AppData\Roaming\npm`
* copy __grunt.cmd__ to __grunt.bat__
More information can be found [here] (http://stackoverflow.com/questions/22393785/exec-maven-plugin-says-cannot-run-specified-program-even-though-it-is-on-the-pa/22395703#22395703).
Installation of Git is also possible using Chocolatey:
C:\> choco install git.install
# Getting Started
## Code checkout
......@@ -101,7 +63,7 @@ mvn -P cargo.run -Drepo.path=storage
The following URLs are available from this project:
* CMS at http://localhost:8080/cms
* Website at http://localhost:8080/site
* Website at http://localhost:8080/site
* Essentials dashboard at http://localhost:8080/essentials
Logs are located in `target/tomcat8x/logs`
......
This diff is collapsed.
......@@ -175,14 +175,21 @@ public class ContentBeansService {
continue;
}
}
log.info("@Missing declaration for: {}. Method will be deleted", internalName);
final boolean deleted = JavaSourceUtils.deleteMethod(method, path);
final String methodName = method.getMethodName();
if (deleted) {
context.addPluginContextData(CONTEXT_BEAN_DATA, new BeanWriterLogEntry(path.toString(), methodName, ActionType.DELETED_METHOD));
eventBus.post(new MessageEvent(String.format("Successfully deleted method: %s", methodName)));
final HippoEssentialsGeneratedObject annotation = JavaSourceUtils.getHippoEssentialsAnnotation(path, method.getMethodDeclaration());
final boolean allowUpdate = annotation != null && annotation.isAllowModifications();
if(allowUpdate) {
log.info("@Missing declaration for: {}. Method will be deleted", internalName);
final boolean deleted = JavaSourceUtils.deleteMethod(method, path);
final String methodName = method.getMethodName();
if (deleted) {
context.addPluginContextData(CONTEXT_BEAN_DATA, new BeanWriterLogEntry(path.toString(), methodName, ActionType.DELETED_METHOD));
eventBus.post(new MessageEvent(String.format("Successfully deleted method: %s", methodName)));
} else {
context.addPluginContextData(CONTEXT_BEAN_DATA, new BeanWriterLogEntry(String.format("Failed to delete method: %s", methodName)));
}
} else {
context.addPluginContextData(CONTEXT_BEAN_DATA, new BeanWriterLogEntry(String.format("Failed to delete method: %s", methodName)));
context.addPluginContextData(CONTEXT_BEAN_DATA, new BeanWriterLogEntry("Method should be removed, but modifications are disabled: "
+ method.getInternalName() + ", " + method.getMethodName()));
}
}
}
......@@ -624,6 +631,8 @@ public class ContentBeansService {
continue;
}
final ExistingMethodsVisitor methods = JavaSourceUtils.getMethodCollection(path);
final HippoEssentialsGeneratedObject annotation = JavaSourceUtils.getHippoGeneratedAnnotation(path);
final boolean allowUpdate = annotation != null && annotation.isAllowModifications();
final List<EssentialsGeneratedMethod> generatedMethods = methods.getGeneratedMethods();
for (EssentialsGeneratedMethod m : generatedMethods) {
final Type type = m.getMethodDeclaration().getReturnType2();
......@@ -633,13 +642,20 @@ public class ContentBeansService {
// check if image type and different than new return type
if (imageTypes.containsKey(returnType) && !returnType.equals(newReturnType)) {
log.info("Found image type: {}", returnType);
updateImageMethod(path, returnType, newReturnType, imageTypes.get(newReturnType));
if (allowUpdate) {
updateImageMethod(path, returnType, newReturnType, imageTypes.get(newReturnType));
} else{
context.addPluginContextData(CONTEXT_BEAN_DATA, new BeanWriterLogEntry("Method return type should be changed, but modifications are disabled: "
+ m.getInternalName() + ", " + m.getMethodName()));
}
}
} else if (JavaSourceUtils.getParameterizedType(type) != null) {
final String returnType = JavaSourceUtils.getParameterizedType(type);
if (imageTypes.containsKey(returnType) && !returnType.equals(newReturnType)) {
log.info("Found image type: {}", returnType);
updateImageMethod(path, returnType, newReturnType, imageTypes.get(newReturnType));
if (allowUpdate) {
updateImageMethod(path, returnType, newReturnType, imageTypes.get(newReturnType));
}
}
}
}
......@@ -739,14 +755,30 @@ public class ContentBeansService {
if (existing.contains(name)) {
log.debug("Property already exists {}. Checking if method signature has changed e.g. single value to multiple", name);
final ExistingMethodsVisitor methodCollection = JavaSourceUtils.getMethodCollection(beanPath);
final List<EssentialsGeneratedMethod> generatedMethods = methodCollection.getGeneratedMethods();
for (EssentialsGeneratedMethod generatedMethod : generatedMethods) {
final HippoEssentialsGeneratedObject annotation = JavaSourceUtils.getHippoEssentialsAnnotation(beanPath, generatedMethod.getMethodDeclaration());
final boolean allowUpdate = annotation != null && annotation.isAllowModifications();
final String internalName = generatedMethod.getInternalName();
if (name.equals(internalName)) {
// check if single/multiple changed:
if (generatedMethod.isMultiType() != multiple) {
log.info("Property changed (single/multiple): {}", internalName);
return JavaSourceUtils.deleteMethod(generatedMethod, beanPath);
if (allowUpdate) {
log.info("Property changed (single/multiple): {}", internalName);
return JavaSourceUtils.deleteMethod(generatedMethod, beanPath);
}else{
// there was a change, however, method is marked as read only
log.warn("Property changed (single/multiple): {}, but changes not allowed", internalName);
context.addPluginContextData(CONTEXT_BEAN_DATA, new BeanWriterLogEntry("Method return type should be changed, but modifications are disabled: "
+ internalName + ", " + generatedMethod.getMethodName()));
return false;
}
}
// TODO: check check if signature changed:
}
......
......@@ -999,6 +999,15 @@ public final class JavaSourceUtils {
return false;
}
public static HippoEssentialsGeneratedObject getHippoEssentialsAnnotation(final Path beanPath, final MethodDeclaration node) {
@SuppressWarnings({UNCHECKED, RAWTYPES})
final List modifiers = node.modifiers();
if (modifiers == null) {
return null;
}
return getGeneratedObject(modifiers, beanPath);
}
public static String getHippoEssentialsAnnotation(final MethodDeclaration node) {
@SuppressWarnings({UNCHECKED, RAWTYPES})
final List modifiers = node.modifiers();
......@@ -1038,6 +1047,10 @@ public final class JavaSourceUtils {
public static HippoEssentialsGeneratedObject getHippoGeneratedAnnotation(final Path path) {
@SuppressWarnings({UNCHECKED, RAWTYPES})
final List modifiers = getClassAnnotations(path);
return getGeneratedObject(modifiers, path);
}
private static HippoEssentialsGeneratedObject getGeneratedObject(final List modifiers, final Path path) {
for (Object modifier : modifiers) {
if (modifier instanceof NormalAnnotation) {
final NormalAnnotation annotation = (NormalAnnotation) modifier;
......@@ -1055,6 +1068,8 @@ public final class JavaSourceUtils {
private static HippoEssentialsGeneratedObject populateGeneratedObject(final Path path, final NormalAnnotation annotation) {
final HippoEssentialsGeneratedObject o = new HippoEssentialsGeneratedObject();
// set default:
o.setAllowModifications(true);
o.setFilePath(path);
@SuppressWarnings(RAWTYPES)
final List values = annotation.values();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment