Commit 0c92b265 authored by Jeroen Hoffman's avatar Jeroen Hoffman

ESSENTIALS-979 Merge branch 'master' into bugfix/ESSENTIALS-979

parents d7428142 460cc363
......@@ -21,7 +21,7 @@
<parent>
<artifactId>hippo-essentials</artifactId>
<groupId>org.onehippo.cms7</groupId>
<version>3.1.0-SNAPSHOT</version>
<version>3.2.0-SNAPSHOT</version>
</parent>
<name>dependencies</name>
......
......@@ -20,7 +20,7 @@
<parent>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-essentials</artifactId>
<version>3.1.0-SNAPSHOT</version>
<version>3.2.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>hippo-essentials-dashboard</artifactId>
......
......@@ -22,7 +22,7 @@
<parent>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-essentials-plugin-sdk</artifactId>
<version>3.1.0-SNAPSHOT</version>
<version>3.2.0-SNAPSHOT</version>
</parent>
<name>Hippo Essentials Plugin SDK API</name>
......
......@@ -22,7 +22,7 @@
<parent>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-essentials-plugin-sdk</artifactId>
<version>3.1.0-SNAPSHOT</version>
<version>3.2.0-SNAPSHOT</version>
</parent>
<name>Hippo Essentials Plugin SDK Implementation</name>
......
......@@ -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();
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2014 Hippo B.V. (http://www.onehippo.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onehippo.cms7.essentials</groupId>
<artifactId>hippo-essentials</artifactId>
<version>1.01.00-SNAPSHOT</version>
</parent>
<name>Hippo dashboard plugins sdk</name>
<description>Hippo dashboard plugins sdk</description>
<artifactId>hippo-essentials-plugin-sdk</artifactId>
<version>1.01.00-SNAPSHOT</version>
<packaging>pom</packaging>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2014-2015 Hippo B.V. (http://www.onehippo.com)
Copyright 2014-2016 Hippo B.V. (http://www.onehippo.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
......@@ -17,13 +17,6 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-cms7-release</artifactId>
<version>7.9.0</version>
</parent>
<name>My Hippo Project</name>
<description>My Hippo Project</description>
<groupId>org.example</groupId>
......@@ -31,68 +24,6 @@
<version>1.01.00-SNAPSHOT</version>
<packaging>pom</packaging>
<!--
The below project elements are emptied/overridden as otherwise their metadata would be
inherited or merged from the parent hippo-cms7-release pom (or its hippo-cms7-project pom).
DO NOT remove these tags but instead fill them in appropriately as needed,
UNLESS the inherited values are valid for your project.
-->
<url/>
<inceptionYear/>
<organization/>
<licenses>
<license/>
</licenses>
<mailingLists>
<mailingList/>
</mailingLists>
<developers>
<developer/>
</developers>
<contributors>
<contributor/>
</contributors>
<issueManagement/>
<!--
<scm>
<connection/>
<developerConnection/>
<url/>
</scm>
-->
<ciManagement/>
<distributionManagement>
<repository>
<id>-</id>
<url>-</url>
</repository>
<snapshotRepository>
<id>-</id>
<url>-</url>
</snapshotRepository>
</distributionManagement>
<!-- End of emptied/overridden metadata from parent hippo-cms7-release pom. -->
<properties>
<!-- ***START temporary override of versions*** -->
<!-- ***END temporary override of versions*** -->
<jsp-api.version>2.1</jsp-api.version>
<jstl.version>1.1.2</jstl.version>
<taglibs.version>1.1.2</taglibs.version>
<commons.lang.version>2.6</commons.lang.version>
<junit.version>4.10</junit.version>
<easymock.version>3.1</easymock.version>
<freemarker.version>2.3.18</freemarker.version>
<filesync.override>false</filesync.override>
<maven.plugins.filesync.version>1.0.0</maven.plugins.filesync.version>
<essentials.version>1.0.2</essentials.version>
</properties>
<repositories>
<repository>
<id>hippo</id>
......@@ -101,230 +32,4 @@
</repository>
</repositories>
<dependencyManagement>
<dependencies>
<!-- other predefined runtime scope versioned dependencies -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>${jstl.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>${taglibs.version}</version>
<scope>runtime</scope>
</dependency>
<!-- other predefined compile scope versioned dependencies -->
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>${commons.lang.version}</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>${freemarker.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>${easymock.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<defaultGoal>package</defaultGoal>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.googlecode.mavenfilesync</groupId>
<artifactId>maven-filesync-plugin</artifactId>
<version>${maven.plugins.filesync.version}</version>
<configuration>
<override>${filesync.override}</override>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>${maven.plugin.buildnumber.version}</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<configuration>
<doCheck>false</doCheck>
<doUpdate>false</doUpdate>
<revisionOnScmFailure>-1</revisionOnScmFailure>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven.plugin.jar.version}</version>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
<manifestEntries>
<Implementation-Build>${buildNumber}</Implementation-Build>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
<property>
<name>jrebel</name>
</property>
</activation>
<modules>
<module>bootstrap</module>
<module>cms</module>
<module>site</module>
</modules>
</profile>
<profile>
<id>cargo.run</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<configuration>
<configuration>
<properties>
<catalina.servlet.uriencoding>UTF-8</catalina.servlet.uriencoding>
</properties>
<configfiles>
<configfile>
<file>${project.basedir}/conf/context.xml</file>
<todir>conf/</todir>
<tofile>context.xml</tofile>
</configfile>
</configfiles>
</configuration>
<container>
<systemProperties>
<derby.stream.error.file>${project.basedir}/target/derby.log</derby.stream.error.file>
<log4j.configuration>file:${project.basedir}/conf/log4j-dev.xml</log4j.configuration>
<rebel.log4j-plugin>true</rebel.log4j-plugin>
<!-- enables auto export: -->
<project.basedir>${project.basedir}</project.basedir>
</systemProperties>
</container>
<deployables>
<deployable>
<type>war</type>
<properties>
<context>/cms</context>
</properties>
<location>${project.basedir}/cms/target/cms.war</location>
</deployable>
<deployable>
<location>${project.basedir}/site/target/site.war</location>
<type>war</type>
<properties>
<context>/site</context>
</properties>
</deployable>
</deployables>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<configuration>
<skipSource>true</skipSource>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>dist</id>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<defaultGoal>validate</defaultGoal>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>distro-assembly</id>
<phase>validate</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>${project.basedir}/src/main/assembly/distribution.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2014 Hippo B.V. (http://www.onehippo.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>hippo-essentials</artifactId>
<groupId>org.onehippo.cms7.essentials</groupId>
<version>1.01.00-SNAPSHOT</version>
</parent>
<artifactId>hippo-plugins-site</artifactId>
<packaging>war</packaging>
<name>Hippo plugins Site</name>
<description>Hippo plugins Site</description>
<properties>
<hippo-utilities.version>1.01.02</hippo-utilities.version>
</properties>
<dependencies>
<dependency>
<groupId>org.onehippo.cms7.essentials</groupId>
<artifactId>hippo-plugins-shared</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onehippo.forge.utilities</groupId>
<artifactId>hippo-utilities-hst</artifactId>
<version>${hippo-utilities.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.onehippo.cms7.hst.dependencies</groupId>
<artifactId>hst-server-dependencies</artifactId>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.onehippo.cms7.hst.dependencies</groupId>
<artifactId>hst-spring-dependencies</artifactId>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.onehippo.cms7.hst.dependencies</groupId>
<artifactId>hst-client-dependencies</artifactId>
<type>pom</type>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>de.pdark</groupId>
<artifactId>decentxml</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
</dependency>
<dependency>
<groupId>org.onehippo.cms7.hst.components</groupId>
<artifactId>hst-jaxrs</artifactId>
</dependency>
<dependency>
<groupId>org.onehippo.cms7.hst.client-modules</groupId>
<artifactId>hst-cms-rest</artifactId>
</dependency>
<dependency>
<groupId>org.onehippo.cms7.hst.client-modules</groupId>
<artifactId>hst-page-composer</artifactId>
</dependency>
<dependency>
<groupId>org.onehippo.cms7.hst.components</groupId>
<artifactId>hst-security</artifactId>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.onehippo.cms7.hst</groupId>
<artifactId>hst-mock</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>underscorejs</artifactId>
<version>1.4.4</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>backbonejs</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>1.9.1</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>requirejs</artifactId>
<version>2.1.5</version>
</dependency>
<dependency>
<groupId>javax.websocket</groupId>
<artifactId>javax.websocket-api</artifactId>
<version>1.0-rc1</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-catalina</artifactId>
<version>${cargo.tomcat.full.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-coyote</artifactId>
<version>${cargo.tomcat.full.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>