Database Reference
In-Depth Information
END appver_conns_role_pkg;
/
-- From New Application Registration
GRANT EXECUTE ON sys.appver_conns_role_pkg
TO appver_admin
;
-- From Admin Users, grant to user, not to role
GRANT EXECUTE ON sys.appver_conns_role_pkg
TO ojsaadm
;
When we register a new application, we will call
p_grant_appver_conns_role
for the current session
user, as we will see in the next subsection of this chapter. At that point, we are proxying through the
avadmin
user, with
appver_admin
role; so you see in Listing 12-50 that we grant execute on
sys.appver_conns_role_pkg
to
appver_admin
.
When we are adding administrators through the
Admin Users
screen, we want to call either
p_grant_appver_conns_role
or
p_revoke_appver_conns_role
, depending on whether the App Register
check box is selected. However, at that point we are proxying through the
ojsaadm
user with
ojs_adm_admin
role, and we are on the wrong instance (
orcl
as opposed to
apver
.) We already have a
package and a database link to solve this issue, so we will create two additional procedures in the
ojsaadm.apver_usr_adm_pkg
package and use them to call the
sys.appver_conns_role_pkg
package across
a database link. The code for this is shown in Listing 12-51. Look back up to the end of Listing 12-50 and
you will see that we grant execute on the
sys.appver_conns_role_pkg
to the
ojsaadm
user.
Listing 12-51.
Grant Appver Conns Role Across Link
PROCEDURE
p_grant_apver_appver_conns
( username VARCHAR2, proxyname VARCHAR2 )
AS
m_stmt VARCHAR2(100);
BEGIN
m_stmt :=
'BEGIN
sys.appver_conns_role_pkg.p_grant_appver_conns_role@apver_link
( :1 ); END;';
EXECUTE IMMEDIATE m_stmt USING username, proxyname;
END p_grant_apver_appver_conns;
PROCEDURE
p_revoke_apver_appver_conns
( username VARCHAR2, proxyname VARCHAR2 )
AS
m_stmt VARCHAR2(100);
BEGIN
m_stmt :=
'BEGIN
sys.appver_conns_role_pkg.p_revoke_appver_conns_role@apver_link
( :1 ); END;';
EXECUTE IMMEDIATE m_stmt USING username, proxyname;
END p_revoke_apver_appver_conns;
The Register Application Button
With all the data entered on the Register New Application screen, and a representative application inner
class created in the Oracle database, we are ready to register the application. That representative inner
class may have been created in the database using the Create App Class button that I described
previously, or you will need to execute a
CREATE OR REPLACE AND RESOLVE JAVA
command to create it.
When the Register button is selected, that event calls the
registerButton_actionPerformed()
method. Again we are using a delayed thread process, and we are displaying the
sayWaitDialog
while we
are processing. In brief, this method does four things. It creates a local instance of the class described by