Ejemplo n.º 1
0
  public void dropMessage(IMessage message) {
    Map<String, Object> headers = message.getHeaders();
    Map<String, Object> cleanHeaders = new HashMap<String, Object>();
    Set<Entry<String, Object>> entrySet = headers.entrySet();
    for (Entry<String, Object> entry : entrySet) {
      String key = entry.getKey();
      Object value = entry.getValue();
      if (value != null && !ignoreSendHeaders.contains(key)) {
        if (Objects.equal("JMSReplyTo", key)) {
          value = JmsTypeConverters.toDestination(value);
        } else if (Objects.equal("JMSExpiration", key)) {
          value = JmsTypeConverters.toTimestamp(value);
        } else if (Objects.equal("JMSTimestamp", key)) {
          value = JmsTypeConverters.toTimestamp(value);
        } else if (Objects.equal("JMSDeliveryMode", key)) {
          value = JmsTypeConverters.toDeliveryMode(value);
        } else if (Objects.equal("JMSRedelivered", key)) {
          value = JmsTypeConverters.toBoolean(value);
        } else if (Objects.equal("JMSPriority", key)) {
          value = JmsTypeConverters.toInteger(value);
        }

        if (value != null) {
          cleanHeaders.put(key, value);
        }
      }
    }

    String body = Strings.getOrElse(message.getBody());

    try {
      // TODO store username/pwd on a queue basis?
      String userName = getBrokerNode().getUserName();
      String password = getBrokerNode().getPassword();
      if (userName != null && password != null) {
        destination.sendTextMessage(cleanHeaders, body, userName, password);
      } else {
        destination.sendTextMessage(cleanHeaders, body);
      }
    } catch (Exception e) {
      FabricPlugin.showUserError(
          "Send message to " + this + " failed", "Could not send message to " + this, e);
    }
  }
Ejemplo n.º 2
0
  private Document readFileToDocument(String filePath) {
    Document doc = null;
    try {
      DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
      DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
      File file = new File(filePath);
      if (file.exists() && file.isFile()) {
        doc = docBuilder.parse(file);
      } else {
        doc = docBuilder.newDocument();
        Element root = doc.createElement("settings");
        doc.appendChild(root);
      }
      doc.getDocumentElement().normalize();
    } catch (Exception ex) {
      FabricPlugin.getLogger().error(ex);
    }

    return doc;
  }
Ejemplo n.º 3
0
 public OpenStackTraceAction(LogsView view, String text) {
   super(text, FabricPlugin.getDefault().getImageDescriptor("stckframe_obj.gif"));
   this.view = view;
   initConsole();
 }
 public CloudDetailsDeleteAction() {
   super(Messages.jcloud_deleteCloudButton);
   setToolTipText(Messages.jcloud_deleteCloudButtonTooktip);
   setImageDescriptor(FabricPlugin.getPlugin().getImageDescriptor("delete.gif"));
 }
Ejemplo n.º 5
0
  private String prepareNewSettingsFile() {
    // check the users maven settings
    String userSettings = MavenPlugin.getMavenConfiguration().getUserSettingsFile();
    if (userSettings == null || userSettings.length() == 0) {
      userSettings = MavenCli.DEFAULT_USER_SETTINGS_FILE.getAbsolutePath();
    }

    if (userSettings != null && userSettings.trim().length() > 0) {
      File mvnConfig = new File(userSettings);
      // now we have to parse the xml config file and check for
      // a servers/server entry named like our fabric
      Document document = readFileToDocument(userSettings);
      String fabServerName = this.node.getFabricNameWithoutSpaces();

      boolean entryExists = checkForFabricServer(document, fabServerName);

      // if yes - no more to do...user knows what he is doing
      if (entryExists) {
        // the entry is already there...use it
      } else {
        // if no - add the server entry for the fabric with auth
        // information and save config to temp folder - then reference
        // to this config file for the next mvn deploy command
        String fabServerUser = this.node.getFabric().getUserName();
        String fabServerPass = this.node.getFabric().getPassword();

        // create a server entry
        NodeList serversList = document.getElementsByTagName(SERVERS_TAG);
        Element serversElement = null;
        if (serversList.getLength() < 1) {
          // no servers element - create one
          serversElement = document.createElement(SERVERS_TAG);
          document.getDocumentElement().appendChild(serversElement);
        } else {
          serversElement = (Element) serversList.item(0);
        }

        Element server = document.createElement(SERVER_TAG);
        serversElement.appendChild(server);

        Element sId = document.createElement(ID_TAG);
        server.appendChild(sId);
        Text textId = document.createTextNode(fabServerName);
        sId.appendChild(textId);

        Element sUser = document.createElement(USERNAME_TAG);
        server.appendChild(sUser);
        Text textUser = document.createTextNode(fabServerUser);
        sUser.appendChild(textUser);

        Element sPass = document.createElement(PASSWORD_TAG);
        server.appendChild(sPass);
        Text textPass = document.createTextNode(fabServerPass);
        sPass.appendChild(textPass);

        // now save the config to a new file
        File newSettings = null;
        try {
          // create the temp file
          newSettings = File.createTempFile("mvnSettings_", "_ide.xml");

          // prepare dom document for writing
          Source source = new DOMSource(document);

          // prepare to write
          Result result = new StreamResult(newSettings);

          // Write the DOM document to the file
          Transformer xformer = TransformerFactory.newInstance().newTransformer();
          xformer.transform(source, result);

          // switch to new maven config
          userSettings = newSettings.getPath();
        } catch (Exception ex) {
          FabricPlugin.getLogger().error(ex);
        } finally {
          // mark file for deletion
          newSettings.deleteOnExit();
        }
      }
    }

    return userSettings;
  }
Ejemplo n.º 6
0
 @Override
 public Image getImage() {
   return FabricPlugin.getDefault().getImage("jms/listeners.gif");
 }