/**
   * @param request
   * @param response
   * @param fileIds
   * @param totalInserted
   * @param totalUpdated
   * @param totalDeleted
   */
  private void getResponseResult(
      Element request,
      Element response,
      List<String> fileIds,
      int totalInserted,
      int totalUpdated,
      int totalDeleted) {
    // transactionSummary
    Element transactionSummary = getTransactionSummary(totalInserted, totalUpdated, totalDeleted);

    // requestID
    String strRequestId = request.getAttributeValue("requestId");
    if (strRequestId != null) transactionSummary.setAttribute("requestId", strRequestId);

    response.addContent(transactionSummary);

    if (totalInserted > 0) {
      Element insertResult = new Element("InsertResult", Csw.NAMESPACE_CSW);
      insertResult.setAttribute("handleRef", "handleRefValue");

      // Namespace NAMESPACE_DC = Namespace.getNamespace("dc", "http://purl.org/dc/elements/1.1/");
      for (String fileId : fileIds) {
        Element briefRecord = new Element("BriefRecord", Csw.NAMESPACE_CSW);
        Element identifier = new Element("identifier"); // ,Csw.NAMESPACE_DC );
        identifier.setText(fileId);
        briefRecord.addContent(identifier);
        insertResult.addContent(briefRecord);
      }

      response.addContent(insertResult);
    }
  }
  public void writeExternal(Element element) throws WriteExternalException {
    Element passwords = new Element(PASSWORDS);
    for (final String cvsRoot : myCvsRootToStoringPasswordMap.keySet()) {
      Element password = new Element(PASSWORD);
      password.setAttribute(CVSROOT_ATTR, cvsRoot);
      password.setAttribute(
          PASSWORD_ATTR,
          PServerPasswordScrambler.getInstance()
              .scramble(myCvsRootToStoringPasswordMap.get(cvsRoot)));
      passwords.addContent(password);
    }
    element.addContent(passwords);

    passwords = new Element(PPKPASSWORDS);
    for (final String cvsRoot : myCvsRootToStoringPPKPasswordMap.keySet()) {
      Element password = new Element(PASSWORD);
      password.setAttribute(CVSROOT_ATTR, cvsRoot);
      password.setAttribute(
          PASSWORD_ATTR,
          PServerPasswordScrambler.getInstance()
              .scramble(myCvsRootToStoringPPKPasswordMap.get(cvsRoot)));
      passwords.addContent(password);
    }
    element.addContent(passwords);
  }
  public Element getState() {
    Element element = new Element("state");

    for (Map.Entry<GroupDescriptor, Map<String, Set<UsageDescriptor>>> appData :
        getApplicationData().entrySet()) {
      Element groupElement = new Element(GROUP_TAG);
      groupElement.setAttribute(GROUP_NAME_ATTR, appData.getKey().getId());
      boolean isEmptyGroup = true;

      for (Map.Entry<String, Set<UsageDescriptor>> projectData : appData.getValue().entrySet()) {
        Element projectElement = new Element(PROJECT_TAG);
        projectElement.setAttribute(PROJECT_ID_ATTR, projectData.getKey());
        final Set<UsageDescriptor> projectDataValue = projectData.getValue();
        if (!projectDataValue.isEmpty()) {
          projectElement.setAttribute(VALUES_ATTR, joinUsages(projectDataValue));
          groupElement.addContent(projectElement);
          isEmptyGroup = false;
        }
      }

      if (!isEmptyGroup) {
        element.addContent(groupElement);
      }
    }

    return element;
  }
 @SuppressWarnings({"HardCodedStringLiteral"})
 private Element writePanel(final JPanel panel) {
   final Component comp = panel.getComponent(0);
   if (comp instanceof Splitter) {
     final Splitter splitter = (Splitter) comp;
     final Element res = new Element("splitter");
     res.setAttribute("split-orientation", splitter.getOrientation() ? "vertical" : "horizontal");
     res.setAttribute("split-proportion", Float.toString(splitter.getProportion()));
     final Element first = new Element("split-first");
     first.addContent(writePanel((JPanel) splitter.getFirstComponent()));
     final Element second = new Element("split-second");
     second.addContent(writePanel((JPanel) splitter.getSecondComponent()));
     res.addContent(first);
     res.addContent(second);
     return res;
   } else if (comp instanceof JBTabs) {
     final Element res = new Element("leaf");
     final EditorWindow window = findWindowWith(comp);
     writeWindow(res, window);
     return res;
   } else if (comp instanceof EditorWindow.TCompForTablessMode) {
     final EditorWithProviderComposite composite =
         ((EditorWindow.TCompForTablessMode) comp).myEditor;
     final Element res = new Element("leaf");
     writeComposite(res, composite.getFile(), composite, false, composite);
     return res;
   } else {
     LOG.error(comp != null ? comp.getClass().getName() : null);
     return null;
   }
 }
Exemple #5
0
 private void insertHead() {
   Element head = new Element("head");
   Element title = new Element("title");
   title.setText(FluxxMessage.m("opml_title"));
   head.addContent(title);
   root.addContent(head);
 }
 public String getReportText() {
   final Element rootElement = new Element("root");
   rootElement.setAttribute("isBackward", String.valueOf(!myForward));
   final List<PsiFile> files = new ArrayList<PsiFile>(myDependencies.keySet());
   Collections.sort(
       files,
       new Comparator<PsiFile>() {
         @Override
         public int compare(PsiFile f1, PsiFile f2) {
           final VirtualFile virtualFile1 = f1.getVirtualFile();
           final VirtualFile virtualFile2 = f2.getVirtualFile();
           if (virtualFile1 != null && virtualFile2 != null) {
             return virtualFile1.getPath().compareToIgnoreCase(virtualFile2.getPath());
           }
           return 0;
         }
       });
   for (PsiFile file : files) {
     final Element fileElement = new Element("file");
     fileElement.setAttribute("path", file.getVirtualFile().getPath());
     for (PsiFile dep : myDependencies.get(file)) {
       Element depElement = new Element("dependency");
       depElement.setAttribute("path", dep.getVirtualFile().getPath());
       fileElement.addContent(depElement);
     }
     rootElement.addContent(fileElement);
   }
   PathMacroManager.getInstance(myProject).collapsePaths(rootElement);
   return JDOMUtil.writeDocument(new Document(rootElement), SystemProperties.getLineSeparator());
 }
 private static void appendModule(final Element problem, final RefModule refModule) {
   if (refModule != null) {
     Element moduleElement = new Element("module");
     moduleElement.addContent(refModule.getName());
     problem.addContent(moduleElement);
   }
 }
  public Element getDataBlockElement() {

    Element dataBlockElement = null;

    if (isSuccess()) {

      dataBlockElement = new Element(EventAttributeName.dataBlock.toString());

      Element nextEle =
          new Element(EventAttributeName.federationExecutionModelHandle.toString())
              .setText(getFederationExecutionModelHandle());

      dataBlockElement.addContent(nextEle);

      Element subscriptionsElement = new Element(EventAttributeName.subscriptions.toString());

      dataBlockElement.addContent(subscriptionsElement);

      if (dataPublications != null) {

        for (String className : dataPublications) {

          if (className != null) {

            Element classNameElement =
                new Element(EventAttributeName.className.toString()).setText(className);

            subscriptionsElement.addContent(classNameElement);
          }
        }
      }
    }

    return dataBlockElement;
  }
 @Override
 protected void fillJDOMConfigElement(Element configElement) {
   super.fillJDOMConfigElement(configElement);
   if (this.getMinLength() > -1) {
     Element element = new Element("minlength");
     element.setText(String.valueOf(this.getMinLength()));
     configElement.addContent(element);
   }
   if (this.getMaxLength() > -1) {
     Element element = new Element("maxlength");
     element.setText(String.valueOf(this.getMaxLength()));
     configElement.addContent(element);
   }
   if (null != this.getRegexp() && this.getRegexp().trim().length() > 0) {
     Element regexpElem = new Element("regexp");
     CDATA cdata = new CDATA(this.getRegexp());
     regexpElem.addContent(cdata);
     configElement.addContent(regexpElem);
   }
   String toStringEqualValue = (this.getValue() != null) ? String.valueOf(this.getValue()) : null;
   this.insertJDOMConfigElement(
       "value", this.getValueAttribute(), toStringEqualValue, configElement);
   String toStringStartValue =
       (this.getRangeStart() != null) ? String.valueOf(this.getRangeStart()) : null;
   this.insertJDOMConfigElement(
       "rangestart", this.getRangeStartAttribute(), toStringStartValue, configElement);
   String toStringEndValue =
       (this.getRangeEnd() != null) ? String.valueOf(this.getRangeEnd()) : null;
   this.insertJDOMConfigElement(
       "rangeend", this.getRangeEndAttribute(), toStringEndValue, configElement);
 }
  public void writeExternalUtil(
      @NotNull Element element, @NotNull OptionsAndConfirmations optionsAndConfirmations)
      throws WriteExternalException {
    final Map<String, VcsShowOptionsSettingImpl> options = optionsAndConfirmations.getOptions();
    final Map<String, VcsShowConfirmationOptionImpl> confirmations =
        optionsAndConfirmations.getConfirmations();

    for (VcsShowOptionsSettingImpl setting : options.values()) {
      if (!Registry.is("saving.state.in.new.format.is.allowed", false) || !setting.getValue()) {
        Element settingElement = new Element(OPTIONS_SETTING);
        element.addContent(settingElement);
        settingElement.setAttribute(VALUE_ATTTIBUTE, Boolean.toString(setting.getValue()));
        settingElement.setAttribute(ID_ATTRIBUTE, setting.getDisplayName());
      }
    }

    for (VcsShowConfirmationOptionImpl setting : confirmations.values()) {
      if (!Registry.is("saving.state.in.new.format.is.allowed", false)
          || setting.getValue() != VcsShowConfirmationOption.Value.SHOW_CONFIRMATION) {
        final Element settingElement = new Element(CONFIRMATIONS_SETTING);
        element.addContent(settingElement);
        settingElement.setAttribute(VALUE_ATTTIBUTE, setting.getValue().toString());
        settingElement.setAttribute(ID_ATTRIBUTE, setting.getDisplayName());
      }
    }
  }
  private List<Element> handleParameterName(String[] parameterNames) throws CatalogException {
    Element values;
    List<Element> domainValuesList = null;

    for (int i = 0; i < parameterNames.length; i++) {

      if (i == 0) domainValuesList = new ArrayList<Element>();

      // Generate DomainValues element
      Element domainValues = new Element("DomainValues", Csw.NAMESPACE_CSW);

      // FIXME what should be the type ???
      domainValues.setAttribute("type", "csw:Record");

      String paramName = parameterNames[i];

      // Set parameterName in any case.
      Element pn = new Element("ParameterName", Csw.NAMESPACE_CSW);
      domainValues.addContent(pn.setText(paramName));

      String operationName = paramName.substring(0, paramName.indexOf('.'));
      String parameterName = paramName.substring(paramName.indexOf('.') + 1);

      CatalogService cs = checkOperation(operationName);
      values = cs.retrieveValues(parameterName);

      // values null mean that the catalog was unable to determine
      // anything about the specified parameter
      if (values != null) domainValues.addContent(values);

      // Add current DomainValues to the list
      domainValuesList.add(domainValues);
    }
    return domainValuesList;
  }
 private Element getSecurityContraintsElement() {
   Element securityContraints = new Element(SECURITY_CONSTRAINTS);
   List allGroupRules = mSecurityConstraints.getAllGroupRules();
   for (int i = 0; i < allGroupRules.size(); i++) {
     GroupRules groupRules = (GroupRules) allGroupRules.get(i);
     List rules = groupRules.getRules();
     if (rules.size() == 0) {
       continue;
     }
     Element groupRulesElement = new Element(GROUP_RULES);
     groupRulesElement.setAttribute(GROUP, groupRules.getGroupName());
     for (int j = 0; j < rules.size(); j++) {
       RuleDescription ruleDescription = (RuleDescription) rules.get(j);
       Element ruleElement;
       if (ruleDescription.getType() == RuleDescription.INCLUDE) {
         ruleElement = new Element(INCLUDE_RULE);
       } else {
         ruleElement = new Element(EXCLUDE_RULE);
       }
       ruleElement.setAttribute(RESOURCE, ruleDescription.getResource());
       ruleElement.setAttribute(CLASS, ruleDescription.getRetsClass());
       String systemNames = StringUtils.join(ruleDescription.getSystemNames().iterator(), " ");
       Element systemNamesElement = new Element(SYSTEM_NAMES);
       systemNamesElement.setText(systemNames);
       ruleElement.addContent(systemNamesElement);
       groupRulesElement.addContent(ruleElement);
     }
     securityContraints.addContent(groupRulesElement);
   }
   return securityContraints;
 }
  public String toXml() throws RetsServerException {
    Element retsConfig = new Element(RETS_CONFIG);
    addChild(retsConfig, PORT, mPort);
    addChild(retsConfig, METADATA_DIR, mMetadataDir);
    addChild(retsConfig, GET_OBJECT_ROOT, mGetObjectRoot);
    addChild(retsConfig, GET_OBJECT_PATTERN, mGetObjectPattern);
    addChild(retsConfig, NONCE_INITIAL_TIMEOUT, mNonceInitialTimeout);
    addChild(retsConfig, NONCE_SUCCESS_TIMEOUT, mNonceSuccessTimeout);
    Element database = new Element(DATABASE);
    addChild(database, TYPE, mDatabase.getDatabaseType().getName());
    addChild(database, HOST, mDatabase.getHostName());
    addChild(database, NAME, mDatabase.getDatabaseName());
    addChild(database, USERNAME, mDatabase.getUsername());
    addChild(database, PASSWORD, mDatabase.getPassword());
    addChild(database, MAX_ACTIVE, mDatabase.getMaxActive());
    addChild(database, MAX_IDLE, mDatabase.getMaxIdle());
    addChild(database, MAX_WAIT, mDatabase.getMaxWait());
    addChild(database, MAX_PS_ACTIVE, mDatabase.getMaxPsActive());
    addChild(database, MAX_PS_IDLE, mDatabase.getMaxPsIdle());
    addChild(database, MAX_PS_WAIT, mDatabase.getMaxPsWait());
    addChild(database, SHOW_SQL, mDatabase.getShowSql());
    retsConfig.addContent(database);
    retsConfig.addContent(getSecurityContraintsElement());

    XMLOutputter xmlOutputter = new XMLOutputter("  ", true);
    xmlOutputter.setLineSeparator(SystemUtils.LINE_SEPARATOR);
    return xmlOutputter.outputString(new Document(retsConfig));
  }
Exemple #14
0
  @Override
  public void perform(Element originalElement, Element patchElement, Element outputParentElement)
      throws AbstractXmlMergeException {

    logger.fine("Merging: " + originalElement + " (original) and " + patchElement + " (patch)");

    Mapper mapper = (Mapper) m_mapperFactory.getOperation(originalElement, patchElement);

    if (originalElement == null) {
      outputParentElement.addContent(mapper.map(patchElement));
    } else if (patchElement == null) {
      outputParentElement.addContent((Content) originalElement.clone());
    } else {

      Element workingElement =
          new Element(
              originalElement.getName(),
              originalElement.getNamespacePrefix(),
              originalElement.getNamespaceURI());
      addAttributes(workingElement, originalElement);

      logger.fine("Adding " + workingElement);
      outputParentElement.addContent(workingElement);

      doIt(workingElement, originalElement, patchElement);
    }
  }
  /**
   * Promotes a set of repositories to a group profile.
   *
   * @param groupProfileId The group profile to promote to.
   * @param repositoryIds A list of repositoryIds to be promoted.
   * @throws RESTLightClientException
   */
  public void promoteRepositories(
      String stagingProfileGroup, String description, List<String> stagedRepositoryIds)
      throws RESTLightClientException {
    if (stagedRepositoryIds == null || stagedRepositoryIds.isEmpty()) {
      throw new RESTLightClientException(
          "No staging repositories specified. Please provide a valid staged repository ids.");
    }

    if (StringUtils.isEmpty(stagingProfileGroup)) {
      throw new RESTLightClientException(
          "No build promotion profile specified. Please provide a build promotion profile.");
    }

    String rootElement =
        this.getVocabulary().getProperty(VocabularyKeys.BULK_ACTION_REQUEST_ROOT_ELEMENT);
    Document body = new Document().setRootElement(new Element(rootElement));

    Element data = new Element("data");
    body.getRootElement().addContent(data);

    if (StringUtils.isNotEmpty(description)) {
      data.addContent(new Element("description").setText(description));
    }

    data.addContent(new Element("stagingProfileGroup").setText(stagingProfileGroup));

    Element staedRepoIds = new Element("stagedRepositoryIds");
    data.addContent(staedRepoIds);

    for (String repoId : stagedRepositoryIds) {
      staedRepoIds.addContent(new Element("string").setText(repoId));
    }

    post(STAGE_REPO_BULK_PROMOTE, null, body);
  }
  private void makeTree(String parentId, File dir, Element result)
      throws UnsupportedEncodingException {

    File[] files = dir.listFiles();
    if (files == null) return;

    for (File f : files) {
      String name = URLEncoder.encode(f.getName(), Jeeves.ENCODING);
      Element element;
      String id = parentId + "/" + f.getName();
      if (f.isDirectory() && legalFile(f)) {
        element = new Element("dir");
        makeTree(id, f, element);
        if (element.getChildren().size() > 0) {
          element.setAttribute("leaf", "false");
          element
              .setAttribute("text", f.getName())
              .setAttribute("path", id)
              .setAttribute("name", name);
          result.addContent(element);
        }
      } else if (isEditibleFileType(f) && legalFile(f)) {
        element = new Element("file");
        element.setAttribute("leaf", "true");
        element
            .setAttribute("text", f.getName())
            .setAttribute("path", id)
            .setAttribute("name", name);
        result.addContent(element);
      }
    }
  }
  private void performStagingAction(
      final StageRepository repo, final String actionSubpath, final List<Element> extraData)
      throws RESTLightClientException {
    if (repo == null) {
      throw new RESTLightClientException(
          "No staging-repository details specified. Please provide a valid StageRepository instance.");
    }

    Map<String, String> params = new HashMap<String, String>();
    params.put(STAGE_REPO_ID_PARAM, repo.getRepositoryId());

    String rootElement =
        getVocabulary().getProperty(VocabularyKeys.PROMOTE_STAGE_REPO_ROOT_ELEMENT);
    Document body = new Document().setRootElement(new Element(rootElement));

    Element data = new Element("data");
    body.getRootElement().addContent(data);

    data.addContent(new Element("stagedRepositoryId").setText(repo.getRepositoryId()));

    if (extraData != null && !extraData.isEmpty()) {
      for (Element extra : extraData) {
        data.addContent(extra);
      }
    }

    post(PROFILES_PATH + "/" + repo.getProfileId() + actionSubpath, null, body);
  }
Exemple #18
0
 private Element createGeoAsciiParamsElement() {
   Element field = createFieldElement(getGeoAsciiParamsTag());
   Element data = new Element(IIO_TIFF_ASCIIS_ELEMENT_NAME);
   field.addContent(data);
   data.addContent(createAsciiElement(_geoAsciiParams.toString()));
   return field;
 }
Exemple #19
0
  public Element toJDOM() {
    Element element = new Element(getTagName(), IMSLD_NAMESPACE_100_EMBEDDED);

    for (ILDModelObject member : getShowHideTypes()) {
      Element child = member.toJDOM();
      if (child != null) {
        element.addContent(child);
      }
    }

    for (ILDModelObject member : getChangePropertyValueTypes()) {
      Element child = member.toJDOM();
      if (child != null) {
        element.addContent(child);
      }
    }

    for (ILDModelObject member : getNotificationTypes()) {
      Element child = member.toJDOM();
      if (child != null) {
        element.addContent(child);
      }
    }

    return element;
  }
 @Override
 public void writeSettings(@NotNull Element node) throws WriteExternalException {
   node.addContent(
       new Element("option")
           .setAttribute("name", "SUGGEST_NULLABLE_ANNOTATIONS")
           .setAttribute("value", String.valueOf(SUGGEST_NULLABLE_ANNOTATIONS)));
   node.addContent(
       new Element("option")
           .setAttribute("name", "DONT_REPORT_TRUE_ASSERT_STATEMENTS")
           .setAttribute("value", String.valueOf(DONT_REPORT_TRUE_ASSERT_STATEMENTS)));
   if (IGNORE_ASSERT_STATEMENTS) {
     node.addContent(
         new Element("option")
             .setAttribute("name", "IGNORE_ASSERT_STATEMENTS")
             .setAttribute("value", "true"));
   }
   if (!REPORT_CONSTANT_REFERENCE_VALUES) {
     node.addContent(
         new Element("option")
             .setAttribute("name", "REPORT_CONSTANT_REFERENCE_VALUES")
             .setAttribute("value", "false"));
   }
   if (TREAT_UNKNOWN_MEMBERS_AS_NULLABLE) {
     node.addContent(
         new Element("option")
             .setAttribute("name", "TREAT_UNKNOWN_MEMBERS_AS_NULLABLE")
             .setAttribute("value", "true"));
   }
 }
 public void writeExternal(final Element element) throws WriteExternalException {
   super.writeExternal(element);
   JavaRunConfigurationExtensionManager.getInstance().writeExternal(this, element);
   writeModule(element);
   DefaultJDOMExternalizer.writeExternal(this, element);
   final Data persistentData = getPersistentData();
   DefaultJDOMExternalizer.writeExternal(persistentData, element);
   EnvironmentVariablesComponent.writeExternal(element, persistentData.getEnvs());
   final String dirName = persistentData.getDirName();
   if (!dirName.isEmpty()) {
     final Element dirNameElement = new Element("dir");
     dirNameElement.setAttribute("value", FileUtil.toSystemIndependentName(dirName));
     element.addContent(dirNameElement);
   }
   final Element patternsElement = new Element(PATTERNS_EL_NAME);
   for (String o : persistentData.getPatterns()) {
     final Element patternElement = new Element(PATTERN_EL_NAME);
     patternElement.setAttribute(TEST_CLASS_ATT_NAME, o);
     patternsElement.addContent(patternElement);
   }
   final String forkMode = getForkMode();
   if (!forkMode.equals("none")) {
     final Element forkModeElement = new Element("fork_mode");
     forkModeElement.setAttribute("value", forkMode);
     element.addContent(forkModeElement);
   }
   element.addContent(patternsElement);
   PathMacroManager.getInstance(getProject()).collapsePathsRecursively(element);
 }
Exemple #22
0
  public void saveData(@NotNull Element element) {
    logger.debug("saveData");
    Element search = new Element("search");
    if (lastSearch != null) {
      search.addContent(createElementWithText("last-search", lastSearch));
    }
    if (lastOffset != null) {
      search.addContent(createElementWithText("last-offset", lastOffset));
    }
    if (lastPattern != null) {
      search.addContent(createElementWithText("last-pattern", lastPattern));
    }
    if (lastReplace != null) {
      search.addContent(createElementWithText("last-replace", lastReplace));
    }
    if (lastSubstitute != null) {
      search.addContent(createElementWithText("last-substitute", lastSubstitute));
    }
    Element text = new Element("last-dir");
    text.addContent(Integer.toString(lastDir));
    search.addContent(text);

    text = new Element("show-last");
    text.addContent(Boolean.toString(showSearchHighlight));
    if (logger.isDebugEnabled()) logger.debug("text=" + text);
    search.addContent(text);

    element.addContent(search);
  }
 public void createXml(String fileName) {
   Document document;
   Element root;
   root = new Element("employees");
   document = new Document(root);
   Element employee = new Element("employee");
   root.addContent(employee);
   Element name = new Element("name");
   name.setText("ddvip");
   employee.addContent(name);
   Element sex = new Element("sex");
   sex.setText("m");
   employee.addContent(sex);
   Element age = new Element("age");
   age.setText("23");
   employee.addContent(age);
   XMLOutputter XMLOut = new XMLOutputter();
   try {
     XMLOut.output(document, new FileOutputStream(fileName));
   } catch (FileNotFoundException e) {
     e.printStackTrace();
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
  /*
   * (non-Javadoc)
   *
   * @see com.csc.muthur.server.model.event.AbstractEvent#getDataBlockElement()
   */
  public Element getDataBlockElement() {

    Element dataBlockElement = new Element(EventAttributeName.dataBlock.toString());

    if (dataObject != null) {

      Element dataObjectAsXMLElement = new Element(EventAttributeName.dataObjectAsXML.toString());

      dataBlockElement.addContent(dataObjectAsXMLElement);

      // let the sub-class add the specific data elements for that class
      //

      dataObject.buildDataObjectAsXMLElement(dataObjectAsXMLElement);
    }

    Element nextEle =
        new Element(EventAttributeName.dataType.toString()).setText(dataType.toString());

    dataBlockElement.addContent(nextEle);

    nextEle =
        new Element(EventAttributeName.federationExecutionModelHandle.toString())
            .setText(getFederationExecutionModelHandle());

    dataBlockElement.addContent(nextEle);

    return dataBlockElement;
  }
  private static void saveJavaModuleExtension(JpsModule module, Element rootModelComponent) {
    JpsJavaModuleExtension extension = getService().getModuleExtension(module);
    if (extension == null) return;
    if (extension.isExcludeOutput()) {
      rootModelComponent.addContent(0, new Element(EXCLUDE_OUTPUT_TAG));
    }

    String testOutputUrl = extension.getTestOutputUrl();
    if (testOutputUrl != null) {
      rootModelComponent.addContent(
          0, new Element(TEST_OUTPUT_TAG).setAttribute(URL_ATTRIBUTE, testOutputUrl));
    }

    String outputUrl = extension.getOutputUrl();
    if (outputUrl != null) {
      rootModelComponent.addContent(
          0, new Element(OUTPUT_TAG).setAttribute(URL_ATTRIBUTE, outputUrl));
    }

    LanguageLevel languageLevel = extension.getLanguageLevel();
    if (languageLevel != null) {
      rootModelComponent.setAttribute(MODULE_LANGUAGE_LEVEL_ATTRIBUTE, languageLevel.name());
    }
    rootModelComponent.setAttribute(
        INHERIT_COMPILER_OUTPUT_ATTRIBUTE, String.valueOf(extension.isInheritOutput()));
    saveAdditionalRoots(rootModelComponent, JAVADOC_PATHS_TAG, extension.getJavadocRoots());
    saveAdditionalRoots(rootModelComponent, ANNOTATION_PATHS_TAG, extension.getAnnotationRoots());
  }
Exemple #26
0
  private Document buildRole(Role role) {
    Element root = new Element(ROLE_REQUEST_ELEMENT);

    Document doc = new Document().setRootElement(root);

    Element data = new Element("data");

    root.addContent(data);

    data.addContent(new Element(ROLE_ID_ELEMENT).setText(role.getId()));
    data.addContent(new Element(ROLE_NAME_ELEMENT).setText(role.getName()));
    data.addContent(new Element(ROLE_DESCRIPTION_ELEMENT).setText(role.getDescription()));
    data.addContent(
        new Element(ROLE_SESSION_TIMEOUT_ELEMENT).setText(role.getSessionTimeout() + ""));

    Element subRoles = new Element(ROLE_ROLES_ELEMENT);
    for (String subRole : role.getRoles()) {
      subRoles.addContent(new Element(ROLE_ROLE_ELEMENT).setText(subRole));
    }
    data.addContent(subRoles);

    Element privileges = new Element(ROLE_PRIVILEGES_ELEMENT);
    for (String privilege : role.getPrivileges()) {
      privileges.addContent(new Element(ROLE_PRIVILEGE_ELEMENT).setText(privilege));
    }
    data.addContent(privileges);

    data.addContent(
        new Element(ROLE_USER_MANAGED_ELEMENT).setText(role.isUserManaged() ? "true" : "false"));

    return doc;
  }
 public Element toXml() {
   Element root = new Element(ROOT_ELEMENT);
   root.setAttribute(ATTR_VERSION, Integer.toString(DEPENDENCIES_VERSION));
   if (myModelHash != null) {
     root.setAttribute(ATTR_MODEL_HASH, myModelHash);
   }
   if (myParametersHash != null) {
     root.setAttribute(ATTR_PARAMS_HASH, myParametersHash);
   }
   String[] models = myUsedModelsHashes.keySet().toArray(new String[myUsedModelsHashes.size()]);
   Arrays.sort(models);
   for (String model : models) {
     Element e = new Element(NODE_MODEL);
     e.setAttribute(ATTR_MODEL_ID, model);
     String hash = myUsedModelsHashes.get(model);
     if (hash != null) {
       e.setAttribute(ATTR_HASH, hash);
     }
     root.addContent(e);
   }
   if (myRootDependencies != null) {
     for (GenerationRootDependencies data : myRootDependencies) {
       Element e = new Element(data.getRootId() != null ? NODE_ROOT : NODE_COMMON);
       data.saveTo(e);
       root.addContent(e);
     }
   }
   return root;
 }
  /**
   * Transforms a list of KeywordBean object into its iso19139 representation.
   *
   * <pre>
   *  <gmd:MD_Keywords>
   *  	<gmd:keyword>
   *  		<gco:CharacterString>Keyword 1</gco:CharacterString>
   *  	</gmd:keyword>
   * 		<gmd:keyword>
   *  		<gco:CharacterString>Keyword 2</gco:CharacterString>
   *  	</gmd:keyword>
   *  	<gmd:type>
   *  		<gmd:MD_KeywordTypeCode codeList="http://www.isotc211.org/2005/resources/codeList.xml#MD_KeywordTypeCode" codeListValue="TYPE"/>
   *  	</gmd:type>
   *  	<gmd:thesaurusName>
   *  		<gmd:CI_Citation id="geonetwork.thesaurus.register.theme.bc44a748-f1a1-4775-9395-a4a6d8bb8df6">
   *  			<gmd:title>
   *  				<gco:CharacterString>THESAURUS NAME</gco:CharacterString>
   *  			</gmd:title>
   *  			<gmd:date gco:nilReason="unknown"/>
   * 			<gmd:otherCitationDetails>
   * 				<gmx:FileName src="http://localhost:8080/geonetwork/srv/eng/metadata.show?uuid=bc44a748-f1a1-4775-9395-a4a6d8bb8df6">register.theme.bc44a748-f1a1-4775-9395-a4a6d8bb8df6</gmx:FileName>
   * 			</gmd:otherCitationDetails>
   *  		</gmd:CI_Citation>
   *  	</gmd:thesaurusName>
   *  </gmd:MD_Keywords>
   *  </pre>
   *
   * @param kbList
   * @return a complex iso19139 representation of the keyword
   */
  public static Element getComplexIso19139Elt(List<KeywordBean> kbList) {
    Element root = new Element("MD_Keywords", NS_GMD);

    Element cs = new Element("CharacterString", NS_GCO);

    List<Element> keywords = new ArrayList<Element>();

    String thName = "";
    Element type = null;
    Element thesaurusName = null;

    for (KeywordBean kb : kbList) {
      Element keyword = new Element("keyword", NS_GMD);

      cs.setText(kb.getValue());
      keyword.addContent((Content) cs.clone());
      keywords.add((Element) keyword.detach());
      thName = kb.getThesaurus();
      if (type == null) type = KeywordBean.createKeywordTypeElt(kb);
      if (thesaurusName == null) thesaurusName = KeywordBean.createThesaurusNameElt(kb);
    }

    // Add elements to the root MD_Keywords element.
    root.addContent(keywords);
    root.addContent(type);
    root.addContent(thesaurusName);

    return root;
  }
Exemple #29
0
  /** {@inheritDoc} */
  public Content encodeXML(String name, Namespace ns) {
    // element in namespace defined by parent element
    Element element = new Element(name, ns);
    // child element are always in default LLRP namespace
    ns = Namespace.getNamespace("llrp", LLRPConstants.LLRPNAMESPACE);

    if (vendorIdentifier == null) {
      LOGGER.warn(" vendorIdentifier not set");
      throw new MissingParameterException(" vendorIdentifier not set");
    } else {
      element.addContent(vendorIdentifier.encodeXML("VendorIdentifier", ns));
    }

    if (parameterSubtype == null) {
      LOGGER.warn(" parameterSubtype not set");
      throw new MissingParameterException(" parameterSubtype not set");
    } else {
      element.addContent(parameterSubtype.encodeXML("ParameterSubtype", ns));
    }

    if (data == null) {
      LOGGER.warn(" data not set");
      throw new MissingParameterException(" data not set");
    } else {
      element.addContent(data.encodeXML("Data", ns));
    }

    // parameters
    return element;
  }
  private void writeAttributes(Element attrElements) throws WriteExternalException {
    List<TextAttributesKey> list = new ArrayList<TextAttributesKey>(myAttributesMap.keySet());
    Collections.sort(list);

    for (TextAttributesKey key : list) {
      TextAttributes defaultAttr =
          myParentScheme != null ? myParentScheme.getAttributes(key) : new TextAttributes();
      TextAttributesKey baseKey = key.getFallbackAttributeKey();
      TextAttributes defaultFallbackAttr =
          baseKey != null && myParentScheme instanceof AbstractColorsScheme
              ? ((AbstractColorsScheme) myParentScheme).getFallbackAttributes(baseKey)
              : null;
      TextAttributes value = myAttributesMap.get(key);
      if (!value.equals(defaultAttr) || defaultAttr == defaultFallbackAttr) {
        Element element = new Element(OPTION_ELEMENT);
        element.setAttribute(NAME_ATTR, key.getExternalName());
        if (baseKey == null || !value.isFallbackEnabled()) {
          Element valueElement = new Element(VALUE_ELEMENT);
          value.writeExternal(valueElement);
          element.addContent(valueElement);
          attrElements.addContent(element);
        } else if (defaultAttr != defaultFallbackAttr) {
          element.setAttribute(BASE_ATTRIBUTES_ATTR, baseKey.getExternalName());
          attrElements.addContent(element);
        }
      }
    }
  }