Last active
July 21, 2020 09:47
-
-
Save sreeni-b/9d2c00e5383f5eb600306881987532d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.aemks.core.servlets; | |
import com.aemks.core.services.MSMService; | |
import org.apache.sling.api.SlingHttpServletRequest; | |
import org.apache.sling.api.SlingHttpServletResponse; | |
import org.apache.sling.api.servlets.SlingAllMethodsServlet; | |
import org.apache.sling.api.servlets.SlingSafeMethodsServlet; | |
import org.apache.sling.servlets.annotations.SlingServletPaths; | |
import org.osgi.service.component.annotations.Component; | |
import org.osgi.service.component.annotations.Reference; | |
import org.osgi.service.component.propertytypes.ServiceDescription; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import javax.servlet.Servlet; | |
import javax.servlet.ServletException; | |
import java.io.IOException; | |
/** | |
* Servlet that writes some sample content into the response. It is mounted for | |
* all resources of a specific Sling resource type. The | |
* {@link SlingSafeMethodsServlet} shall be used for HTTP methods that are | |
* idempotent. For write operations use the {@link SlingAllMethodsServlet}. | |
*/ | |
@Component(service = { Servlet.class }) @SlingServletPaths("/bin/simpleservlet") | |
@ServiceDescription("Simple Demo Servlet") public class SimpleServlet extends SlingSafeMethodsServlet { | |
private static final long serialVersionUID = 1L; | |
@Reference | |
private MSMService msmService; | |
String[] rolloutConfigs = { "/libs/msm/wcm/rolloutconfigs/default", "/libs/msm/wcm/rolloutconfigs/activate", | |
"/libs/msm/wcm/rolloutconfigs/deactivate" }; | |
private static final Logger LOGGER = LoggerFactory.getLogger(SimpleServlet.class); | |
@Override protected void doGet(final SlingHttpServletRequest req, final SlingHttpServletResponse resp) | |
throws ServletException, IOException { | |
msmService.createLiveCopy(req.getResourceResolver(),"/content/aemks/us/en/master", "/content/aemks/us/en", "Live Copy", "livecopy", | |
rolloutConfigs); | |
LOGGER.info("Live Copy Created"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment