Rev 3896 | Blame | Compare with Previous | Last modification | View Log | RSS feed
<%@LANGUAGE="VBSCRIPT"%><%'=====================================================' UPDATE dependencies' --- PROCESS FORM ---'=====================================================%><%Option explicit' Good idea to set when using redirectResponse.Expires = 0 ' always load the page, dont store%><!--#include file="common/conf.asp"--><!--#include file="common/globals.asp"--><!--#include file="common/formating.asp"--><!--#include file="common/qstr.asp"--><!--#include file="common/common_subs.asp"--><!--#include file="common/common_dbedit.asp"--><%' Set rfile parameter. This is a return page after LoginCall objPMod.StoreParameter ( "rfile", "dependencies.asp" )'------------ ACCESS CONTROL ------------------%><!--#include file="_access_control_login.asp"--><!--#include file="_access_control_general.asp"--><!--#include file="_access_control_project.asp"--><%'------------ Variable Definition -------------Dim depArray()Dim array_is_empty'------------ Constants Declaration -----------Const enumlocal_DONOT_DELETE_OLD_DEPENDENCIES = 0Const enumlocal_DELETE_OLD_DEPENDENCIES = 1Const COL_pkg_name = 0Const COL_pkg_version = 1Const COL_build_type = 2'------------ Variable Init -------------------'----------------------------------------------%><%Sub Populate_depArray_from_Import ( SSdep_import, ARRdep, BBarray_is_empty )Dim recCnt, pkg_name, pkg_version, build_type, re, Matches, MatchIf (SSdep_import = "") Then Exit Sub ' exit if no dependencies are submited' Decode Server.URLEncode if presentSSdep_import = URLDecode( SSdep_import )SSdep_import = Replace(SSdep_import, " ", "") ' remove spacesSSdep_import = Replace(SSdep_import, VBTab, "") ' remove horizontal tabsSSdep_import = Replace(SSdep_import, VBVerticalTab, "") ' remove vertical tabsSSdep_import = Replace(SSdep_import, """", "'") ' replace " with 'Set re = New RegExpre.IgnoreCase = Truere.Global = True'The following regular expression captures the package name and version on each matching line.'The following is an example of the format of the input string, SSdep_import.''BuildPkgArchive ( 'linux_kernel_viper' , '2.6.24.6.5000.cots' );''# Packages for creating the debian package'#LinkPkgArchive ( 'debian_dpkg' , '1.13.25000.cots' );'LinkPkgArchive ( 'debian_packager' , '1.1.0000.cr' );'LinkPkgArchive ( 'Jasper Patch (JBoss/Tomcat Hotfix)' , '1.6.0,REV=2006.11.29.02.51' );'LinkPkgArchive ( 'Java 2 SDK, Enterprise Edition (J2EE)' , '1.6.0,REV=2006.11.29.02.51' );'' Note. Jants and Ant dependencies are formatted to look like:' JantStyle('PackageName','PackageVersion');' AntStyle('PackageName','PackageVersion');re.Pattern = "(^|\n)\s*([_A-Za-z0-9]+)\s*\(\s*\'([^\']*)\'\s*\,\s*\'([^\']*)\'\s*\)"Set Matches = re.Execute(SSdep_import)recCnt=0For Each Match in Matchesbuild_type = Match.SubMatches(1)pkg_name = Match.SubMatches(2)pkg_version = Match.SubMatches(3)' Proceed only if:' pkg name is not empty,' pkg version is not empty,If ( pkg_name <> "" ) AND ( pkg_version <> "" ) ThenReDim Preserve ARRdep( 2, recCnt )ARRdep( COL_pkg_name, recCnt ) = pkg_nameARRdep( COL_pkg_version, recCnt ) = pkg_version' Define build typeIf LCase(build_type) = LCase("BuildPkgArchive") ThenARRdep( COL_build_type, recCnt ) = enum_BUILD_PKG_ARCHIVEElseIf LCase(build_type) = LCase("LinkPkgArchive") ThenARRdep( COL_build_type, recCnt ) = enum_LINK_PKG_ARCHIVEElseARRdep( COL_build_type, recCnt ) = enum_BUILD_PKG_ARCHIVE 'neither build_package or link_package is found, hence set to...End IfrecCnt = recCnt + 1BBarray_is_empty = FALSEEnd IfNextEnd Sub' This function is called when update_type is "add_custom". This is only the case when adding dependencies' 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' 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' changed so that users can only add package versions from the relevant release as dependencies to a packge also in that' 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' contains 2 instances of a package, each one having different extensions (eg .mas, .sea).Sub Populate_depArray_from_ADD_Custom ( NNpv_id_list, ARRdep, BBarray_is_empty )Dim depList, lastItem, i, recCnt, pkg_name, pkg_version, V_EXTDim rsTemp, Query_String, PkgBaseViewPkgBaseView = Get_Pkg_Base_View_ID ( Request("pv_id"), Request("rtag_id") )Query_String = _" SELECT pkgs.pkg_id, pkgs.pkg_name, pv.pv_id, pv.pkg_version"&_" FROM packages pkgs, package_versions pv"&_" WHERE pv.pv_id IN ("& NNpv_id_list &")"&_" AND pv.pkg_id = pkgs.pkg_id"Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0))recCnt = 0While ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF))ReDim Preserve ARRdep( 2, recCnt )ARRdep( COL_pkg_name, recCnt ) = rsTemp("pkg_name")ARRdep( COL_pkg_version, recCnt ) = rsTemp("pkg_version")'// Dependencies comming from custom dependency add are set to LinkPkgArchive by default, unless it is a productIf PkgBaseView = enumBASE_VIEW_PRODUCTS ThenARRdep( COL_build_type, recCnt ) = enum_BUILD_PKG_ARCHIVEElseARRdep( COL_build_type, recCnt ) = enum_LINK_PKG_ARCHIVEEnd IfrecCnt = recCnt + 1BBarray_is_empty = FALSErsTemp.MoveNextWEndrsTemp.CloseSet rsTemp = nothingEnd Sub// The form passed to us may only have information for packages that need to change// The enumlocal_DONOT_DELETE_OLD_DEPENDENCIES does not appear to work// Must provide a full set of dependencies with either a new version or the existing version//Sub Populate_depArray_from_EDIT_Custom ( NNpv_id, ARRdep, BBarray_is_empty, sDependBlock )Dim depList, lastItem, i, recCnt, pkg_name, pkg_version, V_EXTDim rsTemp, rsCurrent, Query_StringQuery_String = _" SELECT dpkg.pkg_name, dpv.pkg_version, dpv.pv_id"&_" FROM package_dependencies dep,"&_" package_versions dpv,"&_" packages dpkg"&_" WHERE dep.dpv_id = dpv.pv_id"&_" AND dpv.pkg_id = dpkg.pkg_id"&_" AND dep.pv_id = "& NNpv_idSet rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0))recCnt = 0While ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF))Dim pvid, pkgver, newverpvid = rsTemp("pv_id")pkgver = Request( "pkgn" & pvid )If pkgver <> "" Thennewver = pkgverelsenewver = rsTemp("pkg_version")End ifReDim Preserve ARRdep( 2, recCnt )ARRdep( COL_pkg_name, recCnt ) = rsTemp("pkg_name")ARRdep( COL_pkg_version, recCnt ) = newverARRdep( COL_build_type, recCnt ) = Request( "bt"& pvid )If not rsTemp("pkg_version") = newver ThensDependBlock = rsTemp("pkg_name") & " " & newverEnd IfrecCnt = recCnt + 1BBarray_is_empty = FALSErsTemp.MoveNextWEndrsTemp.CloseSet rsTemp = nothingEnd SubSub Update_Package_Dependencies ( ARRdep, NNpv_id, NNuser_id, NNdelete_old_dependency, sAction_type, sDependBlock )Dim i, OraParameter, sCommentsOraDatabase.Parameters.Add "PV_ID", NNpv_id, ORAPARM_INPUT, ORATYPE_NUMBEROraDatabase.Parameters.Add "PKG_NAME", "", ORAPARM_INPUT, ORATYPE_VARCHAR2OraDatabase.Parameters.Add "PKG_VERSION", "", ORAPARM_INPUT, ORATYPE_VARCHAR2OraDatabase.Parameters.Add "BUILD_TYPE", "", ORAPARM_INPUT, ORATYPE_VARCHAR2OraDatabase.Parameters.Add "USER_ID", NNuser_id, ORAPARM_INPUT, ORATYPE_NUMBEROraDatabase.Parameters.Add "DELETE_PV_ID", NNdelete_old_dependency, ORAPARM_INPUT, ORATYPE_NUMBEROraDatabase.Parameters.Add "ACTION_TYPE_NAME", sAction_type, ORAPARM_INPUT, ORATYPE_VARCHAR2Set OraParameter = OraDatabase.ParametersFor i = 0 To UBound( ARRdep, 2 )If not i = 0 ThensComments = sComments & ", "End IfsComments = sComments & depArray(COL_pkg_name, i) & " " & ARRdep( COL_pkg_version, i )OraParameter("PKG_NAME").Value = ARRdep( COL_pkg_name, i )OraParameter("PKG_VERSION").Value = ARRdep( COL_pkg_version, i )OraParameter("BUILD_TYPE").Value = ARRdep( COL_build_type, i )OraDatabase.ExecuteSQL "BEGIN Update_Package_Dependency ( :PV_ID, :PKG_NAME, :PKG_VERSION, :BUILD_TYPE, :USER_ID, :DELETE_PV_ID ); END;"NextSet OraParameter = NothingIf sAction_type = "depend_add" ThenOraDatabase.Parameters.Add "COMMENTS", sComments, ORAPARM_INPUT, ORATYPE_VARCHAR2ElseIf Len(sDependBlock) <= 4000 ThenOraDatabase.Parameters.Add "COMMENTS", sDependBlock, ORAPARM_INPUT, ORATYPE_VARCHAR2ElseOraDatabase.Parameters.Add "COMMENTS", "Description too long to be inserted!", ORAPARM_INPUT, ORATYPE_VARCHAR2End IfEnd IfOraDatabase.ExecuteSQL _"BEGIN Log_Action ( :PV_ID, :ACTION_TYPE_NAME, :USER_ID, :COMMENTS ); END;"OraDatabase.Parameters.Remove "PV_ID"OraDatabase.Parameters.Remove "PKG_NAME"OraDatabase.Parameters.Remove "PKG_VERSION"OraDatabase.Parameters.Remove "BUILD_TYPE"OraDatabase.Parameters.Remove "USER_ID"OraDatabase.Parameters.Remove "DELETE_PV_ID"OraDatabase.Parameters.Remove "ACTION_TYPE_NAME"OraDatabase.Parameters.Remove "COMMENTS"End SubSub Remove_Old_Dependencies ( SSpv_id )OraDatabase.Parameters.Add "PV_ID", SSpv_id, ORAPARM_INPUT, ORATYPE_NUMBEROraDatabase.ExecuteSQL "DELETE FROM package_dependencies WHERE pv_id = :PV_ID"OraDatabase.Parameters.Remove "PV_ID"End SubSub Update_Mod_Details ( SSpv_id )OraDatabase.Parameters.Add "PV_ID", SSpv_id, ORAPARM_INPUT, ORATYPE_NUMBEROraDatabase.Parameters.Add "RTAG_ID", Request("rtag_id"), ORAPARM_INPUT, ORATYPE_NUMBEROraDatabase.Parameters.Add "USER_ID", objAccessControl.UserId, ORAPARM_INPUT, ORATYPE_NUMBEROraDatabase.ExecuteSQL _" UPDATE package_versions "&_" SET modified_stamp = "& ORA_SYSDATETIME &", modifier_id = :USER_ID"&_" WHERE pv_id = :PV_ID"If Request("rtag_id") <> "" Then' Package in release viewOraDatabase.ExecuteSQL _"BEGIN "&_" Touch_Release ( :RTAG_ID ); "&_"END; "Else' Package viewOraDatabase.ExecuteSQL _"BEGIN "&_" PK_RELEASE.RUN_POST_ACTIONS_BULK ( :PV_ID ); "&_"END; "End IfOraDatabase.Parameters.Remove "PV_ID"OraDatabase.Parameters.Remove "RTAG_ID"OraDatabase.Parameters.Remove "USER_ID"End Sub%><%'----------------------- MAIN LINE ---------------------------'Response.Write "<pre>------------<br>"'Dim Item'For Each Item In Request.Form' Response.Write "User Data: " &Item & ": " & Request.Form(Item) & "<br>"'Next'Response.Write "------------<br>"Dim sDependBlock'--- Process submition ---If (QStrPar("pv_id") <> "") Then' All mandatory parameters FOUNDErr.ClearOn Error Resume NextOraSession.BeginTrans' The called subroutines beneath here do not use "on error resume next", but this calling code does, so if any error' occurs in the called functions, control will resume within this code somewhere. On the assumption that an error might' be the result of some problem in the database, further database commands are not performed, achieved by making them' conditional upon Err.Number being zero. Ultimately, this should result in a rollbackarray_is_empty = TRUEIf Request("update_type") = "add_custom" Then'---- ADD CUSTOM dependency ----' NOTE - this happens when user clicks the Add action button on the dependencies/runtime tabs. Although the underlying search operation' (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' special cases.Call Populate_depArray_from_ADD_Custom ( Request("pkg_list"), depArray, array_is_empty )If ((NOT array_is_empty) AND (Err.number = 0)) ThenCall Update_Package_Dependencies ( depArray, Request("pv_id"), objAccessControl.UserId, enumlocal_DELETE_OLD_DEPENDENCIES, "depend_add", null )End IfElseIf Request("update_type") = "edit_custom" Then'---- EDIT CUSTOM dependency ----Call Populate_depArray_from_EDIT_Custom ( Request("pv_id"), depArray, array_is_empty, sDependBlock )Call Remove_Old_Dependencies ( Request("pv_id") )If ((NOT array_is_empty) AND (Err.number = 0)) ThenCall Update_Package_Dependencies ( depArray, Request("pv_id"), objAccessControl.UserId, enumlocal_DONOT_DELETE_OLD_DEPENDENCIES, "depend_update", sDependBlock )End IfElse'---- JATS, ANT dependency import ----Call Populate_depArray_from_Import ( Request("FRdeps"), depArray, array_is_empty )Call Remove_Old_Dependencies ( Request("pv_id") )If ((NOT array_is_empty) AND (Err.number = 0)) ThenCall Update_Package_Dependencies ( depArray, Request("pv_id"), objAccessControl.UserId, enumlocal_DONOT_DELETE_OLD_DEPENDENCIES, "depend_import", Request("FRdeps") )End IfEnd IfIf Err.number = 0 ThenCall Update_Mod_Details ( Request("pv_id") )End IfIf Err.number <> 0 ThenOraSession.RollBackCall RaiseMsg ( enum_MSG_ERROR, Err.description &"<br>"& Err.Source )ElseOraSession.CommitTransEnd IfResponse.Redirect("dependencies.asp?pv_id="& Request("pv_id") &"&rtag_id="& Request("rtag_id"))ElseResponse.write "Some mandatory parameters are missing!" & "<br>" 'TODOResponse.write QSTR_AllEnd If%><!-- DESTRUCTOR -------><!--#include file="common/destructor.asp"-->