*/
public class DataNamespacesSelectAction extends ConfigAction {
public ActionForward execute(ActionMapping mapping, ActionForm form,
UserContainer user, HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
DataNamespacesSelectForm namespacesForm = (DataNamespacesSelectForm) form;
String action = namespacesForm.getAction();
DataConfig dataConfig = (DataConfig) getDataConfig();
NameSpaceConfig config = null;
Locale locale = (Locale) request.getLocale();
MessageResources messages = servlet.getResources();
String edit = HTMLEncoder.decode(messages.getMessage(locale, "label.edit"));
String delete = HTMLEncoder.decode(messages.getMessage(locale, "label.delete"));
String _default = HTMLEncoder.decode(messages.getMessage(locale, "label.default"));
String nsSelected = namespacesForm.getSelectedNamespace();
if(nsSelected.endsWith("*")){
nsSelected = nsSelected.substring(0,nsSelected.lastIndexOf("*"));
}
config = (NameSpaceConfig) dataConfig.getNameSpace(nsSelected);
if(config==null){
throw new NullPointerException();
}
getUserContainer(request).setNamespaceConfig(config);
if (action.equals(delete))
{
if (dataStoresUseNamespace(dataConfig,nsSelected))
{
//dont delete a namespace thats in use!
ActionErrors errors = new ActionErrors();
errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.namespace.namespaceInUse" ));
request.setAttribute(Globals.ERROR_KEY, errors);
return mapping.findForward("config.data.namespace");
}
dataConfig.removeNameSpace(nsSelected);
getApplicationState().notifyConfigChanged();
getUserContainer(request).setNamespaceConfig(null);
namespacesForm.reset(mapping, request);
return mapping.findForward("config.data.namespace");
}
if (action.equals(_default)) {
if(!nsSelected
.equals(dataConfig.getDefaultNameSpace().getPrefix())){
dataConfig.setDefaultNameSpace(dataConfig.getNameSpace(nsSelected));
getApplicationState().notifyConfigChanged();
}
getUserContainer(request).setNamespaceConfig(null);
namespacesForm.reset(mapping, request);
return mapping.findForward("config.data.namespace");
}
if( action.equals(edit)){
getUserContainer(request).setNamespaceConfig(config);
return mapping.findForward("config.data.namespace.editor");