/*
   *  Reads 'resource-bundle' property from portlet.xml
   * */
  private static boolean readPortletXML(
      String xml, ServletContext servletContext, String bundleName) throws DocumentException {

    boolean resourceBundleSpecified = false;

    Document document = SAXReaderUtil.read(xml, true);

    Element rootElement = document.getRootElement();

    for (Element portletElement : rootElement.elements("portlet")) {

      String resourceBundleString = portletElement.elementText("resource-bundle");
      if (StringUtils.isNotBlank(resourceBundleString)) {
        String resourceBundleName = portletElement.elementText("resource-bundle").replace('.', '/');

        if (resourceBundleName != null) {

          resourceBundleSpecified = true;
          processBundle(resourceBundleName, servletContext, bundleName);
        }
      }
    }

    return resourceBundleSpecified;
  }
  protected void readExpandoTables(PortletDataContext portletDataContext) throws Exception {

    String xml =
        portletDataContext.getZipEntryAsString(
            ExportImportPathUtil.getSourceRootPath(portletDataContext) + "/expando-tables.xml");

    if (xml == null) {
      return;
    }

    Document document = SAXReaderUtil.read(xml);

    Element rootElement = document.getRootElement();

    List<Element> expandoTableElements = rootElement.elements("expando-table");

    for (Element expandoTableElement : expandoTableElements) {
      String className = expandoTableElement.attributeValue("class-name");

      ExpandoTable expandoTable = null;

      try {
        expandoTable =
            _expandoTableLocalService.getDefaultTable(portletDataContext.getCompanyId(), className);
      } catch (NoSuchTableException nste) {
        expandoTable =
            _expandoTableLocalService.addDefaultTable(portletDataContext.getCompanyId(), className);
      }

      List<Element> expandoColumnElements = expandoTableElement.elements("expando-column");

      for (Element expandoColumnElement : expandoColumnElements) {
        long columnId = GetterUtil.getLong(expandoColumnElement.attributeValue("column-id"));
        String name = expandoColumnElement.attributeValue("name");
        int type = GetterUtil.getInteger(expandoColumnElement.attributeValue("type"));
        String defaultData = expandoColumnElement.elementText("default-data");
        String typeSettings = expandoColumnElement.elementText("type-settings");

        Serializable defaultDataObject =
            ExpandoConverterUtil.getAttributeFromString(type, defaultData);

        ExpandoColumn expandoColumn =
            _expandoColumnLocalService.getColumn(expandoTable.getTableId(), name);

        if (expandoColumn != null) {
          _expandoColumnLocalService.updateColumn(
              expandoColumn.getColumnId(), name, type, defaultDataObject);
        } else {
          expandoColumn =
              _expandoColumnLocalService.addColumn(
                  expandoTable.getTableId(), name, type, defaultDataObject);
        }

        _expandoColumnLocalService.updateTypeSettings(expandoColumn.getColumnId(), typeSettings);

        portletDataContext.importPermissions(
            ExpandoColumn.class, columnId, expandoColumn.getColumnId());
      }
    }
  }
Beispiel #3
0
  protected void read(ClassLoader classLoader, String source) throws Exception {

    InputStream is = classLoader.getResourceAsStream(source);

    if (is == null) {
      return;
    }

    if (_log.isDebugEnabled()) {
      _log.debug("Loading " + source);
    }

    Document document = SAXReaderUtil.read(is);

    Element rootElement = document.getRootElement();

    for (Element sqlElement : rootElement.elements("sql")) {
      String file = sqlElement.attributeValue("file");

      if (Validator.isNotNull(file)) {
        read(classLoader, file);
      } else {
        String id = sqlElement.attributeValue("id");
        String content = transform(sqlElement.getText());

        content = replaceIsNull(content);

        _sqlPool.put(id, content);
      }
    }
  }
  protected Document createSampleDocument() {
    Document document = createEmptyDocument();

    addTextElement(document.getRootElement(), "Unlocalizable", "Text 2", false);

    return document;
  }
Beispiel #5
0
  @Override
  public String getXML(Document document, Fields fields) {
    Element rootElement = null;

    try {
      if (document != null) {
        rootElement = document.getRootElement();
      } else {
        document = SAXReaderUtil.createDocument();

        rootElement = document.addElement("root");
      }

      Iterator<Field> itr = fields.iterator(true);

      while (itr.hasNext()) {
        Field field = itr.next();

        List<Node> nodes = getElementsByName(document, field.getName());

        for (Node node : nodes) {
          document.remove(node);
        }

        appendField(rootElement, field);
      }

      return document.formattedString();
    } catch (IOException ioe) {
      throw new SystemException(ioe);
    }
  }
  protected Set<String> getArticleFieldNames(long articleId) throws Exception {

    Set<String> articleFieldNames = new HashSet<>();

    try (LoggingTimer loggingTimer = new LoggingTimer()) {
      String sql =
          "select JournalArticle.content from JournalArticle where " + "JournalArticle.id_ = ?";

      try (PreparedStatement ps = connection.prepareStatement(sql)) {
        ps.setLong(1, articleId);

        try (ResultSet rs = ps.executeQuery()) {
          if (rs.next()) {
            String content = rs.getString("content");

            Document document = SAXReaderUtil.read(content);

            Element rootElement = document.getRootElement();

            articleFieldNames = getArticleDynamicElements(rootElement);
          }
        }
      }
    }

    return articleFieldNames;
  }
  @Override
  public void removeAndStoreSelection(
      List<String> assetEntryUuids, PortletPreferences portletPreferences) throws Exception {

    if (assetEntryUuids.size() == 0) {
      return;
    }

    String[] assetEntryXmls = portletPreferences.getValues("assetEntryXml", new String[0]);

    List<String> assetEntryXmlsList = ListUtil.fromArray(assetEntryXmls);

    Iterator<String> itr = assetEntryXmlsList.iterator();

    while (itr.hasNext()) {
      String assetEntryXml = itr.next();

      Document document = SAXReaderUtil.read(assetEntryXml);

      Element rootElement = document.getRootElement();

      String assetEntryUuid = rootElement.elementText("asset-entry-uuid");

      if (assetEntryUuids.contains(assetEntryUuid)) {
        itr.remove();
      }
    }

    portletPreferences.setValues(
        "assetEntryXml", assetEntryXmlsList.toArray(new String[assetEntryXmlsList.size()]));

    portletPreferences.store();
  }
  @Override
  protected PortletPreferences doImportData(
      PortletDataContext portletDataContext,
      String portletId,
      PortletPreferences portletPreferences,
      String data)
      throws Exception {

    portletDataContext.importPermissions(
        "com.liferay.portlet.calendar",
        portletDataContext.getSourceGroupId(),
        portletDataContext.getScopeGroupId());

    Document document = SAXReaderUtil.read(data);

    Element rootElement = document.getRootElement();

    for (Element eventElement : rootElement.elements("event")) {
      String path = eventElement.attributeValue("path");

      if (!portletDataContext.isPathNotProcessed(path)) {
        continue;
      }

      CalEvent event = (CalEvent) portletDataContext.getZipEntryAsObject(path);

      importEvent(portletDataContext, eventElement, event);
    }

    return null;
  }
  protected void validate(String name, String description, String xsd) throws PortalException {

    if (Validator.isNull(name)) {
      throw new StructureNameException();
    } else if (Validator.isNull(description)) {
      throw new StructureDescriptionException();
    }

    if (Validator.isNull(xsd)) {
      throw new StructureXsdException();
    } else {
      try {
        Document doc = SAXReaderUtil.read(xsd);

        Element root = doc.getRootElement();

        List<Element> children = root.elements();

        if (children.size() == 0) {
          throw new StructureXsdException();
        }

        Set<String> elNames = new HashSet<String>();

        validate(children, elNames);
      } catch (Exception e) {
        throw new StructureXsdException();
      }
    }
  }
  @Override
  protected PortletPreferences doImportData(
      PortletDataContext portletDataContext,
      String portletId,
      PortletPreferences portletPreferences,
      String data)
      throws Exception {

    Document document = SAXReaderUtil.read(data);

    Element rootElement = document.getRootElement();

    if (portletDataContext.getBooleanParameter(_NAMESPACE, "wsrp-producers")) {

      Element wsrpProducersElement = rootElement.element("wsrp-producers");

      importWSRPProducers(portletDataContext, wsrpProducersElement);
    }

    if (portletDataContext.getBooleanParameter(_NAMESPACE, "wsrp-consumers")) {

      Element wsrpConsumersElement = rootElement.element("wsrp-consumers");

      importWSRPConsumers(portletDataContext, wsrpConsumersElement);
    }

    return null;
  }
  protected void readLocks(PortletDataContext portletDataContext) throws Exception {

    String xml =
        portletDataContext.getZipEntryAsString(
            ExportImportPathUtil.getSourceRootPath(portletDataContext) + "/locks.xml");

    if (xml == null) {
      return;
    }

    Document document = SAXReaderUtil.read(xml);

    Element rootElement = document.getRootElement();

    List<Element> assetElements = rootElement.elements("asset");

    for (Element assetElement : assetElements) {
      String path = assetElement.attributeValue("path");
      String className = assetElement.attributeValue("class-name");
      String key = assetElement.attributeValue("key");

      Lock lock = (Lock) portletDataContext.getZipEntryAsObject(path);

      if (lock != null) {
        portletDataContext.addLocks(className, key, lock);
      }
    }
  }
Beispiel #12
0
  public EARBuilder(String originalApplicationXML, String[] pluginFileNames) {
    try {
      Document document = SAXReaderUtil.read(new File(originalApplicationXML));

      Element rootElement = document.getRootElement();

      for (String pluginFileName : pluginFileNames) {
        Element moduleElement = rootElement.addElement("module");

        Element webElement = moduleElement.addElement("web");

        Element webURIElement = webElement.addElement("web-uri");

        webURIElement.addText(pluginFileName);

        Element contextRootElement = webElement.addElement("context-root");

        String contextRoot = _getContextRoot(pluginFileName);

        contextRootElement.addText(contextRoot);
      }

      FileUtil.write(originalApplicationXML, document.formattedString(), true);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Beispiel #13
0
  public static String getUserPreference(
      long userId, long plid, String portletId, String preferenceName) {
    String _preference = StringPool.BLANK;

    PortletPreferences preferences = null;
    try {
      preferences =
          PortletPreferencesLocalServiceUtil.getPortletPreferences(
              userId, PortletKeys.PREFS_OWNER_TYPE_USER, plid, portletId);
    } catch (PortalException e) {
      // ignore
    } catch (SystemException e) {
      // ignore
    }

    if (Validator.isNull(preferences)) return _preference;

    Document document = null;
    try {
      document = SAXReaderUtil.read(preferences.getPreferences());
    } catch (DocumentException e) {
      e.printStackTrace();
    }

    for (Iterator<Element> itr = document.getRootElement().elementIterator("preference");
        itr.hasNext(); ) {
      Element preference = (Element) itr.next();

      if (preference.element("name").getText().equalsIgnoreCase(preferenceName)) {
        _preference = preference.element("value").getText();
      }
    }

    return _preference;
  }
  protected void importAssetLinks(PortletDataContext portletDataContext) throws Exception {

    String xml =
        portletDataContext.getZipEntryAsString(
            ExportImportPathUtil.getSourceRootPath(portletDataContext) + "/links.xml");

    if (xml == null) {
      return;
    }

    Element importDataRootElement = portletDataContext.getImportDataRootElement();

    try {
      Document document = SAXReaderUtil.read(xml);

      Element rootElement = document.getRootElement();

      portletDataContext.setImportDataRootElement(rootElement);

      Element linksElement = portletDataContext.getImportDataGroupElement(StagedAssetLink.class);

      List<Element> linkElements = linksElement.elements();

      for (Element linkElement : linkElements) {
        StagedModelDataHandlerUtil.importStagedModel(portletDataContext, linkElement);
      }
    } finally {
      portletDataContext.setImportDataRootElement(importDataRootElement);
    }
  }
  protected String formatContent(String content) throws Exception {
    String oldCompanyId = (String) _companyIdColumn.getOldValue();
    Long newCompanyId = (Long) _companyIdColumn.getNewValue();
    Long groupId = (Long) _groupIdColumn.getNewValue();
    String articleId = (String) _articleIdColumn.getNewValue();
    Double version = (Double) _versionColumn.getNewValue();

    try {
      Document doc = SAXReaderUtil.read(content);

      Element root = doc.getRootElement();

      format(
          oldCompanyId,
          newCompanyId.longValue(),
          groupId.longValue(),
          articleId,
          version.doubleValue(),
          root);

      content = JournalUtil.formatXML(doc);
    } catch (Exception e) {
      _log.error(
          "Unable to format content for {articleId="
              + articleId
              + ",version="
              + version
              + "}: "
              + e.getMessage());
    }

    return content;
  }
  protected void importSQL() throws Exception {
    Class<?> clazz = getClass();

    ClassLoader classLoader = clazz.getClassLoader();

    InputStream inputStream = classLoader.getResourceAsStream("/resources/data/sql.xml");

    String xml = new String(FileUtil.getBytes(inputStream));

    Document document = SAXReaderUtil.read(xml);

    Element rootElement = document.getRootElement();

    List<Element> batchElements = rootElement.elements("batch");

    for (Element batchElement : batchElements) {
      String testSQL = batchElement.elementText("test-sql");

      int count = getCount(testSQL);

      if (count > 0) {
        continue;
      }

      String[] importSQLs =
          StringUtil.split(batchElement.elementText("import-sql"), StringPool.SEMICOLON);

      runSQL(importSQLs);
    }
  }
  private void _updateLanguageProperties(Document document, String className) throws IOException {

    if (_languageProperties == null) {
      return;
    }

    int index = className.indexOf("ServiceImpl");

    if (index <= 0) {
      return;
    }

    StringBundler sb = new StringBundler();

    sb.append(Character.toLowerCase(className.charAt(0)));

    for (int i = 1; i < index; i++) {
      char c = className.charAt(i);

      if (Character.isUpperCase(c)) {
        if (((i + 1) < index) && Character.isLowerCase(className.charAt(i + 1))) {

          sb.append(CharPool.DASH);
        }

        sb.append(Character.toLowerCase(c));
      } else {
        sb.append(c);
      }
    }

    sb.append("-service-help");

    String key = sb.toString();

    String value = _languageProperties.getProperty(key);

    if (value == null) {
      return;
    }

    Element rootElement = document.getRootElement();

    String comment = rootElement.elementText("comment");

    if ((comment == null) || value.equals(comment)) {
      return;
    }

    index = comment.indexOf("\n\n");

    if (index != -1) {
      value = comment.substring(0, index);
    } else {
      value = comment;
    }

    _updateLanguageProperties(key, value);
  }
  private Element _getDataEl() throws DocumentException {
    if (_dataEl == null) {
      Document doc = SAXReaderUtil.read(getData());

      _dataEl = doc.getRootElement();
    }

    return _dataEl;
  }
  protected void indexField(Document document, Element element, String elType, String elIndexType) {

    if (Validator.isNull(elIndexType)) {
      return;
    }

    com.liferay.portal.kernel.xml.Document structureDocument = element.getDocument();

    Element rootElement = structureDocument.getRootElement();

    String defaultLocale = GetterUtil.getString(rootElement.attributeValue("default-locale"));

    String name = encodeFieldName(element.attributeValue("name"));

    List<Element> dynamicContentElements = element.elements("dynamic-content");

    for (Element dynamicContentElement : dynamicContentElements) {
      String contentLocale =
          GetterUtil.getString(dynamicContentElement.attributeValue("language-id"));

      String[] value = new String[] {dynamicContentElement.getText()};

      if (elType.equals("multi-list")) {
        List<Element> optionElements = dynamicContentElement.elements("option");

        value = new String[optionElements.size()];

        for (int i = 0; i < optionElements.size(); i++) {
          value[i] = optionElements.get(i).getText();
        }
      }

      if (elIndexType.equals("keyword")) {
        if (Validator.isNull(contentLocale)) {
          document.addKeyword(name, value);
        } else {
          if (defaultLocale.equals(contentLocale)) {
            document.addKeyword(name, value);
          }

          document.addKeyword(name.concat(StringPool.UNDERLINE).concat(contentLocale), value);
        }
      } else if (elIndexType.equals("text")) {
        if (Validator.isNull(contentLocale)) {
          document.addText(name, StringUtil.merge(value, StringPool.SPACE));
        } else {
          if (defaultLocale.equals(contentLocale)) {
            document.addText(name, StringUtil.merge(value, StringPool.SPACE));
          }

          document.addText(
              name.concat(StringPool.UNDERLINE).concat(contentLocale),
              StringUtil.merge(value, StringPool.SPACE));
        }
      }
    }
  }
  protected Document createDocument(String... fieldNames) {
    Document document = createEmptyDocument();

    for (String fieldName : fieldNames) {
      addTextElement(document.getRootElement(), fieldName, fieldName, false);
    }

    return document;
  }
  protected Definition doParse(InputStream inputStream) throws Exception {
    Document document = SAXReaderUtil.read(inputStream, _validate);

    Element rootElement = document.getRootElement();

    String name = rootElement.elementText("name");
    String description = rootElement.elementText("description");
    int version = GetterUtil.getInteger(rootElement.elementText("version"));

    Definition definition = new Definition(name, description, document.formattedString(), version);

    List<Element> conditionElements = rootElement.elements("condition");

    for (Element conditionElement : conditionElements) {
      Condition condition = parseCondition(conditionElement);

      definition.addNode(condition);
    }

    List<Element> forkElements = rootElement.elements("fork");

    for (Element forkElement : forkElements) {
      Fork fork = parseFork(forkElement);

      definition.addNode(fork);
    }

    List<Element> joinElements = rootElement.elements("join");

    for (Element joinElement : joinElements) {
      Join join = parseJoin(joinElement);

      definition.addNode(join);
    }

    List<Element> stateElements = rootElement.elements("state");

    for (Element stateElement : stateElements) {
      State state = parseState(stateElement);

      definition.addNode(state);
    }

    List<Element> taskElements = rootElement.elements("task");

    for (Element taskElement : taskElements) {
      Task task = parseTask(taskElement);

      definition.addNode(task);
    }

    parseTransitions(
        definition, conditionElements, forkElements, joinElements, stateElements, taskElements);

    return definition;
  }
  @Override
  public List<String> getAvailableLanguageIds() {
    Document document = getDocument();

    Element rootElement = document.getRootElement();

    String availableLocales = rootElement.attributeValue("available-locales");

    return ListUtil.fromArray(StringUtil.split(availableLocales));
  }
  private String _mergeXsds(String xsd1, String xsd2) throws SystemException {
    try {
      Document document1 = SAXReaderUtil.read(xsd1);
      Document document2 = SAXReaderUtil.read(xsd2);

      Element rootElement1 = document1.getRootElement();
      Element rootElement2 = document2.getRootElement();

      for (Element element : rootElement1.elements()) {
        rootElement1.remove(element);

        rootElement2.add(element);
      }

      return rootElement2.formattedString();
    } catch (Exception e) {
      throw new SystemException(e);
    }
  }
  private void _updateJavadocsXmlFile(
      String fileName, JavaClass javaClass, Document javaClassDocument) throws Exception {

    String javaClassFullyQualifiedName = javaClass.getFullyQualifiedName();

    /*if (!javaClassFullyQualifiedName.contains(".service.") ||
    	!javaClassFullyQualifiedName.endsWith("ServiceImpl")) {

    	return;
    }*/

    Tuple javadocsXmlTuple = _getJavadocsXmlTuple(fileName);

    if (javadocsXmlTuple == null) {
      return;
    }

    Document javadocsXmlDocument = (Document) javadocsXmlTuple.getObject(3);

    Element javadocsXmlRootElement = javadocsXmlDocument.getRootElement();

    List<Element> javadocElements = javadocsXmlRootElement.elements("javadoc");

    for (Element javadocElement : javadocElements) {
      String type = javadocElement.elementText("type");

      if (type.equals(javaClassFullyQualifiedName)) {
        Element javaClassRootElement = javaClassDocument.getRootElement();

        if (Validator.equals(
            javadocElement.formattedString(), javaClassRootElement.formattedString())) {

          return;
        }

        javadocElement.detach();

        break;
      }
    }

    javadocsXmlRootElement.add(javaClassDocument.getRootElement());
  }
  protected List<Element> getDDMStructures(String fileName) throws DocumentException {

    String xml = ContentUtil.get("com/liferay/portal/events/dependencies/" + fileName);

    Document document = SAXReaderUtil.read(xml);

    Element rootElement = document.getRootElement();

    return rootElement.elements("structure");
  }
Beispiel #26
0
  public static Tuple getElements(String xml, String className, int inactiveGroupsCount) {

    List<Element> resultRows = new ArrayList<>();
    int totalRows = 0;

    try {
      xml = XMLUtil.stripInvalidChars(xml);

      Document document = SAXReaderUtil.read(xml);

      Element rootElement = document.getRootElement();

      List<Element> elements = rootElement.elements("entry");

      totalRows =
          GetterUtil.getInteger(
              rootElement.elementText(
                  OpenSearchUtil.getQName("totalResults", OpenSearchUtil.OS_NAMESPACE)));

      for (Element element : elements) {
        try {
          long entryScopeGroupId =
              GetterUtil.getLong(
                  element.elementText(
                      OpenSearchUtil.getQName("scopeGroupId", OpenSearchUtil.LIFERAY_NAMESPACE)));

          if ((entryScopeGroupId != 0) && (inactiveGroupsCount > 0)) {
            Group entryGroup = GroupServiceUtil.getGroup(entryScopeGroupId);

            if (entryGroup.isLayout()) {
              entryGroup = GroupLocalServiceUtil.getGroup(entryGroup.getParentGroupId());
            }

            if (!entryGroup.isActive()) {
              totalRows--;

              continue;
            }
          }

          resultRows.add(element);
        } catch (Exception e) {
          _log.error("Unable to retrieve individual search result for " + className, e);

          totalRows--;
        }
      }
    } catch (Exception e) {
      _log.error("Unable to display content for " + className, e);
    }

    return new Tuple(resultRows, totalRows);
  }
  protected List<Element> getDDMStructures(Locale locale) throws DocumentException {

    String xml = getContent("basic-web-content-structure.xml");

    xml = StringUtil.replace(xml, "[$LOCALE_DEFAULT$]", locale.toString());

    Document document = SAXReaderUtil.read(xml);

    Element rootElement = document.getRootElement();

    return rootElement.elements("structure");
  }
  protected void readAssetLinks(PortletDataContext portletDataContext) throws Exception {

    String xml =
        portletDataContext.getZipEntryAsString(
            portletDataContext.getSourceRootPath() + "/links.xml");

    if (xml == null) {
      return;
    }

    Document document = SAXReaderUtil.read(xml);

    Element rootElement = document.getRootElement();

    List<Element> assetLinkElements = rootElement.elements("asset-link");

    for (Element assetLinkElement : assetLinkElements) {
      String sourceUuid = GetterUtil.getString(assetLinkElement.attributeValue("source-uuid"));
      String[] assetEntryUuidArray =
          StringUtil.split(GetterUtil.getString(assetLinkElement.attributeValue("target-uuids")));
      int assetLinkType = GetterUtil.getInteger(assetLinkElement.attributeValue("type"));

      List<Long> assetEntryIds = new ArrayList<Long>();

      for (String assetEntryUuid : assetEntryUuidArray) {
        try {
          AssetEntry assetEntry =
              AssetEntryLocalServiceUtil.getEntry(
                  portletDataContext.getScopeGroupId(), assetEntryUuid);

          assetEntryIds.add(assetEntry.getEntryId());
        } catch (NoSuchEntryException nsee) {
        }
      }

      if (assetEntryIds.isEmpty()) {
        continue;
      }

      long[] assetEntryIdsArray =
          ArrayUtil.toArray(assetEntryIds.toArray(new Long[assetEntryIds.size()]));

      try {
        AssetEntry assetEntry =
            AssetEntryLocalServiceUtil.getEntry(portletDataContext.getScopeGroupId(), sourceUuid);

        AssetLinkLocalServiceUtil.updateLinks(
            assetEntry.getUserId(), assetEntry.getEntryId(), assetEntryIdsArray, assetLinkType);
      } catch (NoSuchEntryException nsee) {
      }
    }
  }
  protected String extractDynamicContent(String content) {
    try {
      com.liferay.portal.kernel.xml.Document document = SAXReaderUtil.read(content);

      Element rootElement = document.getRootElement();

      return extractDynamicContent(rootElement);
    } catch (DocumentException de) {
      _log.error(de);
    }

    return StringPool.BLANK;
  }
 public static long getScore(Course course)
     throws DocumentException, PortalException, SystemException {
   long score = 0;
   String extraData = course.getCourseExtraData();
   if (extraData != null && extraData.startsWith("<?xml")) {
     Document document = SAXReaderUtil.read(extraData);
     Element rootElement = document.getRootElement();
     Element scoreElement = rootElement.element("score");
     if (scoreElement != null) {
       score = Long.valueOf(scoreElement.attributeValue("value"));
     }
   }
   return score;
 }