
org.xwiki.extension.job.AbstractExtensionRequest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xwiki-commons-extension-api Show documentation
Show all versions of xwiki-commons-extension-api Show documentation
XWiki Commons - Extension - API
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.xwiki.extension.job;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import org.xwiki.extension.ExtensionId;
import org.xwiki.job.AbstractRequest;
import org.xwiki.job.Request;
/**
* Base class for extension manipulation related {@link Request} implementations.
*
* @version $Id: 6a841eaea99c718b25dec91a5bf836158562176e $
* @since 4.0M1
*/
public abstract class AbstractExtensionRequest extends AbstractRequest implements ExtensionRequest
{
/**
* @see #getExtensions()
*/
public static final String PROPERTY_EXTENSIONS = "extensions";
/**
* @see #getExtensions()
*/
public static final String PROPERTY_EXCLUDEDEXTENSIONS = "extensions.excluded";
/**
* @see #getNamespaces()
*/
public static final String PROPERTY_NAMESPACES = "namespaces";
/**
* @see #isRootModificationsAllowed()
*/
public static final String PROPERTY_ROOTMODIFICATIONSALLOWED = "rootModificationsAllowed";
/**
* Serialization identifier.
*/
private static final long serialVersionUID = 1L;
/**
* Default constructor.
*/
public AbstractExtensionRequest()
{
setProperty(PROPERTY_EXTENSIONS, new ArrayList());
setProperty(PROPERTY_EXCLUDEDEXTENSIONS, new HashSet());
}
/**
* @param request the request to copy
*/
public AbstractExtensionRequest(Request request)
{
super(request);
Collection extensions = getExtensions();
if (extensions == null) {
setProperty(PROPERTY_EXTENSIONS, new ArrayList());
}
}
@Override
public Collection getExtensions()
{
return getProperty(PROPERTY_EXTENSIONS);
}
/**
* @return extensions to not take into account
*/
public Collection getExcludedExtensions()
{
return getProperty(PROPERTY_EXCLUDEDEXTENSIONS);
}
@Override
public Collection getNamespaces()
{
return getProperty(PROPERTY_NAMESPACES);
}
@Override
public boolean hasNamespaces()
{
Collection namespaces = getNamespaces();
return namespaces != null && !namespaces.isEmpty();
}
/**
* @param extensionId the extension identifier
*/
public void addExtension(ExtensionId extensionId)
{
getExtensions().add(extensionId);
}
/**
* @param extensionId the extension identifier
*/
public void addExcludedExtension(ExtensionId extensionId)
{
getExcludedExtensions().add(extensionId);
}
/**
* @param namespace the namespace
*/
public void addNamespace(String namespace)
{
Collection namespaces = getNamespaces();
if (namespaces == null) {
namespaces = new ArrayList();
setProperty(PROPERTY_NAMESPACES, namespaces);
}
namespaces.add(namespace);
}
@Override
public boolean isRootModificationsAllowed()
{
return getProperty(PROPERTY_ROOTMODIFICATIONSALLOWED, true);
}
/**
* @param allowed indicate if it's allowed to do modifications on root namespace during the job execution (not taken
* into account if the target of the request is root namespace)
*/
public void setRootModificationsAllowed(boolean allowed)
{
setProperty(PROPERTY_ROOTMODIFICATIONSALLOWED, allowed);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy