added support for users

enhanced list capabilities
This commit is contained in:
jomu
2015-02-04 21:33:27 +00:00
parent b77d6f69ba
commit 586191d078
13 changed files with 2453 additions and 66 deletions

View File

@ -150,6 +150,20 @@
</wsdlFiles>
</configuration>
</execution>
<execution>
<id>usergroup2010</id>
<phase>generate-sources</phase>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<packageName>com.microsoft.schemas.sharepoint.soap.usergroup</packageName>
<wsdlDirectory>${basedir}/src/main/resources/2010/wsdl</wsdlDirectory>
<wsdlFiles>
<wsdlFile>usergroup.wsdl</wsdlFile>
</wsdlFiles>
</configuration>
</execution>
</executions>
</plugin>
@ -211,6 +225,29 @@
<extension>true</extension>
</configuration>
</execution>
<!-- user/group definition, returned by sharepoint when calling usergroup service -->
<execution>
<id>usergroup</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<!-- The schema directory or xsd files. -->
<schemaDirectory>${basedir}/src/main/resources/xsd</schemaDirectory>
<!-- the file to read -->
<schemaFiles>usergroup.xsd</schemaFiles>
<!-- The package in which the source files will be generated. -->
<packageName>de.muehlencord.shared.sharepoint.api.usergroup</packageName>
<!-- The working directory to create the generated java source files. -->
<outputDirectory>${project.build.directory}/generated-sources/jaxb/</outputDirectory>
<removeOldOutput>true</removeOldOutput>
<!-- bindings to use -->
<bindingDirectory>${basedir}/src/main/resources/jaxb</bindingDirectory>
<bindingFiles>usergroup.xml</bindingFiles>
<extension>true</extension>
</configuration>
</execution>
</executions>
</plugin>
</plugins>

View File

@ -24,6 +24,7 @@ import org.xml.sax.SAXException;
/**
*
* @author joern.muehlencord
* @param <T>
*/
public abstract class SPJaxbObject<T> extends SPObject {
@ -34,13 +35,8 @@ public abstract class SPJaxbObject<T> 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<T> 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;
}

View File

@ -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;
/**
*
@ -57,4 +58,34 @@ 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;
}
}

View File

@ -37,8 +37,6 @@ import org.xml.sax.SAXException;
*/
public class SPList extends SPJaxbObject<List> {
private String listName = null;
public SPList(SPContext context, String listName) throws JAXBException {
super(List.class, context);
getValue().name = listName;
@ -53,11 +51,17 @@ public class SPList extends SPJaxbObject<List> {
/* *** 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<java.util.List<String>> getListItems(java.util.List<String> listColumnNames, String rowLimit) throws NoSuchAlgorithmException,
KeyManagementException, JAXBException, MalformedURLException,
@ -98,7 +102,7 @@ public class SPList extends SPJaxbObject<List> {
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<List> {
/* *** manipulating list items *** */
public void addListItem(String listName, Map<String, String> data) throws NoSuchAlgorithmException, KeyManagementException,
public void addListItem(Map<String, String> data) throws NoSuchAlgorithmException, KeyManagementException,
JAXBException, MalformedURLException, SAXException, ParserConfigurationException, IOException {
java.util.List<Map<String, String>> dataList = new LinkedList<>();
dataList.add(data);
addListItems(listName, dataList);
addListItems(dataList);
}
public void addListItems(String listName, java.util.List<Map<String, String>> dataList) throws NoSuchAlgorithmException,
public void addListItems(java.util.List<Map<String, String>> dataList) throws NoSuchAlgorithmException,
KeyManagementException, JAXBException, MalformedURLException, SAXException, ParserConfigurationException, IOException {
SPBatch batch = new SPBatch(getContext());
@ -143,7 +147,8 @@ public class SPList extends SPJaxbObject<List> {
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<List> {
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<List> {
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<List> {
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,24 +227,6 @@ public class SPList extends SPJaxbObject<List> {
// 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);
}
}

View File

@ -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<User> {
public SPUser(SPContext context) throws JAXBException {
super(User.class, context);
}
@Override
protected java.util.List getSchemaLocation() {
java.util.List<String> 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$$
*
*/

View File

@ -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<Handler> handlers = ((BindingProvider) userGroupPort).getBinding().getHandlerChain();
handlers.add(new ServiceLogHandler());
((BindingProvider) userGroupPort).getBinding().setHandlerChain(handlers);
return userGroupPort;
}
/* *** unsorted *** */
}
/**
* History:
*
* $$Log$$
*
*/

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<jxb:bindings version="1.0" xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
jxb:extensionBindingPrefixes="xjc">
<jxb:bindings schemaLocation="../xsd/usergroup.xsd"
node="/xs:schema">
<jxb:globalBindings>
<xjc:simple />
<xjc:serializable uid="100" />
</jxb:globalBindings>
</jxb:bindings>
</jxb:bindings>

View File

@ -27,7 +27,7 @@
<xs:attribute name="EnablePeopleSelector" use="required" type="xs:string"/>
<xs:attribute name="EnableResourceSelector" use="required" type="xs:string"/>
<xs:attribute name="EnableVersioning" use="required" type="xs:string"/>
<xs:attribute name="EnforceDataValidation" use="required" type="xs:string"/>
<xs:atetribute name="EnforceDataValidation" use="required" type="xs:string"/>
<xs:attribute name="EventSinkAssembly" use="required"/>
<xs:attribute name="EventSinkClass" use="required"/>
<xs:attribute name="EventSinkData" use="required"/>
@ -168,18 +168,44 @@
<xs:element name="ServerRelativeUrl" type="xs:string"/>
<xs:element name="Field">
<xs:complexType>
<xs:sequence>
<xs:sequence minOccurs="0">
<xs:element ref="soap:CHOICES"/>
<xs:element ref="soap:Default"/>
</xs:sequence>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:choice>
<xs:element minOccurs="0" ref="soap:CHOICES"/>
<xs:element minOccurs="0" ref="soap:Default"/>
</xs:choice>
<xs:element minOccurs="0" ref="soap:FieldRefs"/>
<xs:element minOccurs="0" ref="soap:DisplayPattern"/>
</xs:sequence>
<xs:attribute name="AppendOnly" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="TRUE" />
<xs:enumeration value="FALSE" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="AuthoringInfo"/>
<xs:attribute name="AllowDuplicateValues" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="TRUE" />
<xs:enumeration value="FALSE" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="CalloutMenu" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="TRUE" />
<xs:enumeration value="FALSE" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="CanToggleHidden" type="xs:string"/>
<xs:attribute name="ClassInfo" type="xs:string"/>
<xs:attribute name="ColName" type="xs:string"/>
<xs:attribute name="ColName2" type="xs:string" use="optional"/>
<xs:attribute name="Decimals" type="xs:int" use="optional"/>
<xs:attribute name="Description"/>
<xs:attribute name="Dir"/>
<xs:attribute name="DisplaceOnUpgrade" type="xs:string"/>
@ -187,15 +213,39 @@
<xs:attribute name="DisplayNameSrcField" type="xs:string"/>
<xs:attribute name="EnableLookup" type="xs:string"/>
<xs:attribute name="EnforceUniqueValues" type="xs:string"/>
<xs:attribute name="FillInChoice" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="TRUE" />
<xs:enumeration value="FALSE" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="FieldRef" type="xs:string"/>
<xs:attribute name="Filterable" type="xs:string"/>
<xs:attribute name="Format" type="xs:string"/>
<xs:attribute name="FriendlyDisplayFormat" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Disabled" />
<xs:enumeration value="Enabled" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="FromBaseType" type="xs:string"/>
<xs:attribute name="Group" type="xs:string"/>
<xs:attribute name="HeaderImage" type="xs:string"/>
<xs:attribute name="Hidden" type="xs:string"/>
<xs:attribute name="ID"/>
<xs:attribute name="Indexed" type="xs:string"/>
<xs:attribute name="IsolateStyles" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="TRUE" />
<xs:enumeration value="FALSE" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="JoinColName" type="xs:string"/>
<xs:attribute name="JoinRowOrdinal" type="xs:int"/>
<xs:attribute name="JoinType" type="xs:string"/>
@ -206,26 +256,125 @@
<xs:attribute name="MaxLength" type="xs:int"/>
<xs:attribute name="Min" type="xs:int"/>
<xs:attribute name="Name" use="required" type="xs:string"/>
<xs:attribute name="NumLines" use="optional" type="xs:int"/>
<xs:attribute name="UserSelectionMode" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="PeopleOnly" />
<xs:enumeration value="PeopleAndGroup" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="UserSelectionScope" use="optional">
<xs:simpleType>
<xs:restriction base="xs:int">
<xs:enumeration value="0" />
<xs:enumeration value="1" />
<xs:enumeration value="2" />
<xs:enumeration value="3" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Percentage" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="TRUE" />
<xs:enumeration value="FALSE" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="RelationshipDeleteBehavior" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Restrict" />
<xs:enumeration value="Cascade" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="PIAttribute" type="xs:string"/>
<xs:attribute name="PITarget"/>
<xs:attribute name="PrimaryKey" type="xs:string"/>
<xs:attribute name="ReadOnly" type="xs:string"/>
<xs:attribute name="RenderXMLUsingPattern" type="xs:string"/>
<xs:attribute name="ReadOnlyEnforced" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="TRUE" />
<xs:enumeration value="FALSE" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Required" type="xs:string"/>
<xs:attribute name="ResultType" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="DateTime" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="RestrictedMode" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="TRUE" />
<xs:enumeration value="FALSE" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="RichText" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="TRUE" />
<xs:enumeration value="FALSE" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="RichTextMode" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Compatible" />
<xs:enumeration value="FullHtml" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="RowOrdinal" type="xs:int"/>
<xs:attribute name="Sealed" type="xs:string"/>
<xs:attribute name="SetAs" type="xs:string"/>
<xs:attribute name="ShowField" type="xs:string"/>
<xs:attribute name="ShowInEditForm" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="TRUE" />
<xs:enumeration value="FALSE" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="ShowInFileDlg" type="xs:string"/>
<xs:attribute name="ShowInVersionHistory" type="xs:string"/>
<xs:attribute name="ShowInViewForm" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="TRUE" />
<xs:enumeration value="FALSE" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Sortable" type="xs:string"/>
<xs:attribute name="SourceID" type="xs:anyURI"/>
<xs:attribute name="StaticName" type="xs:string"/>
<xs:attribute name="StorageTZ" type="xs:string"/>
<xs:attribute name="TextOnly" type="xs:string"/>
<xs:attribute name="Type" type="xs:string"/>
<xs:attribute name="UnlimitedLengthInDocumentLibrary" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="TRUE" />
<xs:enumeration value="FALSE" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="URLEncodeAsURL" type="xs:string"/>
<xs:attribute name="Version" type="xs:int"/>
<xs:attribute name="WebId" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="CHOICES">
@ -245,6 +394,7 @@
</xs:element>
<xs:element name="FieldRef">
<xs:complexType>
<xs:attribute name="ID" use="optional" type="xs:string"/>
<xs:attribute name="Name" use="required" type="xs:string"/>
</xs:complexType>
</xs:element>
@ -253,6 +403,7 @@
<xs:sequence>
<xs:element minOccurs="0" ref="soap:CurrentRights"/>
<xs:element minOccurs="0" ref="soap:HttpHost"/>
<xs:element minOccurs="0" ref="soap:Switch" />
<xs:choice>
<xs:element ref="soap:FieldSwitch"/>
<xs:element ref="soap:IfHasRights"/>
@ -274,6 +425,19 @@
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Switch" >
<xs:complexType>
<xs:sequence>
<xs:element ref="soap:Expr" />
<xs:element minOccurs="0" maxOccurs="unbounded" ref="soap:Case" />
<xs:element ref="soap:Default" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="CurrentRights">
<xs:complexType/>
</xs:element>
@ -369,22 +533,30 @@
</xs:choice>
</xs:complexType>
</xs:element>
<xs:element name="Case">
<xs:complexType>
<xs:choice>
<xs:element ref="soap:Column"/>
<xs:complexType mixed="true">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="soap:Field"/>
<xs:element ref="soap:FieldSwitch"/>
<xs:element ref="soap:GetVar"/>
<xs:element ref="soap:HTML"/>
<xs:element ref="soap:IfEqual"/>
<xs:element ref="soap:LookupColumn"/>
<xs:element maxOccurs="unbounded" ref="soap:GetVar"/>
<xs:element ref="soap:ScriptQuote"/>
<xs:element ref="soap:SetVar"/>
<xs:element ref="soap:Column"/>
</xs:choice>
<xs:attribute name="Value" use="required" type="xs:NMTOKEN"/>
</xs:complexType>
</xs:element>
<xs:element name="Expr">
<xs:complexType>
<xs:choice>
<xs:element ref="soap:GetVar"/>
<xs:element ref="soap:ListProperty"/>
<xs:element ref="soap:LookupColumn"/>
</xs:choice>
</xs:complexType>
</xs:element>
@ -565,5 +737,4 @@
</xs:complexType>
</xs:element>
</xs:schema>

View File

@ -0,0 +1,24 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/sharepoint/soap/directory/" xmlns:soap="http://schemas.microsoft.com/sharepoint/soap/directory/">
<xs:element name="Users">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" ref="soap:User"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="User">
<xs:complexType>
<xs:attribute name="Email" use="required"/>
<xs:attribute name="Flags" use="required" type="xs:integer"/>
<xs:attribute name="ID" use="required" type="xs:integer"/>
<xs:attribute name="IsDomainGroup" use="required" type="xs:NCName"/>
<xs:attribute name="IsSiteAdmin" use="required" type="xs:NCName"/>
<xs:attribute name="LoginName" use="required"/>
<xs:attribute name="Name" use="required"/>
<xs:attribute name="Notes" use="required"/>
<xs:attribute name="Sid" use="required"/>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@ -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<String> columns = new ArrayList<>();
columns.add("Title");
columns.add("ID");
java.util.List<java.util.List<String>> countryCodes = list.getListItems(columns, "300");
Map<String, String> 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<br>with line breaks"); // line breaks using <br>
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);
}
}

View File

@ -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");
}
}

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<User Email="Joern.Muehlencord@wincor-nixdorf.com" Flags="8" ID="16" IsDomainGroup="False" IsSiteAdmin="False" LoginName="i:0#.w|wincor-nixdorf\joern.muehlencord" Name="Muehlencord, Joern" Notes="" Sid="" xmlns="http://schemas.microsoft.com/sharepoint/soap/directory/"/>