/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library 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 library 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.
*/
package com.liferay.configuration.admin.web.internal.portlet.action;
import com.liferay.configuration.admin.web.internal.constants.ConfigurationAdminPortletKeys;
import com.liferay.configuration.admin.web.internal.util.ConfigurationModelRetriever;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.portlet.bridges.mvc.MVCActionCommand;
import com.liferay.portal.kernel.util.ParamUtil;
import java.io.IOException;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;
import org.osgi.service.cm.Configuration;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
/**
* @author Kamesh Sampath
* @author Raymond Augé
*/
@Component(
immediate = true,
property = {
"javax.portlet.name=" + ConfigurationAdminPortletKeys.SYSTEM_SETTINGS,
"mvc.command.name=deleteConfiguration"
},
service = MVCActionCommand.class
)
public class DeleteConfigurationMVCActionCommand implements MVCActionCommand {
@Override
public boolean processAction(
ActionRequest actionRequest, ActionResponse actionResponse)
throws PortletException {
String pid = ParamUtil.getString(actionRequest, "pid");
if (_log.isDebugEnabled()) {
_log.debug("Deleting configuration for service " + pid);
}
try {
Configuration configuration =
_configurationModelRetriever.getConfiguration(pid);
if (configuration == null) {
return false;
}
configuration.delete();
}
catch (IOException ioe) {
throw new PortletException(ioe);
}
return true;
}
private static final Log _log = LogFactoryUtil.getLog(
DeleteConfigurationMVCActionCommand.class);
@Reference
private ConfigurationModelRetriever _configurationModelRetriever;
}