Java 类org.dom4j.tree.DefaultElement 实例源码

项目:jspider    文件:XmlParser.java   
private Object getXmlValueText(List nodes) {
    if (nodes == null || nodes.isEmpty()) {
        return null;
    }
    Object node = nodes.get(0);
    if (node instanceof DefaultText) {
        return StringUtils.trim(((DefaultText) node).getText());
    }
    if (node instanceof DefaultAttribute) {
        return StringUtils.trim(((DefaultAttribute) node).getText());
    }
    if (node instanceof DefaultElement) {
        return StringUtils.trim(((DefaultElement) node).getText());
    }

    throw new IllegalArgumentException("unsupported node type ["+node+"].");
}
项目:iBase4J-Common    文件:XmlUtil.java   
/**
 * 将mq查询结果包装成list--dto的形式,dto内容为item中的内容
 * 
 * @param recv
 * @return
 */
public static Map MqResToDto(String recv) {
    // System.out.println("####recv"+recv);
    List res = new ArrayList();
    Map map = new HashMap();
    try {
        Document doc = DocumentHelper.parseText(recv);
        List list = doc.selectNodes("//item");
        Iterator<DefaultElement> it = list.iterator();
        while (it.hasNext()) {
            Map elementdto = XmlUtil.Dom2Map(it.next());
            res.add(elementdto);
        }
        map.put("resultList", res);// 放入结果集
        /* 如果存在REC_MNT,说明是分页查询类,需要将总记录数返回 */
        Node de = doc.selectSingleNode("//REC_MNT");
        if (DataUtil.isNotEmpty(de)) {
            map.put("countInteger", de.getText());
        }
    } catch (Exception e) {
        logger.error("", e);
    }
    return map;
}
项目:automat    文件:XmlUtil.java   
/**
 * 将mq查询结果包装成list--dto的形式,dto内容为item中的内容
 * 
 * @param recv
 * @return
 */
public static Map MqResToDto(String recv) {
    // System.out.println("####recv"+recv);
    List res = new ArrayList();
    Map map = new HashMap();
    try {
        Document doc = DocumentHelper.parseText(recv);
        List list = doc.selectNodes("//item");
        Iterator<DefaultElement> it = list.iterator();
        while (it.hasNext()) {
            Map elementdto = XmlUtil.Dom2Map(it.next());
            res.add(elementdto);
        }
        map.put("resultList", res);// 放入结果集
        /*
         * 如果存在REC_MNT,说明是分页查询类,需要将总记录数返回
         */
        Node de = doc.selectSingleNode("//REC_MNT");
        if (DataUtil.isNotEmpty(de)) {
            map.put("countInteger", de.getText());
        }
    } catch (Exception e) {
        log.error(XmlUtil.class, e);
    }
    return map;
}
项目:iBase4J    文件:XmlUtil.java   
/**
 * 将mq查询结果包装成list--dto的形式,dto内容为item中的内容
 * 
 * @param recv
 * @return
 */
public static Map MqResToDto(String recv) {
    // System.out.println("####recv"+recv);
    List res = new ArrayList();
    Map map = new HashMap();
    try {
        Document doc = DocumentHelper.parseText(recv);
        List list = doc.selectNodes("//item");
        Iterator<DefaultElement> it = list.iterator();
        while (it.hasNext()) {
            Map elementdto = XmlUtil.Dom2Map(it.next());
            res.add(elementdto);
        }
        map.put("resultList", res);// 放入结果集
        /*
         * 如果存在REC_MNT,说明是分页查询类,需要将总记录数返回
         */
        Node de = doc.selectSingleNode("//REC_MNT");
        if (DataUtil.isNotEmpty(de)) {
            map.put("countInteger", de.getText());
        }
    } catch (Exception e) {
        log.error(XmlUtil.class, e);
    }
    return map;
}
项目:JAVA-    文件:XmlUtil.java   
/**
 * 将mq查询结果包装成list--dto的形式,dto内容为item中的内容
 * 
 * @param recv
 * @return
 */
public static Map MqResToDto(String recv) {
    // System.out.println("####recv"+recv);
    List res = new ArrayList();
    Map map = new HashMap();
    try {
        Document doc = DocumentHelper.parseText(recv);
        List list = doc.selectNodes("//item");
        Iterator<DefaultElement> it = list.iterator();
        while (it.hasNext()) {
            Map elementdto = XmlUtil.Dom2Map(it.next());
            res.add(elementdto);
        }
        map.put("resultList", res);// 放入结果集
        /*
         * 如果存在REC_MNT,说明是分页查询类,需要将总记录数返回
         */
        Node de = doc.selectSingleNode("//REC_MNT");
        if (DataUtil.isNotEmpty(de)) {
            map.put("countInteger", de.getText());
        }
    } catch (Exception e) {
        log.error(XmlUtil.class, e);
    }
    return map;
}
项目:eSDK_EC_SDK_Java    文件:AppMappingDAO.java   
@Override
public boolean addAppMapping(AppMappingConfig appMapping)
{
    try
    {
        Element rootElm = document.getRootElement();
        Element mappingEle = new DefaultElement("mapping");
        mappingEle.add(buildElement("deviceId", appMapping.getDeviceId()));
        mappingEle.add(buildElement("esdkApp", appMapping.getEsdkApp()));
        mappingEle.add(buildElement("deviceApp", appMapping.getDeviceApp()));
        mappingEle.add(buildElement("deviceAppPwd", appMapping.getDeviceAppPwd()));
        rootElm.add(mappingEle);

        writeXmlFile(document, this.file);

    }
    catch (IOException e)
    {
        LOGGER.error("", e);
        return false;
    }

    return true;
}
项目:eSDK_IVS_Java    文件:AppMappingDAO.java   
@Override
public boolean addAppMapping(AppMappingConfig appMapping)
{
    try
    {
        Element rootElm = document.getRootElement();
        Element mappingEle = new DefaultElement("mapping");
        mappingEle.add(buildElement("deviceId", appMapping.getDeviceId()));
        mappingEle.add(buildElement("esdkApp", appMapping.getEsdkApp()));
        mappingEle.add(buildElement("deviceApp", appMapping.getDeviceApp()));
        mappingEle.add(buildElement("deviceAppPwd", appMapping.getDeviceAppPwd()));
        rootElm.add(mappingEle);

        writeXmlFile(document, this.file);

    }
    catch (IOException e)
    {
        LOGGER.error("", e);
        return false;
    }

    return true;
}
项目:AvoinApotti    文件:Logic.java   
private ReportSeedParsedVoCollection parseSeedsFromXML(String reportXML) throws DocumentException
{
    Document document = DocumentHelper.parseText(reportXML);

    ReportSeedParsedVoCollection seeds = new ReportSeedParsedVoCollection();
    List list = document.selectNodes("//Project/Seeds/Seed");
    for (Iterator iter = list.iterator(); iter.hasNext();)
    {
        DefaultElement attribute = (DefaultElement) iter.next();

        ReportSeedParsedVo seed = new ReportSeedParsedVo();
        seed.setName(attribute.valueOf("Name"));
        seed.setType(attribute.valueOf("Type"));
        seed.setBOName(attribute.valueOf("BOName"));
        seed.setBOField(attribute.valueOf("BOField"));
        seed.setCanBeNull(new Boolean(attribute.valueOf("CanBeNull").equalsIgnoreCase("true")));
        seeds.add(seed);
    }

    return seeds;
}
项目:AvoinApotti    文件:Logic.java   
private ReportSeedParsedVoCollection parseSeedsFromXML(String reportXML) throws DocumentException
{
    Document document = DocumentHelper.parseText(reportXML);

    ReportSeedParsedVoCollection seeds = new ReportSeedParsedVoCollection();
    List list = document.selectNodes("//Project/Seeds/Seed");
    for (Iterator iter = list.iterator(); iter.hasNext();)
    {
        DefaultElement attribute = (DefaultElement) iter.next();

        ReportSeedParsedVo seed = new ReportSeedParsedVo();
        seed.setName(attribute.valueOf("Name"));
        seed.setType(attribute.valueOf("Type"));
        seed.setBOName(attribute.valueOf("BOName"));
        seed.setBOField(attribute.valueOf("BOField"));
        seed.setCanBeNull(new Boolean(attribute.valueOf("CanBeNull").equalsIgnoreCase("true")));
        seeds.add(seed);
    }

    return seeds;
}
项目:AvoinApotti    文件:Logic.java   
private ReportSeedParsedVoCollection parseSeedsFromXML(String reportXML) throws DocumentException
{
    Document document = DocumentHelper.parseText(reportXML);

    ReportSeedParsedVoCollection seeds = new ReportSeedParsedVoCollection();
    List list = document.selectNodes("//Project/Seeds/Seed");
    for (Iterator iter = list.iterator(); iter.hasNext();)
    {
        DefaultElement attribute = (DefaultElement) iter.next();

        ReportSeedParsedVo seed = new ReportSeedParsedVo();
        seed.setName(attribute.valueOf("Name"));
        seed.setType(attribute.valueOf("Type"));
        seed.setBOName(attribute.valueOf("BOName"));
        seed.setBOField(attribute.valueOf("BOField"));
        seed.setCanBeNull(new Boolean(attribute.valueOf("CanBeNull").equalsIgnoreCase("true")));
        seeds.add(seed);
    }

    return seeds;
}
项目:AvoinApotti    文件:Logic.java   
private void parseSeedsFromXML(String reportXML) throws DocumentException
{
    Document document = DocumentHelper.parseText(reportXML);

    ReportSeedParsedVoCollection seeds = new ReportSeedParsedVoCollection();
    List list = document.selectNodes("//Project/Seeds/Seed");
    for (Iterator iter = list.iterator(); iter.hasNext();)
    {
        DefaultElement attribute = (DefaultElement) iter.next();

        ReportSeedParsedVo seed = new ReportSeedParsedVo();
        seed.setName(attribute.valueOf("Name"));
        seed.setType(attribute.valueOf("Type"));
        seed.setBOName(attribute.valueOf("BOName"));
        seed.setBOField(attribute.valueOf("BOField"));
        seed.setCanBeNull(new Boolean(attribute.valueOf("CanBeNull").equalsIgnoreCase("true")));
        seeds.add(seed);
    }

    form.getGlobalContext().Admin.setReportSeedParsed(seeds);
}
项目:taskerbox    文件:TaskerboxXmlReader.java   
private void handleMacrosNode(Element xmlChannel) throws IOException {

    for (Object attrObj : xmlChannel.elements()) {
      DefaultElement e = (DefaultElement) attrObj;

      StringWriter sw = new StringWriter();
      XMLWriter writer = new XMLWriter(sw);
      writer.write(e.elements());

      if (this.tasker.getMacros().containsKey(e.attributeValue("name"))) {
        throw new RuntimeException("Macro " + e.attributeValue("name") + " already exists in map.");
      }

      this.tasker.getMacros().put(e.attributeValue("name"), sw.toString());
      this.tasker.getMacroAttrs().put(e.attributeValue("name"), e.attributes());
    }

  }
项目:taskerbox    文件:TaskerboxXmlReader.java   
private void handleDefaultPropertiesNode(Element xmlChannel) {
  for (Object attrObj : xmlChannel.elements()) {
    DefaultElement e = (DefaultElement) attrObj;

    String propertyValue = e.attributeValue("value");

    for (String defaultAttr : this.tasker.getDefaultProperties().keySet()) {
      propertyValue =
          propertyValue.replace("{" + defaultAttr + "}",
              this.tasker.getDefaultProperties().get(defaultAttr));
    }

    this.tasker.getDefaultProperties().put(e.attributeValue("name"), propertyValue);

  }
}
项目:jaxen    文件:DOM4JXPathTest.java   
public void testNamespaceNodesAreInherited() throws JaxenException
{
        Namespace ns0 = Namespace.get("p0", "www.acme0.org");
        Namespace ns1 = Namespace.get("p1", "www.acme1.org");
        Namespace ns2 = Namespace.get("p2", "www.acme2.org");
        Element element = new DefaultElement("test", ns1);
        Attribute attribute = new DefaultAttribute("pre:foo", "bar", ns2);
        element.add(attribute);
        Element root = new DefaultElement("root", ns0);
        root.add(element);
        Document doc = new DefaultDocument(root);

        XPath xpath = new Dom4jXPath( "/*/*/namespace::node()" );

        List results = xpath.selectNodes( doc );

        assertEquals( 4,
                      results.size() );
}
项目:olat    文件:CPTreeController.java   
/**
 * Builds an html-info string about the current page and its linked resources
 * 
 * @return HTML-String
 */
private String getCurrentPageInfoStringHTML() {
    // test if currentPage links to resource, which is used (linked) somewhere
    // else in the manifest
    final CPManager cpMgm = (CPManager) CoreSpringFactory.getBean(CPManager.class);
    final DefaultElement ele = cpMgm.getElementByIdentifier(cp, currentPage.getIdRef());
    boolean single = false;
    if (ele instanceof CPResource) {
        final CPResource res = (CPResource) ele;
        single = cpMgm.isSingleUsedResource(res, cp);
    }

    final StringBuilder b = new StringBuilder();
    b.append("<br /><ul>");
    b.append("<li><b>" + translate("cptreecontroller.pagetitle") + "</b> " + currentPage.getTitle() + "</li>");
    if (single) {
        b.append("<li><b>" + translate("cptreecontroller.file") + "</b> " + currentPage.getFileName() + "</li>");
    }
    b.append("</ul>");
    return b.toString();

}
项目:openmaxims-linux    文件:Logic.java   
private void parseSeedsFromXML(String reportXML) throws DocumentException
{
    Document document = DocumentHelper.parseText(reportXML);

    ReportSeedParsedVoCollection seeds = new ReportSeedParsedVoCollection();
    List list = document.selectNodes("//Project/Seeds/Seed");
    for (Iterator iter = list.iterator(); iter.hasNext();)
    {
        DefaultElement attribute = (DefaultElement) iter.next();

        ReportSeedParsedVo seed = new ReportSeedParsedVo();
        seed.setName(attribute.valueOf("Name"));
        seed.setType(attribute.valueOf("Type"));
        seed.setBOName(attribute.valueOf("BOName"));
        seed.setBOField(attribute.valueOf("BOField"));
        seed.setCanBeNull(new Boolean(attribute.valueOf("CanBeNull").equalsIgnoreCase("true")));
        seeds.add(seed);
    }

    form.getGlobalContext().Admin.setReportSeedParsed(seeds);
}
项目:olat    文件:CPItem.java   
/**
*/
  @Override
  public DefaultElement getElementByIdentifier(final String id) {
      if (identifier.equals(id)) {
          return this;
      }
      DefaultElement e;
      for (final Iterator<CPItem> it = items.iterator(); it.hasNext();) {
          final CPItem item = it.next();
          e = item.getElementByIdentifier(id);
          if (e != null) {
              return e;
          }
      }
      return null;
  }
项目:olat    文件:CPFile.java   
/**
*/
  @Override
  public void buildChildren() {
      final Iterator<DefaultElement> children = this.elementIterator();
      // iterate through children
      while (children.hasNext()) {
          final DefaultElement child = children.next();
          if (child.getName().equals(CPCore.METADATA)) {
              // TODO: implement METADATA
              metadata = new CPMetadata(child);
          } else {
              throw new OLATRuntimeException(CPOrganizations.class, "Invalid IMS-Manifest ( only <metadata> element under <file> is allowed )", new Exception());
          }
      }
      this.clearContent();
      validateElement();
  }
项目:openMAXIMS    文件:Logic.java   
private void parseSeedsFromXML(String reportXML) throws DocumentException
{
    Document document = DocumentHelper.parseText(reportXML);

    ReportSeedParsedVoCollection seeds = new ReportSeedParsedVoCollection();
    List list = document.selectNodes("//Project/Seeds/Seed");
    for (Iterator iter = list.iterator(); iter.hasNext();)
    {
        DefaultElement attribute = (DefaultElement) iter.next();

        ReportSeedParsedVo seed = new ReportSeedParsedVo();
        seed.setName(attribute.valueOf("Name"));
        seed.setType(attribute.valueOf("Type"));
        seed.setBOName(attribute.valueOf("BOName"));
        seed.setBOField(attribute.valueOf("BOField"));
        seed.setCanBeNull(new Boolean(attribute.valueOf("CanBeNull").equalsIgnoreCase("true")));
        seeds.add(seed);
    }

    form.getGlobalContext().Admin.setReportSeedParsed(seeds);
}
项目:olat    文件:CPOrganizations.java   
/**
*/
  @Override
  public void buildChildren() {
      final Iterator<DefaultElement> children = this.elementIterator();
      // iterate through children
      while (children.hasNext()) {
          final DefaultElement child = children.next();
          if (child.getName().equals(CPCore.ORGANIZATION)) {
              final CPOrganization org = new CPOrganization(child);
              org.setParentElement(this);
              org.buildChildren();
              orgas.add(org);
          } else {
              errors.add("Invalid imsmanifest (only \"Organization\"-elements allowed under <organizations> )");
          }
      }
      this.clearContent();
      validateElement();
  }
项目:openMAXIMS    文件:Logic.java   
private ReportSeedParsedVoCollection parseSeedsFromXML(String reportXML) throws DocumentException
{
    Document document = DocumentHelper.parseText(reportXML);

    ReportSeedParsedVoCollection seeds = new ReportSeedParsedVoCollection();
    List list = document.selectNodes("//Project/Seeds/Seed");
    for (Iterator iter = list.iterator(); iter.hasNext();)
    {
        DefaultElement attribute = (DefaultElement) iter.next();

        ReportSeedParsedVo seed = new ReportSeedParsedVo();
        seed.setName(attribute.valueOf("Name"));
        seed.setType(attribute.valueOf("Type"));
        seed.setBOName(attribute.valueOf("BOName"));
        seed.setBOField(attribute.valueOf("BOField"));
        seed.setCanBeNull(new Boolean(attribute.valueOf("CanBeNull").equalsIgnoreCase("true")));
        seeds.add(seed);
    }

    return seeds;
}
项目:olat    文件:CPManifest.java   
/**
 * @param doc
 */
public void buildDocument(final DefaultDocument doc) {
    // Manifest is the root-node of the document, therefore we need to pass the
    // "doc"
    final DefaultElement manifestElement = new DefaultElement(CPCore.MANIFEST);

    manifestElement.add(new DefaultAttribute(CPCore.IDENTIFIER, this.identifier));
    manifestElement.add(new DefaultAttribute(CPCore.SCHEMALOCATION, this.schemaLocation));
    // manifestElement.setNamespace(this.getNamespace()); //FIXME: namespace

    doc.add(manifestElement);

    if (metadata != null) {
        metadata.buildDocument(manifestElement);
    }
    organizations.buildDocument(manifestElement);
    resources.buildDocument(manifestElement);

}
项目:openmaxims-linux    文件:Logic.java   
private ReportSeedParsedVoCollection parseSeedsFromXML(String reportXML) throws DocumentException
{
    Document document = DocumentHelper.parseText(reportXML);

    ReportSeedParsedVoCollection seeds = new ReportSeedParsedVoCollection();
    List list = document.selectNodes("//Project/Seeds/Seed");
    for (Iterator iter = list.iterator(); iter.hasNext();)
    {
        DefaultElement attribute = (DefaultElement) iter.next();

        ReportSeedParsedVo seed = new ReportSeedParsedVo();
        seed.setName(attribute.valueOf("Name"));
        seed.setType(attribute.valueOf("Type"));
        seed.setBOName(attribute.valueOf("BOName"));
        seed.setBOField(attribute.valueOf("BOField"));
        seed.setCanBeNull(new Boolean(attribute.valueOf("CanBeNull").equalsIgnoreCase("true")));
        seeds.add(seed);
    }

    return seeds;
}
项目:community-edition-old    文件:TestAbstractListItemsEndpointTest.java   
/**
 * ALF-19833: MacOS: Could not save to SharePoint
 */
@Test
public void canGetListUsingCorrectListAndSiteName() throws Exception
{
    VtiSoapRequest soapRequest = Mockito.mock(VtiSoapRequest.class);
    VtiSoapResponse soapResponse = new VtiSoapResponse(new MockHttpServletResponse());//Mockito.mock(VtiSoapResponse.class);
    Element requestElement = Mockito.mock(Element.class);
    SimpleNamespaceContext nc = Mockito.mock(SimpleNamespaceContext.class);

    Element rootElement = new DefaultElement(QName.get("root", "lists", "some://uri"));
    when(soapRequest.getDocument()).thenReturn(new DefaultDocument(rootElement));

    // Invoke the method under test.
    listItemsEndpoint.executeListActionDetails(soapRequest, soapResponse,
                "my-site", "documentLibrary", requestElement, nc);

    // Check the condition this test is for.
    verify(listHandler).getList("documentLibrary", "my-site");
}
项目:Openfire    文件:SearchGroupServlet.java   
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    String param = req.getParameter("search");
    Element root = new DefaultElement("result");
    if (param != null && param.length() > 0) {
        GroupManager manager = GroupManager.getInstance();
        Collection<Group> groups = manager.getGroups();
        for (Group gr : groups) {
            if (gr.getName().startsWith(param)) {
                root.addElement("item").addText(gr.getName());
            }
        }
    }
    resp.getOutputStream().write(root.asXML().getBytes());
    resp.getOutputStream().close();
}
项目:olat    文件:CPCore.java   
/**
 * adds an element to the CP. Only accepts <resource> and <organization> elements
 * 
 * @param newElement
 * @return
 */
public void addElement(final DefaultElement newElement) {

    if (newElement instanceof CPResource) {
        rootNode.getResources().addResource((CPResource) newElement);
    } else if (newElement instanceof CPOrganization) {
        rootNode.getOrganizations().addOrganization((CPOrganization) newElement);
    } else if (newElement instanceof CPItem) {
        if (rootNode.getOrganizations().getOrganizations().size() > 0) {
            rootNode.getOrganizations().getOrganizations().elementAt(0).addItem((CPItem) newElement);
        }
    } else {
        throw new OLATRuntimeException(CPOrganizations.class, "invalid newElement for adding to manifest", new Exception());
    }

}
项目:openfire    文件:ProcessPacketTask.java   
public void writeExternal(ObjectOutput out) throws IOException {
    ExternalizableUtil.getInstance().writeBoolean(out, address != null);
    if (address != null) {
        ExternalizableUtil.getInstance().writeSerializable(out, address);
    }
    ExternalizableUtil.getInstance().writeBoolean(out, streamID != null);
    if (streamID != null) {
        ExternalizableUtil.getInstance().writeSafeUTF(out, streamID);
    }
    ExternalizableUtil.getInstance().writeInt(out, sessionType.ordinal());
    if (packet instanceof IQ) {
        ExternalizableUtil.getInstance().writeInt(out, 1);
    } else if (packet instanceof Message) {
        ExternalizableUtil.getInstance().writeInt(out, 2);
    } else if (packet instanceof Presence) {
        ExternalizableUtil.getInstance().writeInt(out, 3);
    }
    ExternalizableUtil.getInstance().writeSerializable(out, (DefaultElement) packet.getElement());
}
项目:olat    文件:CPManifest.java   
/**
*/
  @Override
  public DefaultElement getElementByIdentifier(final String id) {
      if (id.equals(identifier)) {
          return this;
      }
      if (id.equals(CPCore.ORGANIZATIONS)) {
          return organizations;
      }

      DefaultElement e = organizations.getElementByIdentifier(id);
      if (e != null) {
          return e;
      }
      e = resources.getElementByIdentifier(id);

      if (e == null) {
          log.info("Element with id \"" + id + "\" not found in manifest!");
      }
      return e;
  }
项目:openMAXIMS    文件:Logic.java   
private ReportSeedParsedVoCollection parseSeedsFromXML(String reportXML) throws DocumentException
{
    Document document = DocumentHelper.parseText(reportXML);

    ReportSeedParsedVoCollection seeds = new ReportSeedParsedVoCollection();
    List list = document.selectNodes("//Project/Seeds/Seed");
    for (Iterator iter = list.iterator(); iter.hasNext();)
    {
        DefaultElement attribute = (DefaultElement) iter.next();

        ReportSeedParsedVo seed = new ReportSeedParsedVo();
        seed.setName(attribute.valueOf("Name"));
        seed.setType(attribute.valueOf("Type"));
        seed.setBOName(attribute.valueOf("BOName"));
        seed.setBOField(attribute.valueOf("BOField"));
        seed.setCanBeNull(new Boolean(attribute.valueOf("CanBeNull").equalsIgnoreCase("true")));
        seeds.add(seed);
    }

    return seeds;
}
项目:olat    文件:CPCore.java   
/**
 * Gets the linked page for the <item> element with given id if no resource (page) is referenced, null is returned
 * 
 * @param id
 * @return
 */
public String getPageByItemID(final String id) {
    final DefaultElement ele = getElementByIdentifier(id);
    if (ele instanceof CPItem) {
        final CPItem item = (CPItem) ele;
        if (item.getIdentifierRef() == null || item.getIdentifierRef().equals("")) {
            return null;
        }
        final DefaultElement resElement = getElementByIdentifier(item.getIdentifierRef());
        if (resElement instanceof CPResource) {
            final CPResource res = (CPResource) resElement;
            return res.getFullHref();
        } else {
            log.info("method: getPageByItemID(" + id + ") :  invalid manifest.. identifierred of <item> must point to a <resource>-element");
            return null;
        }
    } else {
        return null;
    }
}
项目:Openfire    文件:ProcessPacketTask.java   
public void writeExternal(ObjectOutput out) throws IOException {
    ExternalizableUtil.getInstance().writeBoolean(out, address != null);
    if (address != null) {
        ExternalizableUtil.getInstance().writeSerializable(out, address);
    }
    ExternalizableUtil.getInstance().writeBoolean(out, streamID != null);
    if (streamID != null) {
        ExternalizableUtil.getInstance().writeSafeUTF( out, streamID.getID() );
    }
    ExternalizableUtil.getInstance().writeInt(out, sessionType.ordinal());
    if (packet instanceof IQ) {
        ExternalizableUtil.getInstance().writeInt(out, 1);
    } else if (packet instanceof Message) {
        ExternalizableUtil.getInstance().writeInt(out, 2);
    } else if (packet instanceof Presence) {
        ExternalizableUtil.getInstance().writeInt(out, 3);
    }
    ExternalizableUtil.getInstance().writeSerializable(out, (DefaultElement) packet.getElement());
}
项目:olat    文件:CPTreeController.java   
/**
 * Builds an html-info string about the current page and its linked resources. <br>
 * The untrusted text is already html escaped.
 * 
 * @return HTML-String
 */
private String getCurrentPageInfoStringHTML() {
    // test if currentPage links to resource, which is used (linked) somewhere
    // else in the manifest
    final CPManager cpMgm = (CPManager) CoreSpringFactory.getBean(CPManager.class);
    final DefaultElement ele = cpMgm.getElementByIdentifier(cp, currentPage.getIdRef());
    boolean single = false;
    if (ele instanceof CPResource) {
        final CPResource res = (CPResource) ele;
        single = cpMgm.isSingleUsedResource(res, cp);
    }

    final StringBuilder b = new StringBuilder();
    b.append("<br /><ul>");
    b.append("<li><b>" + translate("cptreecontroller.pagetitle") + "</b> " + StringHelper.escapeHtml(currentPage.getTitle()) + "</li>");
    if (single) {
        b.append("<li><b>" + translate("cptreecontroller.file") + "</b> " + StringHelper.escapeHtml(currentPage.getFileName()) + "</li>");
    }
    b.append("</ul>");
    return b.toString();

}
项目:openfire    文件:SearchGroupServlet.java   
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    String param = req.getParameter("search");
    Element root = new DefaultElement("result");
    if (param != null && param.length() > 0) {
        GroupManager manager = GroupManager.getInstance();
        Collection<Group> groups = manager.getGroups();
        for (Group gr : groups) {
            if (gr.getName().startsWith(param)) {
                root.addElement("item").addText(gr.getName());
            }
        }
    }
    resp.getOutputStream().write(root.asXML().getBytes());
    resp.getOutputStream().close();
}
项目:olat    文件:CPOrganization.java   
/**
*/
  @Override
  public void buildDocument(final DefaultElement parent) {

      final DefaultElement orgaElement = new DefaultElement(CPCore.ORGANIZATION);

      orgaElement.addAttribute(CPCore.IDENTIFIER, identifier);
      orgaElement.addAttribute(CPCore.STRUCTURE, structure);

      final DefaultElement titleElement = new DefaultElement(CPCore.TITLE);
      titleElement.setText(title);
      orgaElement.add(titleElement);

      if (metadata != null) {
          metadata.buildDocument(orgaElement);
      }
      for (final Iterator<CPItem> itItem = items.iterator(); itItem.hasNext();) {
          final CPItem item = itItem.next();
          item.buildDocument(orgaElement);
      }
      parent.add(orgaElement);

  }
项目:olat    文件:CPOrganization.java   
/**
*/
  @Override
  public DefaultElement getElementByIdentifier(final String id) {
      if (identifier.equals(id)) {
          return this;
      }

      DefaultElement e;
      for (final Iterator<CPItem> it = items.iterator(); it.hasNext();) {
          final CPItem item = it.next();
          e = item.getElementByIdentifier(id);
          if (e != null) {
              return e;
          }
      }
      return null;
  }
项目:olat    文件:CPItem.java   
/**
*/
  @Override
  public DefaultElement getElementByIdentifier(final String id) {
      if (identifier.equals(id)) {
          return this;
      }
      DefaultElement e;
      for (final Iterator<CPItem> it = items.iterator(); it.hasNext();) {
          final CPItem item = it.next();
          e = item.getElementByIdentifier(id);
          if (e != null) {
              return e;
          }
      }
      return null;
  }
项目:olat    文件:CPFile.java   
/**
*/
  @Override
  public void buildChildren() {
      final Iterator<DefaultElement> children = this.elementIterator();
      // iterate through children
      while (children.hasNext()) {
          final DefaultElement child = children.next();
          if (child.getName().equals(CPCore.METADATA)) {
              // TODO: implement METADATA
              metadata = new CPMetadata(child);
          } else {
              throw new OLATRuntimeException(CPOrganizations.class, "Invalid IMS-Manifest ( only <metadata> element under <file> is allowed )", new Exception());
          }
      }
      this.clearContent();
      validateElement();
  }
项目:openfire    文件:ProcessPacketTask.java   
public void writeExternal(ObjectOutput out) throws IOException {
    ExternalizableUtil.getInstance().writeBoolean(out, address != null);
    if (address != null) {
        ExternalizableUtil.getInstance().writeSerializable(out, address);
    }
    ExternalizableUtil.getInstance().writeBoolean(out, streamID != null);
    if (streamID != null) {
        ExternalizableUtil.getInstance().writeSafeUTF(out, streamID);
    }
    ExternalizableUtil.getInstance().writeInt(out, sessionType.ordinal());
    if (packet instanceof IQ) {
        ExternalizableUtil.getInstance().writeInt(out, 1);
    } else if (packet instanceof Message) {
        ExternalizableUtil.getInstance().writeInt(out, 2);
    } else if (packet instanceof Presence) {
        ExternalizableUtil.getInstance().writeInt(out, 3);
    }
    ExternalizableUtil.getInstance().writeSerializable(out, (DefaultElement) packet.getElement());
}
项目:olat    文件:CPResources.java   
/**
*/
  @Override
  public void buildChildren() {
      final Iterator<DefaultElement> children = this.elementIterator();
      // iterate through children
      while (children.hasNext()) {
          final DefaultElement child = children.next();
          if (child.getName().equals(CPCore.RESOURCE)) {
              final CPResource res = new CPResource(child);
              res.setParentElement(this);
              res.buildChildren();
              resources.add(res);
          } else {
              errors.add("Invalid IMS-Manifest (only \"resource\"-elements allowed under <resources> )");
          }
      }

      this.clearContent();
      validateElement();
  }
项目:eSDK_EC_SDK_Java    文件:DeviceFileDAO.java   
@Override
public boolean addDevice(DeviceConfig device)
{
    Element rootElm = document.getRootElement();
    Element deviceEle = new DefaultElement("device");
    deviceEle.add(buildElement("deviceId", device.getDeviceId()));
    deviceEle.add(buildElement("deviceName", device.getDeviceName()));
    deviceEle.add(buildElement("serviceAccessPoint", device.getServiceAccessPoint()));
    deviceEle.add(buildElement("loginUser", device.getLoginUser()));
    deviceEle.add(buildElement("loginPwd", device.getLoginPwd()));
    deviceEle.add(buildElement("deviceType", device.getDeviceType()));
    deviceEle.add(buildElement("deviceVersion", device.getDeviceVersion()));
    deviceEle.add(buildElement("connMode", device.getConnMode()));
    deviceEle.add(buildElement("reserver1", device.getReserver1() == null ? "" : device.getReserver1()));
    deviceEle.add(buildElement("reserver2", device.getReserver2() == null ? "" : device.getReserver2()));

    rootElm.add(deviceEle);

    try
    {
        writeXmlFile(document, this.file);
    }
    catch (IOException e)
    {
        rootElm.remove(deviceEle);
        LOGGER.error("", e);
        return false;
    }

    return true;
}