Subversion Repositories DevTools

Rev

Rev 1337 | Rev 3896 | 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
 
146
 
147
Sub Populate_depArray_from_EDIT_Custom ( NNpv_id, ARRdep, BBarray_is_empty, sDependBlock )
129 ghuddy 148
   Dim depList, lastItem, i, recCnt, pkg_name, pkg_version, V_EXT
149
   Dim rsTemp, rsCurrent, Query_String
121 hknight 150
 
129 ghuddy 151
   Query_String = _
152
   " SELECT dpkg.pkg_name, dpv.pkg_version, dpv.pv_id"&_
153
   "  FROM package_dependencies dep,"&_
154
   "       package_versions dpv,"&_
155
   "       packages dpkg"&_
156
   " WHERE dep.dpv_id = dpv.pv_id"&_
157
   "   AND dpv.pkg_id = dpkg.pkg_id"&_
158
   "   AND dep.pv_id = "& NNpv_id
121 hknight 159
 
129 ghuddy 160
   Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0))
121 hknight 161
 
129 ghuddy 162
   recCnt = 0
163
   While ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF))
164
      ReDim Preserve ARRdep( 2, recCnt )
165
      ARRdep( COL_pkg_name, recCnt )    = rsTemp("pkg_name")
166
      ARRdep( COL_pkg_version, recCnt ) = Request( "pkgn"& rsTemp("pv_id") )
167
      ARRdep( COL_build_type, recCnt )  = Request( "bt"& rsTemp("pv_id") )
119 ghuddy 168
 
129 ghuddy 169
      If not rsTemp("pkg_version") =  Request( "pkgn"& rsTemp("pv_id") ) Then
170
         sDependBlock = rsTemp("pkg_name") & " " & Request( "pkgn"& rsTemp("pv_id") )
171
      End If
121 hknight 172
 
129 ghuddy 173
      recCnt = recCnt + 1
174
      BBarray_is_empty = FALSE
175
      rsTemp.MoveNext
176
   WEnd
121 hknight 177
 
129 ghuddy 178
   rsTemp.Close
179
   Set rsTemp = nothing
119 ghuddy 180
End Sub
181
 
182
Sub Update_Package_Dependencies ( ARRdep, NNpv_id, NNuser_id, NNdelete_old_dependency, sAction_type, sDependBlock )
129 ghuddy 183
   Dim i, OraParameter, sComments
121 hknight 184
 
129 ghuddy 185
   OraDatabase.Parameters.Add "PV_ID",            NNpv_id,                 ORAPARM_INPUT, ORATYPE_NUMBER
186
   OraDatabase.Parameters.Add "PKG_NAME",         "",                      ORAPARM_INPUT, ORATYPE_VARCHAR2
187
   OraDatabase.Parameters.Add "PKG_VERSION",      "",                      ORAPARM_INPUT, ORATYPE_VARCHAR2
188
   OraDatabase.Parameters.Add "BUILD_TYPE",       "",                      ORAPARM_INPUT, ORATYPE_VARCHAR2
189
   OraDatabase.Parameters.Add "USER_ID",          NNuser_id,               ORAPARM_INPUT, ORATYPE_NUMBER
190
   OraDatabase.Parameters.Add "DELETE_PV_ID",     NNdelete_old_dependency, ORAPARM_INPUT, ORATYPE_NUMBER
191
   OraDatabase.Parameters.Add "ACTION_TYPE_NAME", sAction_type,            ORAPARM_INPUT, ORATYPE_VARCHAR2
121 hknight 192
 
129 ghuddy 193
   Set OraParameter = OraDatabase.Parameters
121 hknight 194
 
129 ghuddy 195
   For i = 0 To UBound( ARRdep, 2 )
196
      If not i = 0 Then
197
         sComments = sComments & ", "
198
      End If
199
      sComments = sComments & depArray(COL_pkg_name, i) & " " & ARRdep( COL_pkg_version, i )
121 hknight 200
 
129 ghuddy 201
      OraParameter("PKG_NAME").Value    = ARRdep( COL_pkg_name, i )
202
      OraParameter("PKG_VERSION").Value = ARRdep( COL_pkg_version, i )
203
      OraParameter("BUILD_TYPE").Value  = ARRdep( COL_build_type, i )
121 hknight 204
 
129 ghuddy 205
      OraDatabase.ExecuteSQL "BEGIN  Update_Package_Dependency ( :PV_ID, :PKG_NAME, :PKG_VERSION, :BUILD_TYPE, :USER_ID, :DELETE_PV_ID );  END;"
121 hknight 206
 
129 ghuddy 207
   Next
121 hknight 208
 
129 ghuddy 209
   Set OraParameter = Nothing
121 hknight 210
 
129 ghuddy 211
   If sAction_type = "depend_add" Then
212
      OraDatabase.Parameters.Add "COMMENTS",    sComments, ORAPARM_INPUT, ORATYPE_VARCHAR2
213
   Else
214
      If Len(sDependBlock) <= 4000 Then
215
         OraDatabase.Parameters.Add "COMMENTS",    sDependBlock, ORAPARM_INPUT, ORATYPE_VARCHAR2
216
      Else
217
         OraDatabase.Parameters.Add "COMMENTS",    "Description too long to be inserted!", ORAPARM_INPUT, ORATYPE_VARCHAR2
218
      End If
219
   End If
119 ghuddy 220
 
129 ghuddy 221
   OraDatabase.ExecuteSQL _
222
   "BEGIN  Log_Action ( :PV_ID, :ACTION_TYPE_NAME, :USER_ID, :COMMENTS );  END;"
119 ghuddy 223
 
121 hknight 224
 
225
 
129 ghuddy 226
   OraDatabase.Parameters.Remove "PV_ID"
227
   OraDatabase.Parameters.Remove "PKG_NAME"
228
   OraDatabase.Parameters.Remove "PKG_VERSION"
229
   OraDatabase.Parameters.Remove "BUILD_TYPE"
230
   OraDatabase.Parameters.Remove "USER_ID"
231
   OraDatabase.Parameters.Remove "DELETE_PV_ID"
232
   OraDatabase.Parameters.Remove "ACTION_TYPE_NAME"
233
   OraDatabase.Parameters.Remove "COMMENTS"
119 ghuddy 234
End Sub
235
 
236
 
237
Sub Remove_Old_Dependencies ( SSpv_id )
129 ghuddy 238
   OraDatabase.Parameters.Add "PV_ID", SSpv_id,    ORAPARM_INPUT, ORATYPE_NUMBER
121 hknight 239
 
129 ghuddy 240
   OraDatabase.ExecuteSQL "DELETE FROM package_dependencies WHERE pv_id = :PV_ID"
121 hknight 241
 
129 ghuddy 242
   OraDatabase.Parameters.Remove "PV_ID"
119 ghuddy 243
End Sub
244
 
245
 
246
Sub Update_Mod_Details ( SSpv_id )
129 ghuddy 247
   OraDatabase.Parameters.Add "PV_ID",   SSpv_id,                 ORAPARM_INPUT, ORATYPE_NUMBER
248
   OraDatabase.Parameters.Add "RTAG_ID", Request("rtag_id"),      ORAPARM_INPUT, ORATYPE_NUMBER
249
   OraDatabase.Parameters.Add "USER_ID", objAccessControl.UserId, ORAPARM_INPUT, ORATYPE_NUMBER
121 hknight 250
 
129 ghuddy 251
   OraDatabase.ExecuteSQL _
252
      " UPDATE package_versions "&_
253
       " SET modified_stamp = "& ORA_SYSDATETIME &", modifier_id = :USER_ID"&_
254
       " WHERE pv_id = :PV_ID"
121 hknight 255
 
129 ghuddy 256
   If Request("rtag_id") <> "" Then
257
      ' Package in release view
258
      OraDatabase.ExecuteSQL _
259
        "BEGIN "&_
260
      " Touch_Release ( :RTAG_ID ); "&_
261
      "END; "
121 hknight 262
 
129 ghuddy 263
   Else
264
      ' Package view
265
      OraDatabase.ExecuteSQL _
266
        "BEGIN "&_
267
      " PK_RELEASE.RUN_POST_ACTIONS_BULK ( :PV_ID ); "&_
268
      "END; "
121 hknight 269
 
129 ghuddy 270
   End If
121 hknight 271
 
129 ghuddy 272
   OraDatabase.Parameters.Remove "PV_ID"
273
   OraDatabase.Parameters.Remove "RTAG_ID"
274
   OraDatabase.Parameters.Remove "USER_ID"
119 ghuddy 275
End Sub
276
 
277
%>
278
<%
279
'-----------------------  MAIN LINE  ---------------------------
280
 
281
Dim sDependBlock
282
 
283
'--- Process submition ---
284
If (QStrPar("pv_id") <> "")  Then
1337 dpurdie 285
   ' All mandatory parameters FOUND
121 hknight 286
 
129 ghuddy 287
   Err.Clear
288
   On Error Resume Next
289
   OraSession.BeginTrans
290
   ' The called subroutines beneath here do not use "on error resume next", but this calling code does, so if any error
291
   ' occurs in the called functions, control will resume within this code somewhere. On the assumption that an error might
292
   ' be the result of some problem in the database, further database commands are not performed, achieved by making them
293
   ' conditional upon Err.Number being zero. Ultimately, this should result in a rollback
121 hknight 294
 
129 ghuddy 295
   array_is_empty = TRUE
296
   If Request("update_type") = "add_custom" Then
297
      '---- ADD CUSTOM dependency ----
121 hknight 298
      ' NOTE - this happens when user clicks the Add action button on the dependencies/runtime tabs. Although the underlying search operation
299
      ' (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
300
      ' special cases.
129 ghuddy 301
      Call Populate_depArray_from_ADD_Custom ( Request("pkg_list"), depArray, array_is_empty )
121 hknight 302
 
129 ghuddy 303
      If ((NOT array_is_empty) AND (Err.number = 0)) Then
304
         Call Update_Package_Dependencies ( depArray, Request("pv_id"), objAccessControl.UserId, enumlocal_DELETE_OLD_DEPENDENCIES, "depend_add", null )
305
      End If
119 ghuddy 306
 
121 hknight 307
 
129 ghuddy 308
   ElseIf Request("update_type") = "edit_custom" Then
309
      '---- EDIT CUSTOM dependency ----
310
      Call Populate_depArray_from_EDIT_Custom ( Request("pv_id"), depArray, array_is_empty, sDependBlock )
311
      Call Remove_Old_Dependencies ( Request("pv_id") )
121 hknight 312
 
129 ghuddy 313
      If ((NOT array_is_empty) AND (Err.number = 0)) Then
314
         Call Update_Package_Dependencies ( depArray, Request("pv_id"), objAccessControl.UserId, enumlocal_DONOT_DELETE_OLD_DEPENDENCIES, "depend_update", sDependBlock )
315
      End If
119 ghuddy 316
 
121 hknight 317
 
129 ghuddy 318
   Else
319
      '---- JATS, ANT dependency import ----
320
      Call Populate_depArray_from_Import ( Request("FRdeps"), depArray, array_is_empty )
321
      Call Remove_Old_Dependencies ( Request("pv_id") )
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_DONOT_DELETE_OLD_DEPENDENCIES, "depend_import", Request("FRdeps") )
325
      End If
121 hknight 326
 
129 ghuddy 327
   End If
121 hknight 328
 
329
 
129 ghuddy 330
   If Err.number = 0 Then
331
      Call Update_Mod_Details ( Request("pv_id") )
332
   End If
121 hknight 333
 
334
 
129 ghuddy 335
   If Err.number <> 0 Then
336
      OraSession.RollBack
337
      Call RaiseMsg ( enum_MSG_ERROR, Err.description &"<br>"& Err.Source )
338
   Else
339
      OraSession.CommitTrans
340
   End If
121 hknight 341
 
129 ghuddy 342
   Response.Redirect("dependencies.asp?pv_id="& Request("pv_id") &"&rtag_id="& Request("rtag_id"))
119 ghuddy 343
Else
1337 dpurdie 344
   Response.write "Some mandatory parameters are missing!" & "<br>" 'TODO
129 ghuddy 345
   Response.write QSTR_All
119 ghuddy 346
End If
347
%>
348
 
349
<!-- DESTRUCTOR ------->
121 hknight 350
<!--#include file="common/destructor.asp"-->