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
'---------------------------------------------------------------
161 iaugusti 242
Function IsCotsPatch ( apv_id, achange_type)
243
   '--- get old package version ---
244
   Dim rsQry, Query_String
245
   Dim pkg_version_old
246
   Query_string = " SELECT pv.pkg_version FROM package_versions pv WHERE pv.pv_id = "& apv_id
247
   Set rsQry = OraDatabase.DbCreateDynaset(Query_String, cint(0))
248
   pkg_version_old = rsQry("pkg_version")
249
   rsQry.Close()
250
   Set rsQry = Nothing
251
 
252
   Dim myRegExp
253
   Set myRegExp = New RegExp
254
   ' 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.
255
   myRegExp.Pattern = "\.\d{4,}\.cots$"
256
   IsCotsPatch = myRegExp.Test( pkg_version_old ) and (achange_type = "P")
257
   Set myRegExp = Nothing      
258
End Function
259
 
260
'---------------------------------------------------------------
261
'Returns a new subversion package source path string by replacing or adding
262
'the specified label to the specified subversion package source path string.
263
Function  GetNewSvnSrcPath(asrc_path, alabel)
264
  Dim ssrc_base
265
  Dim snew_src_path
266
  Dim ssrc_path
267
  Dim slast_char
268
  Dim i,j
269
 
270
  if IsNull(asrc_path) then
271
    ssrc_path = ""
272
  else
273
    ssrc_path = asrc_path
274
  end if
275
 
276
  'get project directory from current package source path, ie path above either "tags" or "branches" or "trunk" directory
277
  i = InStrRev(LCase(ssrc_path), "/tags")
278
  if i = 0 then
279
    i = InStrRev(LCase(ssrc_path), "/branches")
280
    if i = 0 then
281
      i = InStrRev(LCase(ssrc_path), "/trunk")
282
    end if
283
  end if
284
 
285
  if i = 0 then
286
    '"tags" or "branches" or "trunk" not found
287
    'use current package source path as the project directory
288
    ssrc_base = ssrc_path
289
 
290
    'ensure project directory ends in a slash
291
    j = Len(ssrc_base)
292
    slast_char = Right(ssrc_base,1)
293
    if (j > 0) and (slast_char <> "/") then
294
      ssrc_base = ssrc_base & "/"
295
    end if
296
  else
297
    '"tags" or "branches" or "trunk" found so extract project directory
298
    ssrc_base = Mid(ssrc_path,1,i)
299
  end if
300
 
301
  'append new directory to the default project directory string.
302
  'the default path will be <project directory>/branches/<label>
303
  snew_src_path = ssrc_base & "branches/" & alabel
304
 
305
  GetNewSvnSrcPath = snew_src_path
306
 
307
End Function
308
 
309
'------------------------------------------------------------------
310
'This function is used to create the default package source path
311
'string when a new SubVersion package version is added.
312
'Assumes the specified pv_id is for a subversion package
313
Sub UpdateSubVersionSrcPath(apv_id)
314
  Dim rsQry
315
  Dim anew_src_path
316
  Dim ivcs_type_id
317
  Dim apkg_label
318
  Dim asrc_path
319
  Dim ssql
320
 
321
  'select the package and ensure it is a subversion package
322
  ssql = "SELECT * FROM PACKAGE_VERSIONS WHERE PV_ID ="& apv_id &" AND VCS_TYPE_ID=23"
323
 
324
  Set rsQry = OraDatabase.DbCreateDynaset(ssql, cint(0))
325
 
326
  If rsQry.RecordCount > 0 Then
327
    ivcs_type_id = rsQry("vcs_type_id")
328
    'pkg_label contains the new auto generated label for this version
329
    apkg_label = rsQry("pkg_label")
330
    asrc_path = rsQry("src_path")
331
    anew_src_path = GetNewSvnSrcPath(asrc_path,apkg_label)
332
 
333
    OraDatabase.ExecuteSQL _
334
      "BEGIN "&_
335
      " UPDATE PACKAGE_VERSIONS SET SRC_PATH ='"& anew_src_path &"' WHERE PV_ID ="& apv_id &"; "&_
336
      "END;"
337
  End If
338
 
339
  rsQry.Close()
340
  Set rsQry = nothing
341
 
342
End Sub
343
 
344
'-----------------------------------------------------------------------------------
119 ghuddy 345
%>
346
<%
347
'-----------------------  MAIN LINE  ---------------------------
348
Dim rsQry, Query_String, Record_Count
123 ghuddy 349
Dim versionToSanityCheck
161 iaugusti 350
 
119 ghuddy 351
'--- Process submission ---
161 iaugusti 352
If Request("build_type") = "A" AND VersionHasCotsExtension(parFRnewver) AND NOT (IsCotsPatch(parOLDpv_id,Request("change_type"))) Then
353
  Call RaiseMsg ( enum_MSG_CANNOT_AUTO_GENERATE_COTS_PKG&"?rtag_id="& parRtag_id &"&pv_id="& parOLDpv_id &"", parFRnewver)
121 hknight 354
Else
123 ghuddy 355
   If (parOLDpv_id <> "") AND ( (parFRnewver <> "") OR (parSetToPv_id <> "") ) AND (parRtag_id <> "") Then
356
      ' All mandatory parameters FOUND
119 ghuddy 357
 
123 ghuddy 358
      If ( (parSetToPv_id <> "") OR SanityCheck(parFRnewver) ) Then
119 ghuddy 359
 
131 ghuddy 360
         Record_Count = 0
361
 
123 ghuddy 362
         If Request("build_type") = "M" Then
363
            Query_string = " SELECT pv.pv_id, pv.is_patch, pv.dlocked"&_
364
                           " FROM package_versions pv"&_
365
                           " WHERE pv.pkg_version = '"& parFRnewver &"'"&_
366
                           " AND pv.pkg_id IN (SELECT DISTINCT origpv.pkg_id"&_
367
                           "  FROM package_versions origpv"&_
368
                           " WHERE origpv.pv_id = "& parOLDpv_id &")"
369
 
370
            Set rsQry = OraDatabase.DbCreateDynaset(Query_String, cint(0))
371
            Record_Count = rsQry.RecordCount
372
            rsQry.Close()
373
            Set rsQry = Nothing
374
         End If
375
 
376
         If Record_Count > 0 And Request("build_type") = "M" Then
377
            Call RaiseMsg ( enum_MSG_PACKAGE_VERSION_EXISTS&"?rtag_id="& parRtag_id &"&pv_id="& parOLDpv_id &"", parFRnewver )
378
         Else
379
            Call New_Version ( parFRnewver, parOLDpv_id, parSetToPv_id, parRtag_id, parSync_rtags, NEWpv_id )
380
 
381
            If objEH.Finally Then
382
               Response.Redirect("dependencies.asp?rtag_id="& parRtag_id &"&pv_id="& NEWpv_id )
383
            End If
384
         End If
385
      Else
386
         Call RaiseMsg( enum_MSG_PACKAGE_VERSION_INVALID&"?rtag_id="& parRtag_id &"&pv_id="& parOLDpv_id &"", parFRnewver )
387
      End If
388
 
389
   Else
390
      Response.write "Some mandatory parameters are missing!" & "<br>" 'TODO
391
      Response.write QSTR_All
392
   End If ' If (parOLDpv_id <> "") AND ( (parFRnewver <> "") OR (parSetToPv_id <> "") ) AND (parRtag_id <> "") Then
121 hknight 393
End If ' If Request("build_type") = "A" AND VersionHasCotsExtension( parFRnewver ) Then
119 ghuddy 394
%>
395
 
396
<!-- DESTRUCTOR ------->
123 ghuddy 397
<!--#include file="common/destructor.asp"-->