Group
The following methods are available for manipulating user groups 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.
listGroups
List the groups associated with the current 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:listGroups>
<firstResult>0</firstResult>
<maxResults>2</maxResults>
<sessionId>30fa4f5a-f67c-4ea0-a6a7-60f2e2c3f9c3</sessionId>
</crud:listGroups>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:listGroupsResponse xmlns:ns2="http://datasolutions.pervasive.com/api/crud" xmlns:ns3="http://datasolutions.pervasive.com/api/entity">
<return id="1" permissions="">
<owner id="1362">ds.test</owner>
<account>1</account>
<deleted>false</deleted>
<group>1</group>
<name>UnitTestGroup-1318948936722</name>
<parameters/>
<type>Test</type>
</return>
<return id="2" permissions="">
<owner id="1362">ds.test</owner>
<account>1</account>
<deleted>false</deleted>
<group>2</group>
<name>UnitTestGroup-1318971711237</name>
<parameters/>
<type>Test</type>
</return>
</ns2:listGroupsResponse>
</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<Group> groupList = stub. listGroups (firstResult, maxResults, sessionId);
findGroup
Return a 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:findGroup>
<id>1</id>
<sessionId>30fa4f5a-f67c-4ea0-a6a7-60f2e2c3f9c3</sessionId>
</crud:findGroup>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:findGroupResponse xmlns:ns2="http://datasolutions.pervasive.com/api/crud" xmlns:ns3="http://datasolutions.pervasive.com/api/entity">
<return id="1" permissions="">
<owner id="1362">ds.test</owner>
<account>1</account>
<deleted>false</deleted>
<group>1</group>
<name>UnitTestGroup-1318948936722</name>
<parameters>
<parameter secure="true" key="testparameter"/>
</parameters>
<type>Test</type>
</return>
</ns2:findGroupResponse>
</S:Body>
</S:Envelope>
Java Code Sample
final Long id = 11;
final String sessionId = "125003101222.7BEA.3DC4.0FDA.41CC.93F0.B130";
EntityAPIServiceLocator service = new EntityAPIServiceLocator();
EntityAPIService stub = service.getEntityAPIPort();
Group group = stub.findGroup (id, sessionId);
createGroup
Create a new group associated with the current user. This method only works for administrators.
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:createGroup>
<group permissions="" id="1">
<owner id="1362">ds.test</owner>
<account>1</account>
<createdby>1362</createdby>
<createddate>2011-11-2</createddate>
<deleted>false</deleted>
<group>1</group>
<lastmodifiedby>1362</lastmodifiedby>
<lastmodifieddate>2012-11-02</lastmodifieddate>
<name>UnitTestGroup-1318948936722</name>
<parameters>
<!--Zero or more repetitions:-->
<parameter key="testparameter" secure="true">testparametervalue</parameter>
</parameters>
<type>Test</type>
</group>
<sessionId>30fa4f5a-f67c-4ea0-a6a7-60f2e2c3f9c3</sessionId>
</crud:createGroup>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:createGroupResponse xmlns:ns2="http://datasolutions.pervasive.com/api/crud" xmlns:ns3="http://datasolutions.pervasive.com/api/entity">
<return id="350" permissions="">
<owner id="1362">ds.test</owner>
<account>1</account>
<createdby>1362</createdby>
<deleted>false</deleted>
<group>350</group>
<lastmodifiedby>1362</lastmodifiedby>
<name>UnitTestGroup-1318948936722</name>
<parameters>
<parameter secure="true" key="testparameter"/>
</parameters>
<type>Test</type>
</return>
</ns2:createGroupResponse>
</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();
Group newGroup = new Group();
User u = new User();
newGroup.setCreatedby(u);
newGroup.setCreateddate((long) (2010-05-14));
newGroup.setDeleted(true);
newGroup.setId(1);
newGroup.setLastmodifiedby(u);
newGroup.setLastmodifieddate((long) (2010-05-14));
newGroup.setName("testgroup");
newGroup.setGroup(2);
UserInfo uf = new UserInfo();
uf.setId(172);
uf.set_value("testuser");
newGroup.setOwner(uf);
GroupParameter[] gparameter=new GroupParameter[5];
gparameter[0].setKey("ProductKey");
gparameter[0].set_value("ProductValue");
gparameter[0].setSecure(true);
newGroup.setParameters(gparameter);
newGroup.setPermissions("READ");
newGroup.setType("grouptype");
Group newGroup = stub.createGroup(newGroup, sessionId);
editGroup
Edit a group associated with the current user.
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:editGroup>
<group permissions="?" id="1">
<owner id="1362">ds.test</owner>
<account>1</account>
<createdby>1362</createdby>
<createddate>2011-11-2</createddate>
<deleted>false</deleted>
<group>1</group>
<lastmodifiedby>1362</lastmodifiedby>
<lastmodifieddate>2012-11-2</lastmodifieddate>
<name>UnitTestGroup-1318948936722</name>
<parameters>
<!--Zero or more repetitions:-->
<parameter key="testparameter" secure="true">testparametervalue</parameter>
</parameters>
<type>Test</type>
</group>
<sessionId>30fa4f5a-f67c-4ea0-a6a7-60f2e2c3f9c3</sessionId>
</crud:editGroup>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:editGroupResponse 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();
Group editedGroup = new Group();
User u = new User();
editedGroup.setCreatedby(u);
editedGroup.setCreateddate((long) (2010-05-14));
editedGroup.setDeleted(true);
editedGroup.setId(1);
editedGroup.setLastmodifiedby(u);
editedGroup.setLastmodifieddate((long) (2010-05-14));
editedGroup.setName("testgroup");
UserInfo uf = new UserInfo();
uf.setId(172);
uf.set_value("testuser");
editedGroup.setOwner(uf);
editedGroup.setGroup(2);
GroupParameter[] gparameter=new GroupParameter[5];
gparameter[0].setKey("ProductKey");
gparameter[0].set_value("ProductValue");
gparameter[0].setSecure(true);
editedGroup.setParameters(gparameter);
editedGroup.setPermissions("READ");
editedGroup.setType("grouptype");
stub.editGroup(editedGroup, sessionId);
deleteGroup
Delete a specified group. This method only works for administrators.
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:deleteGroup>
<id>10</id>
<sessionId>30fa4f5a-f67c-4ea0-a6a7-60f2e2c3f9c3</sessionId>
</crud:deleteGroup>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:deleteGroupResponse 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 = 154;
final String sessionId = "125003101227.4253.DC58.5A73.4AC1.AED2.5687";
EntityAPIServiceLocator service = new EntityAPIServiceLocator();
EntityAPIService stub = service.getEntityAPIPort();
stub.deleteGroup(id, sessionId);
getGroupCount
Count the groups to which the current user has access.
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:getGroupCount>
<sessionId>30fa4f5a-f67c-4ea0-a6a7-60f2e2c3f9c3</sessionId>
</crud:getGroupCount>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:getGroupCountResponse xmlns:ns2="http://datasolutions.pervasive.com/api/crud" xmlns:ns3="http://datasolutions.pervasive.com/api/entity">
<return>103</return>
</ns2:getGroupCountResponse>
</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 groupCount = stub.getGroupCount(sessionId);
getGroupParameter
Return the value of a parameter associated with a 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:getGroupParameter>
<id>1</id>
<key>AccessKey</key>
<sessionId>30fa4f5a-f67c-4ea0-a6a7-60f2e2c3f9c3</sessionId>
</crud:getGroupParameter>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:getGroupParameterResponse xmlns:ns2="http://datasolutions.pervasive.com/api/crud" xmlns:ns3="http://datasolutions.pervasive.com/api/entity">
<return>AccessValue</return>
</ns2:getGroupParameterResponse>
</S:Body>
</S:Envelope>
Java Code Sample
final Long id = 150;
final String key = "AccessKey";
final String sessionId = "125003101227.4253.DC58.5A73.4AC1.AED2.5687";
EntityAPIServiceLocator service = new EntityAPIServiceLocator();
EntityAPIService stub = service.getEntityAPIPort();
String groupParameter = stub.getGroupParameter(id, key, sessionId);
putGroupParameter
Store a key/value pair associated with a 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:putGroupParameter>
<id>1</id>
<key>AccessKey</key>
<value>AccessValue</value>
<sessionId>30fa4f5a-f67c-4ea0-a6a7-60f2e2c3f9c3</sessionId>
</crud:putGroupParameter>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:putGroupParameterResponse xmlns:ns2="http://datasolutions.pervasive.com/api/crud" xmlns:ns3="http://datasolutions.pervasive.com/api/entity">
<return>oldAccessValue</return>
</ns2:putGroupParameterResponse>
</S:Body>
</S:Envelope>
Java Code Sample
final Long id = 150;
final String key = "AccessKey";
final String value = "AccessValue";
final String sessionId = "125003101227.4253.DC58.5A73.4AC1.AED2.5687";
EntityAPIServiceLocator service = new EntityAPIServiceLocator();
EntityAPIService stub = service.getEntityAPIPort();
String groupParameter = stub.putGroupParameter(id, key, value, sessionId);
removeGroupParameter
Remove a paramater associated with a 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:removeGroupParameter>
<id>1</id>
<key>AccessKey</key>
<sessionId>30fa4f5a-f67c-4ea0-a6a7-60f2e2c3f9c3</sessionId>
</crud:removeGroupParameter>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:removeGroupParameterResponse xmlns:ns2="http://datasolutions.pervasive.com/api/crud" xmlns:ns3="http://datasolutions.pervasive.com/api/entity">
<return>AccessValue</return>
</ns2:removeGroupParameterResponse>
</S:Body>
</S:Envelope>
Java Code Sample
final Long id = 150;
final String key = "AccessKey";
final String sessionId = "125003101227.4253.DC58.5A73.4AC1.AED2.5687";
EntityAPIServiceLocator service = new EntityAPIServiceLocator();
EntityAPIService stub = service.getEntityAPIPort();
String parameterValue = stub.removeGroupParameter(id, key, sessionId);
listGroupFiles
List files associated with a 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:listGroupFiles>
<id>1</id>
<sessionId>30fa4f5a-f67c-4ea0-a6a7-60f2e2c3f9c3</sessionId>
</crud:listGroupFiles>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:listGroupFilesResponse xmlns:ns2="http://datasolutions.pervasive.com/api/crud" xmlns:ns3="http://datasolutions.pervasive.com/api/entity">
<return>test</return>
</ns2:listGroupFilesResponse>
</S:Body>
</S:Envelope>
Java Code Sample
final Long id = 150;
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.listGroupFiles(id, sessionId);
getGroupFile
Download a file associated with a 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:getGroupFile>
<id>1</id>
<filename>test</filename>
<sessionId>30fa4f5a-f67c-4ea0-a6a7-60f2e2c3f9c3</sessionId>
</crud:getGroupFile>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:getGroupFileResponse xmlns:ns2="http://datasolutions.pervasive.com/api/crud" xmlns:ns3="http://datasolutions.pervasive.com/api/entity">
<return>cid301216703</return>
</ns2:getGroupFileResponse>
</S:Body>
</S:Envelope>
Java Code Sample
final Long id = 150;
final String filename = "testgroupfile";
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.getGroupFile(id, filename, sessionId);
putGroupFile
Upload a file associated with a 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:putGroupFile>
<id>1</id>
<filename>test</filename>
<data>cid:301216703454</data>
<sessionId>30fa4f5a-f67c-4ea0-a6a7-60f2e2c3f9c3</sessionId>
</crud:putGroupFile>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:putGroupFileResponse xmlns:ns2="http://datasolutions.pervasive.com/api/crud" xmlns:ns3="http://datasolutions.pervasive.com/api/entity">
<return>9</return>
</ns2:putGroupFileResponse>
</S:Body>
</S:Envelope>
Java Code Sample
final Long id = 150;
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.putGroupFile(id, filename, dataHandler, sessionId);
deleteGroupFile
Delete a file associated with a 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:deleteGroupFile>
<id>1</id>
<filename>test</filename>
<sessionId>30fa4f5a-f67c-4ea0-a6a7-60f2e2c3f9c3</sessionId>
</crud:deleteGroupFile>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:deleteGroupFileResponse xmlns:ns2="http://datasolutions.pervasive.com/api/crud" xmlns:ns3="http://datasolutions.pervasive.com/api/entity">
<return>9</return>
</ns2:deleteGroupFileResponse>
</S:Body>
</S:Envelope>
Java Code Sample
final Long id = 150;
final String filename = "testgroupfile";
final String sessionId = "125003101227.4253.DC58.5A73.4AC1.AED2.5687";
EntityAPIServiceLocator service = new EntityAPIServiceLocator();
EntityAPIService stub = service.getEntityAPIPort();
Long deletedBytes = stub.deleteGroupFile(id, filename, sessionId);