[java-shib-profile] 01/03: IDP-2121 Future Proofing the Module Plugin infrastructure for Future SP use

Rod Widdowson rdw at steadingsoftware.com
Fri Jun 9 09:35:28 UTC 2023


This is an automated email from the git hooks/post-receive script.

rdw pushed a commit to branch main
in repository java-shib-profile.

View the commit online:
http://git.shibboleth.net/view/?p=java-shib-profile.git;a=commit;h=20169aa92b868297a4f93df6d80498dd402d19e3

commit 20169aa92b868297a4f93df6d80498dd402d19e3
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Thu Jun 8 17:00:56 2023 +0100

    IDP-2121 Future Proofing the Module Plugin infrastructure for Future SP use
    
    https://shibboleth.atlassian.net/browse/IDP-2121
    
    Move the save and new extensions into the Module Interface.
---
 .../shibboleth/profile/module/AbstractModule.java  | 24 +++++++---------------
 .../java/net/shibboleth/profile/module/Module.java | 10 +++++++++
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/shib-profile-api/src/main/java/net/shibboleth/profile/module/AbstractModule.java b/shib-profile-api/src/main/java/net/shibboleth/profile/module/AbstractModule.java
index 6d9c7fc..b729f53 100644
--- a/shib-profile-api/src/main/java/net/shibboleth/profile/module/AbstractModule.java
+++ b/shib-profile-api/src/main/java/net/shibboleth/profile/module/AbstractModule.java
@@ -69,12 +69,6 @@ import net.shibboleth.shared.spring.httpclient.resource.ConnectionClosingInputSt
  */
 public abstract class AbstractModule implements Module {
 
-    /** Extension for preserving user files. */
-    @Nonnull @NotEmpty private final String saveExt;
-
-    /** Base extension for adding new default files. */
-    @Nonnull @NotEmpty private final String baseExt;
-
     /** Class logger. */
     @Nonnull private Logger log = LoggerFactory.getLogger(AbstractModule.class);
     
@@ -82,20 +76,16 @@ public abstract class AbstractModule implements Module {
     @Nonnull private Collection<ModuleResource> moduleResources;
     
     /** Version-aware extension for new files added. */
-    @Nonnull private String idpNewExt;
+    @Nonnull private String appNewExt;
     
     /**
      * Constructor.
      *
      * @param version version of the containing application (or null if none available)
-     * @param basExt extension for adding new default files.
-     * @param savExt extension for preserving user files.
      */
-    protected AbstractModule(@Nullable final String version, @Nonnull @NotEmpty final String basExt, @Nonnull @NotEmpty final String savExt) {
+    protected AbstractModule(@Nullable final String version) {
         moduleResources = CollectionSupport.emptyList();
-        saveExt = savExt;
-        baseExt = basExt;
-        idpNewExt = version != null ? baseExt + "-" + version.replace(".", "") : baseExt;
+        appNewExt = version != null ? getNewExtension() + "-" + version.replace(".", "") : getNewExtension();
     }
     
     /** {@inheritDoc} */
@@ -517,7 +507,7 @@ public abstract class AbstractModule implements Module {
                 if (hasChanged) {
                     if (isReplace()) {
                         destPath = Path.of(moduleContext.getInstallLocation()).resolve(destination);
-                        final Path savedPath = destPath.resolveSibling(destPath.getFileName() + saveExt);
+                        final Path savedPath = destPath.resolveSibling(destPath.getFileName() + getSaveExtension());
                         if (savedPath.toFile().exists()) {
                             throw new IOException(savedPath + " exists, aborting");
                         }
@@ -526,7 +516,7 @@ public abstract class AbstractModule implements Module {
                         result = ResourceResult.REPLACED;
                     } else {
                         final Path basePath = Path.of(moduleContext.getInstallLocation()).resolve(destination);
-                        destPath = basePath.resolveSibling(basePath.getFileName() + idpNewExt);
+                        destPath = basePath.resolveSibling(basePath.getFileName() + appNewExt);
                         result = ResourceResult.ADDED;
                     }
                     
@@ -585,11 +575,11 @@ public abstract class AbstractModule implements Module {
                         result = ResourceResult.REMOVED;
                     } else {
                         log.debug("Module {} backing up resource {}", getId(), resolved);
-                        Files.move(resolved, resolved.resolveSibling(resolved.getFileName() + saveExt),
+                        Files.move(resolved, resolved.resolveSibling(resolved.getFileName() + getSaveExtension()),
                                 StandardCopyOption.REPLACE_EXISTING);
                         result = ResourceResult.SAVED;
                     }
-                    final Path idpnewVersion = resolved.resolveSibling(resolved.getFileName() + idpNewExt);
+                    final Path idpnewVersion = resolved.resolveSibling(resolved.getFileName() + appNewExt);
                     if (Files.exists(idpnewVersion)) {
                         Files.delete(idpnewVersion);
                     }
diff --git a/shib-profile-api/src/main/java/net/shibboleth/profile/module/Module.java b/shib-profile-api/src/main/java/net/shibboleth/profile/module/Module.java
index a77593f..f28f6ef 100644
--- a/shib-profile-api/src/main/java/net/shibboleth/profile/module/Module.java
+++ b/shib-profile-api/src/main/java/net/shibboleth/profile/module/Module.java
@@ -127,6 +127,16 @@ public interface Module extends IdentifiedComponent {
     @Nonnull @NonnullElements Map<ModuleResource,ResourceResult> disable(@Nonnull final ModuleContext moduleContext,
             final boolean clean) throws ModuleException;
 
+    /** Return the extension that the module manager will use to preserve user files.
+     * @return the string.
+     */
+    @Nonnull String getSaveExtension();
+
+    /** Return the extension that the module manager will use for new default files..
+     * @return the string.
+     */
+    @Nonnull String getNewExtension();
+
     /**
      * Interface to a resource managed by the module.
      */

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list