diff --git a/sharepoint/api/pom.xml b/sharepoint/api/pom.xml
index 6ec6af0..1eaabda 100644
--- a/sharepoint/api/pom.xml
+++ b/sharepoint/api/pom.xml
@@ -136,6 +136,20 @@
+
+ search2010
+ generate-sources
+
+ wsimport
+
+
+ com.microsoft.schemas.sharepoint.soap.search
+ ${basedir}/src/main/resources/2010/wsdl
+
+ search.wsdl
+
+
+
@@ -196,7 +210,7 @@
lists.xml
true
-
+
diff --git a/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/SPJaxbObject.java b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/SPJaxbObject.java
index a9a932e..254956d 100644
--- a/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/SPJaxbObject.java
+++ b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/SPJaxbObject.java
@@ -1,16 +1,3 @@
-/*
- * File: $$RCSfile$$
- *
- * Copyright (c) 2011 by Wincor Nixdorf,
- * Heinz-Nixdorf-Ring 1, 33106 Paderborn, Germany
- *
- * This software is the confidential and proprietary information
- * of Wincor Nixdorf.
- *
- * You shall not disclose such confidential information and shall
- * use it only in accordance with the terms of the license agreement
- * you entered into with Wincor Nixdorf.
- */
package de.muehlencord.shared.sharepoint.api;
import java.io.IOException;
@@ -18,7 +5,6 @@ import java.io.InputStream;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.List;
-import java.util.logging.Level;
import javax.xml.XMLConstants;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
@@ -81,7 +67,7 @@ public abstract class SPJaxbObject extends SPObject {
return null;
}
- Schema schema;
+ Schema schema = null;
try {
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
StreamSource[] streamSources = new StreamSource[schemaLocations.size()];
@@ -93,7 +79,8 @@ public abstract class SPJaxbObject extends SPObject {
}
schema = sf.newSchema(streamSources);
} catch (Exception ex) {
- return null; // TODO add error handling
+ ex.printStackTrace(); // TODO add error handling
+ // throw new SAXException ("Cannot convert to object. Reason: "+ex.getMessage(), ex);
}
return schema;
}
diff --git a/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/lists/SPList.java b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/lists/SPList.java
index dacaf07..a0ce5fe 100644
--- a/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/lists/SPList.java
+++ b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/lists/SPList.java
@@ -1,10 +1,11 @@
package de.muehlencord.shared.sharepoint.api.lists;
-import com.microsoft.schemas.sharepoint.soap.lists.GetListCollectionResponse;
-import com.microsoft.schemas.sharepoint.soap.lists.GetListResponse.GetListResult;
-import com.microsoft.schemas.sharepoint.soap.lists.Lists;
+import com.microsoft.schemas.sharepoint.soap.lists.GetListItems;
+import com.microsoft.schemas.sharepoint.soap.lists.GetListItems.QueryOptions;
+import com.microsoft.schemas.sharepoint.soap.lists.GetListItemsResponse;
+import com.microsoft.schemas.sharepoint.soap.lists.GetListResponse;
import com.microsoft.schemas.sharepoint.soap.lists.ListsSoap;
-import com.microsoft.schemas.sharepoint.soap.lists.UpdateListItems.Updates;
+import com.microsoft.schemas.sharepoint.soap.lists.UpdateListItems;
import de.muehlencord.shared.sharepoint.api.SPContext;
import de.muehlencord.shared.sharepoint.api.SPJaxbObject;
import de.muehlencord.shared.sharepoint.api.SPObject;
@@ -14,138 +15,184 @@ import de.muehlencord.shared.sharepoint.api.batch.Method;
import de.muehlencord.shared.sharepoint.api.batch.MethodType;
import java.io.IOException;
import java.net.MalformedURLException;
-import java.net.URL;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
-import java.text.ParseException;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.LinkedList;
-import java.util.List;
import java.util.Map;
import javax.xml.bind.JAXBException;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.handler.Handler;
import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
/**
*
- * @author jomu
+ * @author joern.muehlencord
*/
-public class SPList extends SPJaxbObject {
+public class SPList extends SPJaxbObject {
- public SPList(SPContext context) throws JAXBException {
- super(de.muehlencord.shared.sharepoint.api.lists.Lists.class, context);
+ private String listName = null;
+
+ public SPList(SPContext context, String listName) throws JAXBException {
+ super(List.class, context);
+ getValue().name = listName;
}
@Override
- protected List getSchemaLocation() {
- List schemaList = new ArrayList();
- schemaList.add("/xsd/lists.xsd");
+ protected java.util.List getSchemaLocation() {
+ java.util.List schemaList = new ArrayList();
+ schemaList.add("/xsd/list.xsd");
return schemaList;
}
- public List getListNames() throws NoSuchAlgorithmException, KeyManagementException, MalformedURLException, ParseException, JAXBException,
+
+ /* *** list information *** */
+
+ public String getListName() {
+ return getValue().name;
+ }
+
+ /* *** queries *** */
+ public java.util.List> getListItems(java.util.List listColumnNames, String rowLimit) throws NoSuchAlgorithmException,
+ KeyManagementException, JAXBException, MalformedURLException,
SAXException {
- if (this.getValue().lists == null) {
- getValueFromSharepoint();
- }
- List returnList = new LinkedList<>();
- this.getValue().lists.stream().
- forEach((currentList) -> {
- returnList.add(currentList.name);
- });
- return returnList;
- }
- public String getListName(String listTitle) throws NoSuchAlgorithmException, KeyManagementException, JAXBException, MalformedURLException, SAXException {
- if (this.getValue().lists == null) {
- getValueFromSharepoint();
- }
+ //Here are additional parameters that may be set
+ String viewName = null;
+ GetListItems.ViewFields viewFields = null;
+ GetListItems.Query query = null;
+ QueryOptions queryOptions = new QueryOptions();
+ String webId = null;
- for (de.muehlencord.shared.sharepoint.api.lists.List currentList : this.getValue().lists) {
- if (currentList.title.equals(listTitle)) {
- return currentList.name;
- }
- }
- return null;
- }
+ GetListItemsResponse.GetListItemsResult result = getListsPort().
+ getListItems(getValue().name, viewName, query, viewFields, rowLimit, queryOptions, webId);
- public void getListColumns(String listName) throws NoSuchAlgorithmException, KeyManagementException, JAXBException, MalformedURLException, SAXException {
- GetListResult result = getListsPort(getContext().getSiteURL()).getList(listName);
-
- if (result.getContent() != null) {
+ java.util.List> returnList = new LinkedList<>();
+ if (result != null && result.getContent() != null) {
for (Object content : result.getContent()) {
// TODO - handdling more than one result / should not occur
if (content instanceof Element) {
- // Parse XML file
+
+ // parse XML manually. Attribute list is generated automatically as the columns
+ // are stored as attribute with ows_. This makes an easy to use
+ // XSD generated java object unhandy.
Element rootElement = (Element) content;
- String listsString = SPObject.xmlToString(rootElement.getOwnerDocument());
- System.out.println (listsString);
- // TODO implement handling
- // this.setValue(listsString);
+
+ NodeList list = rootElement.getElementsByTagName("z:row");
+ for (int i = 0; i < list.getLength(); i++) {
+ java.util.List rowList = new LinkedList<>();
+ //Gets the attributes of the current row/element
+ NamedNodeMap attributes = list.item(i).getAttributes();
+ // include all attributes which are requested by the given column names
+ // important - blank codes to _x0020_ as blank is not allowed in XML attribute names
+
+ for (String columnName : listColumnNames) {
+ String internalColumnName = "ows_" + columnName.replace(" ", "_x0020_");
+ if (attributes.getNamedItem(internalColumnName) != null) {
+ rowList.add(attributes.getNamedItem(internalColumnName).getNodeValue());
+ } else {
+ // TODO create better exception handling
+ throw new JAXBException("Couldn't find the '" + columnName + "' column in the '" + listName + "' list in SharePoint.\n");
+ }
+ }
+ returnList.add(rowList);
+ }
}
}
}
+ return returnList; // TODO either return null or return empty lists, currently handled differently
}
- public void addListItem(String listName, Map data) throws NoSuchAlgorithmException, KeyManagementException, JAXBException,
- MalformedURLException, SAXException, ParserConfigurationException, IOException {
- List