Skip to content

Commit

Permalink
Merge pull request #4 from fxprunayre/feature/multinodes-mode
Browse files Browse the repository at this point in the history
Align to develop. Fix login/logout in widget apps
  • Loading branch information
Jesse Eichar committed Dec 10, 2013
2 parents 62f6611 + 92cc0b3 commit 285b537
Show file tree
Hide file tree
Showing 113 changed files with 2,571 additions and 668 deletions.
6 changes: 4 additions & 2 deletions common/src/main/java/org/fao/geonet/utils/XmlRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ protected final Element executeAndReadResponse(HttpRequestBase httpMethod) throw
final ClientHttpResponse httpResponse = doExecute(httpMethod);

if (httpResponse.getRawStatusCode() > 399) {
throw new BadServerResponseEx(httpResponse.getStatusText()+" -- Response Code: "+httpResponse.getRawStatusCode());
throw new BadServerResponseEx(httpResponse.getStatusText() +
" -- URI: " + httpMethod.getURI() +
" -- Response Code: " + httpResponse.getRawStatusCode());
}

byte[] data = null;
Expand All @@ -111,7 +113,7 @@ protected final Element executeAndReadResponse(HttpRequestBase httpMethod) throw

catch(JDOMException e)
{
throw new BadXmlResponseEx(new String(data, "UTF8"));
throw new BadXmlResponseEx("Response: " + new String(data, "UTF8") + " (from URI " + httpMethod.getURI() + ")");
}

finally
Expand Down
56 changes: 56 additions & 0 deletions core/src/main/java/org/fao/geonet/kernel/AddElemValue.java
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;
}
}
Loading

0 comments on commit 285b537

Please sign in to comment.