### Provisioning Model with Run Modes and Start Levels
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/development/slingstart.md
Example of a provisioning model file specifying artifacts and configurations for a particular run mode and start level. This allows for environment-specific configurations.
```text
[feature name=my-feature]
[variables]
eventadmin.version=1.0.0
metatype.version=1.2.0
[artifacts runModes=mymode]
org.apache.sling/metatype/${metatype.version}
[artifacts startLevel=5 runModes=mymode]
org.apache.sling/eventadmin/${eventadmin.version}
[configurations runModes=mymode]
org.apache.sling.eventadmin
useQueue=true
ignoreTopics=["myTopic"]
```
--------------------------------
### Example Assembly-Bundles Header
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/old-stuff/assembly.md
Illustrates how to specify bundles in the `Assembly-Bundles` header, including using the `entry` parameter for local installation and relying on the OSGi Bundle Repository for others.
```text
org.apache.sling.sample1;entry=path.jar,org.apache.sling.sample2
```
--------------------------------
### Install a Bundle using JCR Installer
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/bundles/jcr-installer-provider.md
Copy a bundle JAR file into the designated JCR install folder using `curl`. The JCR installer will automatically pick it up and start the bundle.
```bash
curl -T desktop_awt_all-2.0.0.jar \
http://admin:admin@localhost:8080/apps/jcrtest/install/desktop_awt_all-2.0.0.jar
```
--------------------------------
### Start Sling with Kickstarter
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/feature-model/howtos/kickstart.md
Run the Kickstarter JAR to start Sling. Ensure port 8080 is free. The first start may take time as dependencies are downloaded.
```bash
java -jar org.apache.sling.kickstart-0.0.2.jar
```
--------------------------------
### Verbose Agent Output Example
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/bundles/connection-timeout-agent.md
When started in verbose mode, the agent prints information about the transformers being installed and the classes being transformed. This output helps in verifying the agent's operation and configuration.
```text
[AGENT] Preparing to install URL transformers. Configured timeouts - connectTimeout : 1000, readTimeout: 1000
[AGENT] All transformers installed
[AGENT] JavaNetTimeoutTransformer asked to transform sun/net/www/protocol/https/AbstractDelegateHttpsURLConnection
[AGENT] Transformation of sun/net/www/protocol/https/AbstractDelegateHttpsURLConnection complete
[AGENT] JavaNetTimeoutTransformer asked to transform sun/net/www/protocol/http/HttpURLConnection
[AGENT] Transformation of sun/net/www/protocol/http/HttpURLConnection complete
```
--------------------------------
### Start Sling with Composite NodeStore
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/feature-model/howtos/create-sling-composite.md
Execute this script to start Sling using the Composite NodeStore configuration.
```bash
./bin/run_composite_fm.sh
```
--------------------------------
### Quick Artifact Update Example
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/development/release-management.md
Example commands for updating artifacts in the dist folder without checking out the entire repository. Assumes releasing org.apache.sling.engine 2.6.22 and old versions start with org.apache.sling.engine-2.6.20.
```bash
# Assuming that we are releasing org.apache.sling.engine 2.6.22 and the old version artifact names start with org.apache.sling.engine-2.6.20, we can run the following commands
```
--------------------------------
### Example .cfg.json Configuration
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/bundles/configuration-installer-factory.md
This is an example of a .cfg.json file used for OSGi configurations. It supports typed values and comments.
```json
{
"key": "val",
"some_number": 123,
// This is an integer value:
"size:Integer" : 500
}
```
--------------------------------
### Get All Versions with .V.json Selector
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/bundles/rendering-content-default-get-servlets.md
After creating multiple versions, the VersionInfoServlet will list all available versions for the resource when queried with the .V.json selector. The output is abbreviated in this example.
```json
{
"versions": {
"jcr:rootVersion": {
"successors": [
"1.0"
],
"predecessors": []
},
"1.0": {
"successors": [
"1.1"
],
"predecessors": [
"jcr:rootVersion"
]
},
"1.1": {
"successors": [
"1.2"
],
"predecessors": [
"1.0"
]
},
"1.2": {
"successors": [],
"predecessors": [
"1.1"
]
}
}
}
```
--------------------------------
### Install an OSGi Configuration using JCR Installer
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/bundles/jcr-installer-provider.md
Create a new OSGi configuration node with properties using `curl`. The JCR installer will detect this node and install the configuration.
```bash
curl \
-F "jcr:primaryType=sling:OsgiConfig" \
-F foo=bar -F works=yes \
http://admin:admin@localhost:8080/apps/jcrtest/install/some.config.pid
```
--------------------------------
### Launch Sling Standalone Feature
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/getting-started.md
Execute this command to start Sling using the downloaded Feature Launcher archive. Ensure Java ${sling_minJavaVersion} or later is installed.
```bash
./org.apache.sling.feature.launcher-*/bin/launcher -f org.apache.sling.starter-${sling_releaseVersion}-oak_*_far.far
```
--------------------------------
### Create JCR Folders for Installation
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/bundles/jcr-installer-provider.md
Use `curl` to create the necessary JCR folders under `/apps/jcrtest` to house bundles and configurations for the JCR installer.
```bash
curl -X MKCOL http://admin:admin@localhost:8080/apps/jcrtest
curl -X MKCOL http://admin:admin@localhost:8080/apps/jcrtest/install
```
--------------------------------
### Start Sling with External Logback Configuration
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/development/logging.md
Specify the location of logback.xml using the -Dorg.apache.sling.commons.log.configurationFile system property when starting Sling.
```bash
java -jar org.apache.sling.starter-XXX-standalone.jar -Dorg.apache.sling.commons.log.configurationFile=/path/to/logback
```
--------------------------------
### Install Content Package (Maven)
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/development/content-packages.md
Command to install a content package to a Sling instance using the wcmio-content-package-maven-plugin.
```bash
$ mvn wcmio-content-package:install
```
--------------------------------
### Tailored Sling Instance Setup with FreemarkerTestSupport
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/development/testing-paxexam.md
This abstract class extends TestSupport and injects necessary Sling services. It configures the PaxExam probe with Sling-specific headers and defines base configurations for the Sling instance, including Quickstart, Models, and Scripting.
```java
public abstract class FreemarkerTestSupport extends TestSupport {
@Inject
protected ServletResolver servletResolver;
@Inject
protected SlingRequestProcessor slingRequestProcessor;
@Inject
protected AuthenticationSupport authenticationSupport;
@Inject
protected HttpService httpService;
@Inject
@Filter(value = "(names=freemarker)")
protected ScriptEngineFactory scriptEngineFactory;
public Option baseConfiguration() {
return composite(
super.baseConfiguration(),
slingQuickstart(),
// Sling Scripting FreeMarker
testBundle("bundle.filename"),
mavenBundle().groupId("org.freemarker").artifactId("freemarker").versionAsInProject(),
mavenBundle().groupId("org.apache.servicemix.specs").artifactId("org.apache.servicemix.specs.jaxp-api-1.4").versionAsInProject(),
// testing
slingResourcePresence(),
mavenBundle().groupId("org.jsoup").artifactId("jsoup").versionAsInProject(),
mavenBundle().groupId("org.apache.servicemix.bundles").artifactId("org.apache.servicemix.bundles.hamcrest").versionAsInProject(),
junitBundles()
);
}
@ProbeBuilder
public TestProbeBuilder probeConfiguration(final TestProbeBuilder testProbeBuilder) {
testProbeBuilder.setHeader(Constants.EXPORT_PACKAGE, "org.apache.sling.scripting.freemarker.it.app");
testProbeBuilder.setHeader("Sling-Model-Packages", "org.apache.sling.scripting.freemarker.it.app");
testProbeBuilder.setHeader("Sling-Initial-Content", String.join(",",
"apps/freemarker;path:=/apps/freemarker;overwrite:=true;uninstall:=true",
"content;path:=/content;overwrite:=true;uninstall:=true"
));
return testProbeBuilder;
}
protected Option slingQuickstart() {
final int httpPort = findFreePort();
final String workingDirectory = workingDirectory();
return composite(
slingQuickstartOakTar(workingDirectory, httpPort),
slingModels(),
slingScripting()
);
}
}
```
--------------------------------
### Build and Install Kickstarter Module
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/feature-model/howtos/create-sling-composite.md
Clone the Sling Kickstarter repository and build it to install it into your local Maven repository. This is a prerequisite for seeding the repository.
```bash
git clone https://github.com/apache/sling-org-apache-sling-kickstart.git
cd sling-org-apache-sling-kickstart
mvn clean install
```
--------------------------------
### Override Syntax Examples
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/bundles/context-aware-configuration/context-aware-configuration-override.md
These examples demonstrate the general syntax for defining overrides, including specifying individual properties, entire configuration objects, and applying them to specific context paths.
```plaintext
my-config/property1="value 1"
my-config/sub1/property1="value 1"
my-config/property1=["value 1","value 2"]
my-config/property1=123
x.y.z.MyConfig={"prop1":"value1","prop2":[1,2,3],"prop3":true,"prop4":1.23}
[/content/region1]my-config/property1="value 1"
[/content/region1]my-config/sub1={"prop1":"value 1"}
```
--------------------------------
### Set ACL Example
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/bundles/repository-initialization.md
Provides an example of setting Access Control Lists (ACLs) on multiple paths, including remove and allow permissions for different users, with and without restrictions.
```repoinit
# Set ACL example from SLING-5355
# Without the "with glob" option, we're not planning to support
# that at this time.
set ACL on /libs,/apps, /, /content/example.com/some-other_path
remove * for user1,user2
allow jcr:read for user1,user2
allow privilege_without_namespace for user4
deny jcr:write,something:else,another:one for user2
deny jcr:lockManagement for user1
deny jcr:modifyProperties for user2 restriction(rep:itemNames,prop1,prop2)
end
```
--------------------------------
### Managed Service Factory Configuration Example
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/development/slingstart.md
Example of a configuration name for a Managed Service Factory, including a subname for a specific instance.
```plaintext
com.acme.abc-default
```
--------------------------------
### Example jarWebSupport Configuration with Pax Web
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/development/maven-launchpad-plugin.md
An example of configuring jarWebSupport to use Pax Web as the HttpService provider. Note the use of 'RELEASE' for the version.
```xml
...
org.ops4j.pax.web
pax-web-service
RELEASE
...
```
--------------------------------
### Install Bundle to Running Sling Instance via Maven
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/development/getting-and-building-sling.md
Install a newly developed bundle to a running Sling application directly from the command line. This command requires the Sling URL to be specified.
```bash
mvn \-P autoInstallBundle clean install \-Dsling.url=http://localhost:8080/system/console
```
--------------------------------
### Service User Mapping Configuration Example
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/news/sling-10-released.md
An example of OSGi configuration for service user mapping, demonstrating the use of an array for principal names to map privileges. This style is preferred for clarity and reduced redundancy.
```properties
org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-resourceresolver
user.mapping=[
"org.apache.sling.resourceresolver:mapping\=[repository-reader-service]"
]
```
--------------------------------
### Set up and Execute Scriptable Test Node
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/development/sling-testing-tools.md
This example demonstrates creating a scriptable test node and then executing it. Ensure the scriptable tests provider is active.
```bash
$ curl -u admin:admin -Fjcr:primaryNodeType=sling:Folder -Fsling:resourceType=foo -Fjcr:mixinTypes=sling:Test http://localhost:8080/apps/foo
...
$ echo TEST_PASSED > /tmp/test.txt.esp ; curl -u admin:admin -T/tmp/test.txt.esp http://localhost:8080/apps/foo/test.txt.esp
```
```bash
$ curl -u admin:admin http://localhost:8080/apps/foo.test.txt
TEST_PASSED
```
--------------------------------
### Start Sling Standalone Application
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/the-sling-engine/the-sling-launchpad.md
Starts the Sling Standalone Application with the control port enabled. The control port allows for stopping the instance and getting thread dumps.
```bash
$ java -jar target/org.apache.sling.starter-11.jar start
```
--------------------------------
### Provisioning Model File Example
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/development/slingstart.md
A provisioning model file defining features, variables, artifacts, and configurations. It demonstrates how to specify artifact versions using variables and configure bundles.
```text
[feature name=my-feature]
[variables]
eventadmin.version=1.0.0
metatype.version=1.2.0
[artifacts]
org.apache.sling/eventadmin/${eventadmin.version}
org.apache.sling/metatype/${metatype.version}
org.apache.sling/coordinator/3.0.0
[configurations]
org.apache.sling.eventadmin
useQueue=true
ignoreTopics=["myTopic"]
```
--------------------------------
### Bootstrap Command File Example
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/development/slingstart.md
Defines uninstall directives for bundles to be executed on the first startup. This is useful for cleaning up obsolete or replaced bundles.
```text
[feature name=:launchpad]
[configurations]
# uninstall obsolete bundles which are neither not required anymore or are
# replaced with new bundles
:bootstrap
uninstall org.apache.sling.fragment.activation 1.2
uninstall org.apache.sling.installer.api [1.0,2.0)
uninstall org.apache.sling.tests
```
--------------------------------
### Resource Structure Example for Overlay Approach
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/bundles/resource-merger.md
Illustrates the hierarchical structure of resources in /libs and /apps, and how they are merged into /mnt/overlay for the Overlay Resource Picker.
```text
/libs/sling/example (nt:folder)
+-- sling:resourceType = "some/resource/type"
+-- child1 (nt:folder)
| +-- property1 = "property from /libs/sling/example/child1"
+-- child2 (nt:folder)
| +-- property1 = "property from /libs/sling/example/child2"
+-- child3 (nt:folder)
| +-- property1 = "property from /libs/sling/example/child3"
/apps/sling/example (sling:Folder)
+-- property1 = "property added in apps"
+-- child1 (nt:folder)
| +-- sling:hideResource = true
+-- child2 (nt:folder)
| +-- property1 = "property from /apps/sling/example/child2"
+-- child3 (nt:folder)
| +-- property2 = "property from /apps/sling/example/child3"
/mnt/overlay/sling/example (sling:Folder)
+-- sling:resourceType = "some/resource/type"
+-- property1 = "property added in apps"
+-- child2 (nt:folder)
| +-- property1 = "property from /apps/sling/example/child2"
+-- child3 (nt:folder)
| +-- property1 = "property from /libs/sling/example/child3"
| +-- property2 = "property from /apps/sling/example/child3"
```
--------------------------------
### Base Model for Configuration Removal/Change
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/development/slingstart.md
An example of a base model defining configurations. This serves as a starting point for modifications.
```text
[configurations]
my.special.configuration.b
foo="bar"
another.special.configuration.a
x="y"
```
--------------------------------
### ScriptableHealthCheck Configuration Example
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/bundles/sling-health-check-tool-deprecated.md
Example OSGi configuration for a ScriptableHealthCheck, demonstrating how to set its name, MBean name, tags, and the scripting expression. Service properties starting with 'hc.' are generic, while others are specific to the health check implementation.
```java
Factory PID = org.apache.sling.hc.ScriptableHealthCheck
"hc.name" : "LoadedClassCount and ManagementSpecVersion are in range"
"hc.mbean.name" : "LoadedClassCount and ManagementSpecVersion"
"hc.tags" : [jvm, script]
"expression" : "jmx.attribute('java.lang:type=ClassLoading', 'LoadedClassCount') > 10 && jmx.attribute('java.lang:type=Runtime', 'ManagementSpecVersion') > 1"
"language.extension" : "ecma"
```
--------------------------------
### Create Paths with Properties
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/bundles/repository-initialization.md
Shows how to create paths and set properties, including different data types like String and Long. Supports multiple properties and default values.
```repoinit
create path (sling:Folder) /var/discovery(nt:unstructured)/somefolder2 with properties
set sling:ResourceType{String} to /x/y/z
set cq:allowedTemplates to /d/e/f/*, m/n/*
default someInteger{Long} to 42
end
```
--------------------------------
### Base Model for Artifact Removal/Change
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/development/slingstart.md
An example of a base model defining artifacts. This serves as a starting point for modifications in other models.
```text
[artifacts]
my/special/artifact/1.0.0
commons/library/1.0.0
[artifacts runModes=test]
another/one/2.1.0
```
--------------------------------
### Resource Structure Example for Override Approach
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/bundles/resource-merger.md
Demonstrates the resource structures for the Override Resource Picker, showing how /apps/sling/example extends /apps/sling/base and is then merged into /mnt/override.
```text
/apps/sling/base (nt:folder)
+-- child1 (nt:folder)
| +-- property1 = "property from /libs/sling/example/child1"
+-- child2 (nt:folder)
| +-- property1 = "property from /libs/sling/example/child2"
+-- child3 (nt:folder)
| +-- property1 = "property from /libs/sling/example/child3"
/apps/sling/example (sling:Folder)
+-- sling:resourceSuperType = "/apps/sling/base"
+-- property1 = "property added in /apps/sling/example"
+-- child1 (nt:folder)
| +-- sling:hideResource = true
+-- child2 (nt:folder)
| +-- property1 = "property from /apps/sling/example/child2"
+-- child3 (nt:folder)
| +-- property2 = "property from /apps/sling/example/child3"
/mnt/override/apps/sling/example (sling:Folder)
+-- sling:resourceSuperType = "/apps/sling/base"
+-- property1 = "property added in /apps/sling/example"
+-- child2 (nt:folder)
| +-- property1 = "property from /apps/sling/example/child2"
+-- child3 (nt:folder)
| +-- property1 = "property from /libs/sling/example/child3"
| +-- property2 = "property from /apps/sling/example/child3"
```
--------------------------------
### Example release.properties File
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/development/release-management.md
A sample release.properties file used when the 'release:perform' step needs to be executed manually. It requires the SCM URL and tag of the release.
```properties
scm.url=scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-settings.git
scm.tag=org.apache.sling.settings-1.3.10
```
--------------------------------
### Build and Deploy Bundle to Running Sling Instance
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/development/getting-and-building-sling.md
Navigate to a bundle's module directory and use Maven to build and install the bundle into a running Sling launchpad instance. This ensures the bundle is available locally and deployed.
```bash
cd org.apache.sling.servlets-get
$ mvn clean install sling:install
```
--------------------------------
### Download and Copy Kickstarter JAR
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/feature-model/howtos/kickstart.md
Download the Kickstart Project bundle and copy it to your working directory. Adjust the version number to match your downloaded file.
```bash
mkdir kickstarter
cd kickstarter
cp /some/download/path/org.apache.sling.kickstart-0.0.2.jar .
```
--------------------------------
### Launch Application with Maven
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/feature-model/howtos/sling-with-custom-project.md
Execute this Maven command to clean, install, and launch your Sling application using the defined 'launch' profile. This will start Sling with your custom Feature Model.
```bash
$ mvn clean install -Plaunch
```
--------------------------------
### Get Current Run Modes in Java
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/old-stuff/run-modes-org-apache-sling-runmode.md
Retrieve the current list of active run modes using the RunMode service. Ensure the `org.apache.sling.runmode` bundle is installed and accessible via the BundleContext.
```java
RunMode r = ...get from BundleContext...
String [] currentRunModes = r.getCurrentRunModes();
```
--------------------------------
### Sling Quickstart Configuration
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/development/testing-paxexam.md
Configures the Sling Quickstart environment for testing, including the Oak Tar persistence, Sling Models, and Sling Scripting. Ensure proper cleanup if not specifying working directory or HTTP port to avoid test interference.
```java
protected Option slingQuickstart() {
final String workingDirectory = workingDirectory(); // from TestSupport
final int httpPort = findFreePort(); // from TestSupport
return composite(
slingQuickstartOakTar(workingDirectory, httpPort), // from SlingOptions
slingModels(), // from SlingOptions (for illustration)
slingScripting() // from SlingOptions (for illustration)
);
}
```
--------------------------------
### Get All Parent Resources
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/bundles/scripting/scripting-jsp.md
Retrieves all parent resources of a specified resource in hierarchy order. 'startDepth' can be used to specify the starting level for retrieval. The results are stored in a variable specified by the 'var' attribute.
```jsp
```
--------------------------------
### Run Provisioning Model Conversion with Maven
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/feature-model/howtos/create-sling-fm.md
Use the Kickstarter's Maven POM file to convert Sling Starter's Provisioning Models to Feature Models and aggregate them. Specify the Sling Starter folder using the -Dsling.starter.folder property.
```bash
cd sling-org-apache-sling-kickstart
mvn -f sling-fm-pom.xml install -Dsling.starter.folder=../sling-org-apache-sling-starter
```
--------------------------------
### Simple Integration Test with SlingInstanceRule
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/tutorials-how-tos/testing-sling-based-applications.md
A basic integration test class demonstrating the use of SlingInstanceRule and SlingRule to start a Sling instance and interact with it using SlingClient. This example shows how to create a node and verify its existence.
```java
public class MySimpleIT {
@ClassRule
public static SlingInstanceRule instanceRule = new SlingInstanceRule();
@Rule
public SlingRule methodRule = new SlingRule(); // will configure test timeout, description, etc.
@Test
public void testCreateNode() {
SlingClient client = instanceRule.getAdminClient();
client.createNode("/content/myNode", "nt:unstructured");
Assert.assertTrue("Node should be there", client.exists("/content/myNode"));
//client.adaptTo(OsgiConsoleClient.class).editConfigurationWithWait(10, "MYPID", null, myMap);
}
}
```
--------------------------------
### Debug JarExecutor VM (Server-Side)
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/development/sling-testing-tools.md
Configure the 'jar.executor.vm.options' system environment variable with JPDA debug options to debug the server-side VM started by JarExecutor. This example attaches a debugger on port 8000 and suspends execution until connected.
```bash
mvn test -Djar.executor.vm.options="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000"
```
--------------------------------
### Example .config File Structure
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/bundles/configuration-installer-factory.md
This illustrates the basic structure of a .config file, which uses Apache Felix ConfigAdmin format. It supports comments and typed properties.
```properties
# This is a comment
myprop=myvalue
myint:I=123
myboolean:B=true
myarray: [1,2,3]
mycollection: (a,b,c)
```
--------------------------------
### Fetch Tracer Logs via cURL
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/bundles/log-tracers.md
Retrieve tracer logs in JSON format from the server by making a GET request to '/system/console/tracer/' followed by the request ID and '.json'. This example also shows how to specify tracers and configuration.
```bash
curl -s -D - -H "Sling-Tracer-Record : true" -H "Sling-Tracers : oak-query" \
-H "Sling-Tracer-Config : org.apache.jackrabbit.oak.query" \
-u admin:admin http://localhost:4512/assets.html/content/dam -o /dev/null
```
--------------------------------
### Start Sling with Feature Model
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/feature-model/howtos/create-sling-fm.md
Execute Sling using the Kickstarter JAR and the generated Feature Model JSON file.
```bash
java -jar org.apache.sling.kickstart-0.0.3-SNAPSHOT.jar -s feature-sling12.json
```
--------------------------------
### Get Group Information
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/bundles/managing-users-and-groups-jackrabbit-usermanager.md
Retrieve properties of a specific group by sending a GET request to its resource path. The response format depends on the Default GET Servlet configuration.
```bash
$ curl http://localhost:8080/system/userManager/group/administrators.tidy.1.json
{
"members": [],
"declaredMembers": [],
"memberOf": [],
"declaredMemberOf": []
}
```
--------------------------------
### Prepare Kickstart Run Directory
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/feature-model/howtos/create-sling-fm.md
Create a new directory for running Sling, copy the generated Feature Model JSON file and the Kickstarter JAR into it.
```bash
cd ..
mkdir kickstart-run && cd kickstart-run
cp ../sling-org-apache-sling-kickstart/target/slingfeature-tmp/feature-sling12.json .
cp ../sling-org-apache-sling-kickstart/target/org.apache.sling.kickstart-0.0.3-SNAPSHOT.jar .
```
--------------------------------
### General Kickstarter Command
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/feature-model/howtos/kickstart.md
Use this command to start the Sling Kickstarter. Replace `` with the actual JAR file name. Options can be added before the command.
```bash
java -jar [options] [command]
```
--------------------------------
### Include Install Hook in Content Package with Maven
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/bundles/installer-provider-installhook.md
Configure the Maven dependency plugin to copy the install hook artifact into the content package. This ensures the hook is available during package installation.
```xml
org.apache.maven.plugins
maven-dependency-plugin
copy-hook-into-package
generate-resources
copy
org.apache.sling
org.apache.sling.installer.provider.installhook
1.1.0
${project.build.directory}/vault-work/META-INF/vault/hooks
```
--------------------------------
### Run Sling Starter Integration Tests (Newer Parent POM)
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/contributing.md
Execute integration tests for the Sling Starter using modules with Sling Parent POM 49 or newer. Pass the desired Starter version via the 'starter-its.starter.version' property.
```bash
mvn clean verify -Dstarter-its.starter.version=${sling_snapshotVersion}
```
--------------------------------
### Managed Service Configuration Example
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/development/slingstart.md
Example of a configuration name for a Managed Service.
```plaintext
com.acme.xyz
```
--------------------------------
### Build Kickstarter JAR
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/feature-model/howtos/create-sling-fm.md
Run a clean install on the Kickstarter project to ensure the JAR file is available for use in the next step.
```bash
mvn clean install
```
--------------------------------
### Remove a Bundle using JCR Installer
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/bundles/jcr-installer-provider.md
Delete a bundle's JAR file from the JCR install folder using `curl`. This action will cause the JCR installer to uninstall the corresponding bundle.
```bash
curl -X DELETE \
http://admin:admin@localhost:8080/apps/jcrtest/install/desktop_awt_all-2.0.0.jar
```
--------------------------------
### Create and Execute a Scriptable Test Node
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/bundles/org-apache-sling-junit-bundles.md
This example demonstrates how to create a scriptable test node and then execute it using cURL. The scriptable test node is created with specific properties and then a test file is uploaded and executed.
```bash
$ curl -u admin:admin -Fjcr:primaryNodeType=sling:Folder -Fsling:resourceType=foo -Fjcr:mixinTypes=sling:Test http://localhost:8080/apps/foo
...
$ echo TEST_PASSED > /tmp/test.txt.esp ; curl -u admin:admin -T/tmp/test.txt.esp http://localhost:8080/apps/foo/test.txt.esp
```
```bash
$ curl -u admin:admin http://localhost:8080/apps/foo.test.txt
TEST_PASSED
```
--------------------------------
### Echo Pipe Example
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/bundles/sling-pipes/readers.md
Outputs the configured path. Useful for setting the initial input of a pipe sequence or piping with relative paths.
```bash
echo /content | write foo=bar
```
```bash
echo /content | $ some/parent | echo child/path | ...
```
--------------------------------
### Clone Sling Starter and Build
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/development/getting-and-building-sling.md
Clone the Sling starter repository, navigate into it, and build the project using Maven. This is a quick way to get a runnable Sling instance.
```bash
$ git clone https://github.com/apache/sling-org-apache-sling-starter.git
$ cd sling-org-apache-sling-starter
$ mvn --update-snapshots clean install
```
--------------------------------
### Get Defined Permissions List for a Node
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/bundles/managing-permissions-jackrabbit-accessmanager.md
Send a GET request to retrieve the permissions defined on a particular node in JSON format.
```http
http://localhost:8080/test/node.acl.json
```
--------------------------------
### Run Sling Executable Jar
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/development/getting-and-building-sling.md
Execute the built Sling starter JAR to launch a Sling instance. Ensure you are in the directory containing the JAR file.
```bash
java -jar target/org.apache.sling.starter-*.jar
```
--------------------------------
### Install Sling Scripting Thymeleaf Feature for Karaf
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/bundles/scripting/scripting-thymeleaf.md
Use this command to install the Sling Scripting Thymeleaf feature if you are using Apache Karaf.
```bash
karaf@root()> feature:install sling-scripting-thymeleaf
```
--------------------------------
### Launch Sling Starter with MCP Features
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/bundles/mcp-server.md
Use this command to launch the Sling Starter Docker container with the necessary MCP feature models enabled. Ensure you are using a snapshot version of the `apache/sling` image until version 15 is released.
```bash
docker run --rm -p 8080:8080 \
apache/sling:snapshot oak_tar \
--extra-features \
mvn:org.apache.sling/org.apache.sling.mcp-server/0.1.4/slingosgifeature/main \
mvn:org.apache.sling/org.apache.sling.mcp-server-contributions/0.1.0/slingosgifeature/main
```
--------------------------------
### Get User
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/bundles/managing-users-and-groups-jackrabbit-usermanager.md
Retrieve the properties of a specific user by sending a GET request to their resource path. A 404 status is returned if the user does not exist.
```APIDOC
## Get user
*since version 2.0.8*
The properties of a single user can be retrieved by sending a GET request to the user's resource at `/system/userManager/user/` where `` would be replaced with the name of the user. Depending on the configuration of the [Default GET Servlet](/documentation/bundles/rendering-content-default-get-servlets.html) and/or the availability of a Servlet or Script handling the `sling/user` resource type, a result may be delivered.
Example with curl and the default JSON rendering:
$ curl http://localhost:8080/system/userManager/user/admin.tidy.1.json
{
"memberOf": [],
"declaredMemberOf": []
}
If a non-existing user is requested a `404/NOT FOUND` status is sent back.
```
--------------------------------
### Changing Artifact Version and Start Level
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/development/slingstart.md
This model changes the version of 'commons/library' to 1.1.0 and sets its start level to 5, based on a previous model.
```text
[artifacts startLevel=5]
commons/library/1.1.0
```
--------------------------------
### Kickstarter Commands
Source: https://github.com/apache/sling-site/blob/master/src/main/jbake/content/documentation/feature-model/howtos/kickstart.md
The Kickstarter supports 'stop', 'start', and 'status' commands. For a full list of options, use the '-h' flag.
```bash
$ java -jar -h
```