All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.sling.servlets.post.AbstractSlingPostOperation Maven / Gradle / Ivy

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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 org.apache.sling.servlets.post;

import java.util.List;

import javax.jcr.RepositoryException;

import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.servlets.HtmlResponse;
import org.apache.sling.servlets.post.exceptions.PreconditionViolatedPersistenceException;
import org.apache.sling.servlets.post.exceptions.TemporaryPersistenceException;
import org.apache.sling.servlets.post.impl.helper.HtmlPostResponseProxy;
import org.apache.sling.servlets.post.impl.helper.HtmlResponseProxy;

/**
 * The AbstractSlingPostOperation is the abstract base class
 * implementation of the {@link SlingPostOperation} interface extending the new
 * {@link AbstractPostOperation}.
 * 

* This class exists for backwards compatibility. Existing implementations are * advised to migrate to the new {@link AbstractPostOperation}. * * @deprecated as of 2.0.8 (Bundle version 2.2.0) and replaced by * {@link AbstractPostOperation}. */ public abstract class AbstractSlingPostOperation extends AbstractPostOperation implements SlingPostOperation { /** * * @param request the request * @param response the response * @param changes all changes * @throws RepositoryException in case of problems */ protected abstract void doRun(SlingHttpServletRequest request, HtmlResponse response, List changes) throws RepositoryException; /** * Implementation of the * {@link AbstractPostOperation#doRun(SlingHttpServletRequest, PostResponse, List)} * method calling our own * {@link #run(SlingHttpServletRequest, HtmlResponse, SlingPostProcessor[])} * meethod with a proxy for the Sling API HtmlResponse. */ protected void doRun(SlingHttpServletRequest request, PostResponse response, List changes) throws RepositoryException { final HtmlResponse htmlResponseProxy = (response instanceof HtmlPostResponseProxy) ? ((HtmlPostResponseProxy) response).getHtmlResponse() : new HtmlResponseProxy(response); doRun(request, htmlResponseProxy, changes); } /** * Implementation of the * {@link SlingPostOperation#run(SlingHttpServletRequest, HtmlResponse, SlingPostProcessor[])} * API method calling the * {@link PostOperation#run(SlingHttpServletRequest, PostResponse, SlingPostProcessor[])} * with a proxy around the Sling API HtmlResponse provided. */ public void run(SlingHttpServletRequest request, HtmlResponse response, SlingPostProcessor[] processors) throws PreconditionViolatedPersistenceException, TemporaryPersistenceException { final PostResponse postResponseProxy = new HtmlPostResponseProxy( response); run(request, postResponseProxy, processors); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy