Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dfba855

Browse files
authored
XWIKI-22211: Deprecate NotificationFilterPreferenceProvider (xwiki#2882)
* Deprecate and legacify NotificationFilterPreferenceProvider and NotificationFilterPreference#getProviderHint * Clean up all code relying on it simplifying a lot the implem of NotificationFilterPreference * Only valid usage of the providerHint was for checking if a filter preference was stored or not: replaced it with checking the ID of the filter * Fix bad prefix in filters internal ids * Fix typos
1 parent 8677475 commit dfba855

File tree

30 files changed

+288
-454
lines changed

30 files changed

+288
-454
lines changed

xwiki-platform-core/pom.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,18 @@
138138
139139
Single justification example:
140140
-->
141+
<revapi.differences>
142+
<justification>Deprecated method available through legacy but breakage triggered by a
143+
dependant module.</justification>
144+
<criticality>allowed</criticality>
145+
<differences>
146+
<item>
147+
<ignore>true</ignore>
148+
<code>java.method.removed</code>
149+
<old>method java.lang.String org.xwiki.notifications.filters.NotificationFilterPreference::getProviderHint()</old>
150+
</item>
151+
</differences>
152+
</revapi.differences>
141153

142154

143155
</analysisConfiguration>

xwiki-platform-core/xwiki-platform-legacy/xwiki-platform-legacy-notifications/xwiki-platform-legacy-notifications-filters/xwiki-platform-legacy-notifications-filters-api/pom.xml

Lines changed: 133 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,18 @@
3737
By setting this property, we make sure this application would be automatically uninstalled if the administrator
3838
installs the old Activity Stream Application. -->
3939
<xwiki.extension.features>org.xwiki.platform:xwiki-platform-notifications-filters-api</xwiki.extension.features>
40-
<xwiki.jacoco.instructionRatio>0.63</xwiki.jacoco.instructionRatio>
40+
<xwiki.jacoco.instructionRatio>0.08</xwiki.jacoco.instructionRatio>
4141
</properties>
4242
<dependencies>
43+
<!-- Trigger xwiki-platform-notifications-filters-api dependencies (but without
44+
xwiki-platform-notifications-filters-api jar itself) -->
4345
<dependency>
4446
<groupId>org.xwiki.platform</groupId>
4547
<artifactId>xwiki-platform-notifications-filters-api</artifactId>
4648
<version>${project.version}</version>
49+
<type>pom</type>
4750
<exclusions>
51+
<!-- We want the legacy dependency of notification-api -->
4852
<exclusion>
4953
<groupId>org.xwiki.platform</groupId>
5054
<artifactId>xwiki-platform-notifications-api</artifactId>
@@ -56,6 +60,27 @@
5660
<artifactId>xwiki-platform-legacy-notifications-api</artifactId>
5761
<version>${project.version}</version>
5862
</dependency>
63+
<!-- Aspectified dependency -->
64+
<dependency>
65+
<groupId>org.xwiki.platform</groupId>
66+
<artifactId>xwiki-platform-notifications-filters-api</artifactId>
67+
<version>${project.version}</version>
68+
<!-- We don't want to draw this dependency since we're wrapping it -->
69+
<scope>provided</scope>
70+
<exclusions>
71+
<!-- We want the legacy dependency of notification-api -->
72+
<exclusion>
73+
<groupId>org.xwiki.platform</groupId>
74+
<artifactId>xwiki-platform-notifications-api</artifactId>
75+
</exclusion>
76+
</exclusions>
77+
</dependency>
78+
<!-- Build tools -->
79+
<!-- Needed for backward compatibility Aspects -->
80+
<dependency>
81+
<groupId>org.aspectj</groupId>
82+
<artifactId>aspectjrt</artifactId>
83+
</dependency>
5984
<!-- Test dependencies -->
6085
<dependency>
6186
<groupId>org.xwiki.commons</groupId>
@@ -64,4 +89,111 @@
6489
<scope>test</scope>
6590
</dependency>
6691
</dependencies>
92+
<build>
93+
<plugins>
94+
<!-- Apply Backward compatibility Aspects using the strategy described at
95+
http://blogs.sonatype.com/john/2007/11/09/1194630418546.html -->
96+
<plugin>
97+
<groupId>org.codehaus.mojo</groupId>
98+
<artifactId>aspectj-maven-plugin</artifactId>
99+
<executions>
100+
<execution>
101+
<id>backward-compatibility-aspects</id>
102+
<configuration>
103+
<weaveDependencies>
104+
<weaveDependency>
105+
<groupId>org.xwiki.platform</groupId>
106+
<artifactId>xwiki-platform-notifications-filters-api</artifactId>
107+
</weaveDependency>
108+
</weaveDependencies>
109+
</configuration>
110+
</execution>
111+
</executions>
112+
</plugin>
113+
<!-- Exclude AspectJ's builddef.lst file form the generated JAR since it's not useful there. -->
114+
<plugin>
115+
<groupId>org.apache.maven.plugins</groupId>
116+
<artifactId>maven-jar-plugin</artifactId>
117+
<configuration>
118+
<excludes>
119+
<exclude>**/builddef.lst</exclude>
120+
</excludes>
121+
</configuration>
122+
</plugin>
123+
<plugin>
124+
<!-- Merge components.txt files -->
125+
<groupId>org.apache.maven.plugins</groupId>
126+
<artifactId>maven-antrun-plugin</artifactId>
127+
<executions>
128+
<execution>
129+
<phase>process-classes</phase>
130+
<configuration>
131+
<target>
132+
<!-- Add a line separator before appending the legacy components.
133+
NOTE: The following solutions didn't work:
134+
* the fixlastline parameter of the concat task affects only the appended files, NOT the destination
135+
file; we need the new line at the end of the destination file!
136+
* the text content of the header element inside the concat task is trimmed when the POM is parsed.
137+
See http://jira.codehaus.org/browse/PLX-461 -->
138+
<echo message="${line.separator}" file="${project.build.directory}/classes/META-INF/components.txt" append="true" />
139+
<concat destfile="${project.build.directory}/classes/META-INF/components.txt" append="true">
140+
<filelist dir="${basedir}/src/main/resources/META-INF/" files="components.txt" />
141+
</concat>
142+
</target>
143+
</configuration>
144+
<goals>
145+
<goal>run</goal>
146+
</goals>
147+
</execution>
148+
</executions>
149+
</plugin>
150+
<!-- Make sure we run the tests only with the aspectified JARs since otherwise components will be registered
151+
twice for example. -->
152+
<plugin>
153+
<groupId>org.apache.maven.plugins</groupId>
154+
<artifactId>maven-surefire-plugin</artifactId>
155+
<configuration>
156+
<classpathDependencyExcludes>
157+
<classpathDependencyExcludes>org.xwiki.platform:xwiki-platform-notifications-filters-api:jar</classpathDependencyExcludes>
158+
</classpathDependencyExcludes>
159+
</configuration>
160+
</plugin>
161+
<plugin>
162+
<groupId>fr.inria.gforge.spoon</groupId>
163+
<artifactId>spoon-maven-plugin</artifactId>
164+
<executions>
165+
<execution>
166+
<id>spoon-main</id>
167+
<configuration>
168+
<processorProperties combine.children="append">
169+
<processorProperty>
170+
<name>org.xwiki.tool.spoon.ComponentAnnotationProcessor</name>
171+
<properties>
172+
<property>
173+
<!-- Skip foreign declaration checks since we merge the components.txt -->
174+
<name>skipForeignDeclarations</name>
175+
<value>true</value>
176+
</property>
177+
<!-- TODO: Ideally inherit this from the top level pom but I couldn't find how to do it, or remove
178+
it when spoon is fixed, see https://github.com/INRIA/spoon/issues/3339 -->
179+
<property>
180+
<name>componentsTxtPath</name>
181+
<value>target/classes/META-INF/components.txt</value>
182+
</property>
183+
</properties>
184+
</processorProperty>
185+
</processorProperties>
186+
</configuration>
187+
</execution>
188+
<execution>
189+
<id>spoon-test</id>
190+
<configuration>
191+
<!-- TODO: Remove once https://github.com/INRIA/spoon/issues/3583 is fixed -->
192+
<skip>true</skip>
193+
</configuration>
194+
</execution>
195+
</executions>
196+
</plugin>
197+
</plugins>
198+
</build>
67199
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* See the NOTICE file distributed with this work for additional
3+
* information regarding copyright ownership.
4+
*
5+
* This is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU Lesser General Public License as
7+
* published by the Free Software Foundation; either version 2.1 of
8+
* the License, or (at your option) any later version.
9+
*
10+
* This software is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
* Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public
16+
* License along with this software; if not, write to the Free
17+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19+
*/
20+
package org.xwiki.notifications.filters;
21+
22+
/**
23+
* Add a backward compatibility layer to {@link NotificationFilterPreference}.
24+
*
25+
* @version $Id$
26+
* @since 16.5.0RC1
27+
*/
28+
public privileged aspect NotificationFilterPreferenceCompatibilityAspect
29+
{
30+
declare parents : NotificationFilterPreference implements CompatibilityNotificationFilterPreference;
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* See the NOTICE file distributed with this work for additional
3+
* information regarding copyright ownership.
4+
*
5+
* This is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU Lesser General Public License as
7+
* published by the Free Software Foundation; either version 2.1 of
8+
* the License, or (at your option) any later version.
9+
*
10+
* This software is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
* Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public
16+
* License along with this software; if not, write to the Free
17+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19+
*/
20+
package org.xwiki.notifications.filters;
21+
22+
/**
23+
* Deprecated methods of {@link NotificationFilterPreference}.
24+
*
25+
* @version $Id$
26+
* @since 16.5.0RC1
27+
*/
28+
public interface CompatibilityNotificationFilterPreference
29+
{
30+
/**
31+
* @return the name of the provider hint associated with this preference.
32+
* @deprecated this information is now useless with support of a single location for storing preferences
33+
*/
34+
@Deprecated(since = "16.5.0RC1")
35+
default String getProviderHint()
36+
{
37+
return "";
38+
}
39+
}
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@
3434
*
3535
* @version $Id$
3636
* @since 9.8RC1
37+
* @deprecated this interface is not used anywhere anymore in XWiki Standard.
3738
*/
3839
@Role
40+
@Deprecated(since = "16.5.0RC1")
3941
public interface NotificationFilterPreferenceProvider
4042
{
4143
/**
@@ -73,7 +75,7 @@ default Set<NotificationFilterPreference> getFilterPreferences(WikiReference wik
7375
* @since 9.11.9
7476
*/
7577
void saveFilterPreferences(DocumentReference user, Set<NotificationFilterPreference> filterPreferences)
76-
throws NotificationException;
78+
throws NotificationException;
7779

7880
/**
7981
* Delete a filter preference.
@@ -129,7 +131,7 @@ default void deleteFilterPreference(WikiReference wikiReference, String filterPr
129131
* @since 9.11.9
130132
*/
131133
void setFilterPreferenceEnabled(DocumentReference user, String filterPreferenceId, boolean enabled)
132-
throws NotificationException;
134+
throws NotificationException;
133135

134136
/**
135137
* Enable or disable a filter preference.
@@ -158,4 +160,4 @@ default void setFilterPreferenceEnabled(WikiReference wikiReference, String filt
158160
* @since 9.11.5
159161
*/
160162
void setStartDateForUser(DocumentReference user, Date startDate) throws NotificationException;
161-
}
163+
}

xwiki-platform-core/xwiki-platform-legacy/xwiki-platform-legacy-notifications/xwiki-platform-legacy-notifications-sources/src/test/java/org/xwiki/notifications/sources/internal/LegacyDefaultNotificationParametersFactoryTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,6 @@ private DefaultNotificationFilterPreference getFilterPreference(String property,
368368
filterPreference.setFilterName(ScopeNotificationFilter.FILTER_NAME);
369369
filterPreference.setFilterType(NotificationFilterType.INCLUSIVE);
370370
filterPreference.setNotificationFormats(Collections.singleton(NotificationFormat.ALERT));
371-
filterPreference.setProviderHint("FACTORY");
372371
return filterPreference;
373372
}
374373
}

xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-filters/xwiki-platform-notifications-filters-api/pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
<!-- Name to display by the Extension Manager -->
3636
<xwiki.extension.name>Notifications Filters API</xwiki.extension.name>
3737
<checkstyle.suppressions.location>${basedir}/src/checkstyle/checkstyle-suppressions.xml</checkstyle.suppressions.location>
38+
<!-- Skip revapi since it's handled by the legacy module -->
39+
<xwiki.revapi.skip>true</xwiki.revapi.skip>
3840
</properties>
3941
<dependencies>
4042
<dependency>

xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-filters/xwiki-platform-notifications-filters-api/src/main/java/org/xwiki/notifications/filters/NotificationFilterPreference.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
import org.apache.commons.lang3.StringUtils;
2828
import org.xwiki.notifications.NotificationFormat;
29+
import org.xwiki.stability.Unstable;
2930

3031
import static com.xpn.xwiki.doc.XWikiDocument.DB_SPACE_SEP;
3132

@@ -47,6 +48,13 @@
4748
*/
4849
public interface NotificationFilterPreference
4950
{
51+
/**
52+
* Prefix to be used for the ID only when the preference is stored in database.
53+
* @since 16.5.0RC1
54+
*/
55+
@Unstable
56+
String DB_ID_FILTER_PREFIX = "NFP_";
57+
5058
/**
5159
* @return the unique identifier of the filter preference.
5260
* @since 10.8RC1
@@ -59,11 +67,6 @@ public interface NotificationFilterPreference
5967
*/
6068
String getFilterName();
6169

62-
/**
63-
* @return the name of the {@link NotificationFilterPreferenceProvider} associated with this preference.
64-
*/
65-
String getProviderHint();
66-
6770
/**
6871
* @return true if the current notification preference is enabled.
6972
*/

xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-filters/xwiki-platform-notifications-filters-api/src/main/java/org/xwiki/notifications/filters/NotificationFilterPreferenceManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ Stream<NotificationFilterPreference> getFilterPreferences(
105105
* @since 10.8.3
106106
* @since 9.11.9
107107
*/
108-
void saveFilterPreferences(DocumentReference user, Set<NotificationFilterPreference> notificationFilterPreferences);
108+
void saveFilterPreferences(DocumentReference user, Set<NotificationFilterPreference> notificationFilterPreferences)
109+
throws NotificationException;
109110

110111
/**
111112
* Delete a filter preference.

0 commit comments

Comments
 (0)