User
The following methods are available for manipulating the user entity with the Entity API Service.
Note: The following imports are required for all of the Java code examples on this page.
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.pervasive.datasolutions.api.service.EntityAPIServiceLocator;
import com.pervasive.datasolutions.api.service.EntityAPIService;
import com.pervasive.datasolutions.api.crud.CloudAPIException;
import com.pervasive.datasolutions.api.crud.InvalidSessionException;
import com.pervasive.datasolutions.api.entity.*;
import com.pervasive.datasolutions.api.crud.*;
Tip... Use the
login method to start a session and obtain the sessionId parameter. See
Login and Logout.
listUsers
List the users associated with the current user. Always returns a one-item list.
Parameters
Returns
Example
SOAP Request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:crud="http://datasolutions.pervasive.com/api/crud">
<soapenv:Header/>
<soapenv:Body>
<crud:listUsers>
<firstResult>0</firstResult>
<maxResults>100</maxResults>
<sessionId>125003101222.7BEA.3DC4.0FDA.41CC.93F0.B130</sessionId>
</crud:listUsers>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:listUsersResponse xmlns:ns2="http://datasolutions.pervasive.com/api/crud" xmlns:ns3="http://datasolutions.pervasive.com/api/entity">
<return id="171">
<name>testuser</name>
<parameters>
<parameter key="membership.company">Test Company</parameter>
<parameter key="membership.firstname">Test</parameter>
<parameter key="awsAccessKey">ABCDEFGHIJKLMNOP</parameter>
</parameters>
</return>
</ns2:listUsersResponse>
</S:Body>
</S:Envelope>
Java Code Sample
final int firstResult = 0;
final int maxResults = 100;
final String sessionId = "125003101227.4253.DC58.5A73.4AC1.AED2.5687";
import java.util.List;
EntityAPIServiceLocator service = new EntityAPIServiceLocator();
EntityAPIService stub = service.getEntityAPIPort();
List<User> userList = stub.listUsers(firstResult, maxResults, sessionId);
listUsersByGroup
Lists the users that have access to the specified group.
Parameters
Returns
Example
SOAP Request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:crud="http://datasolutions.pervasive.com/api/crud">
<soapenv:Header/>
<soapenv:Body>
<crud:listUsersByGroup>
<firstResult>0</firstResult>
<maxResults>10</maxResults>
<id>163</id>
<sessionId>82f379ab-44e4-4d04-b0da-7c11404cfd99</sessionId>
</crud:listUsersByGroup>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:listUsersByGroupResponse xmlns:ns2="http://datasolutions.pervasive.com/api/crud" xmlns:ns3="http://datasolutions.pervasive.com/api/entity"/>
</S:Body>
</S:Envelope>
Java Code Sample
final int firstResult = 0;
final int maxResults = 100;
final Long id = 2;
final String sessionId = "125003101227.4253.DC58.5A73.4AC1.AED2.5687";
import java.util.List;
EntityAPIServiceLocator service = new EntityAPIServiceLocator();
EntityAPIService stub = service.getEntityAPIPort();
List<User> userList = stub.listUsersByGroup(firstResult, maxResults, id, sessionId);
findUser
Returns a user specified by ID. Must be the currently logged in user.
Parameters
Returns
Example
SOAP Request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:crud="http://datasolutions.pervasive.com/api/crud">
<soapenv:Header/>
<soapenv:Body>
<crud:findUser>
<id>171</id>
<sessionId>125003101223.6634.326B.C412.41CD.8643.4190</sessionId>
</crud:findUser>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:findUserResponse xmlns:ns2="http://datasolutions.pervasive.com/api/crud" xmlns:ns3="http://datasolutions.pervasive.com/api/entity">
<return id="171">
<name>testuser</name>
<parameters>
<parameter key="membership.company">Test Company</parameter>
<parameter key="membership.firstname">Test</parameter>
<parameter key="awsSecretKey">9wL7pG605I4E3iqJWo3En+KoIKYjv7sLmhz4skXn</parameter>
<parameter key="membership.email">test@test.com</parameter>
<parameter key="membership.lastname">User</parameter>
<parameter key="key">value</parameter>
<parameter key="membership.phone">123-456-7890</parameter>
<parameter key="awsAccessKey">NXVNVTZ4KKGZJ3OLNOCN</parameter>
</parameters>
</return>
</ns2:findUserResponse>
</S:Body>
</S:Envelope>
Java Code Sample
final Long id = 1138;
final String sessionId = "125003101227.4253.DC58.5A73.4AC1.AED2.5687";
EntityAPIServiceLocator service = new EntityAPIServiceLocator();
EntityAPIService stub = service.getEntityAPIPort();
User user = stub.findUser(id, sessionId);
editUser
Edit the currently logged in user. Only parameters can be modified.
Parameters
Example
SOAP Request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:crud="http://datasolutions.pervasive.com/api/crud">
<soapenv:Header/>
<soapenv:Body>
<crud:editUser>
<user id="1362">
<owner id="171">testuser</owner>
<account>100</account>
<active>false</active>
<administrator>false</administrator>
<createdby>171</createdby>
<createddate>2011-11-02T00:00:00-04:00</createddate>
<deleted>false</deleted>
<group>163</group>
<lastmodifiedby>171</lastmodifiedby>
<lastmodifieddate>2011-11-01T00:00:00-04:00</lastmodifieddate>
<name>ds.test</name>
<parameters>
<!--Zero or more repetitions:-->
<parameter key="myuserKey" secure="no">myUSerValue</parameter>
</parameters>
<passwordexpiration>2012-11-01T00:00:00-04:00</passwordexpiration>
<temporarypassword>temp</temporarypassword>
</user>
<sessionId>82f379ab-44e4-4d04-b0da-7c11404cfd99</sessionId>
</crud:editUser>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:editUserResponse xmlns:ns2="http://datasolutions.pervasive.com/api/crud" xmlns:ns3="http://datasolutions.pervasive.com/api/entity"/>
</S:Body>
</S:Envelope>
Java Code Sample
final String sessionId = "125003101227.4253.DC58.5A73.4AC1.AED2.5687";
EntityAPIServiceLocator service = new EntityAPIServiceLocator();
EntityAPIService stub = service.getEntityAPIPort();
User edited
User = new User();
UserInfo uf=new UserInfo();
uf.setId(1138);
uf.set_value("testuser");
editedUser.setAccount((long) 1001);
editedUser.setActive(true);
editedUser.setAdministrator(true);
editedUser.setCreateddate((long) (2010-05-14));
editedUser.setDeleted(false);
editedUser.setId(12056);
editedUser.setLastmodifiedby(editedUser);
editedUser.setLastmodifieddate((long) (2010-05-14));
editedUser.setName("testuser");
editedUser.setOwner(uf);
editedUser.setPasswordexpiration((long) 109);
editedUser.setTemporarypassword(true);
editedUser.setGroup(2);
UserParameter[] parameter=new UserParameter[5];
parameter[0].setKey("ProductKey");
parameter[0].set_value("ProductValue");
parameter[0].setSecure(true);
editedUser.setParameters(parameter);
editedUser.setCreatedby(editedUser);
stub.editUser(editedUser, sessionId);
getUserCount
Count the users associated with the current user. Returns 1.
Parameters
Returns
Example
SOAP Request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:crud="http://datasolutions.pervasive.com/api/crud">
<soapenv:Header/>
<soapenv:Body>
<crud:getUserCount>
<sessionId>125003101222.7BEA.3DC4.0FDA.41CC.93F0.B130</sessionId>
</crud:getUserCount>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:getUserCountResponse xmlns:ns2="http://datasolutions.pervasive.com/api/crud" xmlns:ns3="http://datasolutions.pervasive.com/api/entity">
<return>1</return>
</ns2:getUserCountResponse>
</S:Body>
</S:Envelope>
Java Code Sample
final String sessionId = "125003101227.4253.DC58.5A73.4AC1.AED2.5687";
EntityAPIServiceLocator service = new EntityAPIServiceLocator();
EntityAPIService stub = service.getEntityAPIPort();
Long UserCount = stub.getUserCount(sessionId);
getUserParameter
Return the value of a parameter associated with a specified user.
Parameters
Returns
Example
SOAP Request
<soapenv:Envelope xmlns:soapenv="http:/
/schemas.xmlsoap.org/soap/envelope/" xmlns:crud="http://datasolutions.pervasive.com/api/crud">
<soapenv:Header/>
<soapenv:Body>
<crud:getUserParameter>
<id>171</id>
<key>ParameterKey</key>
<sessionId>125003101223.6634.326B.C412.41CD.8643.4190</sessionId>
</crud:getUserParameter>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:getUserParameterResponse xmlns:ns2="http://datasolutions.pervasive.com/api/crud" xmlns:ns3="http://datasolutions.pervasive.com/api/entity">
<return>User parameter value</return>
</ns2:getUserParameterResponse>
</S:Body>
</S:Envelope>
Java Code Sample
final Long id = 1138;
final String key = "ParameterKey";
final String sessionId = "125003101227.4253.DC58.5A73.4AC1.AED2.5687";
EntityAPIServiceLocator service = new EntityAPIServiceLocator();
EntityAPIService stub = service.getEntityAPIPort();
String UserParameter=stub.getUserParameter(id, key, sessionId);
putUserParameter
Store a key/value pair associated with a specified user.
Parameters
Returns
Example
SOAP Request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:crud="http://datasolutions.pervasive.com/api/crud">
<soapenv:Header/>
<soapenv:Body>
<crud:putUserParameter>
<id>171</id>
<key>userkey</key>
<value>uservalue</value>
<sessionId>125003101223.6634.326B.C412.41CD.8643.4190</sessionId>
</crud:putUserParameter>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:putUserParameterResponse xmlns:ns2="http://datasolutions.pervasive.com/api/crud" xmlns:ns3="http://datasolutions.pervasive.com/api/entity"/>
</S:Body>
</S:Envelope>
Java Code Sample
final Long id = 1138;
final String key = "myAccessKey";
final String value = "myAccessValue";
final String sessionId = "125003101227.4253.DC58.5A73.4AC1.AED2.5687";
EntityAPIServiceLocator service = new EntityAPIServiceLocator();
EntityAPIService stub = service.getEntityAPIPort();
String UserParameter=stub.putUserParameter(id, key, value, sessionId);
removeUserParameter
Remove a parameter from a specified user.
Parameters
Returns
Example
SOAP Request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:crud="http://datasolutions.pervasive.com/api/crud">
<soapenv:Header/>
<soapenv:Body>
<crud:removeUserParameter>
<id>171</id>
<key>userkey</key>
<sessionId>125003101227.4253.DC58.5A73.4AC1.AED2.5687</sessionId>
</crud:removeUserParameter>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:removeUserParameterResponse xmlns:ns2="http://datasolutions.pervasive.com/api/crud" xmlns:ns3="http://datasolutions.pervasive.com/api/entity">
<return>uservalue</return>
</ns2:removeUserParameterResponse>
</S:Body>
</S:Envelope>
Java Code Sample
final Long id = 1138;
final String key = "myAccessKey";
final String sessionId = "125003101227.4253.DC58.5A73.4AC1.AED2.5687";
EntityAPIServiceLocator service = new EntityAPIServiceLocator();
EntityAPIService stub = service.getEntityAPIPort();
String ParameterValue = stub.removeUserParameter(id, key, sessionId);
listUserFiles
List files associated with a specified user.
Parameters
Returns
Example
SOAP Request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:crud="http://datasolutions.pervasive.com/api/crud">
<soapenv:Header/>
<soapenv:Body>
<crud:listUserFiles>
<userId>171</userId>
<sessionId>125003101223.B2F3.63B7.6FA8.469B.9FDE.30AA</sessionId>
</crud:listUserFiles>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:listUserFilesResponse xmlns:ns2="http://datasolutions.pervasive.com/api/crud" xmlns:ns3="http://datasolutions.pervasive.com/api/entity">
<return>testfile</return>
</ns2:listUserFilesResponse>
</S:Body>
</S:Envelope>
Java Code Sample
final Long userId = 1138;
final String sessionId = "125003101227.4253.DC58.5A73.4AC1.AED2.5687";
import java.util.List;
EntityAPIServiceLocator service = new EntityAPIServiceLocator();
EntityAPIService stub = service.getEntityAPIPort();
List<String> Filelist = stub.listUserFiles(userId, sessionId);
getUserFile
Download a file associated with a specified user.
Parameters
Returns
Example
SOAP Request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:crud="http://datasolutions.pervasive.com/api/crud">
<soapenv:Header/>
<soapenv:Body>
<crud:getUserFile>
<userId>171</userId>
<filename>testfile</filename>
<sessionId>125003101223.B2F3.63B7.6FA8.469B.9FDE.30AA</sessionId>
</crud:getUserFile>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:getUserFileResponse xmlns:ns2="http://datasolutions.pervasive.com/api/crud" xmlns:ns3="http://datasolutions.pervasive.com/api/entity">
<return>cid1077498020307</return>
</ns2:getUserFileResponse>
</S:Body>
</S:Envelope>
Java Code Sample
final Long userId = 1138;
final String filename = "testfile";
final String sessionId = "125003101227.4253.DC58.5A73.4AC1.AED2.5687";
import javax.activation.DataHandler;
EntityAPIServiceLocator service = new EntityAPIServiceLocator();
EntityAPIService stub = service.getEntityAPIPort();
DataHandler fileHandlr = null;
fileHandlr = stub.getUserFile(userId, filename, sessionId);
putUserFile
Upload a file associated with a specified user.
Parameters
Returns
Example
SOAP Request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:crud="http://datasolutions.pervasive.com/api/crud">
<soapenv:Header/>
<soapenv:Body>
<crud:putUserFile>
<userId>171</userId>
<filename>test</filename>
<data>cid:173999292590</data>
<sessionId>125003101223.6634.326B.C412.41CD.8643.4190</sessionId>
</crud:putUserFile>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:putUserFileResponse xmlns:ns2="http://datasolutions.pervasive.com/api/crud" xmlns:ns3="http://datasolutions.pervasive.com/api/entity">
<return>9</return>
</ns2:putUserFileResponse>
</S:Body>
</S:Envelope>
Java Code Sample
final Long userId = 1138;
final String filename = "testfile";
final String sessionId = "125003101227.4253.DC58.5A73.4AC1.AED2.5687";
import javax.activation.DataHandler;
import javax.activation.DataSource;
EntityAPIServiceLocator service = new EntityAPIServiceLocator();
EntityAPIService stub = service.getEntityAPIPort();
Long size = 0L;
InputStream in= new FileInputStream(filename);
DataSource dataSource = new DataSource() {
@Override
public InputStream getInputStream() throws IOException {
return in;
}
@Override
public OutputStream getOutputStream() throws IOException {
return null;
}
@Override
public String getContentType() {
return "application/octet-stream";
}
@Override
public String getName() {
return filename;
}
};
DataHandler dataHandler = new DataHandler(dataSource);
size = stub.putUserFile(userId, filename, dataHandler, sessionId);
deleteUserFile
Delete a file associated with a specified user.
Parameters
Returns
Example
SOAP Request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:crud="http://datasolutions.pervasive.com/api/crud">
<soapenv:Header/>
<soapenv:Body>
<crud:deleteUserFile>
<userId>171</userId>
<filename>testfile</filename>
<sessionId>125003101223.B2F3.63B7.6FA8.469B.9FDE.30AA</sessionId>
</crud:deleteUserFile>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:deleteUserFileResponse xmlns:ns2="http://datasolutions.pervasive.com/api/crud" xmlns:ns3="http://datasolutions.pervasive.com/api/entity">
<return>10</return>
</ns2:deleteUserFileResponse>
</S:Body>
</S:Envelope>
Java Code Sample
final Long userId = 1138;
final String filename = "testfile";
final String sessionId = "125003101227.4253.DC58.5A73.4AC1.AED2.5687";
EntityAPIServiceLocator service = new EntityAPIServiceLocator();
EntityAPIService stub = service.getEntityAPIPort();
Long deletedBytes = stub.deleteUserFile(userId, filename, sessionId);