Subversion Repositories DevTools

Rev

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

<%@LANGUAGE="VBSCRIPT"%>
<%
'=====================================================
'                 Destroy Package
'               --- PROCESS FORM ---
'=====================================================
%>
<%
Option explicit
' Good idea to set when using redirect
Response.Expires = 0   ' always load the page, dont store
%>

<!--#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/common_dbedit.asp"-->
<!--#include file="common/daemon_instructions.asp"-->
<%
'------------ ACCESS CONTROL ------------------
%>
<!--#include file="_access_control_login.asp"-->
<!--#include file="_access_control_general.asp"-->
<%
'------------ Variable Definition -------------
Dim ProblemsString
Dim OverideWarnings
Dim bCanDelete
'------------ Constants Declaration -----------
'------------ Variable Init -------------------
ProblemsString = NULL
bCanDelete = FALSE

OverideWarnings = "N"
If InStr( 1, Request("btn"), "YES", 1 ) > 0 Then OverideWarnings = "Y"
'----------------------------------------------
%>
<%
Sub DestroyPackage ( nPvId, cOverrideWarnings, outProblemsString )

   OraDatabase.Parameters.Add "PV_ID",             nPvId,             ORAPARM_INPUT,  ORATYPE_NUMBER
   OraDatabase.Parameters.Add "OVERRIDE_WARNINGS", cOverrideWarnings, ORAPARM_INPUT,  ORATYPE_CHAR
   OraDatabase.Parameters.Add "PROBLEM_STRING",    NULL,              ORAPARM_OUTPUT, ORATYPE_VARCHAR2

   'Response.write nPvId &"-"& cOverrideWarnings &"-"& Request("btn")

   objEH.TryORA ( OraSession )
   On Error Resume Next

   OraDatabase.ExecuteSQL _
   "BEGIN "&_
   " PK_PACKAGE.DESTROY_PACKAGE ( :PV_ID, :OVERRIDE_WARNINGS, :PROBLEM_STRING ); "&_
   "END; "

   objEH.CatchORA ( OraSession )

   outProblemsString = OraDatabase.Parameters("PROBLEM_STRING").Value

   OraDatabase.Parameters.Remove "PV_ID"
   OraDatabase.Parameters.Remove "OVERRIDE_WARNINGS"
   OraDatabase.Parameters.Remove "PROBLEM_STRING"
End Sub

'-------------------------------------------------
' Function:    CanDestroyPackage
' Description: Determine if the user can Destroy the specified Package
'              Match code in _version_browser
'
Function CanDestroyPackage(SSpv_id)
    Dim sqlStr, rsTemp
    CanDestroyPackage = FALSE

    sqlStr =    " SELECT PV.PV_ID," &_
                "   PV.PKG_VERSION," &_
                "   PV.DLOCKED," &_
                "   PV.MODIFIED_STAMP," &_
                "   pv.CREATOR_ID," &_
                "   pv.OWNER_ID," &_
                "   NVL2(rc.rtag_id,1,0) as inuse," &_
                "   trunc(SYSDATE - pv.CREATED_STAMP + 0.5) as age" &_
                " FROM PACKAGE_VERSIONS PV," &_
                "      RELEASE_CONTENT rc" &_
                " WHERE pv.PV_ID = :PV_ID" &_
                "   AND pv.pv_id = rc.pv_id(+)"

   OraDatabase.Parameters.Add "PV_ID", SSpv_id,   ORAPARM_INPUT, ORATYPE_NUMBER
   set rsTemp = OraDatabase.DbCreateDynaset( sqlStr, cint(0))
   If rsTemp.RecordCount <> 0 Then

    ' User can try to delete package iff
    '   Have suffiecient access (unusual)
    '   They created it or own it
    '   The version is not in use by any release (allow to be in pending or WIP)
    '   [Not at the moment] The package was created less than xxxx days ago
    '   Is not locked or Approved for Autobuild
        If  (objAccessControl.UserId = rsTemp("CREATOR_ID")) OR (objAccessControl.UserId = rsTemp("OWNER_ID")) Then
            If rsTemp("inuse") = 0 Then
                'If rsTemp("age") < 1000 Then
                    If rsTemp("dlocked") <> "Y" Then
                        'If rsTemp("dlocked") <> "A" Then
                            CanDestroyPackage = true
                        'End If
                    End If
                'End If
            End If
        End If
    End If
   OraDatabase.Parameters.Remove "PV_ID"
   rsTemp.Close
   Set rsTemp = nothing

End Function
%>
<%
'-----------------------  MAIN LINE  ---------------------------

' Setup persistance object
Call objPMod.StoreParameter ( "bfile", Request("bfile") )
Call objPMod.StoreParameter ( "rfile", Request("rfile") )
Call objPMod.StoreParameter ( "rtag_id", Request("rtag_id") )
Call objPMod.StoreParameter ( "pv_id", Request("pv_id") )
Call objPMod.StoreParameter ( "pkg_id", Request("pkg_id") )
Call objPMod.StoreParameter ( "OLDpv_id", Request("OLDpv_id") )
Call objPMod.StoreParameter ( "FLuser_name", Request("FLuser_name") )
Call objPMod.StoreParameter ( "FLpkg_version", Request("FLpkg_version") )
Call objPMod.StoreParameter ( "FLpkg_version", Request("FLpkg_version") )
Call objPMod.StoreParameter ( "listby", Request("listby") )

'
'   Ensure that the user can destroy the package
'   The user is known to be logged in
'   This page is not always called in the context of a 'Release'
'       ie: When called from the history page displayed from the Dangling Package Versions
'
'  Allow to proceed 
'       If the user can perform any action in the project
'       OR the package looks like they created it and it not in use
'
bCanDelete = canShowControlInProject ( "DestroyPackage" )
If NOT bCanDelete Then
    bCanDelete = CanDestroyPackage(objPMod.GetParamValue("pv_id"))
End If

If NOT bCanDelete Then
 Call RaiseMsg(enum_MSG_ERROR, "You do not have access to delete this version of the package")
End If


If objPMod.GetParamValue("pv_id") Then

   If (DaemonInstructionPreventsEditing(Request("rtag_id"), Request("pv_id"))) Then
      Call RaiseMsg(enum_MSG_ERROR, "This package version has one or more daemon instructions present.<br><br>"&_
                                    "Please delete them or allow them to be consumed before attempting to delete the package version.")
   Else
      '--- Process submition ---
      Call DestroyPackage ( objPMod.GetParamValue("pv_id"), OverideWarnings, ProblemsString )

      If IsNull( ProblemsString ) Then
         Response.Redirect( objPMod.GetParamValue("bfile") &"?DESTROYED=OK"& objPMod.ComposeURLWithout("bfile,pv_id") )
      End If
   End If

Else

   Err.Raise 8, "This page requires more paramaters to run.<br>"& objPMod.ComposeURL()

End If

'----------------------------------------------------------------
%>


<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 rel="stylesheet" href="images/release_manager_style.css" type="text/css">
<link rel="stylesheet" href="images/navigation.css" type="text/css">
<script language="JavaScript" src="images/common.js"></script>
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" >
<!-- BODY ---->


<table width="100%" height="98%"  border="0" cellpadding="0" cellspacing="0">
   <tr>
      <td align="center" valign="middle" background="images/bg_form_lightgray.gif">
         <table width="650" border="0" cellspacing="0" cellpadding="0">
            <tr>
               <td>
                  <table width="100%" border="0" cellspacing="0" cellpadding="0">
                     <tr>
                        <td align="left" valign="top" width="1%" background="images/lbox_bg_blue.gif"><img src="images/lbox_tl_cnr_b.gif" width="13" height="13"></td>
                        <td background="images/lbox_bg_blue.gif"><!-- Heading --><img src="images/h_trsp_dot.gif" width="1" height="20"><!-- END Heading --></td>
                        <td align="right" valign="top" width="1%" background="images/lbox_bg_blue.gif"><img src="images/lbox_tr_cnr_b.gif" width="13" height="13"></td>
                     </tr>
                     <tr>
                        <td width="1%" bgcolor="#FFFFFF"><img src="images/h_trsp_dot.gif" width="10" height="100"></td>
                        <td bgcolor="#FFFFFF" valign="top">
                           <!-- Body -->
                           <table width="100%" border="0" cellspacing="1" cellpadding="2">
                              <form name="form" method="get" action="<%=ScriptName%>">
                                 <tr>
                                    <td width="1%"><img src="images/h_trsp_dot.gif" width="1" height="10"></td>
                                    <td width="1%" nowrap class="form_group" valign="bottom"></td>
                                    <td nowrap width="100%" align="right" class="form_step"></td>
                                 </tr>
                                 <tr>
                                    <td width="1%">&nbsp;</td>
                                    <td colspan="2" width="1%" nowrap class="form_field">
                                       <table width="100%"  border="0" cellspacing="0" cellpadding="10">
                                          <tr>
                                             <td background="images/bg_form_lightbluedark.gif"><p class="err_ttl">Please note:</p></td>
                                          </tr>
                                          <tr>
                                             <td background="images/bg_form_lightgray.gif" class="form_item">
                                                <%
                                                ' Format problem report string to html
                                                Response.write Replace( Server.HTMLEncode( ProblemsString ), VBNewLine, "<br>" )
                                                %>
                                             </td>
                                          </tr>
                                          <tr>
                                             <td background="images/bg_form_lightgray.gif" class="form_item">Do you still want to proceed ? </td>
                                          </tr>
                                       </table>
                                    </td>
                                 </tr>
                                 <tr>
                                    <td width="1%">&nbsp;</td>
                                    <td width="1%" nowrap class="form_field"><img src="images/h_trsp_dot.gif" width="1" height="1"></td>
                                    <td nowrap width="100%" class="body_scol">
                                       <br>
                                       <input type="submit" name="btn" value="  Yes  " class="form_btn">
                                       <input type="reset" name="btn" value="   No   " class="form_btn" onClick="history.back();">
                                       <input type="reset" name="btn" value="Cancel" class="form_btn" onClick="history.back();">
                                       <br><br>
                                    </td>
                                 </tr>
                                 <%=objPMod.ComposeHiddenTags()%>
                              </form>
                           </table>
                           <!-- END Body-->
                        </td>
                        <td width="1%" background="images/lbox_bgside_white.gif">&nbsp;</td>
                     </tr>
                     <tr>
                        <td width="1%" background="images/lbox_bg_blue.gif" valign="bottom"><img src="images/lbox_bl_cnr_b.gif" width="13" height="13"></td>
                        <td background="images/lbox_bg_blue.gif"></td>
                        <td width="1%" background="images/lbox_bg_blue.gif" valign="bottom" align="right"><img src="images/lbox_br_cnr_b.gif" width="13" height="13"></td>
                     </tr>
                  </table>
               </td>
            </tr>
         </table>
      </td>
   </tr>
</table>
</body>
</html>


<!-- DESTRUCTOR ------->
<!--#include file="common/destructor.asp"-->