Skip to content

Commit

Permalink
Merge 21263de into 1a57c79
Browse files Browse the repository at this point in the history
  • Loading branch information
adamcin committed Aug 28, 2020
2 parents 1a57c79 + 21263de commit 31cc5be
Show file tree
Hide file tree
Showing 90 changed files with 4,275 additions and 211 deletions.
2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>net.adamcin.oakpal</groupId>
<artifactId>oakpal</artifactId>
<version>2.1.1-SNAPSHOT</version>
<version>2.2.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Copyright 2020 Mark Adamcin
*
* 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.
*/

package net.adamcin.oakpal.api;

import org.apache.jackrabbit.vault.packaging.JcrPackage;
import org.apache.jackrabbit.vault.packaging.PackageId;
import org.jetbrains.annotations.NotNull;

import java.util.Objects;

/**
* An installable path identified as an embedded package.
*/
public final class EmbeddedPackageInstallable implements SlingInstallable<JcrPackage> {
private final @NotNull PackageId parentId;
private final @NotNull String jcrPath;
private final @NotNull PackageId embeddedId;

/**
* Constructor.
*
* @param parentId the parent package id
* @param jcrPath the embedded jcr path
* @param embeddedId the embedded package id
*/
public EmbeddedPackageInstallable(final @NotNull PackageId parentId,
final @NotNull String jcrPath,
final @NotNull PackageId embeddedId) {
this.parentId = parentId;
this.jcrPath = jcrPath;
this.embeddedId = embeddedId;
}

@NotNull
@Override
public PackageId getParentId() {
return parentId;
}

@NotNull
@Override
public String getJcrPath() {
return jcrPath;
}

@NotNull
public PackageId getEmbeddedId() {
return embeddedId;
}

@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final EmbeddedPackageInstallable that = (EmbeddedPackageInstallable) o;
return parentId.equals(that.parentId) &&
jcrPath.equals(that.jcrPath) &&
embeddedId.equals(that.embeddedId);
}

@Override
public int hashCode() {
return Objects.hash(parentId, jcrPath, embeddedId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Copyright 2020 Mark Adamcin
*
* 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.
*/

package net.adamcin.oakpal.api;

import org.apache.jackrabbit.vault.packaging.PackageId;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
* Sling Installable representing an OSGi config node.
*/
public final class OsgiConfigInstallable implements SlingInstallable<Map<String, Object>> {
private final @NotNull PackageId parentId;
private final @NotNull String jcrPath;
private final @NotNull Map<String, Object> properties;
private final @NotNull String servicePid;
private final @Nullable String factoryPid;

public OsgiConfigInstallable(@NotNull final PackageId parentId,
@NotNull final String jcrPath,
@NotNull final Map<String, Object> properties,
@NotNull final String servicePid,
@Nullable final String factoryPid) {
this.parentId = parentId;
this.jcrPath = jcrPath;
this.properties = Collections.unmodifiableMap(new HashMap<>(properties));
this.servicePid = servicePid;
this.factoryPid = factoryPid;
}

@NotNull
@Override
public PackageId getParentId() {
return parentId;
}

@NotNull
@Override
public String getJcrPath() {
return jcrPath;
}

@NotNull
public Map<String, Object> getProperties() {
return properties;
}

@NotNull
public String getServicePid() {
return servicePid;
}

@Nullable
public String getFactoryPid() {
return factoryPid;
}
}
82 changes: 82 additions & 0 deletions api/src/main/java/net/adamcin/oakpal/api/ProgressCheck.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import javax.jcr.Session;
import java.io.File;
import java.util.List;
import java.util.Set;
import java.util.jar.Manifest;

/**
Expand Down Expand Up @@ -55,6 +56,7 @@ default String getCheckName() {
return getClass().getSimpleName();
}


/**
* Called after the package is uploaded to the package manager at the beginning of the scan. Track subsequent
* events using the package ID provided to this method. This method will only be called once for each package
Expand All @@ -77,6 +79,7 @@ default void identifySubpackage(PackageId packageId, PackageId parentId) {

}


/**
* If the package provides a {@link Manifest}, it will be provided to the check using this method, prior to calling
* {@link #beforeExtract(PackageId, Session, PackageProperties, MetaInf, List)}.
Expand Down Expand Up @@ -154,4 +157,83 @@ default void deletedPath(PackageId packageId, String path, Session inspectSessio
default void afterExtract(PackageId packageId, Session inspectSession) throws RepositoryException {

}

/**
* Override this method to accept an {@link SlingSimulator} to request installation of JCR resources like
* FileVault packages and RepositoryInitializer factory configs, as if running within a Sling repository instance.
* <p>
* Also provied are the set of simulated Sling Run Modes. These are intended to drive construction of JCR path
* patterns to select embedded resources for installation upon receiving a matching
* {@link ProgressCheck#importedPath(PackageId, String, Node, PathAction)} event, but these run modes may also be
* used as a global configuration hint for progress checks that support modal behavior outside of their explicit
* JSON config format. NOTE: this set will always be empty by default, and must be populated in the plan or
* overridden at runtime in the execution layer.
*
* @param slingSimulator the sling simulator
* @param runModes the simulated sling run modes
* @since 2.1.0
*/
default void simulateSling(SlingSimulator slingSimulator, Set<String> runModes) {

}

/**
* Called after each embedded package is opened, if it has been submitted to the {@link SlingSimulator}. Track
* subsequent events using the package ID provided to this method. Conceptually, at least for the purposes of
* enforcing acceptance criteria against packaged JCR content, this is analogous to
* {@link #identifySubpackage(PackageId, PackageId)}.
*
* @param packageId the package ID of the newly opened embeddedPackage
* @param parentId the package ID of the parent package.
* @param jcrPath the JCR path of this embedded package within the repository
* @since 2.1.0
*/
default void identifyEmbeddedPackage(PackageId packageId, PackageId parentId, String jcrPath) {

}

/**
* Provides an opportunity to inspect repository state before installing a resource submitted to the
* {@link SlingSimulator}.
*
* @param lastPackage the last preinstall or scan package
* @param slingInstallable the sling installable
* @param inspectSession session providing access to repository state
* @throws RepositoryException because of access to a {@link Session}
* @since 2.1.0
*/
default void beforeSlingInstall(PackageId lastPackage, SlingInstallable<?> slingInstallable, Session inspectSession)
throws RepositoryException {

}

/**
* Provides an opportunity to inspect repository state after installing a resource submitted to the
* {@link SlingSimulator}.
*
* @param lastPackage the last preinstall or scan package
* @param slingInstallable the sling installable
* @param inspectSession session providing access to repository state
* @throws RepositoryException because of access to a {@link Session}
* @since 2.1.0
*/
default void appliedRepoInitScripts(PackageId lastPackage, SlingInstallable<?> slingInstallable, Session inspectSession)
throws RepositoryException {

}

/**
* Provides an opportunity to inspect repository state after complete installation (including its content,
* subpackages, and Sling installable paths) of a package explicitly listed for scanning. This method is NOT called
* for any of its subpackages or embedded packages.
*
* @param packageId the scanned package id
* @param inspectSession session providing access to repository state
* @throws RepositoryException because of access to a {@link Session}
* @since 2.1.0
*/
default void afterScanPackage(PackageId packageId, Session inspectSession) throws RepositoryException {

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright 2020 Mark Adamcin
*
* 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.
*/

package net.adamcin.oakpal.api;

import org.apache.jackrabbit.vault.packaging.PackageId;
import org.jetbrains.annotations.NotNull;

import java.util.List;

/**
* Locates a jcr path that should be treated as an installable provider of repoinit scripts.
*/
public final class RepoInitScriptsInstallable implements SlingInstallable<Iterable<String>> {
private final @NotNull PackageId parentId;
private final @NotNull String jcrPath;
private final @NotNull List<String> scripts;

public RepoInitScriptsInstallable(final @NotNull PackageId parentId,
final @NotNull String jcrPath,
final @NotNull List<String> scripts) {
this.parentId = parentId;
this.jcrPath = jcrPath;
this.scripts = scripts;
}

@Override
public @NotNull PackageId getParentId() {
return parentId;
}

@Override
public @NotNull String getJcrPath() {
return jcrPath;
}

@NotNull
public List<String> getScripts() {
return scripts;
}

}
36 changes: 36 additions & 0 deletions api/src/main/java/net/adamcin/oakpal/api/SilenceableCheck.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright 2020 Mark Adamcin
*
* 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.
*/

package net.adamcin.oakpal.api;

import org.osgi.annotation.versioning.ConsumerType;

/**
* Extended interface marking progress checks that respect a mid-scan mode that expects oakpal to temporarily silence
* violations triggered by scan events. {@link ProgressCheck}s that do not implement this interface are simply blocked
* from receiving scan events for the duration of the silent period.
*/
@ConsumerType
public interface SilenceableCheck extends ProgressCheck {

/**
* If silenced is true, this check must DISABLE the collection of violations until this method is called again
* with silenced=false.
*
* @param silenced true to silence violation reporting
*/
void setSilenced(boolean silenced);
}
Loading

0 comments on commit 31cc5be

Please sign in to comment.