Subversion Repositories DevTools

Rev

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

Rev Author Line No. Line
119 ghuddy 1
<%@LANGUAGE="VBSCRIPT"%>
2
<%
3
'=====================================================
129 ghuddy 4
'              UPDATE dependencies
119 ghuddy 5
'               --- PROCESS FORM ---
6
'=====================================================
7
%>
8
<%
9
Option explicit
10
' Good idea to set when using redirect
129 ghuddy 11
Response.Expires = 0   ' always load the page, dont store
119 ghuddy 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
<%
21
' Set rfile parameter. This is a return page after Login
22
Call objPMod.StoreParameter ( "rfile", "dependencies.asp" )
23
'------------ ACCESS CONTROL ------------------
24
%>
25
<!--#include file="_access_control_login.asp"-->
26
<!--#include file="_access_control_general.asp"-->
27
<!--#include file="_access_control_project.asp"-->
28
<%
29
'------------ Variable Definition -------------
30
Dim depArray()
31
Dim array_is_empty
32
'------------ Constants Declaration -----------
33
Const enumlocal_DONOT_DELETE_OLD_DEPENDENCIES = 0
34
Const enumlocal_DELETE_OLD_DEPENDENCIES = 1
35
Const COL_pkg_name = 0
36
Const COL_pkg_version = 1
37
Const COL_build_type = 2
38
'------------ Variable Init -------------------
39
'----------------------------------------------
40
%>
41
<%
42
Sub Populate_depArray_from_Import ( SSdep_import, ARRdep, BBarray_is_empty )
161 iaugusti 43
   Dim recCnt, pkg_name, pkg_version, build_type, re, Matches, Match
121 hknight 44
 
129 ghuddy 45
   If (SSdep_import = "") Then Exit Sub      ' exit if no dependencies are submited
121 hknight 46
 
129 ghuddy 47
   ' Decode Server.URLEncode if present
48
   SSdep_import = URLDecode( SSdep_import )
121 hknight 49
 
129 ghuddy 50
   SSdep_import = Replace(SSdep_import, " ", "")            ' remove spaces
51
   SSdep_import = Replace(SSdep_import, VBTab, "")          ' remove horizontal tabs
52
   SSdep_import = Replace(SSdep_import, VBVerticalTab, "")  ' remove vertical tabs
53
   SSdep_import = Replace(SSdep_import, """", "'")          ' replace " with '
121 hknight 54
 
161 iaugusti 55
   Set re = New RegExp
56
   re.IgnoreCase = True
57
   re.Global = True
121 hknight 58
 
161 iaugusti 59
   'The following regular expression captures the package name and version on each matching line.
60
   'The following is an example of the format of the input string, SSdep_import.
61
   '
62
   'BuildPkgArchive ( 'linux_kernel_viper'  , '2.6.24.6.5000.cots' );
63
   '
64
   '#   Packages for creating the debian package
65
   '#LinkPkgArchive  ( 'debian_dpkg'         , '1.13.25000.cots' );
66
   'LinkPkgArchive  ( 'debian_packager'     , '1.1.0000.cr' );
163 brianf 67
   'LinkPkgArchive  ( 'Jasper Patch (JBoss/Tomcat Hotfix)' , '1.6.0,REV=2006.11.29.02.51' );
68
   'LinkPkgArchive  ( 'Java 2 SDK, Enterprise Edition (J2EE)' , '1.6.0,REV=2006.11.29.02.51' );
3959 dpurdie 69
   '
5474 dpurdie 70
   ' Note. Ant dependencies are formatted to look like:
3959 dpurdie 71
   '    AntStyle('PackageName','PackageVersion');
121 hknight 72
 
163 brianf 73
   re.Pattern = "(^|\n)\s*([_A-Za-z0-9]+)\s*\(\s*\'([^\']*)\'\s*\,\s*\'([^\']*)\'\s*\)"
161 iaugusti 74
   Set Matches = re.Execute(SSdep_import)
75
 
76
   recCnt=0
77
   For Each Match in Matches
78
     build_type = Match.SubMatches(1)
79
     pkg_name = Match.SubMatches(2)
80
     pkg_version = Match.SubMatches(3)
81
 
129 ghuddy 82
      ' Proceed only if:
83
      '    pkg name is not empty,
84
      '    pkg version is not empty,
161 iaugusti 85
      If ( pkg_name <> "" )  AND  ( pkg_version <> "" ) Then
129 ghuddy 86
         ReDim Preserve ARRdep( 2, recCnt )
87
         ARRdep( COL_pkg_name, recCnt ) = pkg_name
88
         ARRdep( COL_pkg_version, recCnt ) = pkg_version
89
         ' Define build type
161 iaugusti 90
         If LCase(build_type) = LCase("BuildPkgArchive") Then
129 ghuddy 91
            ARRdep( COL_build_type, recCnt ) = enum_BUILD_PKG_ARCHIVE
161 iaugusti 92
         ElseIf LCase(build_type) = LCase("LinkPkgArchive") Then
129 ghuddy 93
            ARRdep( COL_build_type, recCnt ) = enum_LINK_PKG_ARCHIVE
94
         Else
95
            ARRdep( COL_build_type, recCnt ) = enum_BUILD_PKG_ARCHIVE   'neither build_package or link_package is found, hence set to...
96
         End If
97
         recCnt = recCnt + 1
98
         BBarray_is_empty = FALSE
161 iaugusti 99
     End If
129 ghuddy 100
   Next
121 hknight 101
 
119 ghuddy 102
End Sub
103
 
121 hknight 104
' This function is called when update_type is "add_custom". This is only the case when adding dependencies
105
' The list given via the actual parameter pkg_list is in fact a list of pv_id's supplied from the form_search_result_pkgs.asp
106
' and form_add_pkg_versions.asp files. In the past, it only ever used to be a list of package IDs, but this has now been
107
' changed so that users can only add package versions from the relevant release as dependencies to a packge also in that
108
' release, and to do this, the list has to hold pv_id's instead of pkg_id's, to cater for situations where a release
109
' contains 2 instances of a package, each one having different extensions (eg .mas, .sea).
110
Sub Populate_depArray_from_ADD_Custom ( NNpv_id_list, ARRdep, BBarray_is_empty )
129 ghuddy 111
   Dim depList, lastItem, i, recCnt, pkg_name, pkg_version, V_EXT
112
   Dim rsTemp, Query_String, PkgBaseView
121 hknight 113
 
129 ghuddy 114
   PkgBaseView = Get_Pkg_Base_View_ID ( Request("pv_id"), Request("rtag_id") )
121 hknight 115
 
129 ghuddy 116
   Query_String = _
121 hknight 117
   " SELECT pkgs.pkg_id, pkgs.pkg_name, pv.pv_id, pv.pkg_version"&_
118
   "  FROM packages pkgs, package_versions pv"&_
119
   " WHERE pv.pv_id IN ("& NNpv_id_list &")"&_
120
   "   AND pv.pkg_id = pkgs.pkg_id"
129 ghuddy 121
   Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0))
121 hknight 122
 
129 ghuddy 123
   recCnt = 0
124
   While ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF))
125
      ReDim Preserve ARRdep( 2, recCnt )
126
      ARRdep( COL_pkg_name, recCnt ) = rsTemp("pkg_name")
121 hknight 127
      ARRdep( COL_pkg_version, recCnt ) = rsTemp("pkg_version")
128
 
129 ghuddy 129
      '// Dependencies comming from custom dependency add are set to LinkPkgArchive by default, unless it is a product
130
      If PkgBaseView = enumBASE_VIEW_PRODUCTS Then
131
         ARRdep( COL_build_type, recCnt ) = enum_BUILD_PKG_ARCHIVE
132
      Else
133
         ARRdep( COL_build_type, recCnt ) = enum_LINK_PKG_ARCHIVE
134
      End If
121 hknight 135
 
129 ghuddy 136
      recCnt = recCnt + 1
137
      BBarray_is_empty = FALSE
138
      rsTemp.MoveNext
139
   WEnd
121 hknight 140
 
129 ghuddy 141
   rsTemp.Close
142
   Set rsTemp = nothing
119 ghuddy 143
End Sub
144
 
3959 dpurdie 145
// The form passed to us may only have information for packages that need to change
146
// The enumlocal_DONOT_DELETE_OLD_DEPENDENCIES does not appear to work
147
//  Must provide a full set of dependencies with either a new version or the existing version
148
//
119 ghuddy 149
Sub Populate_depArray_from_EDIT_Custom ( NNpv_id, ARRdep, BBarray_is_empty, sDependBlock )
129 ghuddy 150
   Dim depList, lastItem, i, recCnt, pkg_name, pkg_version, V_EXT
151
   Dim rsTemp, rsCurrent, Query_String
121 hknight 152
 
129 ghuddy 153
   Query_String = _
154
   " SELECT dpkg.pkg_name, dpv.pkg_version, dpv.pv_id"&_
155
   "  FROM package_dependencies dep,"&_
156
   "       package_versions dpv,"&_
157
   "       packages dpkg"&_
158
   " WHERE dep.dpv_id = dpv.pv_id"&_
159
   "   AND dpv.pkg_id = dpkg.pkg_id"&_
160
   "   AND dep.pv_id = "& NNpv_id
121 hknight 161
 
129 ghuddy 162
   Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0))
121 hknight 163
 
129 ghuddy 164
   recCnt = 0
165
   While ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF))
3959 dpurdie 166
      Dim pvid, pkgver, newver
167
      pvid = rsTemp("pv_id")
168
      pkgver = Request( "pkgn" & pvid )
169
 
170
      If pkgver <> "" Then
171
        newver = pkgver
172
      else
173
        newver = rsTemp("pkg_version")
174
      End if
175
 
129 ghuddy 176
      ReDim Preserve ARRdep( 2, recCnt )
177
      ARRdep( COL_pkg_name, recCnt )    = rsTemp("pkg_name")
3959 dpurdie 178
      ARRdep( COL_pkg_version, recCnt ) = newver
179
      ARRdep( COL_build_type, recCnt )  = Request( "bt"& pvid )
119 ghuddy 180
 
3959 dpurdie 181
      If not rsTemp("pkg_version") =  newver Then
182
         sDependBlock = rsTemp("pkg_name") & " " & newver
129 ghuddy 183
      End If
121 hknight 184
 
129 ghuddy 185
      recCnt = recCnt + 1
186
      BBarray_is_empty = FALSE
3959 dpurdie 187
 
129 ghuddy 188
      rsTemp.MoveNext
189
   WEnd
121 hknight 190
 
129 ghuddy 191
   rsTemp.Close
192
   Set rsTemp = nothing
119 ghuddy 193
End Sub
194
 
195
Sub Update_Package_Dependencies ( ARRdep, NNpv_id, NNuser_id, NNdelete_old_dependency, sAction_type, sDependBlock )
129 ghuddy 196
   Dim i, OraParameter, sComments
121 hknight 197
 
129 ghuddy 198
   OraDatabase.Parameters.Add "PV_ID",            NNpv_id,                 ORAPARM_INPUT, ORATYPE_NUMBER
199
   OraDatabase.Parameters.Add "PKG_NAME",         "",                      ORAPARM_INPUT, ORATYPE_VARCHAR2
200
   OraDatabase.Parameters.Add "PKG_VERSION",      "",                      ORAPARM_INPUT, ORATYPE_VARCHAR2
201
   OraDatabase.Parameters.Add "BUILD_TYPE",       "",                      ORAPARM_INPUT, ORATYPE_VARCHAR2
202
   OraDatabase.Parameters.Add "USER_ID",          NNuser_id,               ORAPARM_INPUT, ORATYPE_NUMBER
203
   OraDatabase.Parameters.Add "DELETE_PV_ID",     NNdelete_old_dependency, ORAPARM_INPUT, ORATYPE_NUMBER
204
   OraDatabase.Parameters.Add "ACTION_TYPE_NAME", sAction_type,            ORAPARM_INPUT, ORATYPE_VARCHAR2
121 hknight 205
 
129 ghuddy 206
   Set OraParameter = OraDatabase.Parameters
121 hknight 207
 
129 ghuddy 208
   For i = 0 To UBound( ARRdep, 2 )
209
      If not i = 0 Then
210
         sComments = sComments & ", "
211
      End If
212
      sComments = sComments & depArray(COL_pkg_name, i) & " " & ARRdep( COL_pkg_version, i )
121 hknight 213
 
129 ghuddy 214
      OraParameter("PKG_NAME").Value    = ARRdep( COL_pkg_name, i )
215
      OraParameter("PKG_VERSION").Value = ARRdep( COL_pkg_version, i )
216
      OraParameter("BUILD_TYPE").Value  = ARRdep( COL_build_type, i )
121 hknight 217
 
129 ghuddy 218
      OraDatabase.ExecuteSQL "BEGIN  Update_Package_Dependency ( :PV_ID, :PKG_NAME, :PKG_VERSION, :BUILD_TYPE, :USER_ID, :DELETE_PV_ID );  END;"
121 hknight 219
 
129 ghuddy 220
   Next
121 hknight 221
 
129 ghuddy 222
   Set OraParameter = Nothing
121 hknight 223
 
129 ghuddy 224
   If sAction_type = "depend_add" Then
225
      OraDatabase.Parameters.Add "COMMENTS",    sComments, ORAPARM_INPUT, ORATYPE_VARCHAR2
226
   Else
227
      If Len(sDependBlock) <= 4000 Then
228
         OraDatabase.Parameters.Add "COMMENTS",    sDependBlock, ORAPARM_INPUT, ORATYPE_VARCHAR2
229
      Else
230
         OraDatabase.Parameters.Add "COMMENTS",    "Description too long to be inserted!", ORAPARM_INPUT, ORATYPE_VARCHAR2
231
      End If
232
   End If
119 ghuddy 233
 
129 ghuddy 234
   OraDatabase.ExecuteSQL _
235
   "BEGIN  Log_Action ( :PV_ID, :ACTION_TYPE_NAME, :USER_ID, :COMMENTS );  END;"
119 ghuddy 236
 
121 hknight 237
 
238
 
129 ghuddy 239
   OraDatabase.Parameters.Remove "PV_ID"
240
   OraDatabase.Parameters.Remove "PKG_NAME"
241
   OraDatabase.Parameters.Remove "PKG_VERSION"
242
   OraDatabase.Parameters.Remove "BUILD_TYPE"
243
   OraDatabase.Parameters.Remove "USER_ID"
244
   OraDatabase.Parameters.Remove "DELETE_PV_ID"
245
   OraDatabase.Parameters.Remove "ACTION_TYPE_NAME"
246
   OraDatabase.Parameters.Remove "COMMENTS"
119 ghuddy 247
End Sub
248
 
249
 
250
Sub Remove_Old_Dependencies ( SSpv_id )
129 ghuddy 251
   OraDatabase.Parameters.Add "PV_ID", SSpv_id,    ORAPARM_INPUT, ORATYPE_NUMBER
121 hknight 252
 
129 ghuddy 253
   OraDatabase.ExecuteSQL "DELETE FROM package_dependencies WHERE pv_id = :PV_ID"
121 hknight 254
 
129 ghuddy 255
   OraDatabase.Parameters.Remove "PV_ID"
119 ghuddy 256
End Sub
257
 
258
 
259
Sub Update_Mod_Details ( SSpv_id )
129 ghuddy 260
   OraDatabase.Parameters.Add "PV_ID",   SSpv_id,                 ORAPARM_INPUT, ORATYPE_NUMBER
261
   OraDatabase.Parameters.Add "RTAG_ID", Request("rtag_id"),      ORAPARM_INPUT, ORATYPE_NUMBER
262
   OraDatabase.Parameters.Add "USER_ID", objAccessControl.UserId, ORAPARM_INPUT, ORATYPE_NUMBER
121 hknight 263
 
129 ghuddy 264
   OraDatabase.ExecuteSQL _
265
      " UPDATE package_versions "&_
266
       " SET modified_stamp = "& ORA_SYSDATETIME &", modifier_id = :USER_ID"&_
267
       " WHERE pv_id = :PV_ID"
121 hknight 268
 
129 ghuddy 269
   If Request("rtag_id") <> "" Then
270
      ' Package in release view
271
      OraDatabase.ExecuteSQL _
272
        "BEGIN "&_
273
      " Touch_Release ( :RTAG_ID ); "&_
274
      "END; "
121 hknight 275
 
129 ghuddy 276
   Else
277
      ' Package view
278
      OraDatabase.ExecuteSQL _
279
        "BEGIN "&_
280
      " PK_RELEASE.RUN_POST_ACTIONS_BULK ( :PV_ID ); "&_
281
      "END; "
121 hknight 282
 
129 ghuddy 283
   End If
121 hknight 284
 
129 ghuddy 285
   OraDatabase.Parameters.Remove "PV_ID"
286
   OraDatabase.Parameters.Remove "RTAG_ID"
287
   OraDatabase.Parameters.Remove "USER_ID"
119 ghuddy 288
End Sub
289
 
290
%>
291
<%
292
'-----------------------  MAIN LINE  ---------------------------
3959 dpurdie 293
'Response.Write "<pre>------------<br>"
294
'Dim Item
295
'For Each Item In Request.Form
296
'    Response.Write "User Data: " &Item & ": " & Request.Form(Item) & "<br>"
297
'Next
298
'Response.Write "------------<br>"
119 ghuddy 299
 
300
Dim sDependBlock
301
 
302
'--- Process submition ---
303
If (QStrPar("pv_id") <> "")  Then
1376 dpurdie 304
   ' All mandatory parameters FOUND
121 hknight 305
 
129 ghuddy 306
   Err.Clear
307
   On Error Resume Next
308
   OraSession.BeginTrans
309
   ' The called subroutines beneath here do not use "on error resume next", but this calling code does, so if any error
310
   ' occurs in the called functions, control will resume within this code somewhere. On the assumption that an error might
311
   ' be the result of some problem in the database, further database commands are not performed, achieved by making them
312
   ' conditional upon Err.Number being zero. Ultimately, this should result in a rollback
121 hknight 313
 
129 ghuddy 314
   array_is_empty = TRUE
315
   If Request("update_type") = "add_custom" Then
316
      '---- ADD CUSTOM dependency ----
121 hknight 317
      ' NOTE - this happens when user clicks the Add action button on the dependencies/runtime tabs. Although the underlying search operation
318
      ' (see form_search_pkgs.asp and form_search_result_pkgs.asp) returns a list called "pkg_list", it actually contains a pv_id list in these
319
      ' special cases.
129 ghuddy 320
      Call Populate_depArray_from_ADD_Custom ( Request("pkg_list"), depArray, array_is_empty )
121 hknight 321
 
129 ghuddy 322
      If ((NOT array_is_empty) AND (Err.number = 0)) Then
323
         Call Update_Package_Dependencies ( depArray, Request("pv_id"), objAccessControl.UserId, enumlocal_DELETE_OLD_DEPENDENCIES, "depend_add", null )
324
      End If
119 ghuddy 325
 
121 hknight 326
 
129 ghuddy 327
   ElseIf Request("update_type") = "edit_custom" Then
328
      '---- EDIT CUSTOM dependency ----
329
      Call Populate_depArray_from_EDIT_Custom ( Request("pv_id"), depArray, array_is_empty, sDependBlock )
330
      Call Remove_Old_Dependencies ( Request("pv_id") )
121 hknight 331
 
129 ghuddy 332
      If ((NOT array_is_empty) AND (Err.number = 0)) Then
333
         Call Update_Package_Dependencies ( depArray, Request("pv_id"), objAccessControl.UserId, enumlocal_DONOT_DELETE_OLD_DEPENDENCIES, "depend_update", sDependBlock )
334
      End If
119 ghuddy 335
 
121 hknight 336
 
129 ghuddy 337
   Else
338
      '---- JATS, ANT dependency import ----
339
      Call Populate_depArray_from_Import ( Request("FRdeps"), depArray, array_is_empty )
340
      Call Remove_Old_Dependencies ( Request("pv_id") )
121 hknight 341
 
129 ghuddy 342
      If ((NOT array_is_empty) AND (Err.number = 0)) Then
343
         Call Update_Package_Dependencies ( depArray, Request("pv_id"), objAccessControl.UserId, enumlocal_DONOT_DELETE_OLD_DEPENDENCIES, "depend_import", Request("FRdeps") )
344
      End If
121 hknight 345
 
129 ghuddy 346
   End If
121 hknight 347
 
348
 
129 ghuddy 349
   If Err.number = 0 Then
350
      Call Update_Mod_Details ( Request("pv_id") )
351
   End If
121 hknight 352
 
353
 
129 ghuddy 354
   If Err.number <> 0 Then
355
      OraSession.RollBack
356
      Call RaiseMsg ( enum_MSG_ERROR, Err.description &"<br>"& Err.Source )
357
   Else
358
      OraSession.CommitTrans
359
   End If
121 hknight 360
 
129 ghuddy 361
   Response.Redirect("dependencies.asp?pv_id="& Request("pv_id") &"&rtag_id="& Request("rtag_id"))
119 ghuddy 362
Else
1376 dpurdie 363
   Response.write "Some mandatory parameters are missing!" & "<br>" 'TODO
4955 dpurdie 364
   Response.write QSTR_FullQuery
119 ghuddy 365
End If
366
%>
367
 
368
<!-- DESTRUCTOR ------->
121 hknight 369
<!--#include file="common/destructor.asp"-->