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