You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by di...@apache.org on 2021/06/30 07:51:31 UTC
[sling-org-apache-sling-sitemap] branch master updated:
SLING-10573: moved constants around, minor package adjustments
This is an automated email from the ASF dual-hosted git repository.
diru pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-sitemap.git
The following commit(s) were added to refs/heads/master by this push:
new a1c0c9d SLING-10573: moved constants around, minor package adjustments
a1c0c9d is described below
commit a1c0c9d9ac16e053c1e79307c92b4a61be026358
Author: drudolph <dr...@adobe.com>
AuthorDate: Wed Jun 30 09:45:02 2021 +0200
SLING-10573: moved constants around, minor package adjustments
---
.../org/apache/sling/sitemap/SitemapService.java | 32 ++++++++++++++++++++--
.../sling/sitemap/impl/SitemapEventUtil.java | 21 +++++++-------
.../sling/sitemap/impl/SitemapServiceImpl.java | 2 +-
.../apache/sling/sitemap/impl/SitemapServlet.java | 2 +-
.../spi/{ => common}/SitemapLinkExternalizer.java | 2 +-
.../sitemap/spi/{ => common}/package-info.java | 2 +-
.../sitemap/spi/generator/SitemapGenerator.java | 29 --------------------
.../sling/sitemap/impl/SitemapStorageTest.java | 22 +++++++--------
8 files changed, 54 insertions(+), 58 deletions(-)
diff --git a/src/main/java/org/apache/sling/sitemap/SitemapService.java b/src/main/java/org/apache/sling/sitemap/SitemapService.java
index 13717e2..546e15b 100644
--- a/src/main/java/org/apache/sling/sitemap/SitemapService.java
+++ b/src/main/java/org/apache/sling/sitemap/SitemapService.java
@@ -19,7 +19,7 @@
package org.apache.sling.sitemap;
import org.apache.sling.api.resource.Resource;
-import org.apache.sling.sitemap.spi.SitemapLinkExternalizer;
+import org.apache.sling.sitemap.spi.common.SitemapLinkExternalizer;
import org.jetbrains.annotations.NotNull;
import org.osgi.annotation.versioning.ProviderType;
@@ -36,16 +36,42 @@ public interface SitemapService {
* {@link Resource} or to a {@link Resource}'s jcr:content child.
*/
String PROPERTY_SITEMAP_ROOT = "sling:sitemapRoot";
-
/**
* The default name used for (unnamed) sitemaps.
*/
String DEFAULT_SITEMAP_NAME = "<default>";
-
/**
* The name used for sitemap indexes.
*/
String SITEMAP_INDEX_NAME = "<sitemap-index>";
+ /**
+ * The background generation will send events with that topic right after a generated sitemap was persisted.
+ */
+ String EVENT_TOPIC_SITEMAP_UPDATED = "org/apache/sling/sitemap/UPDATED";
+ /**
+ * The background cleanup will send events with that topic right after an obsolete sitemap file was purged.
+ */
+ String EVENT_TOPIC_SITEMAP_PURGED = "org/apache/sling/sitemap/PURGED";
+ /**
+ * The event property storing the generated sitemap's root path.
+ */
+ String EVENT_PROPERTY_SITEMAP_ROOT = "sitemap.root";
+ /**
+ * The event property storing the generated sitemap's name.
+ */
+ String EVENT_PROPERTY_SITEMAP_NAME = "sitemap.name";
+ /**
+ * The event property storing the generated sitemap's count of urls.
+ */
+ String EVENT_PROPERTY_SITEMAP_URLS = "sitemap.urls";
+ /**
+ * The event property storing the generated sitemap's storage path.
+ */
+ String EVENT_PROPERTY_SITEMAP_STORAGE_PATH = "sitemap.storagePath";
+ /**
+ * The event property storing the generated sitemap's binary size.
+ */
+ String EVENT_PROPERTY_SITEMAP_STORAGE_SIZE = "sitemap.storageSize";
/**
* Returns the configured maximum size (bytes) a sitemap must not exceed.
diff --git a/src/main/java/org/apache/sling/sitemap/impl/SitemapEventUtil.java b/src/main/java/org/apache/sling/sitemap/impl/SitemapEventUtil.java
index 6889d68..b2b77a1 100644
--- a/src/main/java/org/apache/sling/sitemap/impl/SitemapEventUtil.java
+++ b/src/main/java/org/apache/sling/sitemap/impl/SitemapEventUtil.java
@@ -19,6 +19,7 @@
package org.apache.sling.sitemap.impl;
import org.apache.sling.api.resource.Resource;
+import org.apache.sling.sitemap.SitemapService;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventProperties;
@@ -26,12 +27,10 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-import static org.apache.sling.sitemap.spi.generator.SitemapGenerator.*;
-
/**
* A utility class to create new {@link Event}s for sitemap storage operations.
*/
-class SitemapEventUtil {
+final class SitemapEventUtil {
private SitemapEventUtil() {
super();
@@ -39,16 +38,16 @@ class SitemapEventUtil {
static Event newUpdateEvent(SitemapStorageInfo storageInfo, Resource sitemapRoot) {
Map<String, Object> props = new HashMap<>(5);
- props.put(EVENT_PROPERTY_SITEMAP_NAME, storageInfo.getName());
- props.put(EVENT_PROPERTY_SITEMAP_ROOT, sitemapRoot.getPath());
- props.put(EVENT_PROPERTY_SITEMAP_URLS, storageInfo.getEntries());
- props.put(EVENT_PROPERTY_SITEMAP_STORAGE_PATH, storageInfo.getPath());
- props.put(EVENT_PROPERTY_SITEMAP_STORAGE_SIZE, storageInfo.getSize());
- return new Event(EVENT_TOPIC_SITEMAP_UPDATED, new EventProperties(props));
+ props.put(SitemapService.EVENT_PROPERTY_SITEMAP_NAME, storageInfo.getName());
+ props.put(SitemapService.EVENT_PROPERTY_SITEMAP_ROOT, sitemapRoot.getPath());
+ props.put(SitemapService.EVENT_PROPERTY_SITEMAP_URLS, storageInfo.getEntries());
+ props.put(SitemapService.EVENT_PROPERTY_SITEMAP_STORAGE_PATH, storageInfo.getPath());
+ props.put(SitemapService.EVENT_PROPERTY_SITEMAP_STORAGE_SIZE, storageInfo.getSize());
+ return new Event(SitemapService.EVENT_TOPIC_SITEMAP_UPDATED, new EventProperties(props));
}
static Event newPurgeEvent(String path) {
- Map<String, Object> properties = Collections.singletonMap(EVENT_PROPERTY_SITEMAP_STORAGE_PATH, path);
- return new Event(EVENT_TOPIC_SITEMAP_PURGED, new EventProperties(properties));
+ Map<String, Object> properties = Collections.singletonMap(SitemapService.EVENT_PROPERTY_SITEMAP_STORAGE_PATH, path);
+ return new Event(SitemapService.EVENT_TOPIC_SITEMAP_PURGED, new EventProperties(properties));
}
}
diff --git a/src/main/java/org/apache/sling/sitemap/impl/SitemapServiceImpl.java b/src/main/java/org/apache/sling/sitemap/impl/SitemapServiceImpl.java
index 7b7dbac..bb2d27c 100644
--- a/src/main/java/org/apache/sling/sitemap/impl/SitemapServiceImpl.java
+++ b/src/main/java/org/apache/sling/sitemap/impl/SitemapServiceImpl.java
@@ -21,7 +21,7 @@ package org.apache.sling.sitemap.impl;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.sitemap.SitemapInfo;
import org.apache.sling.sitemap.SitemapService;
-import org.apache.sling.sitemap.spi.SitemapLinkExternalizer;
+import org.apache.sling.sitemap.spi.common.SitemapLinkExternalizer;
import org.apache.sling.sitemap.SitemapUtil;
import org.apache.sling.sitemap.SitemapGeneratorManager;
import org.jetbrains.annotations.NotNull;
diff --git a/src/main/java/org/apache/sling/sitemap/impl/SitemapServlet.java b/src/main/java/org/apache/sling/sitemap/impl/SitemapServlet.java
index fb4ef6d..8b622f6 100644
--- a/src/main/java/org/apache/sling/sitemap/impl/SitemapServlet.java
+++ b/src/main/java/org/apache/sling/sitemap/impl/SitemapServlet.java
@@ -24,7 +24,7 @@ import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.servlets.ServletResolverConstants;
import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
import org.apache.sling.sitemap.SitemapException;
-import org.apache.sling.sitemap.spi.SitemapLinkExternalizer;
+import org.apache.sling.sitemap.spi.common.SitemapLinkExternalizer;
import org.apache.sling.sitemap.spi.generator.SitemapGenerator;
import org.apache.sling.sitemap.SitemapGeneratorManager;
import org.apache.sling.sitemap.impl.builder.SitemapImpl;
diff --git a/src/main/java/org/apache/sling/sitemap/spi/SitemapLinkExternalizer.java b/src/main/java/org/apache/sling/sitemap/spi/common/SitemapLinkExternalizer.java
similarity index 98%
rename from src/main/java/org/apache/sling/sitemap/spi/SitemapLinkExternalizer.java
rename to src/main/java/org/apache/sling/sitemap/spi/common/SitemapLinkExternalizer.java
index 9b0223e..be61934 100644
--- a/src/main/java/org/apache/sling/sitemap/spi/SitemapLinkExternalizer.java
+++ b/src/main/java/org/apache/sling/sitemap/spi/common/SitemapLinkExternalizer.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.sling.sitemap.spi;
+package org.apache.sling.sitemap.spi.common;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
diff --git a/src/main/java/org/apache/sling/sitemap/spi/package-info.java b/src/main/java/org/apache/sling/sitemap/spi/common/package-info.java
similarity index 90%
rename from src/main/java/org/apache/sling/sitemap/spi/package-info.java
rename to src/main/java/org/apache/sling/sitemap/spi/common/package-info.java
index 9df2171..63f9a0d 100644
--- a/src/main/java/org/apache/sling/sitemap/spi/package-info.java
+++ b/src/main/java/org/apache/sling/sitemap/spi/common/package-info.java
@@ -17,6 +17,6 @@
* under the License.
*/
@Version("1.0.0")
-package org.apache.sling.sitemap.spi;
+package org.apache.sling.sitemap.spi.common;
import org.osgi.annotation.versioning.Version;
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/sitemap/spi/generator/SitemapGenerator.java b/src/main/java/org/apache/sling/sitemap/spi/generator/SitemapGenerator.java
index 8707c09..a18e60e 100644
--- a/src/main/java/org/apache/sling/sitemap/spi/generator/SitemapGenerator.java
+++ b/src/main/java/org/apache/sling/sitemap/spi/generator/SitemapGenerator.java
@@ -46,35 +46,6 @@ import org.osgi.annotation.versioning.ConsumerType;
public interface SitemapGenerator {
/**
- * The background generation will send events with that topic right after a generated sitemap was persisted.
- */
- String EVENT_TOPIC_SITEMAP_UPDATED = "org/apache/sling/sitemap/UPDATED";
- /**
- * The background cleanup will send events with that topic right after an obsolete sitemap file was purged.
- */
- String EVENT_TOPIC_SITEMAP_PURGED = "org/apache/sling/sitemap/PURGED";
- /**
- * The event property storing the generated sitemap's root path.
- */
- String EVENT_PROPERTY_SITEMAP_ROOT = "sitemap.root";
- /**
- * The event property storing the generated sitemap's name.
- */
- String EVENT_PROPERTY_SITEMAP_NAME = "sitemap.name";
- /**
- * The event property storing the generated sitemap's count of urls.
- */
- String EVENT_PROPERTY_SITEMAP_URLS = "sitemap.urls";
- /**
- * The event property storing the generated sitemap's storage path.
- */
- String EVENT_PROPERTY_SITEMAP_STORAGE_PATH = "sitemap.storagePath";
- /**
- * The event property storing the generated sitemap's binary size.
- */
- String EVENT_PROPERTY_SITEMAP_STORAGE_SIZE = "sitemap.storageSize";
-
- /**
* Returns a {@link Set} of sitemap names this {@link SitemapGenerator} can generate for a particular sitemap
* root {@link Resource}. If the implementation does not generate a sitemap for a particular root it must return an
* empty {@link Set}, if it does but does not differentiate by name, it must return a {@link Set} containing only
diff --git a/src/test/java/org/apache/sling/sitemap/impl/SitemapStorageTest.java b/src/test/java/org/apache/sling/sitemap/impl/SitemapStorageTest.java
index 645dfb2..566fdb5 100644
--- a/src/test/java/org/apache/sling/sitemap/impl/SitemapStorageTest.java
+++ b/src/test/java/org/apache/sling/sitemap/impl/SitemapStorageTest.java
@@ -245,8 +245,8 @@ class SitemapStorageTest {
SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE
));
context.registerService(EventHandler.class, capturedEvents::add, EventConstants.EVENT_TOPIC, new String[]{
- SitemapGenerator.EVENT_TOPIC_SITEMAP_UPDATED,
- SitemapGenerator.EVENT_TOPIC_SITEMAP_PURGED
+ SitemapService.EVENT_TOPIC_SITEMAP_UPDATED,
+ SitemapService.EVENT_TOPIC_SITEMAP_PURGED
});
// when
@@ -266,8 +266,8 @@ class SitemapStorageTest {
SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE
));
context.registerService(EventHandler.class, capturedEvents::add, EventConstants.EVENT_TOPIC, new String[]{
- SitemapGenerator.EVENT_TOPIC_SITEMAP_UPDATED,
- SitemapGenerator.EVENT_TOPIC_SITEMAP_PURGED
+ SitemapService.EVENT_TOPIC_SITEMAP_UPDATED,
+ SitemapService.EVENT_TOPIC_SITEMAP_PURGED
});
// when
@@ -281,8 +281,8 @@ class SitemapStorageTest {
System.out.println(capturedEvents.stream().map(Event::toString).collect(Collectors.joining(",")));
assertThat(capturedEvents, hasSize(2));
assertThat(capturedEvents, hasItems(
- sitemapEvent(SitemapGenerator.EVENT_TOPIC_SITEMAP_UPDATED, storagePath),
- sitemapEvent(SitemapGenerator.EVENT_TOPIC_SITEMAP_PURGED, storagePath)
+ sitemapEvent(SitemapService.EVENT_TOPIC_SITEMAP_UPDATED, storagePath),
+ sitemapEvent(SitemapService.EVENT_TOPIC_SITEMAP_PURGED, storagePath)
));
}
@@ -294,8 +294,8 @@ class SitemapStorageTest {
SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE
));
context.registerService(EventHandler.class, capturedEvents::add, EventConstants.EVENT_TOPIC, new String[]{
- SitemapGenerator.EVENT_TOPIC_SITEMAP_UPDATED,
- SitemapGenerator.EVENT_TOPIC_SITEMAP_PURGED
+ SitemapService.EVENT_TOPIC_SITEMAP_UPDATED,
+ SitemapService.EVENT_TOPIC_SITEMAP_PURGED
});
// when
@@ -307,8 +307,8 @@ class SitemapStorageTest {
// then
assertThat(capturedEvents, hasSize(2));
assertThat(capturedEvents, hasItems(
- sitemapEvent(SitemapGenerator.EVENT_TOPIC_SITEMAP_UPDATED, storagePath),
- sitemapEvent(SitemapGenerator.EVENT_TOPIC_SITEMAP_PURGED, storagePath)
+ sitemapEvent(SitemapService.EVENT_TOPIC_SITEMAP_UPDATED, storagePath),
+ sitemapEvent(SitemapService.EVENT_TOPIC_SITEMAP_PURGED, storagePath)
));
}
@@ -335,7 +335,7 @@ class SitemapStorageTest {
return o instanceof Event
&& topic.equals(((Event) o).getTopic())
&& storagePath.equals(
- ((Event) o).getProperty(SitemapGenerator.EVENT_PROPERTY_SITEMAP_STORAGE_PATH));
+ ((Event) o).getProperty(SitemapService.EVENT_PROPERTY_SITEMAP_STORAGE_PATH));
}
};
}