com.intellij.openapi.util.JDOMUtil Java Examples

The following examples show how to use com.intellij.openapi.util.JDOMUtil. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConsoleHistoryController.java    From consulo with Apache License 2.0 6 votes vote down vote up
public boolean loadHistoryOld(String id) {
  File file = new File(PathUtil.toSystemDependentName(getOldHistoryFilePath(id)));
  if (!file.exists()) return false;
  try {
    Element rootElement = JDOMUtil.load(file);
    String text = loadHistory(rootElement, id);
    if (text != null) {
      myContent = text;
      return true;
    }
  }
  catch (Exception ex) {
    //noinspection ThrowableResultOfMethodCallIgnored
    Throwable cause = ExceptionUtil.getRootCause(ex);
    if (cause instanceof EOFException) {
      LOG.warn("Failed to load " + myRootType.getId() + " history from: " + file.getPath(), ex);
      return false;
    }
    else {
      LOG.error(ex);
    }
  }
  return false;
}
 
Example #2
Source File: UsefulTestCase.java    From consulo with Apache License 2.0 6 votes vote down vote up
protected static void checkSettingsEqual(JDOMExternalizable expected, JDOMExternalizable settings, String message) throws Exception {
  if (expected == null) {
    return;
  }
  if (settings == null) {
    return;
  }
  Element oldS = new Element("temp");
  expected.writeExternal(oldS);
  Element newS = new Element("temp");
  settings.writeExternal(newS);

  String newString = JDOMUtil.writeElement(newS, "\n");
  String oldString = JDOMUtil.writeElement(oldS, "\n");
  assertEquals(message, oldString, newString);
}
 
Example #3
Source File: TelegramSettingsManager.java    From teamcity-telegram-plugin with Apache License 2.0 6 votes vote down vote up
private synchronized void reloadConfiguration() throws JDOMException, IOException {
  LOG.info("Loading configuration file: " + configFile);
  Document document = JDOMUtil.loadDocument(configFile.toFile());

  Element root = document.getRootElement();

  TelegramSettings newSettings = new TelegramSettings();
  newSettings.setBotToken(unscramble(root.getAttributeValue(BOT_TOKEN_ATTR)));
  newSettings.setPaused(Boolean.parseBoolean(root.getAttributeValue(PAUSE_ATTR)));
  newSettings.setUseProxy(Boolean.parseBoolean(root.getAttributeValue(USE_PROXY_ATTR)));
  newSettings.setProxyServer(root.getAttributeValue(PROXY_SERVER_ATTR));
  newSettings.setProxyPort(restoreInteger(root.getAttributeValue(PROXY_PORT_ATTR)));
  newSettings.setProxyUsername(root.getAttributeValue(PROXY_PASSWORD_ATTR));
  newSettings.setProxyPassword(unscramble(root.getAttributeValue(PROXY_PASSWORD_ATTR)));

  settings = newSettings;
  botManager.reloadIfNeeded(settings);
}
 
Example #4
Source File: S3PreSignUrlHelper.java    From teamcity-s3-artifact-storage-plugin with Apache License 2.0 6 votes vote down vote up
@NotNull
public static String writePreSignUrlMapping(@NotNull Map<String, URL> data) {
  Element rootElement = new Element(S3_PRESIGN_URL_MAPPING);
  for (String s3ObjectKey : data.keySet()) {
    URL preSignUrl = data.get(s3ObjectKey);
    Element mapEntry = new Element(S3_PRESIGN_URL_MAP_ENTRY);
    Element preSignUrlElement = new Element(PRE_SIGN_URL);
    preSignUrlElement.addContent(preSignUrl.toString());
    mapEntry.addContent(preSignUrlElement);
    Element s3ObjectKeyElement = new Element(S3_OBJECT_KEY);
    s3ObjectKeyElement.addContent(s3ObjectKey);
    mapEntry.addContent(s3ObjectKeyElement);
    rootElement.addContent(mapEntry);
  }
  return JDOMUtil.writeDocument(new Document(rootElement), System.getProperty("line.separator"));
}
 
Example #5
Source File: S3PreSignUrlHelper.java    From teamcity-s3-artifact-storage-plugin with Apache License 2.0 6 votes vote down vote up
@NotNull
public static Collection<String> readS3ObjectKeys(String data) throws IOException {
  Document document;
  try {
    document = JDOMUtil.loadDocument(data);
  } catch (JDOMException e) {
    return Collections.emptyList();
  }
  Element rootElement = document.getRootElement();
  if (!rootElement.getName().equals(S3_OBJECT_KEYS)) return Collections.emptyList();
  Collection<String> result = new HashSet<String>();
  for (Object element : rootElement.getChildren(S3_OBJECT_KEY)) {
    Element elementCasted = (Element)element;
    result.add(elementCasted.getValue());
  }
  return result;
}
 
Example #6
Source File: ScopeToolState.java    From consulo with Apache License 2.0 6 votes vote down vote up
public boolean equalTo(@Nonnull ScopeToolState state2) {
  if (isEnabled() != state2.isEnabled()) return false;
  if (getLevel() != state2.getLevel()) return false;
  InspectionToolWrapper toolWrapper = getTool();
  InspectionToolWrapper toolWrapper2 = state2.getTool();
  if (!toolWrapper.isInitialized() && !toolWrapper2.isInitialized()) return true;
  try {
    @NonNls String tempRoot = "root";
    Element oldToolSettings = new Element(tempRoot);
    toolWrapper.getTool().writeSettings(oldToolSettings);
    Element newToolSettings = new Element(tempRoot);
    toolWrapper2.getTool().writeSettings(newToolSettings);
    return JDOMUtil.areElementsEqual(oldToolSettings, newToolSettings);
  }
  catch (WriteExternalException e) {
    LOG.error(e);
  }
  return false;
}
 
Example #7
Source File: RunConfigurationSerializerTest.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Test
public void normalizeTemplateRunConfig() throws Exception {
  Element element =
      JDOMUtil.load(
          "<configuration default=\"true\" type=\"BlazeCommandRunConfigurationType\"\n"
              + "    factoryName=\"Bazel Command\">\n"
              + "  <blaze-settings\n"
              + "      handler-id=\"BlazeCommandGenericRunConfigurationHandlerProvider\">\n"
              + "    <blaze-user-flag>--some_flag</blaze-user-flag>\n"
              + "  </blaze-settings>\n"
              + "</configuration>");

  RunnerAndConfigurationSettingsImpl originalConfig =
      new RunnerAndConfigurationSettingsImpl(runManager, null, true);
  originalConfig.readExternal(element, false);
  assertThat(originalConfig.isTemplate()).isTrue();

  RunConfigurationSerializer.normalizeTemplateRunConfig(element);

  RunnerAndConfigurationSettingsImpl normalizedConfig =
      new RunnerAndConfigurationSettingsImpl(runManager, null, true);
  normalizedConfig.readExternal(element, false);
  assertThat(normalizedConfig.isTemplate()).isFalse();
  assertThat(normalizedConfig.getName())
      .isEqualTo(RunConfigurationSerializer.TEMPLATE_RUN_CONFIG_NAME_PREFIX + "Bazel Command");
}
 
Example #8
Source File: RunConfigurationSerializerTest.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Test
public void normalizeNormalRunConfig_doNotReplaceName() throws Exception {
  Element element =
      JDOMUtil.load(
          "<configuration\n"
              + "    default=\"false\"\n"
              + "    factoryName=\"Bazel Command\"\n"
              + "    name=\"ExampleConfig\"\n"
              + "    type=\"BlazeCommandRunConfigurationType\">\n"
              + "</configuration>");

  RunConfigurationSerializer.normalizeTemplateRunConfig(element);

  RunnerAndConfigurationSettingsImpl normalizedConfig =
      new RunnerAndConfigurationSettingsImpl(runManager, null, true);
  normalizedConfig.readExternal(element, false);
  assertThat(normalizedConfig.isTemplate()).isFalse();
  assertThat(normalizedConfig.getName()).isEqualTo("ExampleConfig");
}
 
Example #9
Source File: PluginErrorSubmitDialog.java    From BashSupport with Apache License 2.0 6 votes vote down vote up
public void prepare(String additionalInfo, String stacktrace, String versionId) {
    reportComponent.descriptionField.setText(additionalInfo);
    reportComponent.stacktraceField.setText(stacktrace);
    reportComponent.versionField.setText(versionId);

    File file = new File(getOptionsFilePath());
    if (file.exists()) {
        try {
            Document document = JDOMUtil.loadDocument(file);
            Element applicationElement = document.getRootElement();
            if (applicationElement == null) {
                throw new InvalidDataException("Expected root element >application< not found");
            }
            Element componentElement = applicationElement.getChild("component");
            if (componentElement == null) {
                throw new InvalidDataException("Expected element >component< not found");
            }

            DefaultJDOMExternalizer.readExternal(this, componentElement);
            reportComponent.nameField.setText(USERNAME);
        } catch (Exception e) {
            LOGGER.info("Unable to read configuration file", e);
        }
    }
}
 
Example #10
Source File: UnityFunctionManager.java    From consulo-unity3d with Apache License 2.0 6 votes vote down vote up
public UnityFunctionManager()
{
	try
	{
		Document document = JDOMUtil.loadDocument(UnityFunctionManager.class.getResourceAsStream("/functions.xml"));
		for(Element typeElement : document.getRootElement().getChildren())
		{
			String typeName = typeElement.getAttributeValue("name");
			Map<String, FunctionInfo> value = new THashMap<>();
			myFunctionsByType.put(typeName, value);
			for(Element element : typeElement.getChildren())
			{
				FunctionInfo functionInfo = new FunctionInfo(element);
				value.put(functionInfo.myName, functionInfo);
			}
		}
	}
	catch(JDOMException | IOException e)
	{
		LOGGER.error(e);
	}
}
 
Example #11
Source File: InspectionTestUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static void compareToolResults(@Nonnull GlobalInspectionContextImpl context,
                                      @Nonnull InspectionToolWrapper toolWrapper,
                                      boolean checkRange,
                                      String testDir) {
  final Element root = new Element("problems");
  final Document doc = new Document(root);
  InspectionToolPresentation presentation = context.getPresentation(toolWrapper);

  presentation.updateContent();  //e.g. dead code need check for reachables
  presentation.exportResults(root);

  File file = new File(testDir + "/expected.xml");
  try {
    Document expectedDocument = JDOMUtil.loadDocument(file);

    compareWithExpected(expectedDocument, doc, checkRange);
  }
  catch (Exception e) {
    throw new RuntimeException(e);
  }
}
 
Example #12
Source File: FileEditorManagerTest.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void openFiles(String s) throws IOException, JDOMException, InterruptedException, ExecutionException {
  Document document = JDOMUtil.loadDocument(s);
  Element rootElement = document.getRootElement();
  ExpandMacroToPathMap map = new ExpandMacroToPathMap();
  map.addMacroExpand(PathMacroUtil.PROJECT_DIR_MACRO_NAME, getTestDataPath());
  map.substitute(rootElement, true, true);

  myManager.loadState(rootElement);

  UIAccess uiAccess = UIAccess.get();
  Future<?> future = ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
    @Override
    public void run() {
      myManager.getMainSplitters().openFiles(uiAccess);
    }
  });
  future.get();
}
 
Example #13
Source File: ExternalizablePropertyContainer.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void writeExternal(@Nonnull Element element) {
  if (myExternalizers.isEmpty()) {
    return;
  }

  List<AbstractProperty> properties = new ArrayList<AbstractProperty>(myExternalizers.keySet());
  Collections.sort(properties, AbstractProperty.NAME_COMPARATOR);
  for (AbstractProperty property : properties) {
    Externalizer externalizer = myExternalizers.get(property);
    if (externalizer == null) {
      continue;
    }

    Object propValue = property.get(this);
    if (!Comparing.equal(propValue, property.getDefault(this))) {
      Element child = new Element(property.getName());
      externalizer.writeValue(child, propValue);
      if (!JDOMUtil.isEmpty(child)) {
        element.addContent(child);
      }
    }
  }
}
 
Example #14
Source File: TranslationCompilerProjectMonitor.java    From consulo with Apache License 2.0 6 votes vote down vote up
@RequiredReadAction
public void updateCompileOutputInfoFile() {
  Map<String, Couple<String>> map = buildOutputRootsLayout();

  Element root = new Element("list");
  for (Map.Entry<String, Couple<String>> entry : map.entrySet()) {
    Element module = new Element("module");
    root.addContent(module);

    module.setAttribute("name", entry.getKey());

    String first = entry.getValue().getFirst();
    if (first != null) module.setAttribute("output-url", first);

    String second = entry.getValue().getSecond();
    if (second != null) module.setAttribute("test-output-url", second);
  }

  try {
    JDOMUtil.writeDocument(new Document(root), getOutputUrlsFile(), "\n");
  }
  catch (IOException e) {
    LOG.error(e);
  }
}
 
Example #15
Source File: TranslationCompilerProjectMonitor.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
public Map<String, Couple<String>> getLastOutputRootsLayout() {
  File file = getOutputUrlsFile();

  Map<String, Couple<String>> map = new HashMap<>();
  if (file.exists()) {
    try {
      Element root = JDOMUtil.load(file);

      for (Element module : root.getChildren()) {
        String name = module.getAttributeValue("name");
        String outputUrl = module.getAttributeValue("output-url");
        String testOutputUrl = module.getAttributeValue("test-output-url");

        map.put(name, Couple.of(outputUrl, testOutputUrl));
      }
    }
    catch (IOException | JDOMException e) {
      LOG.error(e);
    }
  }

  return map;
}
 
Example #16
Source File: ApplicationDefaultStoreCache.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
public Element findDefaultStoreElement(@Nonnull Class<?> clazz, @Nonnull String path) {
  Object result = myUrlCache.computeIfAbsent(Pair.create(clazz.getClassLoader(), path), pair -> {
    URL resource = pair.getFirst().getResource(pair.getSecond());

    if(resource != null) {
      try {
        Document document = JDOMUtil.loadDocument(resource);
        Element rootElement = document.getRootElement();
        rootElement.detach();
        return rootElement;
      }
      catch (JDOMException | IOException e) {
        throw new RuntimeException(e);
      }
    }

    return ObjectUtil.NULL;
  });

  return result == ObjectUtil.NULL ? null : (Element)result;
}
 
Example #17
Source File: StateMap.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
public static Element unarchiveState(@Nonnull byte[] state) {
  InputStream in = null;
  try {
    try {
      in = new SnappyInputStream(new ByteArrayInputStream(state));
      //noinspection ConstantConditions
      return JDOMUtil.loadDocument(in).detachRootElement();
    }
    finally {
      if (in != null) {
        in.close();
      }
    }
  }
  catch (IOException | JDOMException e) {
    throw new StateStorageException(e);
  }
}
 
Example #18
Source File: XmlElementStorage.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
protected final Element getElement(@Nonnull StorageData data, boolean collapsePaths, @Nonnull Map<String, Element> newLiveStates) {
  Element element = data.save(newLiveStates);
  if (element == null || JDOMUtil.isEmpty(element)) {
    return null;
  }

  if (collapsePaths && myPathMacroSubstitutor != null) {
    try {
      myPathMacroSubstitutor.collapsePaths(element);
    }
    finally {
      myPathMacroSubstitutor.reset();
    }
  }

  return element;
}
 
Example #19
Source File: SchemesManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void loadBundledScheme(@Nonnull String resourceName, @Nonnull Object requestor, @Nonnull ThrowableConvertor<Element, T, Throwable> convertor) {
  try {
    URL url = requestor instanceof AbstractExtensionPointBean
              ? (((AbstractExtensionPointBean)requestor).getLoaderForClass().getResource(resourceName))
              : DecodeDefaultsUtil.getDefaults(requestor, resourceName);
    if (url == null) {
      // Error shouldn't occur during this operation thus we report error instead of info
      LOG.error("Cannot read scheme from " + resourceName);
      return;
    }
    addNewScheme(convertor.convert(JDOMUtil.load(URLUtil.openStream(url))), false);
  }
  catch (Throwable e) {
    LOG.error("Cannot read scheme from " + resourceName, e);
  }
}
 
Example #20
Source File: DefaultKeymap.java    From consulo with Apache License 2.0 6 votes vote down vote up
public DefaultKeymap() {
  for(BundledKeymapEP bundledKeymapEP : BundledKeymapEP.EP_NAME.getExtensions()) {
      try {
        InputStream inputStream = bundledKeymapEP.getLoaderForClass().getResourceAsStream(bundledKeymapEP.file + ".xml");
        if(inputStream == null) {
          LOG.warn("Keymap: " + bundledKeymapEP.file + " not found in " + bundledKeymapEP.getPluginDescriptor().getPluginId().getIdString());
          continue;
        }
        Document document = JDOMUtil.loadDocument(inputStream);

        loadKeymapsFromElement(document.getRootElement());
      }
      catch (Exception e) {
        LOG.error(e);
      }
  }
}
 
Example #21
Source File: TagBinding.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public Object serialize(@Nonnull Object o, @Nullable Object context, @Nonnull SerializationFilter filter) {
  Object value = myAccessor.read(o);
  Element serialized = new Element(myName);
  if (value == null) {
    return serialized;
  }

  if (myBinding == null) {
    serialized.addContent(new Text(XmlSerializerImpl.convertToString(value)));
  }
  else {
    Object node = myBinding.serialize(value, serialized, filter);
    if (node != null && node != serialized) {
      JDOMUtil.addContent(serialized, node);
    }
  }
  return serialized;
}
 
Example #22
Source File: XDebuggerSettingManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public SettingsState getState() {
  SettingsState settingsState = new SettingsState();
  settingsState.setDataViewSettings(myDataViewSettings);
  settingsState.setGeneralSettings(myGeneralSettings);

  initSettings();
  if (!mySettingsById.isEmpty()) {
    SkipDefaultValuesSerializationFilters filter = new SkipDefaultValuesSerializationFilters();
    for (XDebuggerSettings<?> settings : mySettingsById.values()) {
      Object subState = settings.getState();
      if (subState != null) {
        Element serializedState = XmlSerializer.serializeIfNotDefault(subState, filter);
        if (!JDOMUtil.isEmpty(serializedState)) {
          SpecificSettingsState state = new SpecificSettingsState();
          state.id = settings.getId();
          state.configuration = serializedState;
          settingsState.specificStates.add(state);
        }
      }
    }
  }
  return settingsState;
}
 
Example #23
Source File: InspectionDiff.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static void writeInspectionDiff(final String oldPath, final String newPath, final String outPath) {
  try {
    InputStream oldStream = oldPath != null ? new BufferedInputStream(new FileInputStream(oldPath)) : null;
    InputStream newStream = new BufferedInputStream(new FileInputStream(newPath));

    Document oldDoc = oldStream != null ? JDOMUtil.loadDocument(oldStream) : null;
    Document newDoc = JDOMUtil.loadDocument(newStream);

    OutputStream outStream = System.out;
    if (outPath != null) {
      outStream = new BufferedOutputStream(new FileOutputStream(outPath + File.separator + new File(newPath).getName()));
    }

    Document delta = createDelta(oldDoc, newDoc);
    JDOMUtil.writeDocument(delta, outStream, "\n");
    if (outStream != System.out) {
      outStream.close();
    }
  } catch (Exception e) {
    e.printStackTrace();
  }
}
 
Example #24
Source File: ParameterNameHintsSettings.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void loadState(Element state) {
  myAddedPatterns.clear();
  myRemovedPatterns.clear();

  myIsDoNotShowIfMethodNameContainsParameterName = true;
  myIsShowForParamsWithSameType = false;

  List<Element> allBlackLists = JDOMUtil.getChildren(state.getChild(BLACKLISTS), LANGUAGE_LIST);

  for (Element blacklist : allBlackLists) {
    String language = attributeValue(blacklist, LANGUAGE);
    if (language == null) {
      continue;
    }
    myAddedPatterns.put(language, extractPatterns(blacklist, ADDED));
    myRemovedPatterns.put(language, extractPatterns(blacklist, REMOVED));
  }

  myIsDoNotShowIfMethodNameContainsParameterName = getBooleanValue(state, DO_NOT_SHOW_IF_PARAM_NAME_CONTAINED_IN_METHOD_NAME, true);

  myIsShowForParamsWithSameType = getBooleanValue(state, SHOW_WHEN_MULTIPLE_PARAMS_WITH_SAME_TYPE, false);
}
 
Example #25
Source File: DaemonCodeAnalyzerSettingsImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isCodeHighlightingChanged(DaemonCodeAnalyzerSettings oldSettings) {
  try {
    Element rootNew = new Element(ROOT_TAG);
    writeExternal(rootNew);
    Element rootOld = new Element(ROOT_TAG);
    ((DaemonCodeAnalyzerSettingsImpl)oldSettings).writeExternal(rootOld);

    return !JDOMUtil.areElementsEqual(rootOld, rootNew);
  }
  catch (WriteExternalException e) {
    LOG.error(e);
  }

  return false;
}
 
Example #26
Source File: TemplateSettings.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void loadBundledLiveTemplateSets() {
  try {
    for (BundleLiveTemplateSetEP it : BundleLiveTemplateSetEP.EP_NAME.getExtensions()) {
      ClassLoader loaderForClass = it.getLoaderForClass();
      InputStream inputStream = loaderForClass.getResourceAsStream(it.path + ".xml");
      if (inputStream != null) {
        TemplateGroup group = readTemplateFile(JDOMUtil.loadDocument(inputStream), it.path, true, it.register, loaderForClass);
        if (group != null && group.getReplace() != null) {
          Collection<TemplateImpl> templates = myTemplates.get(group.getReplace());
          for (TemplateImpl template : templates) {
            removeTemplate(template);
          }
        }
      }
      else {
        LOG.warn("Cannot find path for '" + it.path + "'. Plugin: " + it.getPluginDescriptor().getPluginId());
      }
    }
  }
  catch (Exception e) {
    LOG.error(e);
  }
}
 
Example #27
Source File: TemplateSettings.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Deprecated
@SuppressWarnings("deprecation")
private void readDefTemplate(DefaultLiveTemplatesProvider provider, String defTemplate, boolean registerTemplate)
        throws JDOMException, InvalidDataException, IOException {
  InputStream inputStream = DecodeDefaultsUtil.getDefaultsInputStream(provider, defTemplate);
  if (inputStream != null) {
    TemplateGroup group =
            readTemplateFile(JDOMUtil.loadDocument(inputStream), defTemplate, true, registerTemplate, provider.getClass().getClassLoader());
    if (group != null && group.getReplace() != null) {
      Collection<TemplateImpl> templates = myTemplates.get(group.getReplace());
      for (TemplateImpl template : templates) {
        removeTemplate(template);
      }
    }
  }
}
 
Example #28
Source File: S3PreSignUrlHelper.java    From teamcity-s3-artifact-storage-plugin with Apache License 2.0 6 votes vote down vote up
@NotNull
public static Map<String, URL> readPreSignUrlMapping(String data) throws IOException {
  Document document;
  try {
    document = JDOMUtil.loadDocument(data);
  } catch (JDOMException e) {
    return Collections.emptyMap();
  }
  final Element rootElement = document.getRootElement();
  if (!rootElement.getName().equals(S3_PRESIGN_URL_MAPPING)) return Collections.emptyMap();
  final Map<String, URL> result = new HashMap<String, URL>();
  for (Object mapEntryElement : rootElement.getChildren(S3_PRESIGN_URL_MAP_ENTRY)) {
    final Element mapEntryElementCasted = (Element)mapEntryElement;
    final String s3ObjectKey = mapEntryElementCasted.getChild(S3_OBJECT_KEY).getValue();
    final String preSignUrlString = mapEntryElementCasted.getChild(PRE_SIGN_URL).getValue();
    result.put(s3ObjectKey, new URL(preSignUrlString));
  }
  return result;
}
 
Example #29
Source File: SkipDefaultValuesSerializationFilters.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean accepts(@Nonnull Accessor accessor, @Nonnull Object bean, @Nullable Object beanValue) {
  Object defValue = accessor.read(getDefaultBean(bean));
  if (defValue instanceof Element && beanValue instanceof Element) {
    return !JDOMUtil.areElementsEqual((Element)beanValue, (Element)defValue);
  }
  else {
    return !Comparing.equal(beanValue, defValue);
  }
}
 
Example #30
Source File: PluginErrorSubmitDialog.java    From BashSupport with Apache License 2.0 5 votes vote down vote up
public void persist() {
    try {
        Element applicationElement = new Element("application");
        Element componentElement = new Element("component");
        applicationElement.addContent(componentElement);

        USERNAME = reportComponent.nameField.getText();
        DefaultJDOMExternalizer.writeExternal(this, componentElement);

        Document document = new Document(applicationElement);
        JDOMUtil.writeDocument(document, getOptionsFilePath(), "\r\n");
    } catch (Exception e) {
        LOGGER.info("Unable to persist configuration file", e);
    }
}