Subversion Repositories DevTools

Rev

Details | 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
   '
70
   ' Note. Jants and Ant dependencies are formatted to look like:
71
   '    JantStyle('PackageName','PackageVersion');
72
   '    AntStyle('PackageName','PackageVersion');
121 hknight 73
 
163 brianf 74
   re.Pattern = "(^|\n)\s*([_A-Za-z0-9]+)\s*\(\s*\'([^\']*)\'\s*\,\s*\'([^\']*)\'\s*\)"
161 iaugusti 75
   Set Matches = re.Execute(SSdep_import)
76
 
77
   recCnt=0
78
   For Each Match in Matches
79
     build_type = Match.SubMatches(1)
80
     pkg_name = Match.SubMatches(2)
81
     pkg_version = Match.SubMatches(3)
82
 
129 ghuddy 83
      ' Proceed only if:
84
      '    pkg name is not empty,
85
      '    pkg version is not empty,
161 iaugusti 86
      If ( pkg_name <> "" )  AND  ( pkg_version <> "" ) Then
129 ghuddy 87
         ReDim Preserve ARRdep( 2, recCnt )
88
         ARRdep( COL_pkg_name, recCnt ) = pkg_name
89
         ARRdep( COL_pkg_version, recCnt ) = pkg_version
90
         ' Define build type
161 iaugusti 91
         If LCase(build_type) = LCase("BuildPkgArchive") Then
129 ghuddy 92
            ARRdep( COL_build_type, recCnt ) = enum_BUILD_PKG_ARCHIVE
161 iaugusti 93
         ElseIf LCase(build_type) = LCase("LinkPkgArchive") Then
129 ghuddy 94
            ARRdep( COL_build_type, recCnt ) = enum_LINK_PKG_ARCHIVE
95
         Else
96
            ARRdep( COL_build_type, recCnt ) = enum_BUILD_PKG_ARCHIVE   'neither build_package or link_package is found, hence set to...
97
         End If
98
         recCnt = recCnt + 1
99
         BBarray_is_empty = FALSE
161 iaugusti 100
     End If
129 ghuddy 101
   Next
121 hknight 102
 
119 ghuddy 103
End Sub
104
 
121 hknight 105
' This function is called when update_type is "add_custom". This is only the case when adding dependencies
106
' 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
107
' 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
108
' changed so that users can only add package versions from the relevant release as dependencies to a packge also in that
109
' 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
110
' contains 2 instances of a package, each one having different extensions (eg .mas, .sea).
111
Sub Populate_depArray_from_ADD_Custom ( NNpv_id_list, ARRdep, BBarray_is_empty )
129 ghuddy 112
   Dim depList, lastItem, i, recCnt, pkg_name, pkg_version, V_EXT
113
   Dim rsTemp, Query_String, PkgBaseView
121 hknight 114
 
129 ghuddy 115
   PkgBaseView = Get_Pkg_Base_View_ID ( Request("pv_id"), Request("rtag_id") )
121 hknight 116
 
129 ghuddy 117
   Query_String = _
121 hknight 118
   " SELECT pkgs.pkg_id, pkgs.pkg_name, pv.pv_id, pv.pkg_version"&_
119
   "  FROM packages pkgs, package_versions pv"&_
120
   " WHERE pv.pv_id IN ("& NNpv_id_list &")"&_
121
   "   AND pv.pkg_id = pkgs.pkg_id"
129 ghuddy 122
   Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0))
121 hknight 123
 
129 ghuddy 124
   recCnt = 0
125
   While ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF))
126
      ReDim Preserve ARRdep( 2, recCnt )
127
      ARRdep( COL_pkg_name, recCnt ) = rsTemp("pkg_name")
121 hknight 128
      ARRdep( COL_pkg_version, recCnt ) = rsTemp("pkg_version")
129
 
129 ghuddy 130
      '// Dependencies comming from custom dependency add are set to LinkPkgArchive by default, unless it is a product
131
      If PkgBaseView = enumBASE_VIEW_PRODUCTS Then
132
         ARRdep( COL_build_type, recCnt ) = enum_BUILD_PKG_ARCHIVE
133
      Else
134
         ARRdep( COL_build_type, recCnt ) = enum_LINK_PKG_ARCHIVE
135
      End If
121 hknight 136
 
129 ghuddy 137
      recCnt = recCnt + 1
138
      BBarray_is_empty = FALSE
139
      rsTemp.MoveNext
140
   WEnd
121 hknight 141
 
129 ghuddy 142
   rsTemp.Close
143
   Set rsTemp = nothing
119 ghuddy 144
End Sub
145
 
3959 dpurdie 146
// The form passed to us may only have information for packages that need to change
147
// The enumlocal_DONOT_DELETE_OLD_DEPENDENCIES does not appear to work
148
//  Must provide a full set of dependencies with either a new version or the existing version
149
//
119 ghuddy 150
Sub Populate_depArray_from_EDIT_Custom ( NNpv_id, ARRdep, BBarray_is_empty, sDependBlock )
129 ghuddy 151
   Dim depList, lastItem, i, recCnt, pkg_name, pkg_version, V_EXT
152
   Dim rsTemp, rsCurrent, Query_String
121 hknight 153
 
129 ghuddy 154
   Query_String = _
155
   " SELECT dpkg.pkg_name, dpv.pkg_version, dpv.pv_id"&_
156
   "  FROM package_dependencies dep,"&_
157
   "       package_versions dpv,"&_
158
   "       packages dpkg"&_
159
   " WHERE dep.dpv_id = dpv.pv_id"&_
160
   "   AND dpv.pkg_id = dpkg.pkg_id"&_
161
   "   AND dep.pv_id = "& NNpv_id
121 hknight 162
 
129 ghuddy 163
   Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0))
121 hknight 164
 
129 ghuddy 165
   recCnt = 0
166
   While ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF))
3959 dpurdie 167
      Dim pvid, pkgver, newver
168
      pvid = rsTemp("pv_id")
169
      pkgver = Request( "pkgn" & pvid )
170
 
171
      If pkgver <> "" Then
172
        newver = pkgver
173
      else
174
        newver = rsTemp("pkg_version")
175
      End if
176
 
129 ghuddy 177
      ReDim Preserve ARRdep( 2, recCnt )
178
      ARRdep( COL_pkg_name, recCnt )    = rsTemp("pkg_name")
3959 dpurdie 179
      ARRdep( COL_pkg_version, recCnt ) = newver
180
      ARRdep( COL_build_type, recCnt )  = Request( "bt"& pvid )
119 ghuddy 181
 
3959 dpurdie 182
      If not rsTemp("pkg_version") =  newver Then
183
         sDependBlock = rsTemp("pkg_name") & " " & newver
129 ghuddy 184
      End If
121 hknight 185
 
129 ghuddy 186
      recCnt = recCnt + 1
187
      BBarray_is_empty = FALSE
3959 dpurdie 188
 
129 ghuddy 189
      rsTemp.MoveNext
190
   WEnd
121 hknight 191
 
129 ghuddy 192
   rsTemp.Close
193
   Set rsTemp = nothing
119 ghuddy 194
End Sub
195
 
196
Sub Update_Package_Dependencies ( ARRdep, NNpv_id, NNuser_id, NNdelete_old_dependency, sAction_type, sDependBlock )
129 ghuddy 197
   Dim i, OraParameter, sComments
121 hknight 198
 
129 ghuddy 199
   OraDatabase.Parameters.Add "PV_ID",            NNpv_id,                 ORAPARM_INPUT, ORATYPE_NUMBER
200
   OraDatabase.Parameters.Add "PKG_NAME",         "",                      ORAPARM_INPUT, ORATYPE_VARCHAR2
201
   OraDatabase.Parameters.Add "PKG_VERSION",      "",                      ORAPARM_INPUT, ORATYPE_VARCHAR2
202
   OraDatabase.Parameters.Add "BUILD_TYPE",       "",                      ORAPARM_INPUT, ORATYPE_VARCHAR2
203
   OraDatabase.Parameters.Add "USER_ID",          NNuser_id,               ORAPARM_INPUT, ORATYPE_NUMBER
204
   OraDatabase.Parameters.Add "DELETE_PV_ID",     NNdelete_old_dependency, ORAPARM_INPUT, ORATYPE_NUMBER
205
   OraDatabase.Parameters.Add "ACTION_TYPE_NAME", sAction_type,            ORAPARM_INPUT, ORATYPE_VARCHAR2
121 hknight 206
 
129 ghuddy 207
   Set OraParameter = OraDatabase.Parameters
121 hknight 208
 
129 ghuddy 209
   For i = 0 To UBound( ARRdep, 2 )
210
      If not i = 0 Then
211
         sComments = sComments & ", "
212
      End If
213
      sComments = sComments & depArray(COL_pkg_name, i) & " " & ARRdep( COL_pkg_version, i )
121 hknight 214
 
129 ghuddy 215
      OraParameter("PKG_NAME").Value    = ARRdep( COL_pkg_name, i )
216
      OraParameter("PKG_VERSION").Value = ARRdep( COL_pkg_version, i )
217
      OraParameter("BUILD_TYPE").Value  = ARRdep( COL_build_type, i )
121 hknight 218
 
129 ghuddy 219
      OraDatabase.ExecuteSQL "BEGIN  Update_Package_Dependency ( :PV_ID, :PKG_NAME, :PKG_VERSION, :BUILD_TYPE, :USER_ID, :DELETE_PV_ID );  END;"
121 hknight 220
 
129 ghuddy 221
   Next
121 hknight 222
 
129 ghuddy 223
   Set OraParameter = Nothing
121 hknight 224
 
129 ghuddy 225
   If sAction_type = "depend_add" Then
226
      OraDatabase.Parameters.Add "COMMENTS",    sComments, ORAPARM_INPUT, ORATYPE_VARCHAR2
227
   Else
228
      If Len(sDependBlock) <= 4000 Then
229
         OraDatabase.Parameters.Add "COMMENTS",    sDependBlock, ORAPARM_INPUT, ORATYPE_VARCHAR2
230
      Else
231
         OraDatabase.Parameters.Add "COMMENTS",    "Description too long to be inserted!", ORAPARM_INPUT, ORATYPE_VARCHAR2
232
      End If
233
   End If
119 ghuddy 234
 
129 ghuddy 235
   OraDatabase.ExecuteSQL _
236
   "BEGIN  Log_Action ( :PV_ID, :ACTION_TYPE_NAME, :USER_ID, :COMMENTS );  END;"
119 ghuddy 237
 
121 hknight 238
 
239
 
129 ghuddy 240
   OraDatabase.Parameters.Remove "PV_ID"
241
   OraDatabase.Parameters.Remove "PKG_NAME"
242
   OraDatabase.Parameters.Remove "PKG_VERSION"
243
   OraDatabase.Parameters.Remove "BUILD_TYPE"
244
   OraDatabase.Parameters.Remove "USER_ID"
245
   OraDatabase.Parameters.Remove "DELETE_PV_ID"
246
   OraDatabase.Parameters.Remove "ACTION_TYPE_NAME"
247
   OraDatabase.Parameters.Remove "COMMENTS"
119 ghuddy 248
End Sub
249
 
250
 
251
Sub Remove_Old_Dependencies ( SSpv_id )
129 ghuddy 252
   OraDatabase.Parameters.Add "PV_ID", SSpv_id,    ORAPARM_INPUT, ORATYPE_NUMBER
121 hknight 253
 
129 ghuddy 254
   OraDatabase.ExecuteSQL "DELETE FROM package_dependencies WHERE pv_id = :PV_ID"
121 hknight 255
 
129 ghuddy 256
   OraDatabase.Parameters.Remove "PV_ID"
119 ghuddy 257
End Sub
258
 
259
 
260
Sub Update_Mod_Details ( SSpv_id )
129 ghuddy 261
   OraDatabase.Parameters.Add "PV_ID",   SSpv_id,                 ORAPARM_INPUT, ORATYPE_NUMBER
262
   OraDatabase.Parameters.Add "RTAG_ID", Request("rtag_id"),      ORAPARM_INPUT, ORATYPE_NUMBER
263
   OraDatabase.Parameters.Add "USER_ID", objAccessControl.UserId, ORAPARM_INPUT, ORATYPE_NUMBER
121 hknight 264
 
129 ghuddy 265
   OraDatabase.ExecuteSQL _
266
      " UPDATE package_versions "&_
267
       " SET modified_stamp = "& ORA_SYSDATETIME &", modifier_id = :USER_ID"&_
268
       " WHERE pv_id = :PV_ID"
121 hknight 269
 
129 ghuddy 270
   If Request("rtag_id") <> "" Then
271
      ' Package in release view
272
      OraDatabase.ExecuteSQL _
273
        "BEGIN "&_
274
      " Touch_Release ( :RTAG_ID ); "&_
275
      "END; "
121 hknight 276
 
129 ghuddy 277
   Else
278
      ' Package view
279
      OraDatabase.ExecuteSQL _
280
        "BEGIN "&_
281
      " PK_RELEASE.RUN_POST_ACTIONS_BULK ( :PV_ID ); "&_
282
      "END; "
121 hknight 283
 
129 ghuddy 284
   End If
121 hknight 285
 
129 ghuddy 286
   OraDatabase.Parameters.Remove "PV_ID"
287
   OraDatabase.Parameters.Remove "RTAG_ID"
288
   OraDatabase.Parameters.Remove "USER_ID"
119 ghuddy 289
End Sub
290
 
291
%>
292
<%
293
'-----------------------  MAIN LINE  ---------------------------
3959 dpurdie 294
'Response.Write "<pre>------------<br>"
295
'Dim Item
296
'For Each Item In Request.Form
297
'    Response.Write "User Data: " &Item & ": " & Request.Form(Item) & "<br>"
298
'Next
299
'Response.Write "------------<br>"
119 ghuddy 300
 
301
Dim sDependBlock
302
 
303
'--- Process submition ---
304
If (QStrPar("pv_id") <> "")  Then
1376 dpurdie 305
   ' All mandatory parameters FOUND
121 hknight 306
 
129 ghuddy 307
   Err.Clear
308
   On Error Resume Next
309
   OraSession.BeginTrans
310
   ' The called subroutines beneath here do not use "on error resume next", but this calling code does, so if any error
311
   ' occurs in the called functions, control will resume within this code somewhere. On the assumption that an error might
312
   ' be the result of some problem in the database, further database commands are not performed, achieved by making them
313
   ' conditional upon Err.Number being zero. Ultimately, this should result in a rollback
121 hknight 314
 
129 ghuddy 315
   array_is_empty = TRUE
316
   If Request("update_type") = "add_custom" Then
317
      '---- ADD CUSTOM dependency ----
121 hknight 318
      ' NOTE - this happens when user clicks the Add action button on the dependencies/runtime tabs. Although the underlying search operation
319
      ' (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
320
      ' special cases.
129 ghuddy 321
      Call Populate_depArray_from_ADD_Custom ( Request("pkg_list"), depArray, array_is_empty )
121 hknight 322
 
129 ghuddy 323
      If ((NOT array_is_empty) AND (Err.number = 0)) Then
324
         Call Update_Package_Dependencies ( depArray, Request("pv_id"), objAccessControl.UserId, enumlocal_DELETE_OLD_DEPENDENCIES, "depend_add", null )
325
      End If
119 ghuddy 326
 
121 hknight 327
 
129 ghuddy 328
   ElseIf Request("update_type") = "edit_custom" Then
329
      '---- EDIT CUSTOM dependency ----
330
      Call Populate_depArray_from_EDIT_Custom ( Request("pv_id"), depArray, array_is_empty, sDependBlock )
331
      Call Remove_Old_Dependencies ( Request("pv_id") )
121 hknight 332
 
129 ghuddy 333
      If ((NOT array_is_empty) AND (Err.number = 0)) Then
334
         Call Update_Package_Dependencies ( depArray, Request("pv_id"), objAccessControl.UserId, enumlocal_DONOT_DELETE_OLD_DEPENDENCIES, "depend_update", sDependBlock )
335
      End If
119 ghuddy 336
 
121 hknight 337
 
129 ghuddy 338
   Else
339
      '---- JATS, ANT dependency import ----
340
      Call Populate_depArray_from_Import ( Request("FRdeps"), depArray, array_is_empty )
341
      Call Remove_Old_Dependencies ( Request("pv_id") )
121 hknight 342
 
129 ghuddy 343
      If ((NOT array_is_empty) AND (Err.number = 0)) Then
344
         Call Update_Package_Dependencies ( depArray, Request("pv_id"), objAccessControl.UserId, enumlocal_DONOT_DELETE_OLD_DEPENDENCIES, "depend_import", Request("FRdeps") )
345
      End If
121 hknight 346
 
129 ghuddy 347
   End If
121 hknight 348
 
349
 
129 ghuddy 350
   If Err.number = 0 Then
351
      Call Update_Mod_Details ( Request("pv_id") )
352
   End If
121 hknight 353
 
354
 
129 ghuddy 355
   If Err.number <> 0 Then
356
      OraSession.RollBack
357
      Call RaiseMsg ( enum_MSG_ERROR, Err.description &"<br>"& Err.Source )
358
   Else
359
      OraSession.CommitTrans
360
   End If
121 hknight 361
 
129 ghuddy 362
   Response.Redirect("dependencies.asp?pv_id="& Request("pv_id") &"&rtag_id="& Request("rtag_id"))
119 ghuddy 363
Else
1376 dpurdie 364
   Response.write "Some mandatory parameters are missing!" & "<br>" 'TODO
129 ghuddy 365
   Response.write QSTR_All
119 ghuddy 366
End If
367
%>
368
 
369
<!-- DESTRUCTOR ------->
121 hknight 370
<!--#include file="common/destructor.asp"-->