diff --git a/htroot/ViewProfile.java b/htroot/ViewProfile.java
index f87d9c667..5c31cee31 100644
--- a/htroot/ViewProfile.java
+++ b/htroot/ViewProfile.java
@@ -50,6 +50,7 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
@@ -139,7 +140,7 @@ public class ViewProfile {
}
Map.Entry entry;
// all known keys which should be set as they are
- ArrayList knownKeys = new ArrayList();
+ HashSet knownKeys = new HashSet();
knownKeys.add("name");
knownKeys.add("nickname");
// knownKeys.add("homepage");//+http
@@ -160,7 +161,7 @@ public class ViewProfile {
int numUnknown = 0;
while (i.hasNext()) {
entry = (Map.Entry) i.next();
- String key = (String) entry.getKey();
+ String key = ((String) entry.getKey());
String value = new String();
// only comments get "wikified"
@@ -172,16 +173,20 @@ public class ViewProfile {
}
//all known Keys which should be set as they are
- if ((knownKeys.contains(key)) && (value.length() > 0)) {
- prop.put("success_" + key, 1);
- prop.put("success_" + key + "_value", value);
- //special handling, hide flower if no icq uin is set
- } else if ((key.equals("homepage")) && (value.length() > 0)) {
- if (!(value.startsWith("http"))) {
- value = "http://" + value;
- }
- prop.put("success_" + key, 1);
- prop.put("success_" + key + "_value", value);
+ if (knownKeys.contains(key)) {
+ if (value.length() > 0) {
+ prop.put("success_" + key, 1);
+ prop.put("success_" + key + "_value", value);
+ }
+ //special handling, hide flower if no icq uin is set
+ } else if (key.equals("homepage")) {
+ if (value.length() > 0) {
+ if (!(value.startsWith("http"))) {
+ value = "http://" + value;
+ }
+ prop.put("success_" + key, 1);
+ prop.put("success_" + key + "_value", value);
+ }
//This will display unknown items(of newer versions) as plaintext
} else {
//unknown
diff --git a/htroot/ViewProfile.xml b/htroot/ViewProfile.xml
new file mode 100644
index 000000000..a4f1e7312
--- /dev/null
+++ b/htroot/ViewProfile.xml
@@ -0,0 +1,30 @@
+
+null
the old value will not be overwritten.
+ *
+ * @param name the name of the peer owner
+ * @param nickname peer owner nick name
+ * @param homepage
+ * @param email
+ * @param icq
+ * @param jabber
+ * @param yahoo
+ * @param msn
+ * @param comments
+ *
+ * @throws AxisFault if authentication failed
+ */
+ public void setLocalPeerProfile(
+ String name,
+ String nickname,
+ String homepage,
+ String email,
+ String icq,
+ String jabber,
+ String yahoo,
+ String msn,
+ String comments
+ ) throws AxisFault {
+ // extracting the message context
+ extractMessageContext(AUTHENTICATION_NEEDED);
+
+ // load peer properties
+ final Properties profile = new Properties();
+ FileInputStream fileIn = null;
+ try {
+ fileIn = new FileInputStream(new File("DATA/SETTINGS/profile.txt"));
+ profile.load(fileIn);
+ } catch(IOException e) {
+ throw new AxisFault("Unable to load the peer profile");
+ } finally {
+ if (fileIn != null) try { fileIn.close(); } catch (Exception e) {/* */}
+ }
+
+ // set all properties
+ if (name != null) profile.setProperty(PEERPROFILE_NAME,name);
+ if (nickname != null) profile.setProperty(PEERPROFILE_NICKNAME,nickname);
+ if (homepage != null) profile.setProperty(PEERPROFILE_HOMEPAGE,homepage);
+ if (email != null) profile.setProperty(PEERPROFILE_EMAIL,email);
+ if (icq != null) profile.setProperty(PEERPROFILE_ICQ,icq);
+ if (jabber != null) profile.setProperty(PEERPROFILE_JABBER,jabber);
+ if (yahoo != null) profile.setProperty(PEERPROFILE_YAHOO,yahoo);
+ if (msn != null) profile.setProperty(PEERPROFILE_MSN,msn);
+ if (comments != null) profile.setProperty(PEERPROFILE_COMMENT,comments);
+
+ // store it
+ FileOutputStream fileOut = null;
+ try {
+ fileOut = new FileOutputStream(new File("DATA/SETTINGS/profile.txt"));
+ profile.store(fileOut , null );
+
+ // generate a news message
+ Properties news = profile;
+ news.remove(PEERPROFILE_COMMENT);
+ yacyCore.newsPool.publishMyNews(new yacyNewsRecord("prfleupd", news));
+ } catch(IOException e) {
+ throw new AxisFault("Unable to write profile data to file");
+ } finally {
+ if (fileOut != null) try { fileOut.close(); } catch (Exception e) {/* */}
+ }
+ }
+
+ /**
+ * Returns the peer profile of this peer
+ * @return a xml document in the same format as returned by function {@link #getPeerProfile(String)}
+ * @throws Exception
+ */
+ public Document getLocalPeerProfile() throws Exception {
+ return this.getPeerProfile("localhash");
+ }
+
+ /**
+ * Function to query the profile of a remote peer
+ * @param peerhash the peer hash
+ * @return a xml document in the following format
+ *
+ * <?xml version="1.0" encoding="UTF-8"?> + * <profile> + * <status code="3">Peer profile successfully fetched</status> + * <name><![CDATA[myName]]></name> + * <nickname><![CDATA[myNickName]]></nickname> + * <homepage><![CDATA[http://myhompage.de]]></homepage> + * <email/> + * <icq/> + * <jabber/> + * <yahoo/> + * <msn/> + * <comment><![CDATA[Comments]]></comment> + * </profile> + *+ * @throws Exception if authentication failed + */ + public Document getPeerProfile(String peerhash) throws Exception { + // extracting the message context + extractMessageContext(AUTHENTICATION_NEEDED); + + // generating the template containing the network status information + serverObjects args = new serverObjects(); + args.put(PEER_HASH,peerhash); + + // invoke servlet + serverObjects tp = invokeServlet(TEMPLATE_PROFILE_XML,args); + + // query status + if (tp.containsKey(PEER_PROFILE_FETCH_SUCCESS)) { + String success = tp.get(PEER_PROFILE_FETCH_SUCCESS,"3"); + if (success.equals("0")) throw new AxisFault("Invalid parameters passed to servlet."); + else if (success.equals("1")) throw new AxisFault("The requested peer is unknown or can not be accessed."); + else if (success.equals("2")) throw new AxisFault("The requested peer is offline"); + } else { + throw new AxisFault("Unkown error. Unable to determine profile fetching status."); + } + + + // generate output + byte[] result = buildServletOutput(TEMPLATE_PROFILE_XML, tp); + + // sending back the result to the client + return this.convertContentToXML(result); + } } diff --git a/source/de/anomic/soap/services/admin.wsdl b/source/de/anomic/soap/services/admin.wsdl index d9597a1cd..652765d17 100644 --- a/source/de/anomic/soap/services/admin.wsdl +++ b/source/de/anomic/soap/services/admin.wsdl @@ -33,173 +33,184 @@ Built on Apr 22, 2006 (06:55:48 PDT)-->