diff --git a/sharepoint/api/pom.xml b/sharepoint/api/pom.xml index 1eaabda..801969c 100644 --- a/sharepoint/api/pom.xml +++ b/sharepoint/api/pom.xml @@ -149,7 +149,21 @@ search.wsdl - + + + usergroup2010 + generate-sources + + wsimport + + + com.microsoft.schemas.sharepoint.soap.usergroup + ${basedir}/src/main/resources/2010/wsdl + + usergroup.wsdl + + + @@ -210,7 +224,30 @@ lists.xml true - + + + + + usergroup + + xjc + + + + ${basedir}/src/main/resources/xsd + + usergroup.xsd + + de.muehlencord.shared.sharepoint.api.usergroup + + ${project.build.directory}/generated-sources/jaxb/ + true + + ${basedir}/src/main/resources/jaxb + usergroup.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 254956d..461974a 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 @@ -24,6 +24,7 @@ import org.xml.sax.SAXException; /** * * @author joern.muehlencord + * @param */ public abstract class SPJaxbObject extends SPObject { @@ -34,13 +35,8 @@ public abstract class SPJaxbObject extends SPObject { */ private static final String packages = "" // + "de.muehlencord.shared.sharepoint.api.batch" // - + ":de.muehlencord.shared.sharepoint.api.lists"; // - // + ":de.muehlencord.shared.sharepoint.api.sites" // - // + ":com.microsoft.schemas.sharepoint.soap.alerts" // - // + ":com.microsoft.schemas.sharepoint.soap.authentication" // -// + ":com.microsoft.schemas.sharepoint.soap.lists" // -// + ":com.microsoft.schemas.sharepoint.soap.sites" // -// + ":com.microsoft.schemas.sharepoint.soap.webs"; + + ":de.muehlencord.shared.sharepoint.api.lists" // + + ":de.muehlencord.shared.sharepoint.api.usergroup"; // public static JAXBContext getJaxbContext() throws JAXBException { if (jaxbContext == null) { @@ -79,8 +75,7 @@ public abstract class SPJaxbObject extends SPObject { } schema = sf.newSchema(streamSources); } catch (Exception ex) { - ex.printStackTrace(); // TODO add error handling - // throw new SAXException ("Cannot convert to object. Reason: "+ex.getMessage(), ex); + 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/SPObject.java b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/SPObject.java index 400651c..b186750 100644 --- a/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/SPObject.java +++ b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/SPObject.java @@ -10,6 +10,7 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Document; +import org.w3c.dom.Node; /** * @@ -56,5 +57,35 @@ public abstract class SPObject { } return returnString; } + + /** + * Creates a string from an XML file with start and end indicators + * + * @param node node to convert + * @return string of the xml document + */ + public static String xmlToString(Node node) { + String returnString = ""; + try { + //create string from xml tree + //Output the XML + //set up a transformer + TransformerFactory transfac = TransformerFactory.newInstance(); + Transformer trans; + trans = transfac.newTransformer(); + trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); + trans.setOutputProperty(OutputKeys.INDENT, "yes"); + StringWriter sw = new StringWriter(); + StreamResult streamResult = new StreamResult(sw); + DOMSource source = new DOMSource(node); + trans.transform(source, streamResult); + String xmlString = sw.toString(); + //print the XML + returnString = returnString + xmlString; + } catch (TransformerException ex) { + Logger.getLogger(SPObject.class.getName()).log(Level.SEVERE, null, ex); + } + return returnString; + } } 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 a0ce5fe..5ce7d22 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 @@ -37,11 +37,9 @@ import org.xml.sax.SAXException; */ public class SPList extends SPJaxbObject { - private String listName = null; - public SPList(SPContext context, String listName) throws JAXBException { super(List.class, context); - getValue().name = listName; + getValue().name = listName; } @Override @@ -53,11 +51,17 @@ public class SPList extends SPJaxbObject { /* *** list information *** */ - public String getListName() { return getValue().name; } + public String getListTitle() throws NoSuchAlgorithmException, KeyManagementException, JAXBException, MalformedURLException, SAXException { + if (getValue().title == null) { + getListFromSharepoint(); + } + return getValue().title; + } + /* *** queries *** */ public java.util.List> getListItems(java.util.List listColumnNames, String rowLimit) throws NoSuchAlgorithmException, KeyManagementException, JAXBException, MalformedURLException, @@ -98,7 +102,7 @@ public class SPList extends SPJaxbObject { 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"); + throw new JAXBException("Couldn't find the '" + columnName + "' column in the '" + getValue().name + "' list in SharePoint.\n"); } } returnList.add(rowList); @@ -111,14 +115,14 @@ public class SPList extends SPJaxbObject { /* *** manipulating list items *** */ - public void addListItem(String listName, Map data) throws NoSuchAlgorithmException, KeyManagementException, + public void addListItem(Map data) throws NoSuchAlgorithmException, KeyManagementException, JAXBException, MalformedURLException, SAXException, ParserConfigurationException, IOException { java.util.List> dataList = new LinkedList<>(); dataList.add(data); - addListItems(listName, dataList); + addListItems(dataList); } - public void addListItems(String listName, java.util.List> dataList) throws NoSuchAlgorithmException, + public void addListItems(java.util.List> dataList) throws NoSuchAlgorithmException, KeyManagementException, JAXBException, MalformedURLException, SAXException, ParserConfigurationException, IOException { SPBatch batch = new SPBatch(getContext()); @@ -143,7 +147,8 @@ public class SPList extends SPJaxbObject { UpdateListItems.Updates updates = new UpdateListItems.Updates(); Node node = batch.createSharePointCAMLNode(); updates.getContent().add(node); - getListsPort().updateListItems(listName, updates); + + getListsPort().updateListItems(getValue().name, updates); } /* *** information & tools *** */ @@ -175,7 +180,7 @@ public class SPList extends SPJaxbObject { public String getColumnNameByDisplayName(String columnDisplayName) throws NoSuchAlgorithmException, KeyManagementException, JAXBException, MalformedURLException, SAXException { if (getValue().fields == null) { - getListFromSharepoint(getValue().name); + getListFromSharepoint(); } Fields fields = getValue().fields; @@ -187,7 +192,15 @@ public class SPList extends SPJaxbObject { return null; } + public int getItemCount() throws NoSuchAlgorithmException, + KeyManagementException, JAXBException, MalformedURLException, SAXException { + + // refresh list to have current value + getListFromSharepoint(); + return getValue().itemCount; + } /* *** private helper methods *** */ + private ListsSoap getListsPort() throws NoSuchAlgorithmException, KeyManagementException, MalformedURLException { java.net.URL contextURL = getContext().getSiteURL(); java.net.URL wsURL = new java.net.URL(contextURL.toString() + "/_vti_bin/Lists.asmx"); @@ -204,11 +217,9 @@ public class SPList extends SPJaxbObject { return listsPort; } - /* - private void getValueFromSharepoint() throws NoSuchAlgorithmException, KeyManagementException, JAXBException, MalformedURLException, SAXException { - - GetListResponse.GetListResult result = getListsPort().getList(listName); - + private void getListFromSharepoint() throws NoSuchAlgorithmException, KeyManagementException, JAXBException, MalformedURLException, + SAXException { + GetListResponse.GetListResult result = getListsPort().getList(getValue().name); if (result.getContent() != null) { for (Object content : result.getContent()) { // TODO - handdling more than one result / should not occur @@ -216,29 +227,11 @@ public class SPList extends SPJaxbObject { // Parse XML file Element rootElement = (Element) content; String listsString = SPObject.xmlToString(rootElement.getOwnerDocument()); - System.out.println (listsString); this.setValue(listsString); } } } } - */ - - private void getListFromSharepoint(String listName) throws NoSuchAlgorithmException, KeyManagementException, JAXBException, MalformedURLException, SAXException { - GetListResponse.GetListResult result = getListsPort().getList(listName); - if (result.getContent() != null) { - for (Object content : result.getContent()) { - // TODO - handdling more than one result / should not occur - if (content instanceof Element) { - // Parse XML file - Element rootElement = (Element) content; - String listsString = SPObject.xmlToString(rootElement.getOwnerDocument()); - System.out.println(listsString); - this.setValue(listsString); - } - } - } - } /* *** unsorted *** */ } diff --git a/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/usergroup/SPUser.java b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/usergroup/SPUser.java new file mode 100644 index 0000000..fd31a2c --- /dev/null +++ b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/usergroup/SPUser.java @@ -0,0 +1,53 @@ +package de.muehlencord.shared.sharepoint.api.usergroup; + +import de.muehlencord.shared.sharepoint.api.SPContext; +import de.muehlencord.shared.sharepoint.api.SPJaxbObject; +import java.util.ArrayList; +import javax.xml.bind.JAXBException; + +/** + * + * @author joern.muehlencord + */ +public class SPUser extends SPJaxbObject { + + public SPUser(SPContext context) throws JAXBException { + super(User.class, context); + } + + @Override + protected java.util.List getSchemaLocation() { + java.util.List schemaList = new ArrayList(); + schemaList.add("/xsd/usergroup.xsd"); + return schemaList; + } + + + public String getUserID() { + return getValue().id.toString(); + } + + public String getUserName() { + return getValue().name; + } + + public String getUserLoginName() { + return getValue().loginName; + } + + public String getUserEmail() { + return getValue().email; + } + + public String getUserNotes() { + return getValue().notes; + } + +} + +/** + * History: + * + * $$Log$$ + * + */ diff --git a/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/usergroup/SPUserGroup.java b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/usergroup/SPUserGroup.java new file mode 100644 index 0000000..9bdad63 --- /dev/null +++ b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/usergroup/SPUserGroup.java @@ -0,0 +1,90 @@ +package de.muehlencord.shared.sharepoint.api.usergroup; + +import com.microsoft.schemas.sharepoint.soap.usergroup.GetUserInfoResponse; +import com.microsoft.schemas.sharepoint.soap.usergroup.UserGroup; +import com.microsoft.schemas.sharepoint.soap.usergroup.UserGroupSoap; +import de.muehlencord.shared.sharepoint.api.SPContext; +import de.muehlencord.shared.sharepoint.api.SPObject; +import de.muehlencord.shared.sharepoint.api.ServiceLogHandler; +import java.io.IOException; +import java.net.MalformedURLException; +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; +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.xml.sax.SAXException; + +/** + * + * @author joern.muehlencord + */ +public class SPUserGroup extends SPObject { + + public SPUserGroup(SPContext context) { + super(context); + } + + public void addUserToGroup(String userLoginName, String groupName) throws JAXBException, SAXException, ParserConfigurationException, + NoSuchAlgorithmException, IOException, KeyManagementException { + SPUser user = getUser(userLoginName); + if (user == null) { + throw new SAXException ("User not found"); + } + getUserGroupPort().addUserToGroup(groupName, user.getUserName(), user.getUserLoginName(), user.getUserEmail(), user.getUserNotes()); + } + + public String getUserId(String userLoginName) throws NoSuchAlgorithmException, KeyManagementException, MalformedURLException, JAXBException, SAXException { + SPUser user = getUser(userLoginName); + if (user == null) { + return null; + } else { + return user.getUserID(); + } + } + + private SPUser getUser(String userLoginName) throws NoSuchAlgorithmException, KeyManagementException, MalformedURLException, JAXBException, SAXException { + GetUserInfoResponse.GetUserInfoResult result = getUserGroupPort().getUserInfo("i:0#.w|" + userLoginName); + // TODO why is i:0#.w| in front? + + if (result.getContent() != null) { + for (Object content : result.getContent()) { + // TODO - handdling more than one result / should not occur + // Parse XML file + Element rootElement = (Element) content; + String userString = SPObject.xmlToString(rootElement.getFirstChild()); + SPUser user = new SPUser(getContext()); + user.setValue(userString); + return user; + } + } + return null; // not found, return null + } + + private UserGroupSoap getUserGroupPort() throws NoSuchAlgorithmException, KeyManagementException, MalformedURLException { + java.net.URL contextURL = getContext().getSiteURL(); + java.net.URL wsURL = new java.net.URL(contextURL.toString() + "_vti_bin/usergroup.asmx"); + java.net.URL wsdlURL = new java.net.URL(SPContext.class.getResource("/2010/wsdl/usergroup.wsdl").toExternalForm()); + UserGroup service = new UserGroup(wsdlURL); + UserGroupSoap userGroupPort = service.getUserGroupSoap(); + ((BindingProvider) userGroupPort).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, wsURL.toString()); + + // log all incoming and outgoing communication - TODO make this configurable by DEBUG switch + java.util.List handlers = ((BindingProvider) userGroupPort).getBinding().getHandlerChain(); + handlers.add(new ServiceLogHandler()); + ((BindingProvider) userGroupPort).getBinding().setHandlerChain(handlers); + + return userGroupPort; + } + + /* *** unsorted *** */ +} + +/** + * History: + * + * $$Log$$ + * + */ diff --git a/sharepoint/api/src/main/resources/2010/wsdl/usergroup.wsdl b/sharepoint/api/src/main/resources/2010/wsdl/usergroup.wsdl new file mode 100644 index 0000000..0f8c651 --- /dev/null +++ b/sharepoint/api/src/main/resources/2010/wsdl/usergroup.wsdl @@ -0,0 +1,1926 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sharepoint/api/src/main/resources/jaxb/usergroup.xml b/sharepoint/api/src/main/resources/jaxb/usergroup.xml new file mode 100644 index 0000000..5b75c82 --- /dev/null +++ b/sharepoint/api/src/main/resources/jaxb/usergroup.xml @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/sharepoint/api/src/main/resources/xsd/list.xsd b/sharepoint/api/src/main/resources/xsd/list.xsd index ff138f9..dc8486a 100644 --- a/sharepoint/api/src/main/resources/xsd/list.xsd +++ b/sharepoint/api/src/main/resources/xsd/list.xsd @@ -8,8 +8,8 @@ - - + + @@ -27,7 +27,7 @@ - + @@ -52,13 +52,13 @@ - + - + @@ -168,18 +168,44 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -187,15 +213,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -206,26 +256,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -245,7 +394,8 @@ - + + @@ -253,6 +403,7 @@ + @@ -274,6 +425,19 @@ + + + + + + + + + + + + + @@ -335,7 +499,7 @@ - + @@ -369,22 +533,30 @@ + - - - + + + + + + - + + + + + @@ -565,5 +737,4 @@ - diff --git a/sharepoint/api/src/main/resources/xsd/usergroup.xsd b/sharepoint/api/src/main/resources/xsd/usergroup.xsd new file mode 100644 index 0000000..2e251ee --- /dev/null +++ b/sharepoint/api/src/main/resources/xsd/usergroup.xsd @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sharepoint/api/src/test/java/de/muehlencord/shared/sharepoint/api/lists/SPListTest.java b/sharepoint/api/src/test/java/de/muehlencord/shared/sharepoint/api/lists/SPListTest.java index a0dd1ca..12309b6 100644 --- a/sharepoint/api/src/test/java/de/muehlencord/shared/sharepoint/api/lists/SPListTest.java +++ b/sharepoint/api/src/test/java/de/muehlencord/shared/sharepoint/api/lists/SPListTest.java @@ -11,6 +11,7 @@ import javax.xml.bind.JAXBException; import javax.xml.parsers.ParserConfigurationException; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import org.junit.Ignore; import org.junit.Test; import org.xml.sax.SAXException; @@ -35,18 +36,24 @@ public class SPListTest extends BaseTest { IOException { SPLists instance = new SPLists(context); - SPList list = instance.getSpListByTitle("Count"); + SPList list = instance.getSpListByTitle("Test"); assertNotNull(list); String listName = list.getListName(); assertEquals("Listname", "{D8C8D97E-1065-4674-A8F2-026D6D478794}", listName); + // get list of all country codes + java.util.List columns = new ArrayList<>(); + columns.add("Title"); + columns.add("ID"); + java.util.List> countryCodes = list.getListItems(columns, "300"); + Map data = new HashMap<>(); data.put("Title", "Test"); data.put("Choice", "Enter Choice #1"); // is not checked, possible to add wrong value data.put("Country", "357;#DE"); // reference taken from testGetLookupValuesMap data.put("Number", "17"); // is validating data.put("Lines", "Long text
with line breaks"); // line breaks using
- list.addListItem(listName, data); + list.addListItem(data); } @Test @@ -81,7 +88,7 @@ public class SPListTest extends BaseTest { data.put(list.getColumnNameByDisplayName("IbaseOldApplication"), "0"); data.put(list.getColumnNameByDisplayName("MaintenanceContract"), "none"); data.put(list.getColumnNameByDisplayName("Comments"), "This is a test"); - list.addListItem(listName, data); + list.addListItem(data); } @Test @@ -118,6 +125,13 @@ public class SPListTest extends BaseTest { SPLists instance = new SPLists(context); SPList list = instance.getSpListByTitle("Questionnaire"); assertEquals ("Displayname of Current OS", "Current_x0020_OS", list.getColumnNameByDisplayName("Current OS")); - + } + + @Test + @Ignore // Depends on available sharepoint currently + public void testGetItemCount() throws Exception { + SPLists instance = new SPLists(context); + SPList list = instance.getSpListByTitle("Questionnaire"); + assertTrue (list.getItemCount() > 0); } } diff --git a/sharepoint/api/src/test/java/de/muehlencord/shared/sharepoint/api/usergroup/SPUserGroupTest.java b/sharepoint/api/src/test/java/de/muehlencord/shared/sharepoint/api/usergroup/SPUserGroupTest.java new file mode 100644 index 0000000..8186a49 --- /dev/null +++ b/sharepoint/api/src/test/java/de/muehlencord/shared/sharepoint/api/usergroup/SPUserGroupTest.java @@ -0,0 +1,39 @@ +package de.muehlencord.shared.sharepoint.api.usergroup; + +import de.muehlencord.shared.sharepoint.api.BaseTest; +import static de.muehlencord.shared.sharepoint.api.BaseTest.readFileContentFromTest; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import org.junit.Ignore; +import org.junit.Test; + +/** + * + * @author joern.muehlencord + */ +public class SPUserGroupTest extends BaseTest { + + @Test + public void testFromXML() throws Exception { + String xmlString = readFileContentFromTest("usergroups/user.xml", "UTF-8"); + SPUser user = new SPUser(context); + assertNotNull(xmlString); + user.setValue(xmlString); + } + + @Test + @Ignore // Depends on available sharepoint currently + public void testGetUserInfo() throws Exception { + SPUserGroup ug = new SPUserGroup(context); + String userId = ug.getUserId("wincor-nixdorf\\joern.muehlencord"); + assertEquals("Userid", "16", userId); + } + + @Test + @Ignore // Depends on available sharepoint currently + public void testAddUserToGroup() throws Exception { + SPUserGroup ug = new SPUserGroup(context); + ug.addUserToGroup("wincor-nixdorf\\joern.muehlencord", "Test Group"); + } + +} diff --git a/sharepoint/api/src/test/resources/de/muehlencord/shared/sharepoint/api/usergroups/user.xml b/sharepoint/api/src/test/resources/de/muehlencord/shared/sharepoint/api/usergroups/user.xml new file mode 100644 index 0000000..889cba7 --- /dev/null +++ b/sharepoint/api/src/test/resources/de/muehlencord/shared/sharepoint/api/usergroups/user.xml @@ -0,0 +1,2 @@ + +