added updateListItems support

This commit is contained in:
jomu
2015-02-09 12:16:48 +00:00
parent d6f0e6cb8b
commit 59f71fcbda
4 changed files with 47 additions and 5 deletions

View File

@ -0,0 +1,33 @@
package de.muehlencord.shared.sharepoint.api;
import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.util.Date;
/**
*
* @author joern.muehlencord
*/
public class SPHelper {
private static final SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
private static final SimpleDateFormat dateOnlyFormat = new SimpleDateFormat("yyyy-MM-dd");
/* -- Format for Date Only Field -- */
public static String toSPDate(Date d) {
if (d == null) {
return "";
}
return dateOnlyFormat.format(d);
}
/* -- Format for DateTime Field -- */
private static String toSPDateAndTime(Date d) {
if (d == null) {
return "";
}
return dateTimeFormat.format(d);
}
}

View File

@ -10,15 +10,11 @@ import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException; import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller; import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller; import javax.xml.bind.Unmarshaller;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema; import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory; import javax.xml.validation.SchemaFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
/** /**

View File

@ -160,6 +160,19 @@ public class SPList extends SPJaxbObject<List> {
} }
public void updateListItem(Map<String, String> data) throws JAXBException, ParserConfigurationException, NoSuchAlgorithmException,
SAXException, KeyManagementException, IOException {
java.util.List<Map<String, String>> dataList = new ArrayList<>();
dataList.add(data);
updateListItems(dataList);
}
public void updateListItems(java.util.List<Map<String, String>> dataList) throws JAXBException, ParserConfigurationException, NoSuchAlgorithmException,
SAXException, KeyManagementException, IOException {
SPBatch batch = createBatch(dataList, MethodType.UPDATE);
executeUpdate(batch);
}
public void removeListItem(Map<String, String> dataMap) throws JAXBException, ParserConfigurationException, NoSuchAlgorithmException, public void removeListItem(Map<String, String> dataMap) throws JAXBException, ParserConfigurationException, NoSuchAlgorithmException,
SAXException, KeyManagementException, IOException { SAXException, KeyManagementException, IOException {
java.util.List<Map<String, String>> dataList = new ArrayList<>(); java.util.List<Map<String, String>> dataList = new ArrayList<>();

View File

@ -44,7 +44,7 @@ public class SPLists extends SPJaxbObject<de.muehlencord.shared.sharepoint.api.l
if (this.getValue().lists == null) { if (this.getValue().lists == null) {
getValueFromSharepoint(); getValueFromSharepoint();
} }
List list = getListByTitle(listName); List list = getListByTitle(listName); // TODO throw exception if not found
SPList returnList = new SPList(getContext(), listName); SPList returnList = new SPList(getContext(), listName);
returnList.setValue(list); returnList.setValue(list);