Subversion Repositories DevTools

Rev

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