Java tutorial
/* Copyright (C) 2006 NTT DATA Corporation This program is free software; you can redistribute it and/or Modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. This program 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 General Public License for more details. */ package com.clustercontrol.http.action; import org.eclipse.jface.dialogs.MessageDialog; import com.clustercontrol.monitor.util.MonitorSettingEndpointWrapper; import com.clustercontrol.util.HinemosMessage; import com.clustercontrol.util.Messages; import com.clustercontrol.ws.monitor.InvalidRole_Exception; import com.clustercontrol.ws.monitor.MonitorDuplicate_Exception; import com.clustercontrol.ws.monitor.MonitorInfo; /** * HTTP??<BR> * * @version 2.2.0 * @since 2.1.0 */ public class AddHttp { /** * HTTP?????<BR> * @param managerName ??? * @param info HTTP * @return ??????true */ public boolean add(String managerName, MonitorInfo info) { boolean result = false; String[] args = { info.getMonitorId(), managerName }; try { MonitorSettingEndpointWrapper wrapper = MonitorSettingEndpointWrapper.getWrapper(managerName); result = wrapper.addMonitor(info); if (result) { MessageDialog.openInformation(null, Messages.getString("successful"), Messages.getString("message.monitor.33", args)); } else { MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.monitor.34", args)); } } catch (MonitorDuplicate_Exception e) { // ID???????? MessageDialog.openInformation(null, Messages.getString("message"), Messages.getString("message.monitor.53", args)); } catch (Exception e) { String errMessage = ""; if (e instanceof InvalidRole_Exception) { // ?????? MessageDialog.openInformation(null, Messages.getString("message"), Messages.getString("message.accesscontrol.16")); } else { errMessage = ", " + HinemosMessage.replace(e.getMessage()); } MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.monitor.34", args) + errMessage); } return result; } }