Subversion Repositories DevTools

Rev

Rev 3875 | 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' );
3875 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
 
3896 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))
3896 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")
3896 dpurdie 179
      ARRdep( COL_pkg_version, recCnt ) = newver
180
      ARRdep( COL_build_type, recCnt )  = Request( "bt"& pvid )
119 ghuddy 181
 
3896 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
3896 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  ---------------------------
294
 
295
Dim sDependBlock
296
 
297
'--- Process submition ---
298
If (QStrPar("pv_id") <> "")  Then
1337 dpurdie 299
   ' All mandatory parameters FOUND
121 hknight 300
 
129 ghuddy 301
   Err.Clear
302
   On Error Resume Next
303
   OraSession.BeginTrans
304
   ' The called subroutines beneath here do not use "on error resume next", but this calling code does, so if any error
305
   ' occurs in the called functions, control will resume within this code somewhere. On the assumption that an error might
306
   ' be the result of some problem in the database, further database commands are not performed, achieved by making them
307
   ' conditional upon Err.Number being zero. Ultimately, this should result in a rollback
121 hknight 308
 
129 ghuddy 309
   array_is_empty = TRUE
310
   If Request("update_type") = "add_custom" Then
311
      '---- ADD CUSTOM dependency ----
121 hknight 312
      ' NOTE - this happens when user clicks the Add action button on the dependencies/runtime tabs. Although the underlying search operation
313
      ' (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
314
      ' special cases.
129 ghuddy 315
      Call Populate_depArray_from_ADD_Custom ( Request("pkg_list"), depArray, array_is_empty )
121 hknight 316
 
129 ghuddy 317
      If ((NOT array_is_empty) AND (Err.number = 0)) Then
318
         Call Update_Package_Dependencies ( depArray, Request("pv_id"), objAccessControl.UserId, enumlocal_DELETE_OLD_DEPENDENCIES, "depend_add", null )
319
      End If
119 ghuddy 320
 
121 hknight 321
 
129 ghuddy 322
   ElseIf Request("update_type") = "edit_custom" Then
323
      '---- EDIT CUSTOM dependency ----
324
      Call Populate_depArray_from_EDIT_Custom ( Request("pv_id"), depArray, array_is_empty, sDependBlock )
325
      Call Remove_Old_Dependencies ( Request("pv_id") )
121 hknight 326
 
129 ghuddy 327
      If ((NOT array_is_empty) AND (Err.number = 0)) Then
328
         Call Update_Package_Dependencies ( depArray, Request("pv_id"), objAccessControl.UserId, enumlocal_DONOT_DELETE_OLD_DEPENDENCIES, "depend_update", sDependBlock )
329
      End If
119 ghuddy 330
 
121 hknight 331
 
129 ghuddy 332
   Else
333
      '---- JATS, ANT dependency import ----
334
      Call Populate_depArray_from_Import ( Request("FRdeps"), depArray, array_is_empty )
335
      Call Remove_Old_Dependencies ( Request("pv_id") )
121 hknight 336
 
129 ghuddy 337
      If ((NOT array_is_empty) AND (Err.number = 0)) Then
338
         Call Update_Package_Dependencies ( depArray, Request("pv_id"), objAccessControl.UserId, enumlocal_DONOT_DELETE_OLD_DEPENDENCIES, "depend_import", Request("FRdeps") )
339
      End If
121 hknight 340
 
129 ghuddy 341
   End If
121 hknight 342
 
343
 
129 ghuddy 344
   If Err.number = 0 Then
345
      Call Update_Mod_Details ( Request("pv_id") )
346
   End If
121 hknight 347
 
348
 
129 ghuddy 349
   If Err.number <> 0 Then
350
      OraSession.RollBack
351
      Call RaiseMsg ( enum_MSG_ERROR, Err.description &"<br>"& Err.Source )
352
   Else
353
      OraSession.CommitTrans
354
   End If
121 hknight 355
 
129 ghuddy 356
   Response.Redirect("dependencies.asp?pv_id="& Request("pv_id") &"&rtag_id="& Request("rtag_id"))
119 ghuddy 357
Else
1337 dpurdie 358
   Response.write "Some mandatory parameters are missing!" & "<br>" 'TODO
129 ghuddy 359
   Response.write QSTR_All
119 ghuddy 360
End If
361
%>
362
 
363
<!-- DESTRUCTOR ------->
121 hknight 364
<!--#include file="common/destructor.asp"-->