This function creates a new role and/or updates the role functions. The request must contain an AdministrationRole object to specify the role details, and an array of AdministrationFunction for the role. Whether this function is used to update a role, or create a new one, it should be noted that every Yellowfin role requires a mandatory function, Report Access (function code: MIREPORT), MIREPORT access level code must be at least R (read). Each time this function is called, the security functions will be overwritten. Displayed below is a basic request for this function:
AdministrationServiceRequest rsr = new AdministrationServiceRequest();
rsr.setLoginId("admin@yellowfin.com.au");
rsr.setPassword("test");
rsr.setOrgId(1);
rsr.setFunction("SAVEROLE"); |
Then define a role: AdministrationRole role = new AdministrationRole();
|
Role Code is mandatory if you want to modify an existing role: role.setRoleCode("NEWROLE"); // If you want to create a new role, comment this out. |
If you do not specify the Role Code, the call will create a new role even if another role with the same name already exists. You can get the role codes from Yellowfin's database OrgRole table. (Usually, it is based on role name with all letters capitalized and with no space between them.) |
Role Name is mandatory even when modifying an existing role, otherwise the call will set the role name to blank: role.setRoleName("New Role");
role.setRoleDescription("testing");
|
Each time you call the SAVEROLE function, you need to provide a list of security functions. This call overwrites the role function. For instance, 2 functions will be assigned to the role: Report Access (mandatory) and Activity Stream (optional): AdministrationFunction[] f = new AdministrationFunction[1];
f[0] = new AdministrationFunction();
f[0].setFunctionCode("MIREPORT");
f[0].setAccessLevelCode("R");
f[1] = new AdministrationFunction();
f[1].setFunctionCode("ACTIVITYSTREAM");
f[1].setAccessLevelCode("CRUD"); |
You cannot omit security functions; the call will generate an error otherwise. Click here for all available security function options. |
Then feed the security functions to the role: role.setFunctions(f);
rsr.setRole(role);
|
Once the request is configured, perform the call:
AdministrationServiceResponse rs = adminService.remoteAdministrationCall(rsr);
|
Initialize the Administration web service. Click here to learn how to do this.
Complete ExampleBelow is a full example of the SAVEROLE function. To use it for yourself, carry out the following the steps: - Copy the code and save it as ws_saverole.jsp.
- Put the file in the root folder: Yellowfin/appserver/webapps/ROOT.
- Adjust host, port, admin user details according to your environment.
- Run http://<host>:<port>/ws_saverole.jsp from your Internet browser.
<%
/* ws_saverole.jsp */
%>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ page import="com.hof.util.*, java.util.*, java.text.*" %>
<%@ page import="com.hof.web.form.*" %>
<%@ page import="com.hof.mi.web.service.*" %>
<%
AdministrationServiceService s_adm = new AdministrationServiceServiceLocator("localhost",8080, "/services/AdministrationService", false); // adjust host and port number
AdministrationServiceSoapBindingStub adminService = (AdministrationServiceSoapBindingStub) s_adm.getAdministrationService();
AdministrationServiceRequest rsr = new AdministrationServiceRequest();
rsr.setLoginId("admin@yellowfin.com.au"); // provide your Yellowfin web services admin account
rsr.setPassword("test"); // change to the password of the account above
rsr.setOrgId(1);
rsr.setFunction("SAVEROLE");
//define a role:
AdministrationRole role = new AdministrationRole();
role.setRoleCode("NEWROLE");
role.setRoleName("New Role");
role.setRoleDescription("testing");
AdministrationFunction[] f = new AdministrationFunction[2];
f[0] = new AdministrationFunction();
f[0].setFunctionCode("MIREPORT"); // mandatory
f[0].setAccessLevelCode("R");
f[1] = new AdministrationFunction();
f[1].setFunctionCode("ACTIVITYSTREAM");
f[1].setAccessLevelCode("CRUD");
//Feed the security functions to the role:
role.setFunctions(f);
rsr.setRole(role);
AdministrationServiceResponse rs = adminService.remoteAdministrationCall(rsr);
if ("SUCCESS".equals(rs.getStatusCode()) ) {
out.write("Success");
} else {
out.write("Failure");
out.write(" Code: " + rs.getErrorCode());
}
%>
|
|