Subversion Repositories DevTools

Rev

Rev 5902 | Rev 5931 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5357 dpurdie 1
<%@LANGUAGE="VBSCRIPT"%>
2
<%
3
'=====================================================
4
'                 Destroy Package
5
'               --- PROCESS FORM ---
6
'=====================================================
7
%>
8
<%
9
Option explicit
10
' Good idea to set when using redirect
11
Response.Expires = 0   ' always load the page, dont store
12
%>
13
 
14
<!--#include file="common/conf.asp"-->
15
<!--#include file="common/globals.asp"-->
16
<!--#include file="common/formating.asp"-->
17
<!--#include file="common/qstr.asp"-->
18
<!--#include file="common/common_subs.asp"-->
19
<!--#include file="common/common_dbedit.asp"-->
20
<!--#include file="common/daemon_instructions.asp"-->
21
<%
22
'------------ ACCESS CONTROL ------------------
23
%>
24
<!--#include file="_access_control_login.asp"-->
25
<!--#include file="_access_control_general.asp"-->
26
<%
27
'------------ Variable Definition -------------
28
Dim ProblemsString
29
Dim OverideWarnings
5902 dpurdie 30
Dim bCanDelete
5925 dpurdie 31
Dim bCanDestroy
5357 dpurdie 32
'------------ Constants Declaration -----------
33
'------------ Variable Init -------------------
34
ProblemsString = NULL
5902 dpurdie 35
bCanDelete = FALSE
5925 dpurdie 36
bCanDestroy = canShowControlInProject ("DestroyPackage")
5357 dpurdie 37
OverideWarnings = "N"
5925 dpurdie 38
If  bCanDestroy AND InStr( 1, Request("btn"), "YES", 1 ) > 0 Then OverideWarnings = "Y"
5357 dpurdie 39
'----------------------------------------------
40
%>
41
<%
42
Sub DestroyPackage ( nPvId, cOverrideWarnings, outProblemsString )
43
 
44
   OraDatabase.Parameters.Add "PV_ID",             nPvId,             ORAPARM_INPUT,  ORATYPE_NUMBER
45
   OraDatabase.Parameters.Add "OVERRIDE_WARNINGS", cOverrideWarnings, ORAPARM_INPUT,  ORATYPE_CHAR
46
   OraDatabase.Parameters.Add "PROBLEM_STRING",    NULL,              ORAPARM_OUTPUT, ORATYPE_VARCHAR2
47
 
48
   objEH.TryORA ( OraSession )
49
   On Error Resume Next
50
 
51
   OraDatabase.ExecuteSQL _
52
   "BEGIN "&_
53
   " PK_PACKAGE.DESTROY_PACKAGE ( :PV_ID, :OVERRIDE_WARNINGS, :PROBLEM_STRING ); "&_
54
   "END; "
55
 
56
   objEH.CatchORA ( OraSession )
57
 
58
   outProblemsString = OraDatabase.Parameters("PROBLEM_STRING").Value
59
 
60
   OraDatabase.Parameters.Remove "PV_ID"
61
   OraDatabase.Parameters.Remove "OVERRIDE_WARNINGS"
62
   OraDatabase.Parameters.Remove "PROBLEM_STRING"
63
End Sub
5902 dpurdie 64
 
65
'-------------------------------------------------
66
' Function:    CanDestroyPackage
67
' Description: Determine if the user can Destroy the specified Package
68
'              Match code in _version_browser
69
'
70
Function CanDestroyPackage(SSpv_id)
71
    Dim sqlStr, rsTemp
72
    CanDestroyPackage = FALSE
73
 
74
    sqlStr =    " SELECT PV.PV_ID," &_
75
                "   PV.PKG_VERSION," &_
76
                "   PV.DLOCKED," &_
77
                "   PV.MODIFIED_STAMP," &_
78
                "   pv.CREATOR_ID," &_
79
                "   pv.OWNER_ID," &_
80
                "   NVL2(rc.rtag_id,1,0) as inuse," &_
81
                "   trunc(SYSDATE - pv.CREATED_STAMP + 0.5) as age" &_
82
                " FROM PACKAGE_VERSIONS PV," &_
83
                "      RELEASE_CONTENT rc" &_
84
            	" WHERE pv.PV_ID = :PV_ID" &_
85
                "   AND pv.pv_id = rc.pv_id(+)"
86
 
87
   OraDatabase.Parameters.Add "PV_ID", SSpv_id,   ORAPARM_INPUT, ORATYPE_NUMBER
88
   set rsTemp = OraDatabase.DbCreateDynaset( sqlStr, cint(0))
89
   If rsTemp.RecordCount <> 0 Then
90
 
91
    ' User can try to delete package iff
92
    '   Have suffiecient access (unusual)
93
    '   They created it or own it
94
    '   The version is not in use by any release (allow to be in pending or WIP)
95
    '   [Not at the moment] The package was created less than xxxx days ago
96
    '   Is not locked or Approved for Autobuild
97
        If  (objAccessControl.UserId = rsTemp("CREATOR_ID")) OR (objAccessControl.UserId = rsTemp("OWNER_ID")) Then
98
            If rsTemp("inuse") = 0 Then
99
                'If rsTemp("age") < 1000 Then
100
                    If rsTemp("dlocked") <> "Y" Then
101
                        'If rsTemp("dlocked") <> "A" Then
102
                            CanDestroyPackage = true
103
                        'End If
104
                    End If
105
                'End If
106
            End If
107
        End If
108
    End If
109
   OraDatabase.Parameters.Remove "PV_ID"
110
   rsTemp.Close
111
   Set rsTemp = nothing
112
 
113
End Function
5357 dpurdie 114
%>
115
<%
116
'-----------------------  MAIN LINE  ---------------------------
117
 
118
' Setup persistance object
119
Call objPMod.StoreParameter ( "bfile", Request("bfile") )
120
Call objPMod.StoreParameter ( "rfile", Request("rfile") )
121
Call objPMod.StoreParameter ( "rtag_id", Request("rtag_id") )
122
Call objPMod.StoreParameter ( "pv_id", Request("pv_id") )
123
Call objPMod.StoreParameter ( "pkg_id", Request("pkg_id") )
124
Call objPMod.StoreParameter ( "OLDpv_id", Request("OLDpv_id") )
125
Call objPMod.StoreParameter ( "FLuser_name", Request("FLuser_name") )
126
Call objPMod.StoreParameter ( "FLpkg_version", Request("FLpkg_version") )
127
Call objPMod.StoreParameter ( "FLpkg_version", Request("FLpkg_version") )
128
Call objPMod.StoreParameter ( "listby", Request("listby") )
129
 
5902 dpurdie 130
'
131
'   Ensure that the user can destroy the package
132
'   The user is known to be logged in
133
'   This page is not always called in the context of a 'Release'
134
'       ie: When called from the history page displayed from the Dangling Package Versions
135
'
136
'  Allow to proceed 
137
'       If the user can perform any action in the project
138
'       OR the package looks like they created it and it not in use
139
'
5925 dpurdie 140
bCanDelete = bCanDestroy
141
 If NOT bCanDelete Then
5902 dpurdie 142
    bCanDelete = CanDestroyPackage(objPMod.GetParamValue("pv_id"))
143
End If
144
 
145
If NOT bCanDelete Then
146
 Call RaiseMsg(enum_MSG_ERROR, "You do not have access to delete this version of the package")
147
End If
148
 
149
 
5357 dpurdie 150
If objPMod.GetParamValue("pv_id") Then
151
 
152
   If (DaemonInstructionPreventsEditing(Request("rtag_id"), Request("pv_id"))) Then
153
      Call RaiseMsg(enum_MSG_ERROR, "This package version has one or more daemon instructions present.<br><br>"&_
154
                                    "Please delete them or allow them to be consumed before attempting to delete the package version.")
155
   Else
156
      '--- Process submition ---
157
      Call DestroyPackage ( objPMod.GetParamValue("pv_id"), OverideWarnings, ProblemsString )
158
 
159
      If IsNull( ProblemsString ) Then
160
         Response.Redirect( objPMod.GetParamValue("bfile") &"?DESTROYED=OK"& objPMod.ComposeURLWithout("bfile,pv_id") )
161
      End If
162
   End If
163
 
164
Else
165
 
166
   Err.Raise 8, "This page requires more paramaters to run.<br>"& objPMod.ComposeURL()
167
 
168
End If
169
 
170
'----------------------------------------------------------------
171
%>
172
 
173
 
174
<html>
175
<head>
176
<title>Release Manager</title>
177
<link rel="shortcut icon" href="<%=FavIcon%>"/>
178
<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
179
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
180
<link rel="stylesheet" href="images/release_manager_style.css" type="text/css">
181
<link rel="stylesheet" href="images/navigation.css" type="text/css">
182
<script language="JavaScript" src="images/common.js"></script>
183
</head>
184
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" >
185
<!-- BODY ---->
186
 
187
 
188
<table width="100%" height="98%"  border="0" cellpadding="0" cellspacing="0">
189
   <tr>
190
      <td align="center" valign="middle" background="images/bg_form_lightgray.gif">
191
         <table width="650" border="0" cellspacing="0" cellpadding="0">
192
            <tr>
193
               <td>
194
                  <table width="100%" border="0" cellspacing="0" cellpadding="0">
195
                     <tr>
196
                        <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>
197
                        <td background="images/lbox_bg_blue.gif"><!-- Heading --><img src="images/h_trsp_dot.gif" width="1" height="20"><!-- END Heading --></td>
198
                        <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>
199
                     </tr>
200
                     <tr>
201
                        <td width="1%" bgcolor="#FFFFFF"><img src="images/h_trsp_dot.gif" width="10" height="100"></td>
202
                        <td bgcolor="#FFFFFF" valign="top">
203
                           <!-- Body -->
204
                           <table width="100%" border="0" cellspacing="1" cellpadding="2">
205
                              <form name="form" method="get" action="<%=ScriptName%>">
206
                                 <tr>
207
                                    <td width="1%"><img src="images/h_trsp_dot.gif" width="1" height="10"></td>
208
                                    <td width="1%" nowrap class="form_group" valign="bottom"></td>
209
                                    <td nowrap width="100%" align="right" class="form_step"></td>
210
                                 </tr>
211
                                 <tr>
212
                                    <td width="1%">&nbsp;</td>
213
                                    <td colspan="2" width="1%" nowrap class="form_field">
214
                                       <table width="100%"  border="0" cellspacing="0" cellpadding="10">
215
                                          <tr>
216
                                             <td background="images/bg_form_lightbluedark.gif"><p class="err_ttl">Please note:</p></td>
217
                                          </tr>
218
                                          <tr>
219
                                             <td background="images/bg_form_lightgray.gif" class="form_item">
220
                                                <%
221
                                                ' Format problem report string to html
222
                                                Response.write Replace( Server.HTMLEncode( ProblemsString ), VBNewLine, "<br>" )
223
                                                %>
224
                                             </td>
225
                                          </tr>
5925 dpurdie 226
                                       <%If bCanDestroy Then %>
5357 dpurdie 227
                                          <tr>
5925 dpurdie 228
                                             <td background="images/bg_form_lightgray.gif" class="form_item">
229
                                             <%=enum_IMG_Critical%>
230
                                             Destroying this package may delete it from an SBOM or the dependency list of another package.
231
                                             <p>Do you still want to proceed ? </td>
5357 dpurdie 232
                                          </tr>
5925 dpurdie 233
                                       <%End If%>
5357 dpurdie 234
                                       </table>
235
                                    </td>
236
                                 </tr>
237
                                 <tr>
238
                                    <td width="1%">&nbsp;</td>
239
                                    <td width="1%" nowrap class="form_field"><img src="images/h_trsp_dot.gif" width="1" height="1"></td>
240
                                    <td nowrap width="100%" class="body_scol">
241
                                       <br>
5925 dpurdie 242
                                       <%If bCanDestroy Then %>
5357 dpurdie 243
                                       <input type="submit" name="btn" value="  Yes  " class="form_btn">
244
                                       <input type="reset" name="btn" value="   No   " class="form_btn" onClick="history.back();">
5925 dpurdie 245
                                       <%End If%>
5357 dpurdie 246
                                       <input type="reset" name="btn" value="Cancel" class="form_btn" onClick="history.back();">
247
                                       <br><br>
248
                                    </td>
249
                                 </tr>
250
                                 <%=objPMod.ComposeHiddenTags()%>
251
                              </form>
252
                           </table>
253
                           <!-- END Body-->
254
                        </td>
255
                        <td width="1%" background="images/lbox_bgside_white.gif">&nbsp;</td>
256
                     </tr>
257
                     <tr>
258
                        <td width="1%" background="images/lbox_bg_blue.gif" valign="bottom"><img src="images/lbox_bl_cnr_b.gif" width="13" height="13"></td>
259
                        <td background="images/lbox_bg_blue.gif"></td>
260
                        <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>
261
                     </tr>
262
                  </table>
263
               </td>
264
            </tr>
265
         </table>
266
      </td>
267
   </tr>
268
</table>
269
</body>
270
</html>
271
 
272
 
273
<!-- DESTRUCTOR ------->
274
<!--#include file="common/destructor.asp"-->