Subversion Repositories DevTools

Rev

Rev 6289 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<%@LANGUAGE="VBSCRIPT"%>
<%
'=====================================================
'   _delete_package_name.asp
'   Intended to be invoked within an Iframe
'=====================================================
%>
<%
Option explicit
Response.Expires = 0
%>
<!--#include file="common/conf.asp"-->
<!--#include file="common/globals.asp"-->
<!--#include file="common/formating.asp"-->
<!--#include file="common/qstr.asp"-->
<!--#include file="common/common_subs.asp"-->
<!--#include file="common/_form_window_common.asp"-->
<%
'------------ ACCESS CONTROL ------------------
%>
<!--#include file="_access_control_login_optional.asp"-->
<!--#include file="_access_control_general.asp"-->
<%
'------------ VARIABLE DEFINITION -------------
Dim sMessage, sMessageType
Dim parPkgId
Dim rsQry
Dim Qstring
Dim pName
Dim canDoBad
'------------ CONSTANTS DECLARATION -----------
'------------ VARIABLE INIT -------------------
sMessage = NULL
sMessageType = 3
parPkgId = Request("pkgId")
canDoBad = canShowControlInProject ("CreateNewVersion")
Set objFormCollector = CreateObject("Scripting.Dictionary")
'------------ CONDITIONS ----------------------
'----------------------------------------------
%>
<%
'------------------------------------------------------------------------------------------------------------------------------------------
'
' Add a line of text to the System Message
'   eLevel - 1 == Critical, 2==Warning, 3==Note
Sub sMessageAdd(eLevel, text)
    If NOT isNull(sMessage) Then
        sMessage = sMessage & "<br>"
    End If
    sMessage = sMessage & text

    If eLevel < sMessageType  Then
        sMessageType = eLevel
    End If
End Sub

'
'   Check that the package is not in use
'
Function GetPackageVersionCount (nPkgId)
    Dim SqlQry
    Dim rsQry
    GetPackageVersionCount = 0

    OraDatabase.Parameters.Add "PKGID",             nPkgId,             ORAPARM_INPUT,  ORATYPE_NUMBER

    objEH.ErrorRedirect = FALSE
    objEH.TryORA ( OraSession )
    On Error Resume Next

    SqlQry = "select count(*) as count from PACKAGES pkg, PACKAGE_VERSIONS pv " &_
           " where pv.PKG_ID = pkg.PKG_ID AND pkg.PKG_ID = :PKGID"

    Set rsQry = OraDatabase.DbCreateDynaset( SqlQry, ORADYN_DEFAULT )
    objEH.CatchORA ( OraSession )

    If objEH.Finally Then
        If ((NOT rsQry.BOF) AND (NOT rsQry.EOF)) Then
            GetPackageVersionCount = rsQry("count")
        End If
    End If

    rsQry.Close
    Set rsQry = Nothing
    OraDatabase.Parameters.Remove "PKGID"

End Function

'
'   Delete the package name
Sub DestroyPackage ( nPkgId )
    OraDatabase.Parameters.Add "PKGID",             nPkgId,             ORAPARM_INPUT,  ORATYPE_NUMBER

    objEH.ErrorRedirect = FALSE
    objEH.TryORA ( OraSession )
    On Error Resume Next

    OraDatabase.ExecuteSQL "delete from packages where pkg_id = :PKGID"
    objEH.CatchORA ( OraSession )

    OraDatabase.Parameters.Remove "PKGID"
End Sub

'------------ RUN BEFORE PAGE RENDER ----------
' Setup persistance object
Call objPMod.StoreParameter ( "bfile", Request("bfile") )
Call objPMod.StoreParameter ( "pkgid", Request("pkgid") )
'   Basic sanity checks
'
If objAccessControl.UserId = "" Then
    sMessageAdd 1, "No longer logged in"
End If

If parPkgId = "" Then
    sMessageAdd 1, "Internal: PKGID not provided"
End If

If CBool(Request("action")) AND isNULL(sMessage) Then
    '
    '   Attempt to destroy the package name
    DestroyPackage parPkgId
    If GetPackageVersionCount(parPkgId) = 0 Then
        If Request("bfile") <> "" Then
            OpenInParentWindow(objPMod.GetParamValue("bfile") &"?DESTROYED=OK"& objPMod.ComposeURLWithout("bfile,pkgId"))
        Else
            ReloadParentWindow()
        End If
        Call Destroy_All_Objects
        Response.End
    End If
End If

'   Need to generate a display
'   Get the Package Version information
'
Qstring = "SELECT p.pkg_name" &_
          " FROM packages p" &_
          " WHERE p.pkg_id = " & parPkgId

Set rsQry = OraDatabase.DbCreateDynaset( Qstring, cint(0))
If rsQry.RecordCount = 0 Then
    sMessageAdd 1, "Package Name no longer exists"
End If
If NOT canDoBad Then
    sMessageAdd 1, "You do not have permission to delete a unused package name"
End If

If GetPackageVersionCount(parPkgId) <> 0  Then
    sMessageAdd 1, "Package name is used. Cannot delete a name that is in use"
End If
pName = rsQry("pkg_name")
rsQry.Close
Set rsQry = nothing

'----------------------------------------------
%>
<html>
<head>
<title>Release Manager</title>
<link rel="shortcut icon" href="<%=FavIcon%>"/>
<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="images/release_manager_style.css?ver=<%=VixVerNum%>" rel="stylesheet" type="text/css">
<script language="JavaScript" src="images/common.js?ver=<%=VixVerNum%>"></script>
</head>
<body background="images/bg_bage_0.gif" leftmargin="0" topmargin="0" >
<table class="full_table body_txt" border="0" cellspacing="0" cellpadding="10">
   <tr>
      <td bgcolor="#FFFFFF" class="body_txt nowrap">
        <%=enum_IMG_Critical%><span>You are about to delete the unused package name: <%=pName%>.</span>
      </td>
   </tr>
   <%
   '-- FROM START --------------------------------------------------------------------------------------------------------------
   objFormComponent.FormName = "FormName"
   objFormComponent.FormClass = "form_tight"
   objFormComponent.Action = ScriptName
   Call objFormComponent.FormStart()
   %>
   <tr>
      <td>
         <!-- NEW PRODUCT +++++++++++++++++++++++++++++++++++++++++++++++ -->
         <%Call Messenger ( sMessage , sMessageType, "100%" )%>
         <!-- MESSAGE +++++++++++++++++++++++++++++++++++++++++++++++++++ -->
         <!--#include file="messages/_msg_inline.asp"-->

      </td>
   </tr>
   <tr>
      <td bgcolor="#FFFFFF">
         <table class=full_table >
            <tr>
               <td><%=ProgressBar()%></td>
               <td align="right">
                  <%If isNULL(sMessage) Then%>
                  <input name="btn" type="submit" class="form_btn" value="Delete">
                  <%End If%>
                  <input name="btn" type="reset" class="form_btn" value="Cancel" onclick="parent.closeIFrame();">
               </td>
            </tr>
         </table>
      </td>
   </tr>
   <%=objPMod.ComposeHiddenTags()%>
   <input type="hidden" name="action" value="true">
   <%
   Call objFormComponent.FormEnd()
   '-- FROM END ----------------------------------------------------------------------------------------------------------------
   %>
</table>
</body>
</html>
<%
'------------ RUN AFTER PAGE RENDER -----------
Set objFormCollector = Nothing
'----------------------------------------------
On Error Resume Next
Call Destroy_All_Objects
%>