Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
5893 dpurdie 1
<%@LANGUAGE="VBSCRIPT"%>
2
<%
3
'=====================================================
4
'|  form_edit_import_deps.asp
5
'|	Used by JATS and ANT import pages to sanitize the package versions to be used
6
'|  
7
'|  Do not allow user to name packages that do not exist
8
'|  Do not allow the user to name package-versions that do not exist
9
'|	
10
'=====================================================
11
%>
12
<%
13
Option explicit
14
' Good idea to set when using redirect
15
Response.Expires = 0	' always load the page, dont store
16
%>
17
<!--#include file="common/conf.asp"-->
18
<!--#include file="common/globals.asp"-->
19
<!--#include file="common/formating.asp"-->
20
<!--#include file="common/qstr.asp"-->
21
<!--#include file="common/common_subs.asp"-->
22
<%
23
' Make sure rtag_id is always present
24
If Request("pv_id") = "" Then
25
	Response.Redirect("index.asp")
26
End If
27
%>
28
<%
29
'------------ ACCESS CONTROL ------------------
30
%>
31
<!--#include file="_access_control_login.asp"-->
32
<!--#include file="_access_control_general.asp"-->
33
<!--#include file="_access_control_project.asp"-->
34
<%
35
'------------ Variable Definition -------------
36
Dim parPv_id
37
Dim rsPkgs
38
Dim HTML_pkg_list
39
Dim DataFound
40
 
41
'------------ Constants Declaration -----------
42
'------------ Variable Init -------------------
43
parPv_id = Request("pv_id")
44
Set pkgInfoHash = CreateObject("Scripting.Dictionary")
45
 
46
Sub Populate_from_Import ( SSdep_import, SShtml_pkg_list, BBDataFound)
47
   Dim recCnt, pkg_name, pkg_version, build_type, re, Matches, Match
48
   Dim Query_String, rsDeps, PVID, PKGID, builtTypeEnum, LatestVisible
49
   Dim OraParameter
50
 
51
   DataFound = false
52
   If (SSdep_import = "") Then Exit Sub      ' exit if no dependencies are submited
53
 
54
   ' Decode Server.URLEncode if present
55
   SSdep_import = URLDecode( SSdep_import )
56
 
57
   SSdep_import = Replace(SSdep_import, " ", "")            ' remove spaces
58
   SSdep_import = Replace(SSdep_import, VBTab, "")          ' remove horizontal tabs
59
   SSdep_import = Replace(SSdep_import, VBVerticalTab, "")  ' remove vertical tabs
60
   SSdep_import = Replace(SSdep_import, """", "'")          ' replace " with '
61
 
62
   Set re = New RegExp
63
   re.IgnoreCase = True
64
   re.Global = True
65
 
66
   'The following regular expression captures the package name and version on each matching line.
67
   'The following is an example of the format of the input string, SSdep_import.
68
   '
69
   'BuildPkgArchive ( 'linux_kernel_viper'  , '2.6.24.6.5000.cots' );
70
   '
71
   '#   Packages for creating the debian package
72
   '#LinkPkgArchive  ( 'debian_dpkg'         , '1.13.25000.cots' );
73
   'LinkPkgArchive  ( 'debian_packager'     , '1.1.0000.cr' );
74
   'LinkPkgArchive  ( 'Jasper Patch (JBoss/Tomcat Hotfix)' , '1.6.0,REV=2006.11.29.02.51' );
75
   'LinkPkgArchive  ( 'Java 2 SDK, Enterprise Edition (J2EE)' , '1.6.0,REV=2006.11.29.02.51' );
76
   '
77
   ' Note. Ant dependencies are formatted to look like:
78
   '    AntStyle('PackageName','PackageVersion');
79
 
80
   re.Pattern = "(^|\n)\s*([_A-Za-z0-9]+)\s*\(\s*\'([^\']*)\'\s*\,\s*\'([^\']*)\'\s*\)"
81
   Set Matches = re.Execute(SSdep_import)
82
 
83
	Query_String = ReadFile( rootPath & "queries\form_edit_import_deps.sql" )
84
	OraDatabase.Parameters.Add "RTAG_ID", parRtag_id, ORAPARM_INPUT, ORATYPE_NUMBER
85
	OraDatabase.Parameters.Add "PKG_NAME", pkg_name , ORAPARM_INPUT, ORATYPE_STRING
86
	OraDatabase.Parameters.Add "PKG_VERSION", pkg_version, ORAPARM_INPUT, ORATYPE_STRING
87
	Set OraParameter = OraDatabase.Parameters
88
 
89
   recCnt=0
90
   For Each Match in Matches
91
     build_type = Match.SubMatches(1)
92
     pkg_name = Match.SubMatches(2)
93
     pkg_version = Match.SubMatches(3)
94
 
95
      ' Proceed only if:
96
      '    pkg name is not empty,
97
      '    pkg version is not empty,
98
      If ( pkg_name <> "" )  AND  ( pkg_version <> "" ) Then
99
         ReDim Preserve ARRdep( 2, recCnt )
100
         ' Define build type
101
         If LCase(build_type) = LCase("BuildPkgArchive") Then
102
            builtTypeEnum = enum_BUILD_PKG_ARCHIVE
103
         ElseIf LCase(build_type) = LCase("LinkPkgArchive") Then
104
            builtTypeEnum = enum_LINK_PKG_ARCHIVE
105
         Else
106
            builtTypeEnum = enum_BUILD_PKG_ARCHIVE     'neither build_package or link_package is found, hence set to...
107
         End If
108
         recCnt = recCnt + 1
109
		 DataFound = true
110
 
111
         '
112
         ' Create one entry
113
         '
114
         OraParameter("PKG_NAME").Value = pkg_name
115
         OraParameter("PKG_VERSION").Value = pkg_version
116
 
117
         Set rsDeps = OraDatabase.DbCreateDynaset( Query_String, cint(0))
118
         If rsDeps.RecordCount <> 0 Then
119
 
120
            PVID = rsDeps("pv_id")
121
            If isNull(PVID) Then PVID = 0
122
            PKGID = rsDeps("pkg_id")
123
			SShtml_pkg_list = SShtml_pkg_list &"<tr> "
124
 
125
            ' Package Name - will always be present
126
			SShtml_pkg_list = SShtml_pkg_list &"  <td background='images/bg_form_lightgray.gif' nowrap class='form_item'>" & rsDeps("pkg_name")
127
            SShtml_pkg_list = SShtml_pkg_list &"    <input name='bt"& recCnt &"' type='hidden' value='"& builtTypeEnum &"'>"
128
            SShtml_pkg_list = SShtml_pkg_list &"    <input name='btName"& recCnt &"' type='hidden' value='"& rsDeps("pkg_name") & "'>"
129
            SShtml_pkg_list = SShtml_pkg_list &"  </td>"
130
 
131
            ' Package Version specified by user
132
            '   If package does not exist, then this is a text field
133
            '
134
            If isNULL(PKGID) Then
135
    			SShtml_pkg_list = SShtml_pkg_list &"  <td background='images/bg_form_lightgray.gif'>" &_
136
                                    "<input type='text' readonly class='form_item' size='20' value='"& rsDeps("pkg_version") &"' disabled > " &_
137
                                    "<input type='text' hidden id='pkgn"& recCnt &"' name='pkgn"& recCnt &"' value=''> "
138
    			SShtml_pkg_list = SShtml_pkg_list &"  </td>"
139
    			SShtml_pkg_list = SShtml_pkg_list &"  <td background='images/bg_form_lightgray.gif' class='form_item err_alert badPackage'> Package Name does not exist"
140
    			SShtml_pkg_list = SShtml_pkg_list &"  </td>"
141
            Else
142
    			SShtml_pkg_list = SShtml_pkg_list &"  <td background='images/bg_form_lightgray.gif'>" &_
143
                                    "<select style='width:15em;display:none' id='edpkgn"& recCnt &"' class='form_item' > " &_
144
                                    "<input type='text' readonly ondblclick='editVerNum("& PKGID &","&recCnt&");' id='pkgn"& recCnt &"' name='pkgn"& recCnt &"' class='form_item' size='20' value='"& rsDeps("pkg_version") &"' onBlur='Compare_Version ( " & recCnt & " );' onFocus='Compare_Version ( " & recCnt & " );'> "
145
    			SShtml_pkg_list = SShtml_pkg_list &"    <a href='javascript:;' onClick='editVerNum("& PKGID &","& recCnt &")'><img src='images/i_edit.gif' width='12' height='12' align='absmiddle' border='0' title='Edit Version' title='Select Version from a list'></a> "
146
 
147
	            If isNull(rsDeps("pv_id")) Then
148
            		SShtml_pkg_list = SShtml_pkg_list &"  <span class='badPackage' id='divBver"& recCnt &"'>"&_
149
            											  "<img src='images/s_critical.gif' border='0' title='Version does not exist' hspace='2' align='absmiddle'>"&_
150
            											  "<input name='lpBver"& recCnt &"' type='hidden' value='"& rsDeps("pkg_version") &"'></span>"
151
                End If
152
    			SShtml_pkg_list = SShtml_pkg_list &"  </td>"
153
 
154
        		' Latest Versions
155
        		SShtml_pkg_list = SShtml_pkg_list &"  <td background='images/bg_form_lightgray.gif' class='sublbox_hitem'>"
156
            	LatestVisible = ""
157
                If NOT IsNull(rsDeps("lpv_id")) Then
158
            		If ( PVID = rsDeps("lpv_id") ) Then
159
        		        LatestVisible = "style='display:none;'"
160
            		End If
161
 
162
            		SShtml_pkg_list = SShtml_pkg_list &"  <DIV id='divLPV"& recCnt &"' "& LatestVisible &">"&_
163
            								  		      "<a href='javascript:;' onClick='Merge_Version ( """& rsDeps("lpkg_version") & ""","& recCnt & " );'>"&_
164
            											  "<img src='images/bt_move_left.gif' border='0' title='Bring over this latest version' hspace='2' align='absmiddle'>"&_
165
            											  "</a>"& rsDeps("lpkg_version") &"<input name='lp"& recCnt &"' type='hidden' value='"& rsDeps("lpkg_version") &"'></DIV>"
166
                End If
167
    			SShtml_pkg_list = SShtml_pkg_list &"  </td>"
168
            End If
169
        	SShtml_pkg_list = SShtml_pkg_list &"</tr>"
170
         End If
171
     End If
172
   Next
173
 
174
	OraDatabase.Parameters.Remove "RTAG_ID"
175
	OraDatabase.Parameters.Remove "PKG_NAME"
176
	OraDatabase.Parameters.Remove "PKG_VERSION"
177
    Set OraParameter = Nothing
178
 
179
    rsDeps.Close
180
    Set rsDeps = Nothing
181
 
182
End Sub
183
%>
184
<%
185
If parPv_id <> "" Then
186
	Call Get_Pkg_Info ( parPv_id, NULL )
187
End If
188
%>
189
 
190
<%
191
'=================== MAIN LINE =====================
192
Call Populate_from_Import ( Request("FRdeps"), HTML_pkg_list, DataFound )
193
 
194
 
195
If NOT DataFound Then
196
	'Edit button clicked on empty dependency list. Redirect user to Add Dependencies
197
	Response.Redirect ("form_search_pkgs.asp?pv_id="& parPv_id &"&rtag_id="& parRtag_id &"&add_type="& enum_ADD_DEPENDENCIES)
198
End If
199
%>
200
<html>
201
<head>
202
<title>Release Manager</title>
203
<link rel="shortcut icon" href="<%=FavIcon%>"/>
204
<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
205
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
206
<link rel="stylesheet" href="images/release_manager_style.css" type="text/css">
207
<link rel="stylesheet" href="images/navigation.css" type="text/css">
208
<script language="JavaScript" src="images/common.js"></script>
209
<!-- DROPDOWN MENUS -->
210
<!--#include file="_menu_def.asp"-->
211
<script language="JavaScript1.2" src="images/popup_menu.js"></script>
212
<!-- JSON Support -------------------------->
213
<script language="JavaScript" src="scripts/remote_scripting.js"></script>
214
<script type="text/javascript" src="scripts/json2.js"></script>
215
<script language="JavaScript" type="text/JavaScript">
216
<!--
217
// When the page is loaded
218
window.onload = scanBadData;
219
 
220
// ValidateForm
221
function ValidateForm(){
222
	return scanBadData();
223
}
224
 
225
//	Scan the form for bad entries and update the 'Update' button accordingly
226
function scanBadData()
227
{
228
	var elem = MM_findObj("btn_update")
229
	var rv = false;
230
	if (elem) {
231
		rv = document.getElementsByClassName("badPackage").length == 0;
232
		elem.disabled = !rv;
233
	}
234
}
235
 
236
// Restore original value
237
function Merge_Version (lpkg_version, recId) {
238
    endEditVerNum(recId);
239
    var ediv = MM_findObj("divLPV"+ recId.toString() );
240
    var epkg = MM_findObj("pkgn"+ recId.toString() );
241
 
242
    if(epkg) epkg.value = lpkg_version;
243
    if(ediv) ediv.style.display = "none";
244
 
245
    var ebad = MM_findObj("divBver"+ recId.toString() );
246
    if(ebad) ebad.parentElement.removeChild(ebad);
247
	scanBadData();
248
}
249
 
250
// Highlight diff between release and user selection
251
function Compare_Version ( recId ) {
252
	var cv, lv, el;
253
 
254
    el = MM_findObj( "pkgn" + recId.toString() );
255
	cv = (el) ? el.value : 0;
256
 
257
	el = MM_findObj( "lp" + recId.toString() );
258
	if (el)
259
	{
260
		lv = el.value;
261
		var ediv = MM_findObj("divLPV"+ recId.toString() );
262
		if (ediv)
263
		{
264
			ediv.style.display = (cv == lv) ? 'none' : 'block';
265
		}
266
	}
267
}
268
 
269
// Edit the version number
270
var editData = new Object();
271
function editVerNum(NNpkg_id, recId)
272
{
273
    // Only initiate the edit once
274
    if (editData[recId])
275
    {
276
        endEditVerNum(recId);
277
        return;
278
    }
279
 
280
    // Get the base element in the document
281
    var elem = document.getElementById('pkgn' + recId.toString() );
282
    var elemed = document.getElementById('edpkgn' + recId.toString() );
283
    if ( ! (elem && elemed) )
284
        return;
285
 
286
    // Show edit element and hide the fixed text
287
    elem.style.display = 'none';
288
    elemed.style.display = '';
289
 
290
	// Delete the bad version indication
291
    var ebad = MM_findObj("divBver"+ recId.toString() );
292
    if(ebad) ebad.parentElement.removeChild(ebad);
293
 
294
    // Populate essential fields
295
    elemed.onchange = function(){editUpdate(recId);}
296
    elemed.onblur = elemed.onchange;
297
 
298
    // Create a dummy selection to indicate loading
299
    var el = document.createElement("option");
300
    var vname = "Loading";
301
    el.textContent = vname;
302
    el.value = vname;
303
    elemed.appendChild(el);
304
 
305
    // Save refs to the two elements
306
    var np = editData[recId] = new Object();
307
 
308
    np.edit = elemed;
309
    np.elem = elem;
310
    np.Value = elem.value;
311
 
312
    // Load version data into this new element
313
    getVersions(NNpkg_id, recId);
314
	scanBadData();
315
}
316
 
317
function editUpdate(recId)
318
{
319
    var sd = editData[recId];
320
    sd.elem.value = sd.edit.value;
321
    Compare_Version(recId);
322
	scanBadData();
323
}
324
 
325
// Globals are used to save state information
326
function endEditVerNum(recId)
327
{
328
    var sd = editData[recId];
329
    if (sd) {
330
        sd.elem.value = sd.edit.value;
331
        sd.edit.style.display = 'none';
332
        sd.elem.style.display = '';
333
 
334
        delete editData[recId];
335
    }
336
	scanBadData();
337
}
338
 
339
// Allow the user to populate the version selector box
340
// Enables the selector once its been populated
341
// Uses AJAX to populate the item on demand
342
function getVersions(NNpkg_id, NN_pv_id)
343
{
344
    xmlHttp=GetXmlHttpObject(getVersionsDone);
345
    if (xmlHttp==null)
346
    {
347
        alert ("Your browser does not support AJAX!");
348
        return;
349
    }
350
 
351
    var url = "_json_checkPackage.asp?"
352
            + "pkg_id=" + NNpkg_id
353
            + "&ref=" + NN_pv_id
354
            + "&Opr=getVerList";
355
    MM_showProgressBar();
356
    xmlHttp.open("GET",url,true);  // `false` makes the request synchronous
357
    xmlHttp.send(null);
358
}
359
 
360
// Call back for getVersions
361
function getVersionsDone()
362
{
363
    //readyState of 4 or 'complete' represents that data has been returned
364
    if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete'){
365
        MM_hideProgressBar();
366
 
367
        //Gather the results from the callback
368
        var str = xmlHttp.responseText;
369
//alert("JSON:" + str);
370
        if ( !str ) {
371
            alert("Empty responce from Release Manager. May have been logged ");
372
            return;
373
        }
374
        var myJson = JSON.parse(str);
375
        if(myJson.error)
376
        {
377
            alert("Invalid responce from Release Manager");
378
            return;
379
        }
380
 
381
        var ref = myJson.VersionRef;
382
        var sd = editData[ref];
383
        var select = sd.edit;
384
        var sv = (sd) ? sd.Value  : 0;
385
 
386
        select.innerHTML = '';
387
        select.disabled = false;
388
        for( var ii=0; ii< myJson.Versions.length; ii++)
389
        {
390
            var el = document.createElement("option");
391
            var vname = myJson.Versions[ii].vname;
392
 
393
            el.selected = ( vname == sv );
394
            var p1 = el.selected ? '>' : ' ';
395
            var p2 = (myJson.Versions[ii].dlocked == "Y") ? 'R ' : '    ';
396
 
397
            el.textContent = p1 + p2 + vname;
398
            el.value = vname;
399
            select.appendChild(el);
400
        }
401
    }
402
}
403
 
404
// -->
405
</script>
406
 
407
</head>
408
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0">
409
<!-- MENU LAYERS -------------------------------------->
410
<div id="popmenu" class="menuskin" onMouseover="clearhidemenu();highlightmenu(event,'on')" onMouseout="highlightmenu(event,'off');dynamichide(event)">
411
</div>
412
<!-- TIPS LAYERS -------------------------------------->
413
<div id="formTipsLayer" style="position: absolute; z-index: 1000; visibility: hidden; left:0; top: 0; width: 10">&nbsp;</div>
414
<!----------------------------------------------------->
415
<!-- HEADER -->
416
<!--#include file="_header.asp"-->
417
<!-- BODY ---->
418
<table width="100%" height="80%" border="0" cellpadding="0" cellspacing="0">
419
  <tr>
420
    <td align="center" valign="top" background="images/bg_lght_gray.gif">
421
      <!-- MIDDLE ---------------------------------------->
422
      <table width="650" border="0" cellspacing="0" cellpadding="0">
423
        <tr>
424
          <td> <table width="100%" border="0" cellspacing="0" cellpadding="0">
425
              <tr>
426
                <td width="1%"></td>
427
                <td align="right"><img src="images/h_trsp_dot.gif" width="30" height="30"></td>
428
                <td width="1%"></td>
429
              </tr>
430
              <tr>
431
                <td width="1%"></td>
432
                <td> <table width="100%" border="0" cellspacing="0" cellpadding="0">
433
                    <tr>
434
                      <td nowrap class="form_ttl">EDIT dependencies</td>
435
                      <td align="right" valign="bottom"></td>
436
                    </tr>
437
                  </table></td>
438
                <td width="1%"></td>
439
              </tr>
440
              <tr>
441
                <td align="left" valign="top" width="1%" background="images/lbox_bg_blue.gif"><img src="images/lbox_tl_cnr_b.gif" width="13" height="13"></td>
442
                <td background="images/lbox_bg_blue.gif" align="right">
443
                  <!-- Heading -->
444
                  <img src="images/h_trsp_dot.gif" width="1" height="20">
445
                  <!-- END Heading -->
446
                </td>
447
                <td align="right" valign="top" width="1%" background="images/lbox_bg_blue.gif"><img src="images/lbox_tr_cnr_b.gif" width="13" height="13"></td>
448
              </tr>
449
              <tr>
450
                <td width="1%" bgcolor="#FFFFFF"><img src="images/h_trsp_dot.gif" width="10" height="100"></td>
451
                <td bgcolor="#FFFFFF" valign="top">
452
                  <!-- Body -->
453
                  <table width="100%" border="0" cellspacing="1" cellpadding="2">
454
				    <form name="editdep" method="post" action="_update_dependencies.asp" onSubmit="return ValidateForm();">
455
				      <tr>
456
                        <td colspan="2" width="1%" nowrap class="form_field"><%=pkgInfoHash.Item ("pkg_name")%>&nbsp;<%=pkgInfoHash.Item ("pkg_version")%></td>
457
                      </tr>
458
                      <tr>
459
                        <td colspan="2" width="1%" nowrap class="form_field">
460
                          <table width="100%" border="0" cellspacing="1" cellpadding="2">
461
                            <tr>
462
                              <td background="images/bg_form_lightbluedark.gif" nowrap width="1%" class="form_field">Package Name<img src="images/h_trsp_dot.gif" width="1" height="20" align="absmiddle"></td>
463
                              <td background="images/bg_form_lightbluedark.gif" nowrap width="50%" class="form_field">Version</td>
464
							  <td background="images/bg_form_lightbluedark.gif" nowrap width="50%" class="form_field">Released</td>
465
                            </tr>
466
                      		<%=HTML_pkg_list%>
467
                            <tr>
468
                              <td nowrap><img src="images/h_trsp_dot.gif" width="120" height="1"></td>
469
                              <td></td>
470
							  <td></td>
471
                            </tr>
472
                          </table></td>
473
                      </tr>
474
                      <tr>
475
                        <td colspan="2" nowrap>
476
                          <input type="submit" name="btn" value="Update" class="form_btn" id="btn_update">
477
						  <input type="reset" name="btn" value="Back" class="form_btn" onClick="history.back();">
478
                          <input name="btn" type="reset" class="form_btn" value="Cancel" onClick="window.location='dependencies.asp?pv_id=<%=Request("pv_id")%>&rtag_id=<%=Request("rtag_id")%>';"></td>
479
                          <SPAN id="ProgressBar" name="ProgressBar" style="visibility:hidden;" class="body_scol"><img src="images/i_processing.gif" width="11" height="17" align="absmiddle" hspace="3">Processing...</SPAN>
480
                          <br> <br> </td>
481
                      </tr>
482
					  <input type="hidden" name="update_type" value="edit_import">
483
					  <input type="hidden" name="pv_id" value="<%=parPv_id%>">
484
                      <input type="hidden" name="rtag_id" value="<%=parRtag_id%>">
485
                    </form>
486
                  </table>
487
                  <!-- END Body-->
488
                </td>
489
                <td width="1%" background="images/lbox_bgside_white.gif">&nbsp;</td>
490
              </tr>
491
              <tr>
492
                <td width="1%" background="images/lbox_bg_blue.gif" valign="bottom"><img src="images/lbox_bl_cnr_b.gif" width="13" height="13"></td>
493
                <td background="images/lbox_bg_blue.gif"></td>
494
                <td width="1%" background="images/lbox_bg_blue.gif" valign="bottom" align="right"><img src="images/lbox_br_cnr_b.gif" width="13" height="13"></td>
495
              </tr>
496
            </table></td>
497
        </tr>
498
      </table>
499
      <!-------------------------------------------------->
500
    </td>
501
  </tr>
502
  <tr>
503
    <td valign="bottom" background="images/bg_lght_gray.gif">
504
	<!-- FOOTER -->
505
	<!--#include file="_footer.asp"-->
506
	</td>
507
  </tr>
508
</table>
509
</body>
510
</html>
511
<%
512
Call Destroy_All_Objects
513
%>