Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
119 ghuddy 1
<%@LANGUAGE="VBSCRIPT"%>
2
<%
3
'=====================================================
123 ghuddy 4
'                  NEW VERSION
119 ghuddy 5
'               --- PROCESS FORM ---
6
'=====================================================
7
%>
8
<%
9
Option explicit
10
' Good idea to set when using redirect
123 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 parOLDpv_id
31
Dim parFRnewver
32
Dim NEWpv_id
33
Dim parSetToPv_id
34
Dim parSync_rtags
35
Dim toTouch
36
'------------ Constants Declaration -----------
37
'------------ Variable Init -------------------
38
parOLDpv_id = QStrPar("OLDpv_id")
39
parFRnewver = QStrPar("FRnewver")
40
parSetToPv_id = QStrPar("pv_id")
41
parSync_rtags = Request("sync_rtags")
151 ghuddy 42
 
119 ghuddy 43
'----------------------------------------------
44
%>
45
<%
46
Sub New_Version ( SSnewver, NNorig_pv_id, NNSetToPv_id, NNrtag_id, sSyncRtags, retNEWpv_id )
123 ghuddy 47
   Dim cAlterReleaseWhileRestrictive, rsQry
48
 
49
   On Error Resume Next
50
   objEH.ErrorRedirect = TRUE
51
 
52
   If Request("build_type") = "A" Then
53
      SSnewver = ""
54
   End If
55
 
56
   OraDatabase.Parameters.Add "ORIG_PV_ID", NNorig_pv_id, ORAPARM_INPUT, ORATYPE_NUMBER
57
 
58
   If Request("build_type") = "M" Then
59
      ' Manual build
60
      OraDatabase.Parameters.Add "PKG_VERSION", SSnewver, ORAPARM_INPUT, ORATYPE_VARCHAR2
61
   Else
62
      ' Automated Build
63
      OraDatabase.Parameters.Add "PKG_VERSION", Request("v_ext"), ORAPARM_INPUT, ORATYPE_VARCHAR2
64
   End If
65
 
66
   ' Access Control - Allow release change while release is in restrictive mode
67
   cAlterReleaseWhileRestrictive = "N"
68
   If objAccessControl.IsActive("AlterReleaseContentsInRestrictiveMode") Then cAlterReleaseWhileRestrictive = "Y"
69
 
70
   OraDatabase.Parameters.Add "BUILD_TYPE",                Request("build_type"),         ORAPARM_INPUT, ORATYPE_CHAR
71
   OraDatabase.Parameters.Add "ALTER_RELEASE",             cAlterReleaseWhileRestrictive, ORAPARM_INPUT, ORATYPE_CHAR
72
   OraDatabase.Parameters.Add "SET_TO_PV_ID",              NNSetToPv_id,                  ORAPARM_INPUT, ORATYPE_NUMBER
73
   OraDatabase.Parameters.Add "RTAG_ID",                   NNrtag_id,                     ORAPARM_INPUT, ORATYPE_NUMBER
74
   OraDatabase.Parameters.Add "USER_ID",                   objAccessControl.UserId,       ORAPARM_INPUT, ORATYPE_NUMBER
75
   OraDatabase.Parameters.Add "enumISSUES_STATE_IMPORTED", enumISSUES_STATE_IMPORTED,     ORAPARM_INPUT, ORATYPE_NUMBER
76
   OraDatabase.Parameters.Add "RETPV_ID",                  0,                             ORAPARM_OUTPUT,ORATYPE_NUMBER
77
 
78
   objEH.TryORA ( OraSession )
79
 
80
   Set rsQry = OraDatabase.DbCreateDynaset("SELECT * FROM RELEASE_CONTENT WHERE RTAG_ID ="& Request("rtag_id") &" AND PV_ID = "& NNorig_pv_id &"", cint(0))
81
 
82
   If (NOT IsNull(rsQry("pkg_id"))) AND rsQry("pkg_state") = 6  Then
83
 
84
      Dim rsPv_id
85
 
86
      If (SSnewver) <> ""  Then
87
 
88
         Set rsPv_id = OraDatabase.DbCreateDynaset("SELECT * FROM PACKAGE_VERSIONS WHERE PKG_VERSION ='"& SSnewver &"' AND PKG_ID = "& rsQry("pkg_id") &"", cint(0))
89
 
90
         retNEWpv_id =  rsPv_id("pv_id")
91
 
92
         rsPv_id.Close()
93
         Set rsPv_id = nothing
94
      Else
95
         retNEWpv_id = NNSetToPv_id
96
      End If
97
      If NOT IsNull(retNewpv_id) Then
98
         OraDatabase.ExecuteSQL _
99
         "BEGIN "&_
100
         " UPDATE RELEASE_CONTENT SET PV_ID ="& retNEWpv_id &" WHERE RTAG_ID ="& Request("rtag_id") &" AND PV_ID ="& Request("OLDpv_id")&"; "&_
101
         "END;"
102
      Else
103
         OraDatabase.ExecuteSQL _
104
         "BEGIN "&_
105
         " PK_PACKAGE.NEW_VERSION ( :ORIG_PV_ID, "&_
106
         "                    :PKG_VERSION,"&_
107
         "                    :BUILD_TYPE,"&_
108
         "                    :SET_TO_PV_ID,"&_
109
         "                    :RTAG_ID,"&_
110
         "                    :USER_ID,"&_
111
         "                    :enumISSUES_STATE_IMPORTED,"&_
112
         "                    :RETPV_ID ); "&_
113
         " PK_RELEASE.CAN_USER_WRITE_TO_RELEASE ( :RTAG_ID, :RETPV_ID, :ALTER_RELEASE ); "&_
114
         " PK_ENVIRONMENT.REPLACE_PACKAGE ( :RETPV_ID, :ORIG_PV_ID, :RTAG_ID, :USER_ID ); "&_
115
         "END;"
116
 
117
         retNEWpv_id = OraDatabase.Parameters("RETPV_ID").Value
161 iaugusti 118
 
119
        Call UpdateSubVersionSrcPath(retNEWpv_id)
120
 
123 ghuddy 121
      End If
122
   Else
123
      OraDatabase.ExecuteSQL _
124
      "BEGIN "&_
125
      " PK_PACKAGE.NEW_VERSION ( :ORIG_PV_ID, "&_
126
      "                    :PKG_VERSION,"&_
127
      "                    :BUILD_TYPE,"&_
128
      "                    :SET_TO_PV_ID,"&_
129
      "                    :RTAG_ID,"&_
130
      "                    :USER_ID,"&_
131
      "                    :enumISSUES_STATE_IMPORTED,"&_
132
      "                    :RETPV_ID ); "&_
133
      " PK_RELEASE.CAN_USER_WRITE_TO_RELEASE ( :RTAG_ID, :RETPV_ID, :ALTER_RELEASE ); "&_
134
      " PK_ENVIRONMENT.REPLACE_PACKAGE ( :RETPV_ID, :ORIG_PV_ID, :RTAG_ID, :USER_ID ); "&_
135
      "END;"
136
 
137
      retNEWpv_id = OraDatabase.Parameters("RETPV_ID").Value
161 iaugusti 138
 
139
      Call UpdateSubVersionSrcPath(retNEWpv_id)
140
 
123 ghuddy 141
   End If
142
 
151 ghuddy 143
   objEH.CatchORA ( OraSession )
144
   If objEH.LastOraFailed = FALSE Then
145
      Call UpdateChangeType (retNEWpv_id, Request("change_type"))
146
      Call UpdateReasonForVersion (retNEWpv_id, Request("FRreason"))
147
   End If
148
 
123 ghuddy 149
   rsQry.Close()
150
   Set rsQry = nothing
151
 
152
   OraDatabase.Parameters.Remove "ORIG_PV_ID"
153
   OraDatabase.Parameters.Remove "ALTER_RELEASE"
154
   OraDatabase.Parameters.Remove "PKG_VERSION"
155
   OraDatabase.Parameters.Remove "BUILD_TYPE"
156
   OraDatabase.Parameters.Remove "SET_TO_PV_ID"
157
   OraDatabase.Parameters.Remove "RTAG_ID"
158
   OraDatabase.Parameters.Remove "USER_ID"
159
   OraDatabase.Parameters.Remove "enumISSUES_STATE_IMPORTED"
160
   OraDatabase.Parameters.Remove "RETPV_ID"
119 ghuddy 161
End Sub
162
'---------------------------------------------------------------
163
Sub Config_Spec (NNRtag_id, NNPv_id)
123 ghuddy 164
   OraDatabase.Parameters.Add "RTAG_ID", NNRtag_id,   ORAPARM_INPUT, ORATYPE_NUMBER
165
   OraDatabase.Parameters.Add "PV_ID", NNPv_id,   ORAPARM_INPUT, ORATYPE_NUMBER
119 ghuddy 166
 
123 ghuddy 167
   Set rsQry = OraDatabase.DbCreateDynaset( GetQuery("config_spec.sql"), cint(0))
119 ghuddy 168
 
123 ghuddy 169
   OraDatabase.Parameters.Remove "RTAG_ID"
170
   OraDatabase.Parameters.Remove "PV_ID"
119 ghuddy 171
End Sub
172
'---------------------------------------------------------------
173
Sub Config_Spec_Template (config_branch, pkg_label, src_path, pkg_name, release_name)
174
 
123 ghuddy 175
   Dim myMail, LocalPath, Template
119 ghuddy 176
 
123 ghuddy 177
   Set myMail=Server.CreateObject("Persits.MailSender")
178
   'LocalPath = Server.MapPath("docs\compareReleases_"&objAccessControl.UserName&".html")
179
   myMail.Host = SMTP_HOST
180
   myMail.Subject="Config Specs for package "& pkg_name &" in "& release_name &""
181
   myMail.From = ADMIN_EMAIL
182
   myMail.AddAddress objAccessControl.UserEmail
183
   ' Attach the file
184
   'myMail.AddAttachment LocalPath
185
   Template = "element * CHECKEDOUT" & chr(13) & chr(10) & _
186
   "element .../lost+found -none" & chr(13) & chr(10) & _
187
   "element * .../"& config_branch &"/LATEST" & chr(13) & chr(10) & _
188
   "element * "& pkg_label &" -mkbranch "& config_branch &"" & chr(13) & chr(10) & _
189
   "element * /main/0 -mkbranch "& config_branch &"" & chr(13) & chr(10) & _
190
   "load "& src_path &""
119 ghuddy 191
 
123 ghuddy 192
   myMail.Body = Template
193
   myMail.Send
194
   set myMail=nothing
195
 
196
 
119 ghuddy 197
End Sub
198
'---------------------------------------------------------------
199
Function SanityCheck ( newVersion )
200
 
123 ghuddy 201
   SanityCheck = False
119 ghuddy 202
 
123 ghuddy 203
   Dim objRegEx, objRegEx2
204
   Set objRegEx = New RegExp
205
   Set objRegEx2 = New RegExp
119 ghuddy 206
 
123 ghuddy 207
   objRegEx.IgnoreCase = True
208
   objRegEx.Pattern = "^[0-9]+\.[0-9]+\.[0-9]+\.[a-zA-Z0-9]+$"
209
   objRegEx2.Pattern = "\.cots$"
121 hknight 210
 
123 ghuddy 211
   If Len(newVersion) <= 50 Then
212
      If objRegEx.Test( newVersion ) OR objRegEx2.Test( newVersion ) Then
213
         SanityCheck = True
214
      End If
215
   End If
216
 
217
   If Request("build_type") = "A" Then
218
      SanityCheck = True
219
   End If
220
 
221
   Set objRegEx = Nothing
222
   Set objRegEx2 = Nothing
121 hknight 223
End Function
161 iaugusti 224
 
121 hknight 225
'---------------------------------------------------------------
226
Function VersionHasCotsExtension ( newVersion )
123 ghuddy 227
   VersionHasCotsExtension = False
119 ghuddy 228
 
123 ghuddy 229
   Dim myRegExp
230
   Set myRegExp = New RegExp
231
 
232
   myRegExp.Pattern = "\.cots$"
233
 
234
   If myRegExp.Test( newVersion ) Then
235
      VersionHasCotsExtension = True
236
   End If
237
 
238
   Set myRegExp = Nothing
119 ghuddy 239
End Function
161 iaugusti 240
 
119 ghuddy 241
'---------------------------------------------------------------
163 brianf 242
'Returns TRUE if the package is a COTS package and it has an ERG style
243
'patch-build number that can be rippled by the build system.
161 iaugusti 244
Function IsCotsPatch ( apv_id, achange_type)
245
   '--- get old package version ---
246
   Dim rsQry, Query_String
247
   Dim pkg_version_old
248
   Query_string = " SELECT pv.pkg_version FROM package_versions pv WHERE pv.pv_id = "& apv_id
249
   Set rsQry = OraDatabase.DbCreateDynaset(Query_String, cint(0))
250
   pkg_version_old = rsQry("pkg_version")
251
   rsQry.Close()
252
   Set rsQry = Nothing
253
 
254
   Dim myRegExp
255
   Set myRegExp = New RegExp
256
   ' Must be a patch and the version must have a patch build number, ie a dot and at least 4 digits before the cots extenstion.
257
   myRegExp.Pattern = "\.\d{4,}\.cots$"
258
   IsCotsPatch = myRegExp.Test( pkg_version_old ) and (achange_type = "P")
259
   Set myRegExp = Nothing      
260
End Function
261
 
262
'---------------------------------------------------------------
263
'Returns a new subversion package source path string by replacing or adding
264
'the specified label to the specified subversion package source path string.
265
Function  GetNewSvnSrcPath(asrc_path, alabel)
266
  Dim ssrc_base
267
  Dim snew_src_path
268
  Dim ssrc_path
269
  Dim slast_char
270
  Dim i,j
271
 
272
  if IsNull(asrc_path) then
273
    ssrc_path = ""
274
  else
275
    ssrc_path = asrc_path
276
  end if
277
 
278
  'get project directory from current package source path, ie path above either "tags" or "branches" or "trunk" directory
279
  i = InStrRev(LCase(ssrc_path), "/tags")
280
  if i = 0 then
281
    i = InStrRev(LCase(ssrc_path), "/branches")
282
    if i = 0 then
283
      i = InStrRev(LCase(ssrc_path), "/trunk")
284
    end if
285
  end if
286
 
287
  if i = 0 then
288
    '"tags" or "branches" or "trunk" not found
289
    'use current package source path as the project directory
290
    ssrc_base = ssrc_path
291
 
292
    'ensure project directory ends in a slash
293
    j = Len(ssrc_base)
294
    slast_char = Right(ssrc_base,1)
295
    if (j > 0) and (slast_char <> "/") then
296
      ssrc_base = ssrc_base & "/"
297
    end if
298
  else
299
    '"tags" or "branches" or "trunk" found so extract project directory
300
    ssrc_base = Mid(ssrc_path,1,i)
301
  end if
302
 
303
  'append new directory to the default project directory string.
304
  'the default path will be <project directory>/branches/<label>
305
  snew_src_path = ssrc_base & "branches/" & alabel
306
 
307
  GetNewSvnSrcPath = snew_src_path
308
 
309
End Function
310
 
311
'------------------------------------------------------------------
312
'This function is used to create the default package source path
313
'string when a new SubVersion package version is added.
314
'Assumes the specified pv_id is for a subversion package
315
Sub UpdateSubVersionSrcPath(apv_id)
316
  Dim rsQry
317
  Dim anew_src_path
318
  Dim ivcs_type_id
319
  Dim apkg_label
320
  Dim asrc_path
321
  Dim ssql
322
 
323
  'select the package and ensure it is a subversion package
324
  ssql = "SELECT * FROM PACKAGE_VERSIONS WHERE PV_ID ="& apv_id &" AND VCS_TYPE_ID=23"
325
 
326
  Set rsQry = OraDatabase.DbCreateDynaset(ssql, cint(0))
327
 
328
  If rsQry.RecordCount > 0 Then
329
    ivcs_type_id = rsQry("vcs_type_id")
330
    'pkg_label contains the new auto generated label for this version
331
    apkg_label = rsQry("pkg_label")
332
    asrc_path = rsQry("src_path")
333
    anew_src_path = GetNewSvnSrcPath(asrc_path,apkg_label)
334
 
335
    OraDatabase.ExecuteSQL _
336
      "BEGIN "&_
337
      " UPDATE PACKAGE_VERSIONS SET SRC_PATH ='"& anew_src_path &"' WHERE PV_ID ="& apv_id &"; "&_
338
      "END;"
339
  End If
340
 
341
  rsQry.Close()
342
  Set rsQry = nothing
343
 
344
End Sub
345
 
346
'-----------------------------------------------------------------------------------
119 ghuddy 347
%>
348
<%
349
'-----------------------  MAIN LINE  ---------------------------
350
Dim rsQry, Query_String, Record_Count
123 ghuddy 351
Dim versionToSanityCheck
161 iaugusti 352
 
119 ghuddy 353
'--- Process submission ---
161 iaugusti 354
If Request("build_type") = "A" AND VersionHasCotsExtension(parFRnewver) AND NOT (IsCotsPatch(parOLDpv_id,Request("change_type"))) Then
355
  Call RaiseMsg ( enum_MSG_CANNOT_AUTO_GENERATE_COTS_PKG&"?rtag_id="& parRtag_id &"&pv_id="& parOLDpv_id &"", parFRnewver)
121 hknight 356
Else
123 ghuddy 357
   If (parOLDpv_id <> "") AND ( (parFRnewver <> "") OR (parSetToPv_id <> "") ) AND (parRtag_id <> "") Then
358
      ' All mandatory parameters FOUND
119 ghuddy 359
 
123 ghuddy 360
      If ( (parSetToPv_id <> "") OR SanityCheck(parFRnewver) ) Then
119 ghuddy 361
 
131 ghuddy 362
         Record_Count = 0
363
 
123 ghuddy 364
         If Request("build_type") = "M" Then
365
            Query_string = " SELECT pv.pv_id, pv.is_patch, pv.dlocked"&_
366
                           " FROM package_versions pv"&_
367
                           " WHERE pv.pkg_version = '"& parFRnewver &"'"&_
368
                           " AND pv.pkg_id IN (SELECT DISTINCT origpv.pkg_id"&_
369
                           "  FROM package_versions origpv"&_
370
                           " WHERE origpv.pv_id = "& parOLDpv_id &")"
371
 
372
            Set rsQry = OraDatabase.DbCreateDynaset(Query_String, cint(0))
373
            Record_Count = rsQry.RecordCount
374
            rsQry.Close()
375
            Set rsQry = Nothing
376
         End If
377
 
378
         If Record_Count > 0 And Request("build_type") = "M" Then
379
            Call RaiseMsg ( enum_MSG_PACKAGE_VERSION_EXISTS&"?rtag_id="& parRtag_id &"&pv_id="& parOLDpv_id &"", parFRnewver )
380
         Else
381
            Call New_Version ( parFRnewver, parOLDpv_id, parSetToPv_id, parRtag_id, parSync_rtags, NEWpv_id )
382
 
383
            If objEH.Finally Then
384
               Response.Redirect("dependencies.asp?rtag_id="& parRtag_id &"&pv_id="& NEWpv_id )
385
            End If
386
         End If
387
      Else
388
         Call RaiseMsg( enum_MSG_PACKAGE_VERSION_INVALID&"?rtag_id="& parRtag_id &"&pv_id="& parOLDpv_id &"", parFRnewver )
389
      End If
390
 
391
   Else
392
      Response.write "Some mandatory parameters are missing!" & "<br>" 'TODO
393
      Response.write QSTR_All
394
   End If ' If (parOLDpv_id <> "") AND ( (parFRnewver <> "") OR (parSetToPv_id <> "") ) AND (parRtag_id <> "") Then
121 hknight 395
End If ' If Request("build_type") = "A" AND VersionHasCotsExtension( parFRnewver ) Then
119 ghuddy 396
%>
397
 
398
<!-- DESTRUCTOR ------->
123 ghuddy 399
<!--#include file="common/destructor.asp"-->