forked from geonetwork/core-geonetwork
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from fxprunayre/feature/multinodes-mode
Align to develop. Fix login/logout in widget apps
- Loading branch information
Showing
113 changed files
with
2,571 additions
and
668 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
core/src/main/java/org/fao/geonet/kernel/AddElemValue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package org.fao.geonet.kernel; | ||
|
||
import com.google.common.collect.Lists; | ||
import org.fao.geonet.constants.Geonet; | ||
import org.fao.geonet.utils.Log; | ||
import org.fao.geonet.utils.Xml; | ||
import org.jdom.Element; | ||
import org.jdom.JDOMException; | ||
|
||
import java.io.IOException; | ||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
/** | ||
* A simple container class for some add methods in {@link EditLib} | ||
* Created by Jesse on 12/10/13. | ||
*/ | ||
public class AddElemValue { | ||
private final String stringValue; | ||
private final Element nodeValue; | ||
|
||
public AddElemValue(String stringValue) { | ||
String finalStringVal = stringValue; | ||
Element finalNodeVal = null; | ||
if (stringValue.trim().startsWith("<")) { | ||
try { | ||
finalNodeVal = Xml.loadString(stringValue, false); | ||
finalStringVal = null; | ||
} catch (JDOMException e) { | ||
Log.debug(Geonet.EDITORADDELEMENT, "Invalid XML fragment to insert " + stringValue + ". Error is: " + e.getMessage()); | ||
e.printStackTrace(); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
this.nodeValue = finalNodeVal; | ||
this.stringValue = finalStringVal; | ||
} | ||
|
||
public AddElemValue(Element nodeValue) { | ||
this.nodeValue = nodeValue; | ||
this.stringValue = null; | ||
} | ||
|
||
public boolean isXml() { | ||
return nodeValue != null; | ||
} | ||
public String getStringValue() { | ||
return stringValue; | ||
} | ||
|
||
public Element getNodeValue() { | ||
return nodeValue; | ||
} | ||
} |
Oops, something went wrong.