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