コード例 #1
0
  public DataSource createDataSource() {

    SAXBuilder sb = new SAXBuilder();
    DataSource dataSource = null;
    try {
      Document xmlDoc = sb.build("config/data.xml");
      Element root = xmlDoc.getRootElement();
      Element url = root.getChild("url");

      dataSource = new DataSource();
      dataSource.setHost(url.getText());
      dataSource.setDbName(root.getChild("database").getText());
      dataSource.setDriverClass(root.getChildText("driver-class"));
      dataSource.setPort(root.getChildText("port"));
      dataSource.setUserLogin(root.getChildText("login"));
      dataSource.setUserPwd(root.getChildText("password"));

    } catch (JDOMException e) {
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    return dataSource;
  }
コード例 #2
0
ファイル: ContextMaker.java プロジェクト: eMerchantPay/jPOS
  public void setConfiguration(Configuration cfg) throws ConfigurationException {
    super.setConfiguration(cfg);

    Element persist = getPersist();

    String ssp = persist.getChildText("space");

    sp = SpaceFactory.getSpace(ssp != null ? ssp : "");

    String sTimeout = persist.getChildText("timeout");
    timeout = sTimeout == null ? 10000 : Long.parseLong(sTimeout);

    contextName = persist.getChildText("context-name");
    if (contextName == null) {
      throw new ConfigurationException(
          "Missing 'context-name' property - the context name of the object received on 'in'");
    }

    in = persist.getChildText("in");
    if (in == null) {
      throw new ConfigurationException(
          "Missing 'in' property - the queue to process objects from.");
    }

    out = persist.getChildText("out");
    if (out == null) {
      throw new ConfigurationException(
          "Missing 'out' property - the target queue of the created context");
    }

    Element values = persist.getChild("context-values");
    if (values != null) {
      contextValues = values.getChildren();
    }
  }
コード例 #3
0
ファイル: QuestManager.java プロジェクト: teeppiphat/scald
 public void createInformation(Element inf, Quest quest) {
   if (inf != null) {
     quest.setName(inf.getChildText("Name"));
     quest.setDescription(inf.getChildText("Description"));
     quest.setObjective(inf.getChildText("Objective"));
   }
 }
コード例 #4
0
  /*
   * Liest die Scenario Informationen in die entsprechenden Objekte
   * und gibt eine Liste davon zurueck. Siehe dazu auch MeteringProcessStorage.java.
   * @param fileName Dateiname der Storagedatei
   * @return Liste mit den Scenario-Objekte.
   */
  public List getList() {
    List scenariosList = new ArrayList();
    try {
      SAXBuilder builder = new SAXBuilder();
      StorageDoc = builder.build(appPath + storageFileName);
      Root = StorageDoc.getRootElement();
      List scenarioChildren = Root.getChildren("scenario", ipfixConfigNS);
      Iterator listIterator = scenarioChildren.iterator();
      Element currentElement;

      while (listIterator.hasNext()) {
        currentElement = (Element) listIterator.next();
        Scenario currentScenario = new Scenario();
        // currentscenario.setId(Integer.valueOf(currentElement.getAttributeValue("id")));
        currentScenario.setName(currentElement.getChildText("name", ipfixConfigNS));
        currentScenario.setDescription(currentElement.getChildText("descript", ipfixConfigNS));
        List deviceList = new ArrayList();
        Element devices = currentElement.getChild("devices", ipfixConfigNS);
        List childList = devices.getChildren("device", ipfixConfigNS);
        Iterator devicesIterator = childList.iterator();
        while (devicesIterator.hasNext()) {
          Element currentDevice = (Element) devicesIterator.next();
          deviceList.add(currentDevice.getText());
        }
        currentScenario.setDeviceList(deviceList);
        scenariosList.add(currentScenario);
      }

    } catch (Exception ex) {
      ex.printStackTrace();
    }
    return scenariosList;
  }
コード例 #5
0
 /**
  * Parses a rule template attribute
  *
  * @param element the attribute XML element
  * @param ruleTemplate the ruleTemplate to update
  * @return a parsed rule template attribute
  * @throws XmlException if the attribute does not exist
  */
 private RuleTemplateAttributeBo parseRuleTemplateAttribute(
     Element element, RuleTemplateBo ruleTemplate) throws XmlException {
   String attributeName = element.getChildText(NAME, RULE_TEMPLATE_NAMESPACE);
   String requiredValue = element.getChildText(REQUIRED, RULE_TEMPLATE_NAMESPACE);
   String activeValue = element.getChildText(ACTIVE, RULE_TEMPLATE_NAMESPACE);
   if (org.apache.commons.lang.StringUtils.isEmpty(attributeName)) {
     throw new XmlException("Attribute name must be non-empty");
   }
   boolean required = DEFAULT_ATTRIBUTE_REQUIRED;
   if (requiredValue != null) {
     required = Boolean.parseBoolean(requiredValue);
   }
   boolean active = DEFAULT_ATTRIBUTE_ACTIVE;
   if (activeValue != null) {
     active = Boolean.parseBoolean(activeValue);
   }
   RuleAttribute ruleAttribute =
       KEWServiceLocator.getRuleAttributeService().findByName(attributeName);
   if (ruleAttribute == null) {
     throw new XmlException("Could not locate rule attribute for name '" + attributeName + "'");
   }
   RuleTemplateAttributeBo templateAttribute = new RuleTemplateAttributeBo();
   templateAttribute.setRuleAttribute(ruleAttribute);
   templateAttribute.setRuleAttributeId(ruleAttribute.getId());
   templateAttribute.setRuleTemplate(ruleTemplate);
   templateAttribute.setRequired(Boolean.valueOf(required));
   templateAttribute.setActive(Boolean.valueOf(active));
   templateAttribute.setDisplayOrder(new Integer(templateAttributeCounter++));
   return templateAttribute;
 }
コード例 #6
0
 public void loadFieldDetails(Element paramElement) throws Exception {
   List localList = null;
   String str1 = null;
   String str2 = "";
   String str3 = "";
   try {
     localList = paramElement.getChildren("DataField");
     Iterator localIterator = localList.iterator();
     for (Element localElement = null; localIterator.hasNext(); localElement = null) {
       localElement = (Element) localIterator.next();
       str1 = localElement.getChildText("FieldLocation");
       int i = str1 != null ? Integer.parseInt(str1) : -1;
       str2 = localElement.getChildText("ColumnName");
       str3 = localElement.getChildText("FieldType");
       str1 = null;
       str1 = localElement.getChildText("FieldLength");
       int j = str1 != null ? Integer.parseInt(str1) : -1;
       this.fieldDetails[i] = new MappingField(i, str2, str3, j);
       i = -1;
       j = -1;
       str2 = null;
       str3 = null;
     }
   } catch (Exception localException) {
     logger.debug("Unable to load the Data Field details for :" + this.fileName);
     throw localException;
   }
 }
コード例 #7
0
  private RuleTemplateBo parseRuleTemplate(Element element, List<RuleTemplateBo> ruleTemplates)
      throws XmlException {
    String name = element.getChildText(NAME, RULE_TEMPLATE_NAMESPACE);
    String description = element.getChildText(DESCRIPTION, RULE_TEMPLATE_NAMESPACE);
    Attribute allowOverwriteAttrib = element.getAttribute("allowOverwrite");

    boolean allowOverwrite = false;
    if (allowOverwriteAttrib != null) {
      allowOverwrite = Boolean.valueOf(allowOverwriteAttrib.getValue()).booleanValue();
    }
    if (org.apache.commons.lang.StringUtils.isEmpty(name)) {
      throw new XmlException("RuleTemplate must have a name");
    }
    if (org.apache.commons.lang.StringUtils.isEmpty(description)) {
      throw new XmlException("RuleTemplate must have a description");
    }

    // look up the rule template by name first
    RuleTemplateBo ruleTemplate =
        KEWServiceLocator.getRuleTemplateService().findByRuleTemplateName(name);

    if (ruleTemplate == null) {
      // if it does not exist create a new one
      ruleTemplate = new RuleTemplateBo();
    } else {
      // if it does exist, update it, only if allowOverwrite is set
      if (!allowOverwrite) {
        throw new RuntimeException(
            "Attempting to overwrite template " + name + " without allowOverwrite set");
      }

      // the name should be equal if one was actually found
      assert (name.equals(ruleTemplate.getName()))
          : "Existing template definition name does not match incoming definition name";
    }

    // overwrite simple properties
    ruleTemplate.setName(name);
    ruleTemplate.setDescription(description);

    // update the delegation template
    updateDelegationTemplate(element, ruleTemplate, ruleTemplates);

    // update the attribute relationships
    updateRuleTemplateAttributes(element, ruleTemplate);

    // save the rule template first so that the default/template rule that is generated
    // in the process of setting defaults is associated properly with this rule template
    ruleTemplate = KEWServiceLocator.getRuleTemplateService().save(ruleTemplate);

    // update the default options
    updateRuleTemplateDefaultOptions(element, ruleTemplate);

    ruleTemplate = KEWServiceLocator.getRuleTemplateService().save(ruleTemplate);

    return ruleTemplate;
  }
コード例 #8
0
ファイル: CoreClient.java プロジェクト: andham/nexus
  private PlexusRole parsePlexusRole(Element element) {
    PlexusRole plexusRole = new PlexusRole();

    plexusRole.setRoleId(element.getChildText(PLEXUS_ROLE_ID_ELEMENT));
    plexusRole.setName(element.getChildText(PLEXUS_ROLE_NAME_ELEMENT));
    plexusRole.setSource(element.getChildText(PLEXUS_ROLE_SOURCE_ELEMENT));

    return plexusRole;
  }
コード例 #9
0
ファイル: TaskDescription.java プロジェクト: rhansen/rpstir
 /** @param element */
 public TaskDescription(Element element) {
   this.name = element.getAttributeValue(ATTR_NAME);
   this.description = element.getChildText(TAG_DESCRIPTION);
   this.scriptFile = new File(element.getChildText(TAG_SCRIPT_FILE));
   List<Element> argDescriptionElements = getChildren(element, TAG_ARG_DESCRIPTION);
   for (Element argDescriptionElement : argDescriptionElements) {
     ArgDescription argDescription = new ArgDescription(argDescriptionElement);
     argDescriptions.add(argDescription);
   }
 }
コード例 #10
0
 private static Ratings getRatings(Element e) {
   if (e == null) {
     return null;
   }
   Ratings r = new Ratings();
   r.setAvg(DOUBLE.safeValue(e.getChildText("avg")));
   r.setVotes(INTEGER.safeValue(e.getChildText("votes")));
   r.setHistory(new HashMap<String, Integer>());
   populateMap(r.getHistory(), e.getChild("history"));
   return r;
 }
コード例 #11
0
ファイル: ItTree.java プロジェクト: jdahaldev/itsimple
  /**
   * Builds the tree node representing the project, which is structured in a XML type file
   *
   * @param xmlProject an Element which contains the data of the project
   * @param path a String with the path of the file where the project is saved
   */
  public void buildStructure(Element xmlProject, String path) {
    if (xmlProject != null) {

      ItTreeNode root = (ItTreeNode) treeModel.getRoot();

      /*
       * The project node is created with an
       * id higher than the current highest id
       */
      int currentIdValue, maxIdValue = 0;
      for (int i = 0; i < root.getChildCount(); i++) {
        ItTreeNode current = (ItTreeNode) root.getChildAt(i);
        currentIdValue = Integer.parseInt(current.getReference().getAttributeValue("id"));
        if (currentIdValue > maxIdValue) maxIdValue = currentIdValue;
      }
      String idValue = String.valueOf(maxIdValue + 1);
      Element projectId = new Element("id");
      projectId.setText(idValue);
      xmlProject.getChild("generalInformation").addContent(projectId);

      Element projectHeader = new Element("projectHeader");
      Attribute headerId = new Attribute("id", idValue);
      Element filePath = new Element("filePath");

      if (path != null) {
        filePath.setText(path);
      }
      // If it is null then it is a new project (*itSIMPLE* is a internal control)
      else {
        filePath.setText("*itSIMPLE*" + idValue);
        xmlProject.getChild("name").setText(xmlProject.getChildText("name") + " " + idValue);
      }

      projectHeader.setAttribute(headerId);
      projectHeader.addContent(filePath);

      ItTreeNode treeProject =
          new ItTreeNode(xmlProject.getChildText("name"), xmlProject, projectHeader, null);
      // treeProject.setIcon(new ImageIcon("resources/images/project.png"));
      treeModel.insertNodeInto(treeProject, root, root.getChildCount());

      if (xmlProject.getName().equals("project")) {
        treeProject.setIcon(new ImageIcon("resources/images/project.png"));
        buildDiagramNode(xmlProject, treeProject);
      } else if (xmlProject.getName().equals("pddlproject")) {
        // System.out.println(path);
        treeProject.setIcon(new ImageIcon("resources/images/virtualprototype.png"));
        // System.out.println("PDDL project open");
        buildPDDLNode(xmlProject, treeProject, path);
      }
    }
  }
コード例 #12
0
 private UserInfo mkUserInfo(Element user) {
   UserInfo info = new UserInfo();
   String name = user.getChildText("name");
   String address = user.getChildText("email");
   String peerid = user.getChildText("peerid");
   String status = user.getChildText("status");
   if (status == null) status = "0";
   info.setAddress(address);
   info.setPeerID(peerid);
   info.setName(name);
   info.setStatus(Integer.parseInt(status));
   return info;
 }
コード例 #13
0
ファイル: XmlDAO.java プロジェクト: 7Silvan/ncl
  @Override
  public Collection<Task> loadTasks() {
    Collection<Task> loadedTasks = null;
    try {
      String path = config.getFileName();
      if (path == null) {
        log.error("Cannot get path to taskFile. Will halt.");
        throw new BadConfigException("Cannot get path to taskFile. Will halt.");
      }
      if (new File(path).exists()) {
        Boolean valid = Tools.valXML(path);
        if (valid) {
          try {
            SAXBuilder builder = new SAXBuilder();
            doc = builder.build(config.getFileName());

            Iterator it = doc.getRootElement().getChildren("task").iterator();
            loadedTasks = new TreeSet<Task>(taskComparator);

            while (it.hasNext()) {
              Element element = (Element) it.next();

              String id = element.getAttributeValue("id");
              String name = element.getChildText("name");
              String description = element.getChildText("description");
              String date = element.getChildText("date");

              Task task = new Task(id, name, description, sdf.parse(date));

              loadedTasks.add(task);
            }
          } catch (JDOMException ex) {
            log.error("Error in loading tasks from xml ", ex);
            throw new IOException("Error in loading tasks from xml ", ex);
          } catch (ParseException ex) {
            log.error("Error in xml parsing.");
            throw new IOException("Error in xml parsing.", ex);
          }
        } else {
          log.info("XML File is not valid. Check it.");
          throw new InvalidFileException("XML File is not valid. Check it.");
        }
      } else {
        saveTask(null);
      }
    } catch (Exception ex) {
      log.error("Tasks wasn't loaded, IO or XML errors occured", ex);
      throw new InternalControllerException("Tasks wasn't loaded, IO or XML errors occured", ex);
    }
    return loadedTasks;
  }
コード例 #14
0
ファイル: ItTree.java プロジェクト: jdahaldev/itsimple
  public ItTreeNode buildProblemNode(Element problem, ItTreeNode treeProject) {
    ItTreeNode treeProblem = new ItTreeNode(problem.getChildText("name"), problem, null, null);
    treeProblem.setIcon(new ImageIcon("resources/images/planningProblem.png"));
    treeModel.insertNodeInto(treeProblem, treeProject, treeProject.getChildCount());

    // Build each Object Diagram under the Problem Node
    Iterator objectDiagrams =
        problem.getChild("objectDiagrams").getChildren("objectDiagram").iterator();
    while (objectDiagrams.hasNext()) {
      Element objectDiagram = (Element) objectDiagrams.next();
      ItTreeNode treeDiagram =
          new ItTreeNode(
              objectDiagram.getChildText("name")
                  + " - "
                  + objectDiagram.getChildText("sequenceReference"),
              objectDiagram,
              null,
              null);
      treeDiagram.setIcon(new ImageIcon("resources/images/objectDiagram.png"));
      treeProblem.add(treeDiagram);

      Iterator objects = objectDiagram.getChild("objects").getChildren("object").iterator();
      while (objects.hasNext()) {
        Element objectReference = (Element) objects.next();
        Element object =
            getElement(
                problem.getParentElement().getParentElement(),
                "objects",
                objectReference.getAttributeValue("id"));
        if (object != null) {
          Element itsClass = null;
          try {
            XPath path =
                new JDOMXPath(
                    "project/elements/classes/class[@id=" + object.getChildText("class") + "]");
            itsClass = (Element) path.selectSingleNode(problem.getDocument());
          } catch (JaxenException e2) {
            e2.printStackTrace();
          }
          // Element itsClass = getElement(xmlProject, "classes", object.getChildText("class"));
          ItTreeNode treeObject =
              new ItTreeNode(object.getChildText("name"), object, objectReference, itsClass);
          treeObject.setIcon(new ImageIcon("resources/images/object.png"));
          treeDiagram.add(treeObject);
        }
      }
    }

    return treeProblem;
  }
コード例 #15
0
  @Override
  public void update(SettingManager settings, Dbms dbms) throws SQLException {

    final int MIN_HARVEST_ID = 100000;
    Element result =
        dbms.select("select * from Settings where parentid = 2 and id < " + MIN_HARVEST_ID);

    if (result.getChildren().size() > 0) {
      dbms.execute("SELECT * INTO Harvester FROM Settings WHERE parentid = 2");
      int changed = result.getChildren().size();
      while (changed > 0) {
        changed =
            dbms.execute(
                "INSERT INTO Harvester SELECT * FROM Settings WHERE parentid IN (SELECT id FROM Harvester) AND NOT id IN (SELECT id FROM Harvester)");
      }

      dbms.execute("DELETE FROM Settings WHERE id IN (SELECT id FROM Harvester)");
      int newHarvesterBaseIndex = Math.max(max(dbms), 100000);
      @SuppressWarnings("unchecked")
      List<Element> harvesterValues = dbms.select("SELECT * from Harvester").getChildren();

      Map<Integer, Integer> updates = new HashMap<Integer, Integer>();
      updates.put(2, 2); // Add harvesting node parentid to id map
      for (Element element : harvesterValues) {
        int id = Integer.parseInt(element.getChildText("id"));
        newHarvesterBaseIndex++;
        updates.put(id, newHarvesterBaseIndex);
      }
      StringBuilder builder = new StringBuilder("INSERT INTO Settings VALUES ");
      for (Element element : harvesterValues) {
        int id = Integer.parseInt(element.getChildText("id"));
        int parentid = Integer.parseInt(element.getChildText("parentid"));
        String name = element.getChildText("name");
        String value = element.getChildText("value");
        builder
            .append("(")
            .append(updates.get(id))
            .append(',')
            .append(updates.get(parentid))
            .append(",'")
            .append(name)
            .append("','")
            .append(value)
            .append("'),");
      }
      builder.deleteCharAt(builder.length() - 1);
      dbms.execute(builder.toString());
    }
  }
コード例 #16
0
ファイル: QuestManager.java プロジェクト: teeppiphat/scald
  public void createDependencies(Element dep, Quest quest) {
    if (dep != null) {

      // if there are quests
      if (dep.getChild("Quest") != null) {
        // get the quest dependencies
        quest.setQuestDependencies(loadOneDependencie(dep.getChild("Quest")));
      }

      // if there are itens needed
      if (dep.getChild("Itens") != null) {
        // get the Itens
        Object[] objects;
        objects = loadTwoDependencies(dep.getChild("Itens"));
        // set their places
        quest.setItemDependencies((String[]) objects[0]);
        quest.setItemDependenciesQuantity((int[]) objects[1]);
      }

      // if exists the need for levels
      if (dep.getChild("Level") != null) {
        // get the Level
        quest.setLevelDependencie(Integer.parseInt(dep.getChildText("Level")));
      }
    }
  }
コード例 #17
0
ファイル: QuestManager.java プロジェクト: teeppiphat/scald
  public void createReward(Element rew, Quest quest) {
    if (rew != null) {

      // if there´s money to be rewarded
      if (rew.getChild("Money") != null) {
        quest.setMoneyRewarded(Integer.parseInt(rew.getChildText("Money")));
      } else {
        // if there´s no money reward
        quest.setMoneyRewarded(-1);
      }

      // if there´s one or more itens to be rewarded
      if (rew.getChild("Itens") != null) {
        // get the Itens
        Object[] objects;
        objects = loadTwoDependencies(rew.getChild("Itens"));
        // set their places
        quest.setRewardItem((String[]) objects[0]);
        quest.setRewardedItem((int[]) objects[1]);
      }

      // if there´s something of the character that increases
      if (rew.getChild("Features") != null) {
        // get the Itens
        Object[] objects;
        objects = loadThreeDependencies(rew.getChild("Features"));
        // set their places
        quest.setFeatureName((String[]) objects[0]);
        quest.setFeatureType((String[]) objects[1]);
        quest.setFeatureValue((int[]) objects[2]);
      }
    }
  }
コード例 #18
0
ファイル: Objectives.java プロジェクト: projectestac/qv
  /* (non-Javadoc)
   * @see edu.xtec.qv.qti.QTIObject#createFromXML(org.jdom.Element)
   */
  public void createFromXML(Element eElement) {
    if (eElement != null) {
      setAttribute(VIEW, eElement.getChildText(VIEW.getTagName()));

      // Add qticomment
      if (eElement.getChild(QTICOMMENT.getTagName(), eElement.getNamespace()) != null) {
        QTIComment oComment =
            new QTIComment(eElement.getChild(QTICOMMENT.getTagName(), eElement.getNamespace()));
        setAttribute(QTICOMMENT, oComment);
      }

      // Add material and flow_mat
      Vector vContents = new Vector();
      Iterator itContents = eElement.getChildren().iterator();
      while (itContents.hasNext()) {
        Element eContent = (Element) itContents.next();
        QTIObject oContent = null;
        if (FLOW_MAT.equals(eContent.getName())) {
          oContent = new FlowMat(eContent);
        } else if (MATERIAL.equals(eContent.getName())) {
          oContent = new Material(eContent);
        }
        if (oContent != null) {
          vContents.addElement(oContent);
        }
      }
      setAttribute(CONTENT, vContents);
    }
  }
コード例 #19
0
  // This method returns the destination list for a message
  private Vector<SocketInfo> getDestinationList(Element element, boolean senderIsMailUser) {
    Vector<SocketInfo> usersVector = new Vector<SocketInfo>();

    String target = element.getChildText("toName");

    // If sender is a POS user
    if (!senderIsMailUser) {
      usersVector = SocketServer.getAllClients(groupID);
    }
    // If sender is a POP user
    else {
      // If destination is one user
      if (target != null) {
        SocketInfo destination = getUserData(target, false);
        if (destination != null) {
          usersVector.add(destination);
          return usersVector;
        }
      }
      // If destination is a group
      usersVector = SocketServer.getAllClients(target);
    }

    return usersVector;
  }
コード例 #20
0
  /**
   * Creates this from a JDOM element.
   *
   * @param jdom input
   */
  public UserQueryInput(Element jdom) {

    // Done in LuceneSearcher#computeQuery
    // protectRequest(jdom);

    for (Object e : jdom.getChildren()) {
      if (e instanceof Element) {
        Element node = (Element) e;
        String nodeName = node.getName();
        String nodeValue = StringUtils.trim(node.getText());
        if (SearchParameter.SIMILARITY.equals(nodeName)) {
          setSimilarity(jdom.getChildText(SearchParameter.SIMILARITY));
        } else {
          if (StringUtils.isNotBlank(nodeValue)) {

            if (SECURITY_FIELDS.contains(nodeName) || nodeName.contains("_op")) {
              addValues(searchPrivilegeCriteria, nodeName, nodeValue);
            } else if (RESERVED_FIELDS.contains(nodeName)) {
              searchOption.put(nodeName, nodeValue);
            } else {
              // addValues(searchCriteria, nodeName, nodeValue);
              // Rename search parameter to lucene index field
              // when needed
              addValues(
                  searchCriteria,
                  (searchParamToLuceneField.containsKey(nodeName)
                      ? searchParamToLuceneField.get(nodeName)
                      : nodeName),
                  nodeValue);
            }
          }
        }
      }
    }
  }
コード例 #21
0
  protected String getRallyAPIError(String responseXML) {
    String errorMsg = "";

    try {

      org.jdom.input.SAXBuilder bSAX = new org.jdom.input.SAXBuilder();
      org.jdom.Document doc = bSAX.build(new StringReader(responseXML));
      Element root = doc.getRootElement();

      XPath xpath = XPath.newInstance("//Errors");
      List xlist = xpath.selectNodes(root);

      Iterator iter = xlist.iterator();
      while (iter.hasNext()) {

        Element item = (Element) iter.next();
        errorMsg = item.getChildText("OperationResultError");
      }

    } catch (Exception e) {
      errorMsg = e.toString();
    }

    return errorMsg;
  }
コード例 #22
0
ファイル: QServer.java プロジェクト: Zengwn/jPOS
  private void initWhoToSendTo() {

    Element persist = getPersist();
    sendMethod = persist.getChildText("send-request");
    if (sendMethod == null) {
      sendMethod = "LAST";
    }
  }
コード例 #23
0
  private void xmlToTemplate(Element xmlTemplate, String key) {
    String subject = xmlTemplate.getChildText("subject");
    String body = xmlTemplate.getChildText("message");
    String locale = xmlTemplate.getChildText("locale");
    String versionString = xmlTemplate.getChildText("version");

    if (!emailTemplateService.templateExists(key, new Locale(locale))) {
      EmailTemplate template = new EmailTemplate();
      template.setSubject(subject);
      template.setMessage(body);
      template.setLocale(locale);
      template.setKey(key);
      template.setVersion(
          Integer.valueOf(
              1)); // setVersion(versionString != null ? Integer.valueOf(versionString) :
                   // Integer.valueOf(0));	// set version
      template.setOwner("admin");
      template.setLastModified(new Date());
      this.emailTemplateService.saveTemplate(template);
      M_log.info(this + " user notification tempalte " + key + " added");
    } else {
      EmailTemplate existingTemplate =
          this.emailTemplateService.getEmailTemplate(key, new Locale(locale));
      String oVersionString =
          existingTemplate.getVersion() != null ? existingTemplate.getVersion().toString() : null;
      if ((oVersionString == null && versionString != null)
          || (oVersionString != null
              && versionString != null
              && !oVersionString.equals(versionString))) {
        existingTemplate.setSubject(subject);
        existingTemplate.setMessage(body);
        existingTemplate.setLocale(locale);
        existingTemplate.setKey(key);
        existingTemplate.setVersion(
            versionString != null
                ? Integer.valueOf(versionString)
                : Integer.valueOf(0)); // set version
        existingTemplate.setOwner("admin");
        existingTemplate.setLastModified(new Date());
        this.emailTemplateService.updateTemplate(existingTemplate);
        M_log.info(this + " user notification tempalte " + key + " updated to newer version");
      }
    }
  }
コード例 #24
0
ファイル: WeightTable.java プロジェクト: le-gorgo/dicf
 private void setTempFromTextElement(int type, Element e) {
   switch (type) {
     case FUNCTION:
     case PREDICATE:
       if (e.getChildText("Aggregator") != null)
         tempAggregator = toCode(e.getChildTextTrim("Aggregator"));
       if (e.getChildText("UseParam") != null)
         tempUseParam = toCode(e.getChildTextTrim("UseParam"));
       if (e.getChildText("IntegerWeight") != null)
         tempIntW = Double.parseDouble(e.getChildTextTrim("IntegerWeight"));
       if (e.getChildText("VariableWeight") != null)
         tempVarW = Double.parseDouble(e.getChildTextTrim("VariableWeight"));
     case CONSTANT:
     case INTEGER:
     case VARIABLE:
       if (e.getChildText("Weight") != null)
         tempWeight = Double.parseDouble(e.getChildTextTrim("Weight"));
   }
 }
コード例 #25
0
  // Add all the protocols and services of the list in the stack
  private void createFeatures(String name, TGLinkedList<TElement> newFeatures) {
    Iterator<TElement> it = newFeatures.iterator();
    while (it.hasNext()) {
      Element element = it.next().getElement();

      try {
        if (element.getName().equals("Service")) {
          this.stack.newService(element);
        } else if (element.getName().equals("Protocol")) {
          ProtocolModule newProt = this.stack.newProtocolModule(element);
          newProt.init();
          if (!newProt.getName().equals(name)) newProt.linkToService();
        } else throw new RuntimeException("Unknown Element Name: " + element);
      } catch (SamoaClassException e) {
        System.err.println(e.getMessage());
      } catch (AlreadyExistingServiceException e) {
        System.err.println("Service already exist: " + element.getChildText("Name"));
      } catch (AlreadyExistingProtocolModuleException e) {
        System.err.println("Protocol already exist: " + element.getChildText("Name"));
      } catch (AlreadyBoundServiceException e) {
        System.err.println(
            "Service provided by the protocol has already a provider: "
                + element.getChildText("Name"));
      }
    }

    // Unlink the old protocol and bound the new one
    try {
      ProtocolModule newP = stack.getProtocol(name);

      if (newP != null) {
        consensus.unlinkExecuter();
        newP.linkToService();

        // Issue a response informing of the change of protocol
        ReplaceProtocolResponseParameters nparams =
            new ReplaceProtocolResponseParameters(consensus, newP);
        replaceConsensus.response(nparams, null);
      } else System.err.println("The protocol with name " + name + " does not exist!");
    } catch (AlreadyBoundServiceException ex) {
      throw new RuntimeException("Error in conception. Should not be possible!");
    }
  }
コード例 #26
0
ファイル: CoreClient.java プロジェクト: andham/nexus
  @SuppressWarnings("unchecked")
  private PlexusUser parsePlexusUser(Element element) {
    PlexusUser plexusUser = new PlexusUser();

    plexusUser.setUserId(element.getChildText(PLEXUS_USER_ID_ELEMENT));
    plexusUser.setName(element.getChildText(PLEXUS_USER_NAME_ELEMENT));
    plexusUser.setEmail(element.getChildText(PLEXUS_USER_EMAIL_ELEMENT));
    plexusUser.setSource(element.getChildText(PLEXUS_USER_SOURCE_ELEMENT));

    Element rolesElement = element.getChild(PLEXUS_USER_ROLES_ELEMENT);

    if (rolesElement != null) {
      for (Element roleElement : (List<Element>) rolesElement.getChildren()) {
        plexusUser.getPlexusRoles().add(parsePlexusRole(roleElement));
      }
    }

    return plexusUser;
  }
コード例 #27
0
ファイル: CoreClient.java プロジェクト: andham/nexus
  @SuppressWarnings("unchecked")
  private UserToRole parseUserToRole(final Element element) {
    UserToRole userToRole = new UserToRole();

    userToRole.setUserId(element.getChildText(USER_TO_ROLE_USER_ID_ELEMENT));

    userToRole.setSource(element.getChildText(USER_TO_ROLE_SOURCE_ELEMENT));

    Element rolesElement = element.getChild(USER_TO_ROLE_ROLES_ELEMENT);

    if (rolesElement != null) {
      for (Element roleElement :
          (List<Element>) rolesElement.getChildren(USER_TO_ROLE_ROLE_ELEMENT)) {
        userToRole.getRoles().add(roleElement.getValue());
      }
    }

    return userToRole;
  }
コード例 #28
0
ファイル: QuestManager.java プロジェクト: teeppiphat/scald
  public Object[] loadThreeDependencies(Element element) {

    // get the children to a list
    List list = element.getChildren();

    // greater array
    Object[] objects = new Object[3];

    // allocate the array according to the size
    String[] names = new String[list.size()];
    String[] types = new String[list.size()];
    int[] values = new int[list.size()];

    // create the iterator to access the list
    Iterator i = list.iterator();
    int cont = 0;

    // temporary element used to get the elements
    Element temp;

    // get the elements from the list
    while (i.hasNext()) {
      // get the first object
      temp = (Element) i.next();
      // put the object in the array of names
      names[cont] = temp.getChildText("Name");
      // put the object in the array of types
      types[cont] = temp.getChildText("Type");
      // put the object in the array of values
      values[cont] = Integer.parseInt(temp.getChildText("Value"));
      // increase
      cont++;
    }

    // set the arrays in their places
    objects[0] = names;
    objects[1] = types;
    objects[2] = values;

    // return
    return objects;
  }
コード例 #29
0
 private void checkVersion() throws Exception {
   HttpMethod method = doREST("/rest/workflow/version", false);
   InputStream stream = method.getResponseBodyAsStream();
   Element element = new SAXBuilder(false).build(stream).getRootElement();
   final boolean timeTrackingAvailable =
       element.getName().equals("version")
           && VersionComparatorUtil.compare(element.getChildText("version"), "4.1") >= 0;
   if (!timeTrackingAvailable) {
     throw new Exception("This version of Youtrack the time tracking is not supported");
   }
 }
コード例 #30
0
  private void getMessageParams(Element element) {
    groupIDString = element.getChildText("idgroup");
    groupID = Integer.parseInt(groupIDString);
    date = Calendar.getInstance().getTime();
    from = (element.getChildText("from")).trim();
    dateString = formatDate.format(date);
    hourString = formatHour.format(date);
    subject = element.getChildText("subject");
    body = element.getChildText("message");
    Element mailLifeTime = element.getChild("timeAlife");
    lifeTime = mailLifeTime != null ? Integer.parseInt(mailLifeTime.getValue()) : 0;

    if (CONTROL_MODE) {
      // This is a message control
      if (lifeTime > 0) {
        control = true;
        body += "\n====================================\n" + "Este mensaje es de control\n";
      }
    }
  }