2013-04-03 sources upload tizen_2.1 2.1b_release
authordonghee yang <donghee.yang@samsung.com>
Wed, 3 Apr 2013 03:30:20 +0000 (12:30 +0900)
committerdonghee yang <donghee.yang@samsung.com>
Wed, 3 Apr 2013 03:30:20 +0000 (12:30 +0900)
Change-Id: I1e88890ff266b1f57e8016c5198d798a94709c28

92 files changed:
README
build-cli
build-svr
dibs-web/app/controllers/admin_controller.rb
dibs-web/app/controllers/admin_distribution_controller.rb
dibs-web/app/controllers/admin_group_controller.rb
dibs-web/app/controllers/admin_project_controller.rb
dibs-web/app/controllers/admin_server_controller.rb
dibs-web/app/controllers/admin_user_controller.rb
dibs-web/app/controllers/projects_controller.rb
dibs-web/app/controllers/utils.rb
dibs-web/config/application.rb
dibs-web/config/database.yml [deleted file]
dibs-web/config/routes.rb
dibs-web/public/index.html
dibs-web/public/javascripts/admin-distribution-add.js
dibs-web/public/javascripts/admin-distribution-modify.js
dibs-web/public/javascripts/admin-distribution.js
dibs-web/public/javascripts/admin-group-add.js
dibs-web/public/javascripts/admin-group-modify.js
dibs-web/public/javascripts/admin-group.js
dibs-web/public/javascripts/admin-project-add.js
dibs-web/public/javascripts/admin-project-modify.js
dibs-web/public/javascripts/admin-project.js
dibs-web/public/javascripts/admin-server-add.js
dibs-web/public/javascripts/admin-server-modify.js
dibs-web/public/javascripts/admin-server-remove.js
dibs-web/public/javascripts/admin-user-modify.js
dibs-web/public/javascripts/admin-user.js
dibs-web/public/javascripts/build.js
dibs-web/public/javascripts/dibs-api.js
dibs-web/public/javascripts/jobs.js
dibs-web/public/javascripts/log.js
dibs-web/public/javascripts/main.js
dibs-web/public/javascripts/projects.js
dibs-web/public/javascripts/session.js
dibs-web/public/javascripts/user.js
dibs-web/public/log.html
dibs-web/public/stylesheets/style.css [new file with mode: 0644]
dibs-web/public/upload.html
package/build.linux
package/build.macos
package/build.windows
package/changelog
package/pkginfo.manifest
pkg-cli
pkg-svr
src/build_server/BuildClientOptionParser.rb
src/build_server/BuildJob.rb
src/build_server/BuildServer.rb
src/build_server/BuildServerController.rb
src/build_server/BuildServerException.rb
src/build_server/BuildServerOptionParser.rb
src/build_server/CommonJob.rb
src/build_server/DistributionManager.rb
src/build_server/GitBuildJob.rb
src/build_server/JobLog.rb
src/build_server/JobManager.rb
src/build_server/MultiBuildJob.rb
src/build_server/PackageSync.rb
src/build_server/RegisterPackageJob.rb
src/build_server/RemoteBuildJob.rb [deleted file]
src/build_server/RemoteBuildServer.rb
src/build_server/ReverseBuildChecker.rb
src/build_server/SocketJobRequestListener.rb
src/builder/Builder.rb
src/common/BuildComm.rb
src/common/FileTransferViaDirect.rb
src/common/Version.rb
src/common/db_utils.rb [new file with mode: 0644]
src/common/log.rb
src/common/package.rb
src/common/parser.rb
src/common/utils.rb
src/pkg_server/SocketRegisterListener.rb
src/pkg_server/client.rb
src/pkg_server/clientOptParser.rb
src/pkg_server/downloader.rb
src/pkg_server/packageServer.rb
src/pkg_server/serverOptParser.rb
test/build-server.basic1/build-cli-01.testcase
test/build-server.basic1/build-cli-11.testcase
test/build-server.basic1/buildsvr.init
test/build-server.basic1/pkgsvr.init
test/build-server.basic1/testsuite
test/build-server.multi-svr1/buildsvr1.init
test/build-server.multi-svr2/buildsvr.init
test/build-server.multi_dist2/build-svr3-03.testcase
test/build-server.multi_dist2/buildsvr.init
test/pkg-cli-update.testcase [deleted file]
test/pkg-cli.testsuite
web-svr [new file with mode: 0755]

diff --git a/README b/README
index f373da2..9bbb9a1 100644 (file)
--- a/README
+++ b/README
@@ -194,22 +194,13 @@ There are more useful commands provided
 4.1 List Up Available Packages
 You can list up available packages of server.
 
-    ## pkg-cli list-rpkg [-o <os>] [-u <package server url>] 
+    ## pkg-cli list-rpkg -u <package server url> [-o <os>]
     ## -o : Target OS(ubuntu-32/ubuntu-64/windows-32/windows-64/macos-64)
     ## -u : Package server URL which contains binary and development packages.
     ##      If ommited, it will use previous server URL.
 
     1. List up packages
         ex) 
-            
-            $ pkg-cli update -u http://172.21.17.55/dibs/unstable_release
-
-        ex) 
-            
-            $ pkg-cli list-rpkg
-
-    2. List up packages with updating
-        ex) 
         
             $ pkg-cli list-rpkg -u http://172.21.17.55/dibs/unstable_release
 
@@ -224,41 +215,7 @@ You can list up packages of your install directory
         
             $ pkg-cli list-lpkg -l ~/tizen_sdk
 
-4.2 Update Package List
-You should have package list of server in your host before listing, installing and downloading packages. So, if you want to install the latest package, then you should update your package list before installing.
-
-    ## pkg-cli update [-u <package server url>] 
-    ## -u : Package server URL which contains binary and development packages.
-    ##      If ommited, it will use previous server URL.
-
-    1. Update package list from server
-        ex) 
-
-            $ pkg-cli update -u http://172.21.17.55/dibs/unstable_release
-
-    2. Install / download packages from server
-        ex) 
-
-            $ pkg-cli install -p nativeapp-eplugin -l ~/tizen_sdk
-
-        ex) 
-
-            $ pkg-cli install -p unittest-eplugin -l ~/tizen_sdk
-
-        ex) 
-
-            $ pkg-cli download -p base-ide-product -l ~/downloads
-
-    3. If package is updated on server and you want to use is, you should update your package list. If you do not set the server url, it will be set previous server URL.
-        ex) 
-
-            $ pkg-cli update
-
-        ex) 
-
-            $ pkg-cli install -p nativeapp-eplugin -l ~/tizen_sdk
-        
-4.3 Upgrade Packages
+4.2 Upgrade Packages
 You can upgrade your installed packages from server.
 
     ## pkg-cli upgrade -l <location> -u <package server url>
@@ -270,28 +227,22 @@ You can upgrade your installed packages from server.
     1. Check package for upgrading
         ex)
 
-            $ pkg-cli update -u http://172.21.17.55/dibs/unstable_release
-            $ pkg-cli check-upgrade -l ~/tizen_sdk
+            $ pkg-cli check-upgrade -l ~/tizen_sdk -u http://172.21.17.55/dibs/unstable_release
 
     2. Upgrade packages
         ex)
-
-            $ pkg-cli upgrade -l ~/tizen_sdk
-
-    3. Upgrade packages with updating
-        ex)
         
             $ pkg-cli upgrade -l ~/tizen_sdk -u http://172.21.17.55/dibs/unstable_release
 
-    4. If you want to upgrade specific package, you can upgrade it as installing
+    3. If you want to upgrade specific package, you can upgrade it as installing
         ex)
 
             $ pkg-cli install -p common-eplugin -l ~/tizen_sdk -u http://172.21.17.55/dibs/unstable_release
 
-4.4 Install SDK
+4.3 Install SDK
 You can also install new SDK using the network install command. Originally this command is used for installing packages by network. But you can set "TIZEN-SDK" as package name, all Tizen SDK packages will be installed.
 
-    ## pkg-cli install -p <package name> [-u <package server url>] [-l <location>] [-t] [-f]
+    ## pkg-cli install -p <package name> -u <package server url> [-l <location>] [-t] [-f]
     ## -p : Binary package name which you want to install
     ## -u : Package server URL which contains binary and development packages.
     ##      If ommited, it will use previous server URL.
@@ -304,7 +255,7 @@ You can also install new SDK using the network install command. Originally this
     1. Install "TIZEN-SDK" by network to new location("~/tizen_sdk2")
         ex) 
 
-            $ pkg-cli install -p TIZEN-SDK -l ~/tizen_sdk2 -t
+            $ pkg-cli install -p TIZEN-SDK -u http://172.21.17.55/dibs/unstable_release -l ~/tizen_sdk2 -t
 
     2. Change Tizen SDK configuration
         ex) 
index fb9758e..e6120db 100755 (executable)
--- a/build-cli
+++ b/build-cli
@@ -138,6 +138,22 @@ def query_job_list(ip, port)
        end
 end
 
+def upload_request(bs_ip, bs_port, dock, transporter, package )
+       client = BuildCommClient.create( bs_ip, bs_port, nil, 0 )
+       if client.nil? then
+               raise RuntimeError, "Can't access server #{bs_ip}:#{bs_port}"
+       end
+       msg = "UPLOAD|#{dock}"
+       client.send( msg )
+       result = client.send_file(package, transporter)
+       client.terminate
+       if not result then
+               raise RuntimeError, "Uploading file failed!.. #{result}"
+       else 
+               puts "Uploading file success!.. #{result}"
+       end
+end
+
 
 # if "--os" is not specified, use pe
 if option[:os].nil? then
@@ -171,22 +187,22 @@ begin
                        puts "Connection to server failed!"
                        exit 1
                end
-       when "resolve"
-               result = Utils.parse_server_addr(option[:domain])
-               if result.nil? then
-                       puts "Server address is incorrect. (#{option[:domain]})"
-                       puts "Tune as following format."
-                       puts " <ip>:<port>"
-                       exit 1
-               end
-               client = BuildCommClient.create( result[0], result[1], nil, 0 )
-               if not client.nil? then
-                       client.send "RESOLVE|GIT|#{option[:project]}|#{option[:passwd]}|#{option[:os]}|#{option[:async]}|#{option[:dist]}|#{option[:user]}|#{option[:verbose]}"
-                       if not client.print_stream then
-                               puts "ERROR: #{client.get_error_msg()}"
-                       end
-                       client.terminate
-               end
+#      when "resolve"
+#              result = Utils.parse_server_addr(option[:domain])
+#              if result.nil? then
+#                      puts "Server address is incorrect. (#{option[:domain]})"
+#                      puts "Tune as following format."
+#                      puts " <ip>:<port>"
+#                      exit 1
+#              end
+#              client = BuildCommClient.create( result[0], result[1], nil, 0 )
+#              if not client.nil? then
+#                      client.send "RESOLVE|GIT|#{option[:project]}|#{option[:passwd]}|#{option[:os]}|#{option[:async]}|#{option[:dist]}|#{option[:user]}|#{option[:verbose]}"
+#                      if not client.print_stream then
+#                              puts "ERROR: #{client.get_error_msg()}"
+#                      end
+#                      client.terminate
+#              end
        when "query"
                result = Utils.parse_server_addr(option[:domain])
                if result.nil? then
@@ -297,34 +313,38 @@ begin
                        transporter = FileTransferDirect.new( nil )
                end
 
-               # upload
-               client = BuildCommClient.create( bs_ip, bs_port, nil, 0 )
-               if client.nil? then
-                       puts "Can't access server #{bs_ip}:#{bs_port}"
-                       exit(-1)
-               end
-               dock = Utils.create_uniq_name()
-               msg = "UPLOAD|#{dock}"
-               client.send( msg )
-               result = client.send_file(option[:package], transporter)
-               client.terminate
-               if not result then
-                       puts "Uploading file failed!.. #{option[:package]}"
-                       exit(-1)
-               end
-
                # register
                client = BuildCommClient.create( bs_ip, bs_port, nil, 0 )
                if client.nil? then
                        puts "Can't access server #{bs_ip}:#{bs_port}"
                        exit(-1)
                end
-               client.send("REGISTER|BINARY|#{File.basename(option[:package])}|#{option[:passwd]}|#{dock}|#{option[:dist]}|#{option[:user]}|#{option[:noreverse]}")
-               if not client.print_stream then
-                       puts "ERROR: #{client.get_error_msg()}"
-               end
-               client.terminate
 
+               begin
+                       dock = Utils.create_uniq_name()
+                       client.send("REGISTER|BINARY|#{File.basename(option[:package])}|#{option[:passwd]}|#{dock}|#{option[:dist]}|#{option[:user]}|#{option[:noreverse]}")
+                       client.read_lines do |line|
+                               if line.eql?("WAITFORUPLOAD") then
+                                       # upload
+                                       thread = Thread.new do
+                                               begin 
+                                                       upload_request(bs_ip, bs_port, dock, transporter, option[:package])
+                                               rescue => e
+                                                       puts "Transfering file failed!"
+                                                       puts e.message
+                                                       puts e.backtrace.inspect
+                                               end
+                                       end
+            
+                                       thread.join
+                                       client.send("REGISTERCONTINUE")
+                               else
+                                       puts line
+                               end
+                       end
+               ensure
+                       client.terminate
+               end
        else
                raise RuntimeError, "input option incorrect : #{option[:cmd]}"
        end
index fc9a98f..12306e9 100755 (executable)
--- a/build-svr
+++ b/build-svr
@@ -172,7 +172,7 @@ begin
                pkgsvr_url = option[:url]
                pkgsvr_addr = svr_result[0]
                pkgsvr_port = svr_result[1]
-               BuildServerController.add_distribution( option[:name], option[:dist], pkgsvr_url, pkgsvr_addr, pkgsvr_port )
+               BuildServerController.add_distribution( option[:name], option[:dist], pkgsvr_url, pkgsvr_addr, pkgsvr_port, option[:passwd] )
 
        when "remove-dist"
                BuildServerController.remove_distribution( option[:name], option[:dist] )
index b2803d5..c6ea473 100644 (file)
@@ -31,23 +31,23 @@ class AdminController < ApplicationController
        before_filter :check_login_status, :check_admin_group
 
        def queryAllOS
-               os_list = SupportedOs.all(:order => "name")
+               os_list = SupportedOs.find_by_sql("SELECT supported_os.name AS os_name
+                                                                                               , os_category.name AS category_name
+                                                                                        FROM supported_os
+                                                                                               , os_category
+                                                                                       WHERE supported_os.os_category_id = os_category.id
+                                                                                       ORDER BY supported_os.name")
 
                doc = Builder::XmlMarkup.new( :target => out_string = "", :indent => 2 )
                doc.Response {
                        generate_xml_header(doc)
 
                        doc.Data {
-                               if not os_list.nil? 
-                                       os_list.each do |os|
-                                               doc.OS {
-                                                       doc.OsName(os.name)
-                                                       category = OsCategory.find(:first, :conditions => ["id = ?", os.os_category_id]) 
-                                                       if not category.nil?
-                                                               doc.OsCategory(category.name)
-                                                       end
-                                               }
-                                       end
+                               os_list.each do |os|
+                                       doc.OS {
+                                               doc.OsName(os.os_name)
+                                               doc.OsCategory(os.category_name)
+                                       }
                                end
                        }
                }
@@ -57,17 +57,15 @@ class AdminController < ApplicationController
        end
 
        def queryAllOSCategory
-               os_category_list = OsCategory.all(:order => "name")
+               os_category_list = OsCategory.find(:all, :order => "name")
 
                doc = Builder::XmlMarkup.new( :target => out_string = "", :indent => 2 )
                doc.Response {
                        generate_xml_header(doc)
 
                        doc.Data {
-                               if not os_category_list.nil? 
-                                       os_category_list.each do |category|
-                                               doc.OsCategoryName(category.name)
-                                       end
+                               os_category_list.each do |category|
+                                       doc.OsCategoryName(category.name)
                                end
                        }
                }
index 6d838c6..aa91a87 100644 (file)
@@ -30,28 +30,6 @@ class AdminDistributionController < ApplicationController
 
        before_filter :check_login_status, :check_admin_group
 
-       def queryAllDistribution
-               # get full distribution list
-               distributions = Distribution.all
-
-               doc = Builder::XmlMarkup.new( :target => out_string = "", :indent => 2 )
-               doc.Response {
-                       generate_xml_header(doc)
-
-                       #generate to XML
-                       doc.Data {
-                               if not distributions.nil? 
-                                       distributions.each do |distribution|
-                                               doc.DistributionName(distribution.name)
-                                       end
-                               end
-                       }
-               }
-               
-               #send_data
-               render :text => out_string, :content_type => "text/xml"
-       end
-
        def queryDistributionInfo
                dist_name = params[:distribution]
 
index 5818e1b..6820593 100644 (file)
@@ -32,37 +32,36 @@ class AdminGroupController < ApplicationController
        skip_before_filter :check_admin_group, :only => [:queryAllGroup]
 
        def queryAllGroup
-               project_list = Project.all(:order => "name")
-               group_list = Group.all
+               group_list = Group.find(:all)
             
                doc = Builder::XmlMarkup.new( :target => out_string = "", :indent => 2 )
                doc.Response {
                        generate_xml_header(doc)
 
                        doc.Data {
-                               if not group_list.nil? 
-                                       group_list.each do |group|
-                                               group_access_list = GroupProjectAccess.find(:all, :conditions => ["group_id = ?", group.id])
-                    
-                                               doc.Group {
-                                                       doc.GroupName(group.name)
-                                                       doc.AdminFlag(group.admin)
-                                                       doc.Description(group.description)
-
-                                                       if not group_access_list.nil? 
-                                                               group_access_list.each do |group_right|
-                                                                       project = Project.find(:first, :conditions => ["id = ?", group_right.project_id]);
-                                                                       distribution = Distribution.find(:first, :conditions => ["id = ?", project.distribution_id]);
-                                                                       if not project.nil?
-                                                                               doc.AccessableProject {
-                                                                                       doc.ProjectName(project.name)
-                                                                                       doc.ProjectDistribution(distribution.name)
-                                                                               }
-                                                                       end
-                                                               end
-                                                       end
-                                               }
-                                       end
+                               group_list.each do |group|
+                                       doc.Group {
+                                               doc.GroupName(group.name)
+                                               doc.AdminFlag(group.admin)
+                                               doc.Description(group.description)
+
+                                               project_list = GroupProjectAccess.find_by_sql("SELECT projects.name AS project_name
+                                                                                                                                                       , distributions.name AS distribution_name
+                                                                                                                                                FROM group_project_accesses
+                                                                                                                                                       , projects
+                                                                                                                                                       , distributions
+                                                                                                                                               WHERE group_project_accesses.group_id = #{group.id}
+                                                                                                                                                 AND projects.id = group_project_accesses.project_id
+                                                                                                                                                 AND distributions.id = projects.distribution_id
+                                                                                                                                               ORDER BY projects.name")
+
+                                               project_list.each do |project|
+                                                       doc.AccessableProject {
+                                                               doc.ProjectName(project.project_name)
+                                                               doc.ProjectDistribution(project.distribution_name)
+                                                       }
+                                               end
+                                       }
                                end
                        }
                }
@@ -84,37 +83,36 @@ class AdminGroupController < ApplicationController
                        return
                end
 
-               project_list = Project.all(:order => "name")
-
                #generate to XML
                doc = Builder::XmlMarkup.new( :target => out_string = "", :indent => 2 )
                doc.Response {
                        generate_xml_header(doc)
                        doc.Data {
-                               if not project_list.nil?
-                                       project_list.each do |project|
-                                               distribution = Distribution.find(:first, :conditions => ["id = ?", project.distribution_id]);
-                                               doc.Project{
-                                                       doc.Name(project.name)
-                                                       doc.Id(project.id)
-                                                       doc.DistName(distribution.name)
-                                               }
-                                       end
+                               project_list = Project.find_by_sql("SELECT projects.name AS project_name
+                                                                                                                , projects.id AS project_id
+                                                                                                                , distributions.name AS distribution_name
+                                                                                                         FROM projects
+                                                                                                                , distributions
+                                                                                                        WHERE distributions.id = projects.distribution_id
+                                                                                                        ORDER BY projects.name")
+                                                                                                                                 
+                               project_list.each do |project|
+                                       doc.Project{
+                                               doc.Name(project.project_name)
+                                               doc.Id(project.project_id)
+                                               doc.DistName(project.distribution_name)
+                                       }
                                end
             
                                doc.Group {
-                                       doc.Name(group.name)
-                                       
                                        group_access_list = GroupProjectAccess.find(:all, :conditions => ["group_id = ?", group.id])
                     
-                                       if not group_access_list.nil? and not group_access_list.empty? 
-                                               project_id_list = []
-                                               group_access_list.each do |group_right|
-                                                       project_id_list.push group_right.project_id
-                                               end
-            
-                                               doc.ProjectList(project_id_list.join(","))
+                                       project_id_list = []
+                                       group_access_list.each do |group_right|
+                                               project_id_list.push group_right.project_id
                                        end
+            
+                                       doc.ProjectIdList(project_id_list.join(","))
                                }
                        }
                }
index a0f7b72..e125bc6 100644 (file)
@@ -28,22 +28,25 @@ Contributors:
 
 class AdminProjectController < ApplicationController
        def queryAllProject
-               project_list = Project.all(:order => "name")
+               project_list = Project.find_by_sql("SELECT projects.name AS project_name
+                                                                                                , projects.id AS project_id
+                                                                                                , distributions.name AS distribution_name
+                                                                                         FROM projects
+                                                                                                , distributions
+                                                                                        WHERE distributions.id = projects.distribution_id
+                                                                                        ORDER BY projects.name")
 
                doc = Builder::XmlMarkup.new( :target => out_string = "", :indent => 2 )
                doc.Response {
                        generate_xml_header(doc)
 
                        doc.Data {
-                               if not project_list.nil? 
-                                       project_list.each do |project|
-                                       distribution = Distribution.find(:first, :conditions => ["id = ?", project.distribution_id]);
-                                               doc.Project{
-                                                       doc.Name(project.name)
-                                                       doc.Id(project.id)
-                                                       doc.DistName(distribution.name)
-                                               }
-                                       end
+                               project_list.each do |project|
+                                       doc.Project{
+                                               doc.Name(project.project_name)
+                                               doc.Id(project.project_id)
+                                               doc.DistName(project.distribution_name)
+                                       }
                                end
                        }
                }
@@ -81,37 +84,39 @@ class AdminProjectController < ApplicationController
                                                                                                         WHERE distributions.name = \"#{dist_name}\"
                                                                                                           AND distributions.id = projects.distribution_id 
                                                                                                         ORDER BY projects.name")
-                               if not project_list.nil?
-                                       project_list.each do |project|
-                                               doc.Project {
-                                                       doc.ProjectName(project.name)
-                                                       doc.Type(project.ptype)
+
+                               project_list.each do |project|
+                                       doc.Project {
+                                               doc.ProjectName(project.name)
+                                               doc.Type(project.ptype)
             
-                                                       os_list = ProjectOs.find(:all, :conditions => ["project_id = ?", project.id])
-                                                       if not os_list.nil? then
-                                                               os_list.each do |os|
-                                                                       supported_os = SupportedOs.find(:first, :conditions => ["id = ?", os.supported_os_id])
-                                                                       doc.OS(supported_os.name)
-                                                               end
+                                               os_list = ProjectOs.find_by_sql("SELECT supported_os.name AS name
+                                                                                                                  FROM project_os
+                                                                                                                     , supported_os
+                                                                                                                 WHERE project_os.project_id = #{project.id}
+                                                                                                                   AND project_os.supported_os_id = supported_os.id
+                                                                                                                 ORDER BY supported_os.name")
+                                               os_list.each do |os|
+                                                       doc.OS(os.name)
+                                               end
+
+                                               case project.ptype.upcase
+                                               when "GIT"
+                                                       git = ProjectGit.find(:first, :conditions => ["project_id = ?", project.id])
+                                                       if not git.nil? then
+                                                               doc.GitRepos(git.git_repos)
+                                                               doc.GitBranch(git.git_branch)
                                                        end
-
-                                                       case project.ptype.upcase
-                                                       when "GIT"
-                                                               git = ProjectGit.find(:first, :conditions => ["project_id = ?", project.id])
-                                                               if not git.nil? then
-                                                                       doc.GitRepos(git.git_repos)
-                                                                       doc.GitBranch(git.git_branch)
-                                                               end
-                    
-                                                       when "BINARY"
-                                                               bin = ProjectBin.find(:first, :conditions => ["project_id = ?", project.id])
-                                                               if not bin.nil? then
-                                                                       doc.PackageName(bin.pkg_name)
-                                                               end
+                
+                                               when "BINARY"
+                                                       bin = ProjectBin.find(:first, :conditions => ["project_id = ?", project.id])
+                                                       if not bin.nil? then
+                                                               doc.PackageName(bin.pkg_name)
                                                        end
-                                               }
-                                       end
+                                               end
+                                       }
                                end
+                               
                        }
                }
                
index 8efb20d..35f0d5a 100644 (file)
@@ -29,8 +29,8 @@ Contributors:
 class AdminServerController < ApplicationController
        def queryAllServer
                # get full distribution list
-               server_config = Server_config.all
-               remote_build_servers = RemoteBuildServer.all
+               server_config = Server_config.find(:all)
+               remote_build_servers = RemoteBuildServer.find(:all)
 
                doc = Builder::XmlMarkup.new( :target => out_string = "", :indent => 2 )
                doc.Response {
@@ -38,32 +38,28 @@ class AdminServerController < ApplicationController
         
                        #generate to XML
                        doc.Data {
-                               if not server_config.nil? 
-                                       server_config.each do |info|
-                                               doc.ServerConfig {
-                                                       doc.Property( info.property )
-                                                       doc.Value( info.value )
-                                               }
-                                       end
+                               server_config.each do |info|
+                                       doc.ServerConfig {
+                                               doc.Property( info.property )
+                                               doc.Value( info.value )
+                                       }
                                end
 
-                               if not remote_build_servers.nil? 
-                                       remote_build_servers.each do |server|
-                                               doc.RemoteBuildServer {
-                                                       doc.Address(server.svr_addr)
-                                                       supported_os = SupportedOs.find(:first, :conditions => ["id = ?", server.supported_os_id])
-                                                       if supported_os.nil?
-                                                               doc.SupportedOS("")
-                                                       else
-                                                               doc.SupportedOS(supported_os.name)
-                                                       end
-                                                       doc.Status(server.status)
-                                                       doc.MaxJobCount(server.max_job_count)
-                                                       doc.WorkingJobCount(server.working_job_count)
-                                                       doc.WaitingJobCount(server.waiting_job_count)
-                                                       doc.Description(server.description)
-                                               }
-                                       end
+                               remote_build_servers.each do |server|
+                                       doc.RemoteBuildServer {
+                                               doc.Address(server.svr_addr)
+                                               supported_os = SupportedOs.find(:first, :conditions => ["id = ?", server.supported_os_id])
+                                               if supported_os.nil?
+                                                       doc.SupportedOS("")
+                                               else
+                                                       doc.SupportedOS(supported_os.name)
+                                               end
+                                               doc.Status(server.status)
+                                               doc.MaxJobCount(server.max_job_count)
+                                               doc.WorkingJobCount(server.working_job_count)
+                                               doc.WaitingJobCount(server.waiting_job_count)
+                                               doc.Description(server.description)
+                                       }
                                end
                        }
                }
index 7f4af7e..17791c3 100644 (file)
@@ -31,34 +31,34 @@ class AdminUserController < ApplicationController
        before_filter :check_login_status, :check_admin_group
 
        def queryAllUser
-               user_list = User.all(:order => "name")
+               user_list = User.find(:all, :order => "name")
 
                doc = Builder::XmlMarkup.new( :target => out_string = "", :indent => 2 )
                doc.Response {
                        generate_xml_header(doc)
                
                        doc.Data {
-                               if not user_list.nil? 
-                                       user_list.each do |user|
-                                               doc.User {
-                                                       doc.Name(user.name)
-                                                       doc.Email(user.email)
-                                                       doc.GroupList {
-                                                               group_list = Group.find_by_sql("SELECT groups.name
-                                                                                                                                       , groups.admin
-                                                                                                                                       , groups.description
-                                                                                                                               FROM users
-                                                                                                                               , user_groups
-                                                                                                                               , groups
-                                                                                                                               WHERE users.id = user_groups.user_id
-                                                                                                                       AND user_groups.group_id = groups.id
-                                                                                                                               AND users.email = \"#{user.email}\"")
-                                                               group_list.each { |group|
-                                                                               doc.GroupName(group.name)
-                                                               }
-                                                       }
+                               user_list.each do |user|
+                                       doc.User {
+                                               doc.Name(user.name)
+                                               doc.Email(user.email)
+                                               doc.Id(user.id)
+                                               doc.GroupList {
+                                                       group_list = Group.find_by_sql("SELECT groups.name
+                                                                                                                                , groups.admin
+                                                                                                                                , groups.description
+                                                                                                                         FROM users
+                                                                                                                        , user_groups
+                                                                                                                        , groups
+                                                                                                                        WHERE users.email = \"#{user.email}\"
+                                                                                                                          AND users.id = user_groups.user_id
+                                                                                                                  AND user_groups.group_id = groups.id
+                                                                                                                        ORDER BY users.name")
+                                                       group_list.each do |group|
+                                                               doc.GroupName(group.name)
+                                                       end
                                                }
-                                       end
+                                       }
                                end
                        }
                }
@@ -67,13 +67,55 @@ class AdminUserController < ApplicationController
                render :text => out_string, :content_type => "text/xml"
        end
 
+       def queryUserInfo
+               user_id = params[:user_id]
+
+               user = User.find(:first, :conditions => ["id = ?", user_id])
+
+               doc = Builder::XmlMarkup.new( :target => out_string = "", :indent => 2 )
+               doc.Response {
+                       generate_xml_header(doc)
+               
+                       doc.Data {
+                               doc.User {
+                                       doc.Name(user.name)
+                                       doc.Email(user.email)
+                                       doc.Id(user.id)
+                                       doc.GroupInfo{
+                                               full_group_list = Group.find(:all)
+                                               full_group_list.each do |group|
+                                                       doc.Group {
+                                                               doc.Name(group.name)
+                                                               doc.Id(group.id)
+                                                       }
+                                               end
+
+                                               group_list = Group.find_by_sql("SELECT user_groups.group_id
+                                                                                                                 FROM users
+                                                                                                                , user_groups
+                                                                                                                WHERE users.id = #{user.id}
+                                                                                                                  AND users.id = user_groups.user_id")
+                                               group_id_list = []
+                                               group_list.each do |group|
+                                                       group_id_list.push group.group_id
+                                               end
+                                               doc.GroupIdList(group_id_list.join(","))
+                                       }
+                               }
+                       }
+               }
+
+               #send_data
+               render :text => out_string, :content_type => "text/xml"
+       end
+
        def modifyUser
                change_user_list = params[:ChangeInfoList]
                change_item = change_user_list[0]
                errmsg = ""
 
                email = change_item[:Email]
-               group_name = change_item[:GroupName]
+               group_id_list = change_item[:GroupIdList].split(",")
                user_name = change_item[:UserName]
 
                if email.nil? or email.empty?
@@ -89,29 +131,21 @@ class AdminUserController < ApplicationController
                        end
                end
 
-               if group_name.nil? or group_name.empty?
-                       render :text => "Group name is invalid", :status => 406
-                       return
-               else
-                       group = Group.find(:first, :conditions => ["name = ?", group_name])
-                       if group.nil? 
-                               errmsg = "Can't find group information"
-                               render :text => errmsg, :status => 406
-                               return
-                       end
-               end
-
-               user.name  = user_name
+               user.name = user_name
                user.save
 
                UserGroup.delete_all(["user_id = ?", user.id])
 
-               user_groups = UserGroup.new
-
-               user_groups.user_id = user.id
-               user_groups.group_id = group.id
-               user_groups.status = "ACTIVE"
-               user_groups.save
+               if not group_id_list.nil? 
+                       group_id_list.each do |group_id|
+                               user_groups = UserGroup.new
+                
+                               user_groups.user_id = user.id
+                               user_groups.group_id = group_id
+                               user_groups.status = "ACTIVE"
+                               user_groups.save
+                       end
+               end
 
                render :json => { :success => "OK!" }
        end
index 2bb8c94..947b5e0 100644 (file)
@@ -48,11 +48,9 @@ class ProjectsController < ApplicationController
        password_list = []
 
        dist_name = nil
-       build_type = nil
 
        change_group_list.each do |change_item|
                dist_name = change_item[:distribution]
-               build_type = change_item[:buildType]
                project_name = change_item[:projectName]
                os = change_item[:os]
 
@@ -71,7 +69,7 @@ class ProjectsController < ApplicationController
        if (project_list.length > 1) or (not (project_list[0].nil? or project_list[0].empty?))
                # execute build command
                begin
-                       Utils.sbi_build_command(build_type, dist_name, project_list, os_list, password_list, get_user_email)
+                       Utils.sbi_build_command(dist_name, project_list, os_list, password_list, get_user_email)
                rescue => e
                        render :text => e.message, :status => 406
                        return
@@ -132,8 +130,16 @@ class ProjectsController < ApplicationController
        dist_name = params[:distribution]
 
        user_id = get_user_id
-       distribution = Distribution.find(:first, :conditions => ["name = ?", dist_name])
-       projects = Project.find(:all, :conditions => ["distribution_id = ?", distribution.id], :order => "name")
+       projects = Project.find_by_sql("SELECT projects.name AS project_name
+                                                                                , projects.ptype AS project_type
+                                                                                , projects.id AS project_id
+                                                                                , users.email AS maintainer
+                                                                         FROM projects
+                                                                                , distributions
+                                                                                , users
+                                                                        WHERE distributions.name = \"#{dist_name}\"
+                                                                          AND projects.distribution_id = distributions.id
+                                                                          AND users.id = projects.user_id")
 
        #generate to XML
        doc = Builder::XmlMarkup.new( :target => out_string = "", :indent => 2 )
@@ -143,28 +149,23 @@ class ProjectsController < ApplicationController
                        doc.ProjectList {
                                projects.each { |project|
                                        doc.Project {
-                                               doc.Name(project.name)
-                                               doc.Type(project.ptype)
-                                               maintainer = User.find(:first, :conditions => ["id = ?", project.user_id])
-                                               if not maintainer.nil? 
-                                                       doc.Maintainer(maintainer.email)
-                                               else
-                                                       doc.Maintainer("")
-                                               end
+                                               doc.Name(project.project_name)
+                                               doc.Type(project.project_type)
+                                               doc.Maintainer(project.maintainer)
 
-                                               if checkUserAccessProject(user_id, project.id)
+                                               if checkUserAccessProject(user_id, project.project_id)
                                                        doc.GroupAccess("TRUE")
                                                else
                                                        doc.GroupAccess("FALSE")
                                                end
 
-                                               os_list = ProjectOs.find(:all, :conditions => ["project_id = ?", project.id], :order => "supported_os_id")
+                                               os_list = ProjectOs.find(:all, :conditions => ["project_id = ?", project.project_id], :order => "supported_os_id")
                                                os_list.each { |os|
                                                        doc.ProjectOs {
                                                                os_info = SupportedOs.find(:first, :conditions => ["id = ?", os.supported_os_id])
                                                                doc.OsName(os_info.name)
 
-                                                               source = queryPackageInfo(project.id, os.supported_os_id) 
+                                                               source = queryPackageInfo(project.project_id, os.supported_os_id) 
                                                                if source.nil?
                                                                        doc.Package {
                                                                                doc.PackageName()
@@ -205,20 +206,20 @@ class ProjectsController < ApplicationController
        dist_name = params[:distribution]
 
        running_project_list = Project.find_by_sql("SELECT projects.name
-                , projects.ptype
-                , jobs.status
-                , supported_os.name AS os_name
-                       FROM jobs 
-                                , projects
-                                , supported_os
-                                , distributions
-                       WHERE jobs.project_id = projects.id
-                               AND distributions.name = \"#{dist_name}\"
-                               AND projects.distribution_id = distributions.id
-                               AND NOT jobs.status in ('FINISHED', 'ERROR', 'CANCELED')
-                               AND supported_os.id = jobs.supported_os_id
-                       ORDER BY jobs.id")
-
+                                                                                                    , projects.ptype
+                                                                                                    , jobs.status
+                                                                                                    , supported_os.name AS os_name
+                                                                                                 FROM jobs 
+                                                                                                    , projects
+                                                                                                    , supported_os
+                                                                                                    , distributions
+                                                                                                WHERE jobs.project_id = projects.id
+                                                                                                  AND distributions.name = \"#{dist_name}\"
+                                                                                                  AND projects.distribution_id = distributions.id
+                                                                                                  AND NOT jobs.status in ('FINISHED', 'ERROR', 'CANCELED')
+                                                                                                  AND supported_os.id = jobs.supported_os_id
+                                                                                                ORDER BY jobs.id")
+                    
        #generate to XML
        doc = Builder::XmlMarkup.new( :target => out_string = "", :indent => 2 )
        doc.Response {
@@ -258,24 +259,7 @@ class ProjectsController < ApplicationController
        projects = Project.find(:all, :conditions => ["distribution_id = ?", distribution.id], :order => "name")
        osList = SupportedOs.find(:all)
 
-       # check can build
-       project_access_list = []
-
-       # get all my project
-       group_list = get_group_list(get_user_email)
-
-       group_id_list = []
-       group_list.each { |group|
-               group_id_list.push group.id
-       }
-
-       group_name_list_string = 
-       group_access_project_list = GroupProjectAccess.find(:all, :conditions => ["group_id in (?)", group_id_list.join(",") ])
-       if not group_access_project_list.nil?
-               group_access_project_list.each do |access_project| 
-                       project_access_list.push access_project.project_id
-               end
-       end
+       user_id = get_user_id
 
        #generate to XML
        doc = Builder::XmlMarkup.new( :target => out_string = "", :indent => 2 )
@@ -293,7 +277,7 @@ class ProjectsController < ApplicationController
                        projects.each do |project|
                                if project.ptype.eql? "BINARY" 
                                        bin = ProjectBin.find(:first, :conditions => ["project_id = ?", project.id])
-                                       if project_access_list.include? project.id 
+                                       if checkUserAccessProject(user_id, project.id)
                                                doc.BinaryProject {
                                                        doc.ProjectName(project.name)
                                                        if not bin.nil? then
@@ -317,7 +301,7 @@ class ProjectsController < ApplicationController
                                                buildOsNameList.push(supported_os.name)
                                        end
     
-                                       if project_access_list.include? project.id 
+                                       if checkUserAccessProject(user_id, project.id)
                                                doc.Project {
                                                        doc.ProjectName(project.name)
                                                        doc.OsList(buildOsNameList.join(","))
@@ -340,13 +324,8 @@ class ProjectsController < ApplicationController
   end
 
   def queryDistribution
-       distribution_list = []
-
        # get full distribution list
-       distributions = Distribution.all
-       distributions.each {|distribution| 
-               distribution_list.push distribution.name
-       }
+       distribution_list = Distribution.find(:all)
 
        #generate to XML
        doc = Builder::XmlMarkup.new( :target => out_string = "", :indent => 2 )
@@ -354,10 +333,8 @@ class ProjectsController < ApplicationController
                generate_xml_header(doc)
 
                doc.Data {
-                       if not distribution_list.nil?
-                               distribution_list.each do |distribution|
-                                       doc.DistributionName(distribution)
-                               end
+                       distribution_list.each do |distribution|
+                               doc.DistributionName(distribution.name)
                        end
                }
        }
index b0e5f4b..92c9826 100644 (file)
@@ -30,7 +30,7 @@ Contributors:
 BUILD_SERVER_ADDRESS = "127.0.0.1"
 
 class Utils < ApplicationController
-  def Utils.sbi_build_command(sub_cmd, distribution, project_list, os_list, password_list, email)
+  def Utils.sbi_build_command(distribution, project_list, os_list, password_list, email)
        dibs_path = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__))))
        dibs_config = Server_config.find(:first, :conditions => ["property = \"port\""])
        if dibs_config.nil?
@@ -51,7 +51,7 @@ class Utils < ApplicationController
                options = options + " -U #{email} "
        end
 
-       cmd = "#{dibs_path}/build-cli #{sub_cmd} #{options}"
+       cmd = "#{dibs_path}/build-cli build #{options}"
 puts "Build command"
 puts "[[[#{cmd}]]]"
 
@@ -111,6 +111,7 @@ puts "[[[#{cmd}]]]"
 
        options = "-n #{server_name} --dist #{dist_name} "
        cmd = "#{dibs_path}/build-svr fullbuild #{options}"
+       cmd = "which ruby"
 puts "Fullbuild command"
 puts "[[[#{cmd}]]]"
        return execute_shell_return(cmd)
@@ -121,8 +122,8 @@ puts "[[[#{cmd}]]]"
     ret = false
   
     # get result
-    IO.popen("#{cmd}")
-    #system "#{cmd}"
+    #IO.popen("#{cmd}")
+    system "#{cmd}"
 
        return true
   end
index 1e8680c..fd10b4f 100644 (file)
@@ -58,5 +58,6 @@ module Dibs
 
     # Version of your assets, change this if you want to expire all your assets
     config.assets.version = '1.0'
+
   end
 end
diff --git a/dibs-web/config/database.yml b/dibs-web/config/database.yml
deleted file mode 100644 (file)
index 319f61e..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-# SQLite version 3.x
-#   gem install sqlite3
-#
-#   Ensure the SQLite 3 gem is defined in your Gemfile
-#   gem 'sqlite3'
-# development:
-#   adapter: sqlite3
-#   database: db/development.sqlite3
-#   pool: 5
-#   timeout: 5000
-# 
-# # Warning: The database defined as "test" will be erased and
-# # re-generated from your development database when you run "rake".
-# # Do not set this db to the same as development or production.
- test:
-   adapter: 
-   encoding:
-   host:
-   port:
-   database:
-   username:
-   password:
-   pool:
-   timeout: 
- production:
-   adapter: 
-   encoding:
-   host:
-   port:
-   database:
-   username:
-   password:
-   pool:
-   timeout: 
-
- development:
-   adapter: 
-   encoding: 
-   host: 
-   port: 
-   database: 
-   username: 
-   password: 
-   pool: 
-   timeout: 
index 5d0385e..b9b9e8d 100644 (file)
@@ -27,7 +27,6 @@ Contributors:
 =end
 
 Dibs::Application.routes.draw do
-    root :to => "sessions#new"
 
        get "sessions/new" => "sessions#new"
 
@@ -83,6 +82,7 @@ Dibs::Application.routes.draw do
 
        # admin user
        get "admin_user/queryAllUser" 
+       get "admin_user/queryUserInfo/:user_id" => "admin_user#queryUserInfo" 
        post "admin_user/removeUser" 
        post "admin_user/modifyUser" 
 
@@ -109,7 +109,6 @@ Dibs::Application.routes.draw do
        post "admin_project/modifyProject" 
 
        # admin distribution
-       get "admin_distribution/queryAllDistribution" 
        match "admin_distribution/queryDistributionInfo/:distribution" => "admin_distribution#queryDistributionInfo", :constraints => { :distribution => /[0-9A-Za-z\-\.\_]+/ } 
        post "admin_distribution/addDistribution" 
        post "admin_distribution/removeDistribution" 
index e132087..23771bb 100644 (file)
@@ -36,13 +36,13 @@ Contributors:
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
        <meta name="description" content="A master-detail template generated by Tizen Web IDE"/>
 
-       <link rel="stylesheet" href="stylesheets/jquery.mobile-1.1.0.css"/>
+       <link rel="stylesheet" href="stylesheets/jquery.mobile-1.1.1.min.css"/>
        <link rel="stylesheet" href="stylesheets/jqm-docs.css"/>
        <link rel="stylesheet" href="stylesheets/style.css"/>
        
-       <script src="javascripts/jquery-1.7.1.js"></script>
+       <script src="javascripts/jquery-1.7.1.min.js"></script>
        <script src="javascripts/jqm-docs.js"></script>
-       <script src="javascripts/jquery.mobile-1.1.0.js"></script>
+       <script src="javascripts/jquery.mobile-1.1.1.min.js"></script>
        <script src="javascripts/popup-window.js"></script>
 
        <script src="javascripts/main.js"></script>
@@ -72,7 +72,7 @@ Contributors:
 <body>
        <div data-role="page" id="index" class="type-interior">
                <div data-role="header" data-theme="a">
-                       <a href=#index data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">Home</a>
+                       <a href=#index data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-left jqm-home">Home</a>
                        <h1>DIBS 2.0</h1>
                        <div class="sessionInfo">
                        </div>
@@ -98,11 +98,11 @@ Contributors:
                        <h1>Log in</h1>
                </div>
                <div data-role="content">
-                       <form id="loginForm">
-                               <label for="login-email" style="text-align: left; font-size: 12px">Email</label>
-                               <input id="login-email" name="email" type="text" style="font-size: 12px"/>
-                               <label for="login-password" style="text-align: left; font-size: 12px">Password</label>
-                               <input id="login-password" name="password" type="password" style="font-size: 12px"/>
+                       <form id="login-form">
+                               <label for="login-form-email" >Email</label>
+                               <input id="login-form-email" type="email" name="email"/>
+                               <label for="login-form-password">Password</label>
+                               <input id="login-form-password" type="password" name="password"/>
                                <br/>
                                <div data-role="controlgroup" data-type="horizontal">   
                                        <a href="#" data-rel="back" data-role="button" data-mini="true" >Cancel</a>
@@ -112,43 +112,31 @@ Contributors:
                </div> 
        </div><!-- /page -->
 
-       <div data-role="page" id="signup" >
+       <div data-role="page" id="signup">
                <div data-role="header"  data-theme="e" >
                        <h1>Sign up</h1>
                </div>
                <div data-role="content">
-                       <form id="signupForm">
-                               <label for="user-email" style="text-align: left; font-size: 12px">Email</label>
-                               <input id="user-email" name="user[email]" type="text" style="font-size: 12px"/>
-                               <label for="user-name" style="text-align: left; font-size: 12px">Name</label>
-                               <input id="user-name" name="user[name]" type="text" style="font-size: 12px"/>
-                               <label for="user-password" style="text-align: left; font-size: 12px">Password</label>
-                               <input id="user-password" name="user[password]" type="password" style="font-size: 12px"/>
-                               <label for="user-password-confirmation" style="text-align: left; font-size: 12px">Password Comfirmation</label>
-                               <input id="user-password-confirmation" name="user[password_confirmation]" type="password" style="font-size: 12px"/>
-                               <div data-role="controlgroup" id="applyGroupRadio">
-                               </div>
+                       <form id="signup-form">
+                               <label for="signup-form-email">Email</label>
+                               <input id="signup-form-email" type="email" name="email" autocomplete="off"/>
+                               <label for="signup-form-name">Name</label>
+                               <input id="signup-form-name" type="text" name="name" autocomplete="off" />
+                               <label for="signup-form-password">Password</label>
+                               <input id="signup-form-password" type="password" name="password" />
+                               <label for="signup-form-password-confirmation">Password Comfirmation</label>
+                               <input id="signup-form-password-confirmation" type="password" name="password-confirmation" />
                                <div data-role="controlgroup" data-type="horizontal">
                                        <a href="#" data-rel="back" data-role="button" data-mini="true" >Cancel</a>
                                        <a href="#" onClick="userSignUp()" data-role="button" data-mini="true" data-inline="true">Sign up</a>
                                </div>
                        </form> 
-                       <p id="signupErrorMessage" style="text-align: left; font-size: 12px font-color: red">
-                       </p>
                </div> 
        </div><!-- /page -->
 
-       <div data-role="page" id="notification" >
-               <div data-role="header"  data-theme="e" >
-                       <h1></h1>
-               </div>
-               <div data-role="content">
-               </div> 
-       </div><!-- /page -->
-       
        <div data-role="page" id="projects" class="type-interior">
         <div data-role="header" data-theme="a">                                                        
-            <a href=#index data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">Home</a>
+            <a href=#index data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-left jqm-home">Home</a>
             <h1>DIBS 2.0</h1>
             <div class="sessionInfo">
             </div>  
@@ -157,21 +145,22 @@ Contributors:
                <div data-role="content" >
                        <div class="content-primary">
                                <div data-role="fieldcontain" style="text-align: center; font-size: 14px;">
-                                       <select id="projects-select-distribution"  data-native-menu="false" onchange='projectsQueryProjectListType("MY")'>
+                                       <select id="projects-distribution-select"  data-native-menu="false" onchange='projectsQueryProjectListType("MY")'>
                                        </select>
                                </div>
                                <br>
-                               <div id="projectsSearchSelect">
-                                       <fieldset data-role="controlgroup" data-type="horizontal" data-mini="true" id="projectSearchSelectControlGroup">
-                                               <input type="radio" name="radio-choice" id="projects-project-select-1" value="MY PROJECT" checked="checked" onClick='projectsQueryProjectListType("MY")' />
-                                               <label for="projects-project-select-1">MY PROJECT</label>
-                                               <input type="radio" name="radio-choice" id="projects-project-select-2" value="ALL PROJECT" onClick='projectsQueryProjectListType("ALL")'/>
-                                               <label for="projects-project-select-2">ALL PROJECT</label>
-                                               
-                                               <input type="radio" name="radio-choice" id="projects-project-select-3" value="GIT PROJECT" onClick='projectsQueryProjectListType("GIT")' />
-                                               <label for="projects-project-select-3">GIT PROJECT</label>
-                                               <input type="radio" name="radio-choice" id="projects-project-select-4" value="BINARY PROJECT" onClick='projectsQueryProjectListType("BINARY")' />
-                                               <label for="projects-project-select-4">BINARY PROJECT</label>
+                               <div id="projects-type-select">
+                                       <fieldset data-role="controlgroup" data-type="horizontal" data-mini="true">
+                                               <form>
+                                                       <input type="radio" name="radio-choice" id="projects-type-select-1" checked="checked" onClick='projectsQueryProjectListType("MY")' />
+                                                       <label for="projects-type-select-1">MY PROJECT</label>
+                                                       <input type="radio" name="radio-choice" id="projects-type-select-2" onClick='projectsQueryProjectListType("ALL")'/>
+                                                       <label for="projects-type-select-2">ALL PROJECT</label>
+                                                       <input type="radio" name="radio-choice" id="projects-type-select-3" onClick='projectsQueryProjectListType("GIT")' />
+                                                       <label for="projects-type-select-3">GIT PROJECT</label>
+                                                       <input type="radio" name="radio-choice" id="projects-type-select-4" onClick='projectsQueryProjectListType("BINARY")' />
+                                                       <label for="projects-type-select-4">BINARY PROJECT</label>
+                                               </form>
                                        </fieldset>
                                </div>
                                <br>
@@ -188,7 +177,7 @@ Contributors:
 
        <div data-role="page" id="build" class="type-interior">
         <div data-role="header" data-theme="a">                                                        
-            <a href=#index data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">Home</a>
+            <a href=#index data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-left jqm-home">Home</a>
             <h1>DIBS 2.0</h1>
             <div class="sessionInfo">
             </div>  
@@ -198,38 +187,27 @@ Contributors:
                        <div class="content-primary">
                                <div>
                                        <div data-role="fieldcontain" style="text-align: center; font-size: 14px;">
-                                               <select id="select-distribution"  data-native-menu="false" onchange="buildQueryProjectList()">
+                                               <select id="build-distribution-select"  data-native-menu="false" onchange="buildQueryProjectList()">
                                                </select>
                                        </div>
                                </div>
-                               <div data-role="collapsible" data-collapsed="false"  style="width: auto;" >
+                               <div data-role="collapsible" data-collapsed="false" style="width: auto;" >
                                        <h3>Git project</h3>
                                        <div align="right" style="font-size: 10px">
-                                               <a href="#" data-role="button" data-inline="true" data-mini="true" onClick='buildBuildProject("build")'>Build</a>
-                                               <a href="#" data-role="button" data-inline="true" data-mini="true" onClick='buildBuildProject("resolve")'>Resolve</a>
+                                               <a href="#" data-role="button" data-inline="true" data-mini="true" onClick='buildBuildProject()'>Build</a>
                                        </div>
                                        <div data-role="content">
-                                               <table class="projectTableStyle" style="font-size: 14px" id="projectTable">
+                                               <table class="build-project-table" style="font-size: 14px" id="build-git-table">
                                                </table>
                                        </div>
                                </div>
-                               <div data-role="collapsible" data-collapsed="false">
+                               <div data-role="collapsible" data-collapsed="false" style="width: auto;" >
                                        <h3>Binary project</h3>
                                        <div data-role="content">
-                                               <table class="projectTableStyle" style="font-size: 14px" id="binaryProjectTable">
+                                               <table class="build-project-table" style="font-size: 14px" id="build-binary-table">
                                                </table>
                                        </div>
                                </div>
-                               <!--
-                               <div data-role="collapsible" data-collapsed="false">
-                                       <h3>Binary project batch upload</h3>
-                                       <div data-role="content">
-                                               <input id="buildBatchFileUploadPath" align="right" type="file" webkitdirectory multiple data-inline="true" />
-                                               <input id="buildBatchFileRegister" align="right" type="button" value="Register" data-mini="true" data-inline="true" />
-                                               <ul id="buildBatchFileList"</ul>
-                                       </div>
-                               </div>
-                               -->
                        </div><!--/content-primary -->
 
                        <div class="content-secondary">
@@ -241,7 +219,7 @@ Contributors:
 
        <div data-role="page" id="jobs" class="type-interior">
         <div data-role="header" data-theme="a">                                                        
-            <a href=#index data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">Home</a>
+            <a href=#index data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-left jqm-home">Home</a>
             <h1>DIBS 2.0</h1>
             <div class="sessionInfo">
             </div>  
@@ -249,73 +227,72 @@ Contributors:
 
                <div data-role="content" >
                        <div class="content-primary">
-                               <div id="jobDivDistribution" data-role="fieldcontain" style="text-align: center; font-size: 14px;">
-                                       <select id="jobSelectDistribution" date-mini="true" data-native-menu="false" onchange="jobsSearchSelected()">
+                               <div data-role="fieldcontain" style="text-align: center; font-size: 14px;">
+                                       <select id="jobs-distribution-select" date-mini="true" data-native-menu="false" onchange="jobsSearchSelected()">
                                        </select>
                                </div>
                                <br/>
                                <div class="ui-grid-a">
-                                       <div id="jobSearchSelect" class="ui-block-a">
+                                       <div id="jobs-type-select" class="ui-block-a">
                                                <fieldset data-role="controlgroup" data-type="horizontal" data-mini="true">
                                                        <form>
-                                                               <input type="radio" name="radio-choice" id="search-radio-choice-1" class="jobSearch" value="ALL" checked="checked" />
-                                                               <label for="search-radio-choice-1">ALL</label>
+                                                               <input type="radio" name="radio-choice" id="jobs-type-1" class="jobSearch" value="ALL" checked="checked" />
+                                                               <label for="jobs-type-1">ALL</label>
                                                                
-                                                               <input type="radio" name="radio-choice" id="search-radio-choice-2" class="jobSearch" value="JOBID"  />
-                                                               <label for="search-radio-choice-2">JOB ID</label>
+                                                               <input type="radio" name="radio-choice" id="jobs-type-2" class="jobSearch" value="JOBID" />
+                                                               <label for="jobs-type-2">JOB ID</label>
                                                                
-                                                               <input type="radio" name="radio-choice" id="search-radio-choice-3" class="jobSearch" value="USER"  />
-                                                               <label for="search-radio-choice-3">USER</label>
+                                                               <input type="radio" name="radio-choice" id="jobs-type-3" class="jobSearch" value="USER" />
+                                                               <label for="jobs-type-3">USER</label>
                                                                
-                                                               <input type="radio" name="radio-choice" id="search-radio-choice-4" class="jobSearch" value="GROUP"  />
-                                                               <label for="search-radio-choice-4">GROUP</label>
+                                                               <input type="radio" name="radio-choice" id="jobs-type-4" class="jobSearch" value="GROUP" />
+                                                               <label for="jobs-type-4">GROUP</label>
                
-                                                               <input type="radio" name="radio-choice" id="search-radio-choice-5" class="jobSearch" value="PROJECT"  />
-                                                               <label for="search-radio-choice-5">PROJECT</label>
+                                                               <input type="radio" name="radio-choice" id="jobs-type-5" class="jobSearch" value="PROJECT" />
+                                                               <label for="jobs-type-5">PROJECT</label>
                                                                
-                                                               <input type="radio" name="radio-choice" id="radio-choice-6" class="jobSearch" value="DATE"  />
-                                                               <label for="radio-choice-6">DATE</label>
+                                                               <input type="radio" name="radio-choice" id="jobs-type-6" class="jobSearch" value="DATE" />
+                                                               <label for="jobs-type-6">DATE</label>
                                                        </form>
                                                </fieldset>
                                        </div>
-                                       <div id="jobStatusSelect" class="ui-block-b" style="text-align:right">
+                                       <div id="jobs-status-select" class="ui-block-b" style="text-align:right">
                                                <fieldset data-role="controlgroup" data-type="horizontal" data-mini="true">
                                                        <form>
-                                                               <input type="radio" name="radio-choice" id="search-radio-choice-1" class="jobSearch" value="ALL" checked="checked" />
-                                                               <label for="search-radio-choice-1">ALL</label>
+                                                               <input type="radio" name="radio-choice" id="jobs-type-7" class="jobSearch" value="ALL" checked="checked" />
+                                                               <label for="jobs-type-7">ALL</label>
                                                                
-                                                               <input type="radio" name="radio-choice" id="search-radio-choice-2" class="jobSearch" value="SUCCESS"  />
-                                                               <label for="search-radio-choice-2">SUCCESS</label>
+                                                               <input type="radio" name="radio-choice" id="jobs-type-8" class="jobSearch" value="SUCCESS" />
+                                                               <label for="jobs-type-8">SUCCESS</label>
                                                                
-                                                               <input type="radio" name="radio-choice" id="search-radio-choice-3" class="jobSearch" value="WORKING"  />
-                                                               <label for="search-radio-choice-3">WORKING</label>
+                                                               <input type="radio" name="radio-choice" id="jobs-type-9" class="jobSearch" value="WORKING" />
+                                                               <label for="jobs-type-9">WORKING</label>
                                                                
-                                                               <input type="radio" name="radio-choice" id="search-radio-choice-4" class="jobSearch" value="ERROR"  />
-                                                               <label for="search-radio-choice-4">ERROR</label>
+                                                               <input type="radio" name="radio-choice" id="jobs-type-10" class="jobSearch" value="ERROR" />
+                                                               <label for="jobs-type-10">ERROR</label>
                                                        </form>
-       
                                                </fieldset>
                                        </div>
                                </div>
 
-                               <div id="jobDivSearchInput" >
-                                       <input type="search" name="search-mini" id="jobSearchInputText" autocomplete="off" value="" data-mini="true" />
+                               <div id="jobs-search-input" >
+                                       <input type="search" name="search-mini" id="jobs-search-input-text" autocomplete="off" value="" data-mini="true" />
                                        <a href="#" onClick="searchJobInput()" data-role="button" data-mini="true"  data-inline="true">Search</a>
                                                
-                                       <ul data-role="listview" id="jobSearchList" data-inset="true">
+                                       <ul data-role="listview" id="jobs-search-list" data-inset="true">
                                        </ul>
                                </div>
-                               <div id="jobDivSearchDate" >
-                                       <input type="date" name="date" id="jobSearchDate" autocomplete="off" data-mini="true" data-inline="true" data-options='{"mode": "flipbox","noButtonFocusMode": true}' />
+                               <div id="jobs-search-date" >
+                                       <input type="date" name="date" id="jobs-search-date-value" autocomplete="off" data-mini="true" data-inline="true" data-options='{"mode": "flipbox","noButtonFocusMode": true}' />
                                        <a href="#" onClick="searchJobDate()" data-role="button" data-mini="true"  data-inline="true">Search</a>
                                </div>
                                <br>
 
-                               <ul id="jobList" data-role="listview">
+                               <ul id="jobs-job-list" data-role="listview">
                                </ul>
                                <br>
 
-                               <button id="moreJobList" onClick="queryJobList()" data-mini="true">MORE</button>
+                               <button id="jobs-job-more" onClick="queryJobList()" data-mini="true">MORE</button>
                        </div><!--/content-primary -->
 
                        <div class="content-secondary">
@@ -325,18 +302,9 @@ Contributors:
                </div><!-- /content -->
        </div><!-- /page -->
 
-    <div data-role="page" id="log">
-       <table id="logTable" style="border: #000000 1px solid; font-size:9pt">
-       </table> 
-       <div data-role="controlgroup" data-type="horizontal">
-               <input type="button" value="More" onClick=moreLog() / > 
-               <input type="button" value="Stop" onClick=stopLog() / > 
-       </div>
-       </div><!-- /page -->
-       
        <div data-role="page" id="adminUser" class="type-interior">
         <div data-role="header" data-theme="a">                                                        
-            <a href=#index data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">Home</a>
+            <a href=#index data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-left jqm-home">Home</a>
             <h1>DIBS 2.0</h1>
             <div class="sessionInfo">
             </div>  
@@ -346,7 +314,7 @@ Contributors:
                        <div class="content-primary">
                                <h2>User information</h2>
                                <div>
-                               <table class="imagetable" style="font-size: 14px" id="adminUserTable">
+                               <table class="imagetable" style="font-size: 14px" id="adminUser-contents">
                                </table>
                                </div>
                        </div><!--/content-primary -->
@@ -358,35 +326,34 @@ Contributors:
                </div><!-- /content -->
        </div><!-- /page -->
        
-       <div data-role="page" id="adminUserModifyPopup" style="height: 800px; width: 800px">
+       <div data-role="page" id="adminUserModify" style="height: 800px; width: 800px">
                <div data-role="header" >
                        <h1>Modify User</h1>
                </div>
                <div data-role="content">
                        <form method="post" style="font-size: 12px">
-                               <label for="popup:modifyUserName"> User name </label>
-                               <input type="text" id="popup:modifyUserName"/> 
+                               <label for="adminUserModify-name"> User name </label>
+                               <input type="text" id="adminUserModify-name" name="adminUserModify-contents" /> 
                                <br>
-                               <label for="popup:modifyUserEmail"> Email </label>
-                               <input type="text" id="popup:modifyUserEmail"/> 
+                               <label for="adminUserModify-email"> Email </label>
+                               <input type="text" id="adminUserModify-email" name="adminUserModify-contents" disabled="disabled"/>
                                <br>
-                               <div data-role="fieldcontain">
-                                       <label for="popup:modifyUserGroup"> Group </label>
+                               <div>
+                                       <fieldset data-role="controlgroup" data-mini="true" data-role="fieldcontain" id="adminUserModify-group">
+                                       </fieldset>
                                        <br>
-                                       <select id="popup:modifyUserGroup">
-                                       </select>
                                </div>
                                <br>
                        </form>
                </div>
                <div align="right" style="font-size: 10px">
-                       <a href=#adminUser onClick="adminUserModifyPopupModify()" data-role="button" data-inline="true" data-icon="gear">Save</a>
+                       <a href=#adminUser onClick="adminUserModify()" data-role="button" data-inline="true" data-icon="gear">Save</a>
                </div>
        </div><!-- /page -->
 
        <div data-role="page" id="adminGroup" class="type-interior">
         <div data-role="header" data-theme="a">                                                        
-            <a href=#index data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">Home</a>
+            <a href=#index data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-left jqm-home">Home</a>
             <h1>DIBS 2.0</h1>
             <div class="sessionInfo">
             </div>  
@@ -396,10 +363,10 @@ Contributors:
                        <div class="content-primary">
                                <h2>Group information</h2>
                                <div align="right" style="font-size: 10px">
-                                       <a href="#adminGroupAddPopup" data-role="button" data-rel="dialog"  data-inline="true" data-icon="plus"> Add group </a>
+                                       <a href="#adminGroupAdd" data-role="button" data-rel="dialog"  data-inline="true" data-icon="plus"> Add group </a>
                                </div>
                                <div data-role="content" class="container">
-                                       <table class="imagetable" style="font-size: 14px" id="groupTable">
+                                       <table class="imagetable" style="font-size: 14px" id="adminGroup-contents">
                                        </table>
                                </div>
                        </div><!--/content-primary -->
@@ -413,7 +380,7 @@ Contributors:
                        
        <div data-role="page" id="adminServer" class="type-interior">
         <div data-role="header" data-theme="a">                                                        
-            <a href=#index data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">Home</a>
+            <a href=#index data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-left jqm-home">Home</a>
             <h1>DIBS 2.0</h1>
             <div class="sessionInfo">
             </div>  
@@ -458,7 +425,7 @@ Contributors:
 
        <div data-role="page" id="adminProject" class="type-interior">
         <div data-role="header" data-theme="a">                                                        
-            <a href=#index data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">Home</a>
+            <a href=#index data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-left jqm-home">Home</a>
             <h1>DIBS 2.0</h1>
             <div class="sessionInfo">
             </div>  
@@ -469,7 +436,7 @@ Contributors:
                                <h2>Project information</h2>
                                <div>
                                        <div data-role="fieldcontain" style="text-align: center; font-size: 14px;">
-                                               <select id="adminProjectDistributionSelect" data-native-menu="false" onchange="adminProjectSetProjectInfo()">
+                                               <select id="adminProject-distribution-select" data-native-menu="false" onchange="adminProjectSetProjectInfo()">
                                                </select>
                                        </div>
                                </div>
@@ -478,19 +445,19 @@ Contributors:
                                                <div data-role="collapsible" data-theme="b" data-content-theme="c" data-collapsed="false" > 
                                                        <h2> Git project </h2>
                                                        <div align="right" style="font-size: 10px">
-                                                               <a href="#addGitProject"  data-role="button" data-rel="dialog"  data-inline="true" data-icon="plus"> Add git project</a>
+                                                               <a href="#adminProjectAddGit"  data-role="button" data-rel="dialog"  data-inline="true" data-icon="plus"> Add git project</a>
                                                        </div>
                                                        <br> 
-                                                       <table class="imagetable" id="adminProjectTable" style="font-size: 14px">
+                                                       <table class="imagetable" id="adminProject-git" style="font-size: 14px">
                                                        </table>
                                                </div>
                                                <br>
                                                <div data-role="collapsible" data-theme="b" data-content-theme="c" data-collapsed="false" > 
                                                        <h2> Binary project </h2>
                                                        <div align="right" style="font-size: 10px">
-                                                               <a href="#addBinaryProject"  data-role="button"data-rel="dialog"  data-inline="true" data-icon="plus"> Add binary project</a>
+                                                               <a href="#adminProjectAddBinary"  data-role="button"data-rel="dialog"  data-inline="true" data-icon="plus"> Add binary project</a>
                                                        </div>
-                                                       <table class="imagetable" id="adminBinaryProjectTable" style="font-size: 14px">
+                                                       <table class="imagetable" id="adminProject-binary" style="font-size: 14px">
                                                        </table>
                                                </div>
                                        </div>
@@ -506,7 +473,7 @@ Contributors:
 
        <div data-role="page" id="adminDistribution" class="type-interior">
         <div data-role="header" data-theme="a">                                                        
-            <a href=#index data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">Home</a>
+            <a href=#index data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-left jqm-home">Home</a>
             <h1>DIBS 2.0</h1>
             <div class="sessionInfo">
             </div>  
@@ -517,7 +484,7 @@ Contributors:
                                <h2>Distribution information</h2>
                                <div>
                                        <div data-role="fieldcontain" style="text-align: center; font-size: 14px;">
-                                               <select id="adminDistributionSelect" data-native-menu="false" onchange="adminDistributionSetInfo()">
+                                               <select id="adminDistribution-distribution-select" data-native-menu="false" onchange="adminDistributionSetInfo()">
                                                </select>
                                        </div>
                                        <div align="right" style="font-size: 10px">
@@ -525,29 +492,29 @@ Contributors:
                                        </div>
                                        <div data-role="collapsible" data-theme="c" data-content-theme="d" data-collapsed="false" > 
                                                <h2> Package server url </h2>
-                                               <p id="adminDistribution:packageServerUrl" style="font-size: 14px"> </p>
+                                               <p id="adminDistribution-url" style="font-size: 14px"> </p>
                                        </div>
                                        <div data-role="collapsible" data-theme="c" data-content-theme="d" data-collapsed="false" > 
                                                <h2> Package server address </h2>
-                                               <p id="adminDistribution:packageServerAddress" style="font-size: 14px"> </p>
+                                               <p id="adminDistribution-address" style="font-size: 14px"> </p>
                                        </div>
                                        <div data-role="collapsible" data-theme="c" data-content-theme="d" data-collapsed="false" > 
                                                <h2> Status </h2>
-                                               <p id="adminDistribution:distributionStatus" style="font-size: 14px"> </p>
+                                               <p id="adminDistribution-status" style="font-size: 14px"> </p>
                                        </div>
                                        <div data-role="collapsible" data-theme="c" data-content-theme="d" data-collapsed="false" > 
                                                <h2> Description </h2>
-                                               <p id="adminDistribution:distributionDescription" style="font-size: 14px"> </p>
+                                               <p id="adminDistribution-description" style="font-size: 14px"> </p>
                                        </div>
                                        <div data-role="collapsible" data-theme="c" data-content-theme="d" data-collapsed="false" >
                                                <h2> Sync package server </h2>
-                                               <div id="adminDistribution-SyncPackageServer">
+                                               <div id="adminDistribution-syncPackageServer">
                                                </div>
                                        </div>  
                                        <br> 
                                        <div align="right" style="font-size: 10px">
-                                               <a href="#addDistribution" data-role="button" data-rel="dialog" data-inline="true" data-icon="plus"> Add distribution</a>
-                                               <a href="#modifyDistribution" data-role="button" data-rel="dialog" data-inline="true" data-icon="gear"> Modify distribution</a>
+                                               <a href="#adminDistributionAdd" data-role="button" data-rel="dialog" data-inline="true" data-icon="plus"> Add distribution</a>
+                                               <a href="#adminDistributionModify" data-role="button" data-rel="dialog" data-inline="true" data-icon="gear"> Modify distribution</a>
                                                <a href="javascript:adminDistributionRemove()" data-role="button" data-rel="dialog" data-inline="true" data-icon="minus"> Remove distribution</a>
                                        </div>
                                </div>
@@ -560,38 +527,38 @@ Contributors:
                </div><!-- /content -->
        </div><!-- /page -->            
 
-       <div data-role="page" id="addDistribution" style="height: 800px; width: 800px">
+       <div data-role="page" id="adminDistributionAdd" style="height: 800px; width: 800px">
                <div data-role="header" >
                        <h1>Add Distribution</h1>
                </div>
                <div data-role="content">
                        <form method="post" style="font-size: 12px">
-                               <label for="adminDistributionAddPopup-DistirubtionName"> Distirbution name </label>
-                               <input type="text" id="adminDistributionAddPopup-DistirubtionName"/>
+                               <label for="adminDistributionAdd-name"> Distirbution name </label>
+                               <input type="text" id="adminDistributionAdd-name" name="name" />
                                <br>
-                               <label for="adminDistributionAddPopup-PackageServerUrl"> Package server url </label>
-                               <input type="text" id="adminDistributionAddPopup-PackageServerUrl"/>
+                               <label for="adminDistributionAdd-url"> Package server url </label>
+                               <input type="text" id="adminDistributionAdd-url" name="url" />
                                <br>
-                               <label for="adminDistributionAddPopup-PackageServerAddress"> Package server address </label>
-                               <input type="text" id="adminDistributionAddPopup-PackageServerAddress"/>
+                               <label for="adminDistributionAdd-address"> Package server address </label>
+                               <input type="text" id="adminDistributionAdd-address" name="address" />
                                <br>
-                               <label for="adminDistributionAddPopup-DistributionStatus"> Distribution status </label>
-                               <select id="adminDistributionAddPopup-DistributionStatus">
+                               <label for="adminDistributionAdd-status"> Distribution status </label>
+                               <select id="adminDistributionAdd-status" name="status" >
                                        <option value="OPEN" selected="selected">OPEN</option>
                                        <option value="CLOSE">CLOSE</option>
                                </select>
                                <br>
-                               <label for="adminDistributionAddPopup-DistributionDescription"> Description </label>
-                               <input type="text" id="adminDistributionAddPopup-DistributionDescription"/>
+                               <label for="adminDistributionAdd-description"> Description </label>
+                               <input type="text" id="adminDistributionAdd-description" name="description" />
                                <br>
                                <div>
                                        <h3> Sync package server </h3>
-                                       <label for="adminDistributionAddPopup-SyncPackageServer-Url"> Url </label>
-                                       <input type="text" id="adminDistributionAddPopup-SyncPackageServer-Url"/>
-                                       <label for="adminDistributionAddPopup-SyncPackageServer-period"> Period </label>
-                                       <input type="text" id="adminDistributionAddPopup-SyncPackageServer-period"/>
-                                       <label for="adminDistributionAddPopup-SyncPackageServer-Description"> Description </label>
-                                       <input type="text" id="adminDistributionAddPopup-SyncPackageServer-Description"/>
+                                       <label for="adminDistributionAdd-syncPackageServer-url"> Url </label>
+                                       <input type="text" id="adminDistributionAdd-syncPackageServer-url" name="url" />
+                                       <label for="adminDistributionAdd-syncPackageServer-period"> Period </label>
+                                       <input type="text" id="adminDistributionAdd-syncPackageServer-period" name="period" />
+                                       <label for="adminDistributionAdd-syncPackageServer-description"> Description </label>
+                                       <input type="text" id="adminDistributionAdd-syncPackageServer-description" name="description" />
                                </div>
                        </form>
                </div>
@@ -600,33 +567,33 @@ Contributors:
                </div>
        </div><!-- /page -->
        
-       <div data-role="page" id="modifyDistribution" style="height: 800px; width: 800px">
+       <div data-role="page" id="adminDistributionModify" style="height: 800px; width: 800px">
                <div data-role="header" >
                        <h1>Modofy Distribution</h1>
                </div>
                <div data-role="content">
                        <form method="post" style="font-size: 12px">
-                               <label for="adminDistributionModifyPopup-PackageServerUrl"> Package server url </label>
-                               <input type="text" id="adminDistributionModifyPopup-PackageServerUrl"/>
+                               <label for="adminDistributionModify-url"> Package server url </label>
+                               <input type="text" id="adminDistributionModify-url" name="description" />
                                <br>
-                               <label for="adminDistributionModifyPopup-PackageServerAddress"> Package server address </label>
-                               <input type="text" id="adminDistributionModifyPopup-PackageServerAddress"/>
+                               <label for="adminDistributionModify-address"> Package server address </label>
+                               <input type="text" id="adminDistributionModify-address" name="address" />
                                <br>
-                               <label for="adminDistributionModifyPopup-Status"> Distribution status </label>
-                               <select id="adminDistributionModifyPopup-Status">
+                               <label for="adminDistributionModify-status"> Distribution status </label>
+                               <select id="adminDistributionModify-status" name="status" >
                                </select>
                                <br>
-                               <label for="adminDistributionModifyPopup-Description"> Description </label>
-                               <input type="text" id="adminDistributionModifyPopup-Description"/>
+                               <label for="adminDistributionModify-description"> Description </label>
+                               <input type="text" id="adminDistributionModify-description" name="description" />
                                <br>
                                <div>
                                        <h3> Sync package server </h3>
-                                       <label for="adminDistributionModifyPopup-SyncPackageServer-Url"> Url </label>
-                                       <input type="text" id="adminDistributionModifyPopup-SyncPackageServer-Url"/>
-                                       <label for="adminDistributionModifyPopup-SyncPackageServer-Period"> Period </label>
-                                       <input type="text" id="adminDistributionModifyPopup-SyncPackageServer-Period"/>
-                                       <label for="adminDistributionModifyPopup-SyncPackageServer-Description"> Description </label>
-                                       <input type="text" id="adminDistributionModifyPopup-SyncPackageServer-Description"/>
+                                       <label for="adminDistributionModify-syncPackageServer-url"> Url </label>
+                                       <input type="text" id="adminDistributionModify-syncPackageServer-url" name="url" />
+                                       <label for="adminDistributionModify-syncPackageServer-period"> Period </label>
+                                       <input type="text" id="adminDistributionModify-syncPackageServer-period" name="period" />
+                                       <label for="adminDistributionModify-syncPackageServer-description"> Description </label>
+                                       <input type="text" id="adminDistributionModify-syncPackageServer-description" name="description" />
                                </div>
                        </form>
                </div>
@@ -635,26 +602,26 @@ Contributors:
                </div>
        </div>
        
-       <div data-role="page" id="addGitProject" style="height: 800px; width: 800px">
+       <div data-role="page" id="adminProjectAddGit" style="height: 800px; width: 800px">
                <div data-role="header" >
                        <h1>Add Git Project</h1>
                </div>
                <div data-role="content">
                        <form method="post" style="font-size: 12px">
-                               <label for="popup:addGitProjectName"> Project name </label>
-                               <input type="text" id="popup:addGitProjectName"/>
+                               <label for="adminProjectAddGit-name"> Project name </label>
+                               <input type="text" id="adminProjectAddGit-name" name="name" />
                                <br>
-                               <label for="popup:addGitProjectPassword"> Project password </label>
-                               <input type="text" id="popup:addGitProjectPassword"/>
+                               <label for="adminProjectAddGit-password"> Project password </label>
+                               <input type="text" id="adminProjectAddGit-password" name="password" />
                                <br>
-                               <label for="popup:addGitAddress"> Git address </label>
-                               <input type="text" id="popup:addGitAddress"/>
+                               <label for="adminProjectAddGit-address"> Git address </label>
+                               <input type="text" id="adminProjectAddGit-address" name="address" />
                                <br>
-                               <label for="popup:addGitBranch"> Git Branch </label>
-                               <input type="text" id="popup:addGitBranch"/>
+                               <label for="adminProjectAddGit-branch"> Git Branch </label>
+                               <input type="text" id="adminProjectAddGit-branch" name="branch" />
                                <br>
                                <div data-role="fieldcontain">
-                                       <fieldset data-role="controlgroup" data-mini="true" id="popup:addGitProjectOs">
+                                       <fieldset data-role="controlgroup" data-mini="true" id="adminProjectAddGit-os" name="os" >
                                        </fieldset>
                                        <br>
                                </div>
@@ -665,22 +632,22 @@ Contributors:
                </div>
        </div><!-- /page -->
        
-       <div data-role="page" id="addBinaryProject" style="height: 800px; width: 800px">
+       <div data-role="page" id="adminProjectAddBinary" style="height: 800px; width: 800px">
                <div data-role="header" >
                        <h1>Add Binary Project</h1>
                </div>
                <div data-role="content">
                        <form method="post" style="font-size: 12px">
-                               <label for="popup:addBinaryProjectName"> Project name </label>
-                               <input type="text" id="popup:addBinaryProjectName"/>
+                               <label for="adminProjectAddBinary-name"> Project name </label>
+                               <input type="text" id="adminProjectAddBinary-name" name="name" />
                                <br>
-                               <label for="popup:addBinaryProjectPassword"> Project password</label>
-                               <input type="text" id="popup:addBinaryProjectPassword"/>
+                               <label for="adminProjectAddBinary-password"> Project password</label>
+                               <input type="text" id="adminProjectAddBinary-password" name="password" />
                                <br>
-                               <label for="popup:addBinaryPackageName"> Pakcage name</label>
-                               <input type="text" id="popup:addBinaryPackageName"/>
+                               <label for="adminProjectAddBinary-packagename"> Pakcage name</label>
+                               <input type="text" id="adminProjectAddBinary-packagename" name="name" />
                                <div data-role="fieldcontain">
-                                       <fieldset data-role="controlgroup" data-mini="true" id="popup:addBinaryProjectOs">
+                                       <fieldset data-role="controlgroup" data-mini="true" id="adminProjectAddBinary-os" name="os" >
                                        </fieldset>
                                        <br>
                                </div>
@@ -691,33 +658,24 @@ Contributors:
                </div>
        </div><!-- /page -->
        
-       <div data-role="page" id="modifyBinaryProject" style="height: 800px; width: 800px">
+       <div data-role="page" id="adminProjectModifyBinary" style="height: 800px; width: 800px">
                <div data-role="header" >
                        <h1>Modify Project</h1>
                </div>
                <div data-role="content">
                        <form method="post" style="font-size: 12px">
-                               <input type="hidden" id="popup:modifyBinaryOldProjectName" disabled="disabled"/> 
+                               <input type="hidden" id="adminProjectModifyBinary-oldName" disabled="disabled" name="name" /> 
                                <br>
-                               <label for="popup:modifyBinaryNewProjectName"> New Project name </label>
-                               <input type="text" id="popup:modifyBinaryNewProjectName"/> 
+                               <label for="adminProjectModifyBinary-newName"> New Project name </label>
+                               <input type="text" id="adminProjectModifyBinary-newName" name="name" /> 
                                <br>
-                               <div data-role="fieldcontain">
-                                       <label for="popup:modifyBinaryProjectType"> Project type </label>
-                                       <br>
-                                       <select id="popup:modifyBinaryProjectType" disabled="disabled">
-                                               <option value="git">Git</option>
-                                               <option value="binary" selected="selected">Binary</option>
-                                       </select>
-                               </div>
+                               <label for="adminProjectModifyBinary-password"> Project password</label>
+                               <input type="text" id="adminProjectModifyBinary-password" name="name" />
                                <br>
-                               <label for="popup:modifyBinaryProjectPassword"> Project password</label>
-                               <input type="text" id="popup:modifyBinaryProjectPassword"/>
-                               <br>
-                               <label for="popup:modifyBinaryPackageName"> Pakcage name</label>
-                               <input type="text" id="popup:modifyBinaryPackageName"/>
+                               <label for="adminProjectModifyBinary-packageName"> Pakcage name</label>
+                               <input type="text" id="adminProjectModifyBinary-packageName" name="name" />
                                <div data-role="fieldcontain">
-                                       <fieldset data-role="controlgroup" data-mini="true" id="popup:modifyBinaryProjectOs">
+                                       <fieldset data-role="controlgroup" data-mini="true" id="adminProjectModifyBinary-os" name="os" >
                                        </fieldset>
                                        <br>
                                </div>
@@ -728,37 +686,28 @@ Contributors:
                </div>
        </div><!-- /page -->
 
-       <div data-role="page" id="modifyGitProject" style="height: 800px; width: 800px">
+       <div data-role="page" id="adminProjectModifyGit" style="height: 800px; width: 800px">
                <div data-role="header" >
                        <h1>Modify Project</h1>
                </div>
                <div data-role="content">
                        <form method="post" style="font-size: 12px">
-                               <input type="hidden" id="popup:modifyGitOldProjectName" disabled="disabled"/> 
+                               <input type="hidden" id="adminProjectModifyGit-oldName" disabled="disabled" name="name" /> 
                                <br>
-                               <label for="popup:modifyGitNewProjectName"> New Project name </label>
-                               <input type="text" id="popup:modifyGitNewProjectName"/> 
+                               <label for="adminProjectModifyGit-newName"> New Project name </label>
+                               <input type="text" id="adminProjectModifyGit-newName" name="name" /> 
                                <br>
-                               <div data-role="fieldcontain">
-                                       <label for="popup:modifyGitProjectType"> Project type </label>
-                                       <br>
-                                       <select id="popup:modifyGitProjectType" disabled="disabled">
-                                               <option value="git" selected="selected">Git</option>
-                                               <option value="binary">Binary</option>
-                                       </select>
-                               </div>
-                               <br>
-                               <label for="popup:modifyGitProjectPassword"> Project password</label>
-                               <input type="text" id="popup:modifyGitProjectPassword"/>
+                               <label for="adminProjectModifyGit-password"> Project password</label>
+                               <input type="text" id="adminProjectModifyGit-password" name="password" />
                                <br>
-                               <label for="popup:modifyGitProjectAddress"> Git address </label>
-                               <input type="text" id="popup:modifyGitProjectAddress"/>
+                               <label for="adminProjectModifyGit-address"> Git address </label>
+                               <input type="text" id="adminProjectModifyGit-address" name="address" />
                                <br>
-                               <label for="popup:modifyGitProjectBranch"> Git branch</label>
-                               <input type="text" id="popup:modifyGitProjectBranch"/>
+                               <label for="adminProjectModifyGit-branch"> Git branch</label>
+                               <input type="text" id="adminProjectModifyGit-branch" name="branch" />
                                <br>
                                <div data-role="fieldcontain">
-                                       <fieldset data-role="controlgroup" data-mini="true" id="popup:modifyGitProjectOs">
+                                       <fieldset data-role="controlgroup" data-mini="true" id="adminProjectModifyGit-os" name="os" >
                                        </fieldset>
                                        <br>
                                </div>
@@ -769,29 +718,29 @@ Contributors:
                </div>
        </div><!-- /page -->
 
-       <div data-role="page" id="adminGroupAddPopup" style="height: 800px; width: 800px">
+       <div data-role="page" id="adminGroupAdd" style="height: 800px; width: 800px">
                <div data-role="header" >
                        <h1>Add Group</h1>
                </div>
                <div data-role="content">
                        <form method="post" style="font-size: 12px">
-                               <label for="adminGroupAddPopup-Name"> Group name </label>
-                               <input type="text" id="adminGroupAddPopup-Name"/>
+                               <label for="adminGroupAdd-name"> Group name </label>
+                               <input type="text" id="adminGroupAdd-name" name="name" />
                                <br>
                                <div data-role="fieldcontain">
-                                       <label for="adminGroupAddPopup-Admin"> Admin Flag </label>
+                                       <label for="adminGroupAdd-admin"> Admin Flag </label>
                                        <br>
-                                       <select id="adminGroupAddPopup-Admin">
+                                       <select id="adminGroupAdd-admin" name="admin" >
                                                <option value="TRUE">True</option>
                                                <option value="FALSE" selected="selected">False</option>
                                        </select>
                                </div>
                                <br>
-                               <label for="adminGroupAddPopup-Description"> Description </label>
-                               <input type="text" id="adminGroupAddPopup-Description"/>
+                               <label for="adminGroupAdd-description"> Description </label>
+                               <input type="text" id="adminGroupAdd-description" name="description" />
                                <br>
                                <div data-role="fieldcontain">
-                                       <fieldset data-role="controlgroup" data-mini="true" id="popup:addProjectCheckbox">
+                                       <fieldset data-role="controlgroup" data-mini="true" id="adminGroupAdd-project" name="project" >
                                        </fieldset>
                                        <br>
                                </div>
@@ -802,28 +751,29 @@ Contributors:
                </div>
        </div><!-- /page -->
        
-       <div data-role="page" id="adminGroupModifyPopup" style="height: 800px; width: 800px">
+       <div data-role="page" id="adminGroupModify" style="height: 800px; width: 800px">
                <div data-role="header" >
                        <h1>modify Group</h1>
                </div>
                <div data-role="content" data-role="fieldcontain">
                        <form method="post" style="font-size: 12px">
-                               <input type="hidden" id="adminGroupModifyPopup-Name"/>
-                               <label for="adminGroupModifyPopup-NewName"> New group name </label>
-                               <input type="text" id="adminGroupModifyPopup-NewName"/>
+                               <input type="hidden" id="adminGroupModify-oldName" name="name" />
+                               <br>
+                               <label for="adminGroupModify-newName"> New group name </label>
+                               <input type="text" id="adminGroupModify-newName" name="name" />
                                <br>
                                <div data-role="fieldcontain">
-                                       <label for="adminGroupModifyPopup-Admin"> Admin Flag </label>
+                                       <label for="adminGroupModify-admin"> Admin Flag </label>
                                        <br>
-                                       <select id="adminGroupModifyPopup-Admin">
+                                       <select id="adminGroupModify-admin" name="admin" >
                                        </select>
                                </div>
                                <br>
-                               <label for="adminGroupModifyPopup-Description"> Description </label>
-                               <input type="text" id="adminGroupModifyPopup-Description"/>
+                               <label for="adminGroupModify-description"> Description </label>
+                               <input type="text" id="adminGroupModify-description" name="description" />
                                <br>
                                <div>
-                                       <fieldset data-role="controlgroup" data-mini="true" data-role="fieldcontain" id="popup:modifyProjectSelect">
+                                       <fieldset data-role="controlgroup" data-mini="true" data-role="fieldcontain" id="adminGroupModify-project" name="project" >
                                        </fieldset>
                                        <br>
                                </div>
@@ -841,10 +791,10 @@ Contributors:
                <div data-role="content" data-role="fieldcontain">
                        <form method="post" style="font-size: 12px">
                                <label for="adminServer-AddRemoteBuildServer-Address"> Server address </label>
-                               <input type="text" id="adminServer-AddRemoteBuildServer-Address"/>
+                               <input type="text" id="adminServer-AddRemoteBuildServer-Address" name="address" />
                                <br>
                                <label for="adminServer-AddRemoteBuildServer-Description"> Server description</label>
-                               <input type="text" id="adminServer-AddRemoteBuildServer-Description"/>
+                               <input type="text" id="adminServer-AddRemoteBuildServer-Description" name="description" />
                        </form>
                </div>
                <div align="right" style="font-size: 10px">
@@ -857,13 +807,13 @@ Contributors:
                </div>
                <div data-role="content" data-role="fieldcontain">
                        <form method="post" style="font-size: 12px">
-                               <input type="hidden" id="adminServer-modifyRemoteBuildServer-OldAddress"/>
+                               <input type="hidden" id="adminServer-modifyRemoteBuildServer-OldAddress" name="address" />
                                <br>
                                <label for="adminServer-modifyRemoteBuildServer-newAddress"> New server address </label>
-                               <input type="text" id="adminServer-modifyRemoteBuildServer-newAddress"/>
+                               <input type="text" id="adminServer-modifyRemoteBuildServer-newAddress" name="address" />
                                <br>
                                <label for="adminServer-modifyRemoteBuildServer-description"> Description </label>
-                               <input type="text" id="adminServer-modifyRemoteBuildServer-description"/>
+                               <input type="text" id="adminServer-modifyRemoteBuildServer-description" name="description" />
                        </form>
                </div>
                <div align="right" style="font-size: 10px">
@@ -872,23 +822,23 @@ Contributors:
                </div>
        </div><!-- /page -->
 
-       <div data-role="page" id="userModifyPopup" style="height: 800px; width: 800px"> 
+       <div data-role="page" id="userModify" style="height: 800px; width: 800px"> 
                <div data-role="header" >
                        <h1>User information</h1>
                </div>
                <div data-role="content" data-role="fieldcontain">
                        <form method="post" style="font-size: 12px">
-                               <label for="popup-user-info-email">Email</label>
-                               <input type="text" id="popup-user-info-email" disabled="disabled"/>
+                               <label for="userModify-email">Email</label>
+                               <input type="text" id="userModify-email" disabled="disabled" name="email" />
                                <br>
-                               <label for="popup-user-info-name">Name</label>
-                               <input type="text" id="popup-user-info-name"/>
+                               <label for="userModify-name">Name</label>
+                               <input type="text" id="userModify-name" name="email" />
                                <br>
-                               <label for="popup-user-info-password">Password</label>
-                               <input type="password" id="popup-user-info-password"/>
+                               <label for="userModify-password">Password</label>
+                               <input type="password" id="userModify-password" name="password" />
                                <br>
-                               <label for="popup-user-info-password-confirm">Password confirmation</label>
-                               <input type="password" id="popup-user-info-password-confirm"/>
+                               <label for="userModify-password-confirm">Password confirmation</label>
+                               <input type="password" id="userModify-password-confirm" name="password" />
                        </form>
                </div>
                <div align="right" style="font-size: 10px">
@@ -903,12 +853,12 @@ Contributors:
                <div data-role="content" data-role="fieldcontain">
                        <form method="post" style="font-size: 12px">
                                <label for="adminServer-AddSupportedOs-OsName">Supported os name</label>
-                               <input type="text" id="adminServer-AddSupportedOs-OsName"/>
+                               <input type="text" id="adminServer-AddSupportedOs-OsName" name="os" />
                                <br>
                                <div data-role="fieldcontain">
                                        <label for="adminServer-AddSupportedOs-OsCategory"> Os category </label>
                                        <br>
-                                       <select id="adminServer-AddSupportedOs-OsCategory">
+                                       <select id="adminServer-AddSupportedOs-OsCategory" name="os-category" >
                                        </select>
                                </div>
                        </form>
@@ -924,14 +874,14 @@ Contributors:
                </div>
                <div data-role="content" data-role="fieldcontain">
                        <form method="post" style="font-size: 12px">
-                               <input type="hidden" id="adminServer-ModifySupportedOs-OldOsName" disabled="disabled"/>
+                               <input type="hidden" id="adminServer-ModifySupportedOs-OldOsName" disabled="disabled" name="name" />
                                <label for="adminServer-ModifySupportedOs-OsName">Supported os name</label>
-                               <input type="text" id="adminServer-MoidfySupportedOs-OsName"/>
+                               <input type="text" id="adminServer-MoidfySupportedOs-OsName" name="name" />
                                <br>
                                <div data-role="fieldcontain">
                                        <label for="adminServer-ModifySupportedOs-OsCategory"> Os category </label>
                                        <br>
-                                       <select id="adminServer-ModifySupportedOs-OsCategory">
+                                       <select id="adminServer-ModifySupportedOs-OsCategory" name="os-category" >
                                        </select>
                                </div>
                        </form>
@@ -949,7 +899,7 @@ Contributors:
                <div data-role="content" data-role="fieldcontain">
                        <form method="post" style="font-size: 12px">
                                <label for="adminServer-AddOsCategory-Name">OS category name</label>
-                               <input type="text" id="adminServer-AddOsCategory-Name"/>
+                               <input type="text" id="adminServer-AddOsCategory-Name" name="name" />
                        </form>
                </div>
                <div align="right" style="font-size: 10px">
@@ -966,7 +916,7 @@ Contributors:
                                <div data-role="fieldcontain">
                                        <label for="adminServer-RemoveOSCategory-CategorySelect"> Os category </label>
                                        <br>
-                                       <select id="adminServer-RemoveOSCategory-CategorySelect">
+                                       <select id="adminServer-RemoveOSCategory-CategorySelect" name="osCategory" >
                                        </select>
                                </div>
                        </form>
@@ -982,10 +932,10 @@ Contributors:
                <div data-role="content" data-role="fieldcontain">
                        <form method="post" style="font-size: 12px">
                                <label for="adminServer-addServerInfo-property"> Property</label>
-                               <input type="text" id="adminServer-addServerInfo-property"/>
+                               <input type="text" id="adminServer-addServerInfo-property" name="property" />
                                <br>
                                <label for="adminServer-addServerInfo-value"> Value </label>
-                               <input type="text" id="adminServer-addServerInfo-value"/>
+                               <input type="text" id="adminServer-addServerInfo-value" name="value" />
                        </form>
                </div>
                <div align="right" style="font-size: 10px">
@@ -999,10 +949,10 @@ Contributors:
                <div data-role="content" data-role="fieldcontain">
                        <form method="post" style="font-size: 12px">
                                <label for="adminServer-modifyServerInfo-property"> Property</label>
-                               <input type="text" id="adminServer-modifyServerInfo-property" disabled="disabled"/>
+                               <input type="text" id="adminServer-modifyServerInfo-property" disabled="disabled" name="property" />
                                <br>
                                <label for="adminServer-modifyServerInfo-value"> Value </label>
-                               <input type="text" id="adminServer-modifyServerInfo-value"/>
+                               <input type="text" id="adminServer-modifyServerInfo-value" name="value" />
                        </form>
                </div>
                <div align="right" style="font-size: 10px">
index f648638..9ea84ca 100644 (file)
@@ -29,15 +29,15 @@ Contributors:
 function adminDistributionAdd() {
        var changeInfoList = [];
        var changeInfoItem;
-       var name = document.getElementById("adminDistributionAddPopup-DistirubtionName").value;
-       var url = document.getElementById("adminDistributionAddPopup-PackageServerUrl").value;
-       var address = document.getElementById("adminDistributionAddPopup-PackageServerAddress").value;
-       var description = document.getElementById("adminDistributionAddPopup-DistributionDescription").value;
-       var distStatus = $("#adminDistributionAddPopup-DistributionStatus option:selected").val();
+       var name = $("#adminDistributionAdd-name").val();
+       var url = $("#adminDistributionAdd-url").val();
+       var address = $("#adminDistributionAdd-address").val();
+       var description = $("#adminDistributionAdd-description").val();
+       var distStatus = $("#adminDistributionAdd-status option:selected").val();
 
-       var sync_pkg_svr_url = document.getElementById("adminDistributionAddPopup-SyncPackageServer-Url").value;
-       var sync_pkg_svr_period = document.getElementById("adminDistributionAddPopup-SyncPackageServer-period").value;
-       var sync_pkg_svr_description = document.getElementById("adminDistributionAddPopup-SyncPackageServer-Description").value;
+       var sync_pkg_svr_url = $("#adminDistributionAdd-syncPackageServer-url").val();
+       var sync_pkg_svr_period = $("#adminDistributionAdd-syncPackageServer-period").val();
+       var sync_pkg_svr_description = $("#adminDistributionAdd-syncPackageServer-description").val();
 
        if(name == "" || url == "" || address == ""){
                alert("You must input full data");
@@ -48,13 +48,13 @@ function adminDistributionAdd() {
        changeInfoList.push(changeInfoItem);
        
        addDistribution(changeInfoList, function () {
-               document.getElementById("adminDistributionAddPopup-DistirubtionName").value = "";
-               document.getElementById("adminDistributionAddPopup-PackageServerUrl").value = "";
-               document.getElementById("adminDistributionAddPopup-PackageServerAddress").value = "";
-               document.getElementById("adminDistributionAddPopup-DistributionDescription").value = "";
-               document.getElementById("adminDistributionAddPopup-SyncPackageServer-Url").value = "";
-               document.getElementById("adminDistributionAddPopup-SyncPackageServer-period").value = "";
-               document.getElementById("adminDistributionAddPopup-SyncPackageServer-Description").value = "";
+               $("#adminDistributionAdd-name").val("");
+               $("#adminDistributionAdd-url").val("");
+               $("#adminDistributionAdd-address").val("");
+               $("#adminDistributionAdd-description").val("");
+               $("#adminDistributionAdd-syncPackageServer-url").val("");
+               $("#adminDistributionAdd-syncPackageServer-period").val("");
+               $("#adminDistributionAdd-syncPackageServer-description").val("");
 
                $.mobile.changePage("#adminDistribution"); 
        });
index 5c5c293..679e46a 100644 (file)
@@ -27,15 +27,15 @@ Contributors:
 */
 
 function adminDistributionModifyPopupInit() {
-       var distName = $("#adminDistributionSelect option:selected").val();
-       var packageServerUrl = document.getElementById("adminDistribution:packageServerUrl").innerHTML;
-       var packageServeraddress = document.getElementById("adminDistribution:packageServerAddress").innerHTML;
-       var serverStatusText = document.getElementById("adminDistribution:distributionStatus").innerHTML;
-       var serverDescription = document.getElementById("adminDistribution:distributionDescription").innerHTML;
+       var distName = $("#adminDistribution-distribution-select option:selected").val();
+       var packageServerUrl = $("#adminDistribution-url").html();
+       var packageServeraddress = $("#adminDistribution-address").html();
+       var serverStatusText = $("#adminDistribution-status").html();
+       var serverDescription = $("#adminDistribution-description").html();
 
-       var syncPkgSvrUrl = document.getElementById("adminDistribution-SyncPackageServer-Url").innerHTML;
-       var syncPkgSvrPeriod = document.getElementById("adminDistribution-SyncPackageServer-period").innerHTML;
-       var syncPkgSvrDescription = document.getElementById("adminDistribution-SyncPackageServer-Description").innerHTML;
+       var syncPkgSvrUrl = $("#adminDistribution-syncPackageServer-url").html();
+       var syncPkgSvrPeriod = $("#adminDistribution-syncPackageServer-period").html();
+       var syncPkgSvrDescription = $("#adminDistribution-syncPackageServer-description").html();
 
        if (syncPkgSvrUrl) {
                syncPkgSvrUrl = syncPkgSvrUrl.replace("Package server url : ", "");
@@ -54,42 +54,42 @@ function adminDistributionModifyPopupInit() {
                syncPkgSvrDescription = ""
        }
 
-       document.getElementById('adminDistributionModifyPopup-PackageServerUrl').value = packageServerUrl;
-       document.getElementById('adminDistributionModifyPopup-PackageServerAddress').value = packageServeraddress;
-       document.getElementById('adminDistributionModifyPopup-Description').value = serverDescription;
-       document.getElementById('adminDistributionModifyPopup-SyncPackageServer-Url').value = syncPkgSvrUrl;
-       document.getElementById('adminDistributionModifyPopup-SyncPackageServer-Period').value = syncPkgSvrPeriod;
-       document.getElementById('adminDistributionModifyPopup-SyncPackageServer-Description').value = syncPkgSvrDescription;
+       $("#adminDistributionModify-url").val(packageServerUrl);
+       $("#adminDistributionModify-address").val(packageServeraddress);
+       $("#adminDistributionModify-description").val(serverDescription);
+       $("#adminDistributionModify-syncPackageServer-url").val(syncPkgSvrUrl);
+       $("#adminDistributionModify-syncPackageServer-period").val(syncPkgSvrPeriod);
+       $("#adminDistributionModify-syncPackageServer-description").val(syncPkgSvrDescription);
 
-       $("#adminDistributionModifyPopup-Status").empty();
+       $("#adminDistributionModify-status").empty();
        var option; 
        if(serverStatusText.toUpperCase() == "OPEN") {
                option = '<option value="OPEN" selected="selected">OPEN</option>';
        } else {
                option = '<option value="OPEN">OPEN</option>';
        }
-       $("#adminDistributionModifyPopup-Status").append(option);
+       $("#adminDistributionModify-status").append(option);
        
        if(serverStatusText.toUpperCase() == "CLOSE") {
                option = '<option value="CLOSE" selected="selected">CLOSE</option>';
        } else {
                option = '<option value="CLOSE">FALSE</option>';
        }
-       $("#adminDistributionModifyPopup-Status").append(option);
-       $("#adminDistributionModifyPopup-Status").selectmenu("refresh");
+       $("#adminDistributionModify-status").append(option);
+       $("#adminDistributionModify-status").selectmenu("refresh");
 }
 
 function adminDistributionModify() {
        var changeInfoList = [];
        var changeInfoItem;
-       var distName = $("#adminDistributionSelect option:selected").val();
-       var url = document.getElementById("adminDistributionModifyPopup-PackageServerUrl").value;
-       var address = document.getElementById("adminDistributionModifyPopup-PackageServerAddress").value;
-       var description = document.getElementById("adminDistributionModifyPopup-Description").value;
-       var distStatus = $("#adminDistributionModifyPopup-Status option:selected").val();
-       var syncPkgSvrUrl = document.getElementById("adminDistributionModifyPopup-SyncPackageServer-Url").value;
-       var syncPkgSvrPeriod = document.getElementById("adminDistributionModifyPopup-SyncPackageServer-Period").value;
-       var syncPkgSvrDescription = document.getElementById("adminDistributionModifyPopup-SyncPackageServer-Description").value;
+       var distName = $("#adminDistribution-distribution-select option:selected").val();
+       var url = $("#adminDistributionModify-url").val();
+       var address = $("#adminDistributionModify-address").val();
+       var description = $("#adminDistributionModify-description").val();
+       var distStatus = $("#adminDistributionModify-status option:selected").val();
+       var syncPkgSvrUrl = $("#adminDistributionModify-syncPackageServer-url").val();
+       var syncPkgSvrPeriod = $("#adminDistributionModify-syncPackageServer-period").val();
+       var syncPkgSvrDescription = $("#adminDistributionModify-syncPackageServer-description").val();
 
        if(distName == "" || url == "" || address == ""){
                alert("You must input full data");
index 12e112b..7fd24de 100644 (file)
@@ -27,32 +27,32 @@ Contributors:
 */
 
 function adminDistributionInit() {
-       queryAllDistribution( function (xml) {
-               var oldDistName = $("#adminDistributionSelect option:selected").val();
+       queryDistribution( function (xml) {
+               var oldDistName = $("#adminDistribution-distribution-select option:selected").val();
                var find = false;
                var distributionList = $(xml).find("Data").find("DistributionName");
 
                // remove old select options
-               $("#adminDistributionSelect").empty();
+               $("#adminDistribution-distribution-select").empty();
 
                distributionList.each(function(){
                        var name = $(this).text();
        
                        if( oldDistName == name ) {
-                               $("#adminDistributionSelect").append("<option value=\'"+name+"\' selected=\"selected\">"+name+"</option>");
+                               $("#adminDistribution-distribution-select").append("<option value=\'"+name+"\' selected=\"selected\">"+name+"</option>");
                                find = true;
                                
                        } else {
-                               $("#adminDistributionSelect").append("<option value=\'"+name+"\'>"+name+"</option>");
+                               $("#adminDistribution-distribution-select").append("<option value=\'"+name+"\'>"+name+"</option>");
                        }
                });
        
                /* default distribution selection */
                if(!find) {
-                       $("#adminDistributionSelect option:eq(0)").attr("selected", "selected");
+                       $("#adminDistribution-distribution-select option:eq(0)").attr("selected", "selected");
                }
 
-               $("#adminDistributionSelect").selectmenu('refresh');
+               $("#adminDistribution-distribution-select").selectmenu('refresh');
 
                // set distribution info
                adminDistributionSetInfo();
@@ -60,7 +60,7 @@ function adminDistributionInit() {
 }
 
 function adminDistributionSetInfo() {
-       var distName = $("#adminDistributionSelect option:selected").val();
+       var distName = $("#adminDistribution-distribution-select option:selected").val();
 
        queryDistributionInfo( distName, function (xml) {
                var data = $(xml).find("Data").find("DistributionInfo");
@@ -71,10 +71,10 @@ function adminDistributionSetInfo() {
                var distStatus = data.find("Status").text();
                var distDescription = data.find("Description").text();
 
-               $("#adminDistribution\\:packageServerUrl").text(url);
-               $("#adminDistribution\\:packageServerAddress").text(address);
-               $("#adminDistribution\\:distributionStatus").text(distStatus);
-               $("#adminDistribution\\:distributionDescription").text(distDescription);
+               $("#adminDistribution-url").text(url);
+               $("#adminDistribution-address").text(address);
+               $("#adminDistribution-status").text(distStatus);
+               $("#adminDistribution-description").text(distDescription);
 
                adminDistributionInitSyncPackageServer(syncPackageServer);
        });
@@ -83,7 +83,7 @@ function adminDistributionSetInfo() {
 function adminDistributionRemove() {
        var changeInfoList = [];
        var changeInfoItem;
-       var distName = $("#adminDistributionSelect option:selected").val();
+       var distName = $("#adminDistribution-distribution-select option:selected").val();
 
        changeInfoItem = {"DistributionName":distName};
        changeInfoList.push(changeInfoItem);
@@ -100,19 +100,19 @@ function adminDistributionRemove() {
 }
 
 function adminDistributionInitSyncPackageServer(serverInfo){
-       $("#adminDistribution-SyncPackageServer").empty();
+       $("#adminDistribution-syncPackageServer").empty();
 
-       var info = '<h3 style="font-size: 16px" id="adminDistribution-SyncPackageServer-Url">Package server url : '+serverInfo.find("Url").text()+'</h3>';
-       info += '<p style="font-size: 14px" id="adminDistribution-SyncPackageServer-period">Period : '+serverInfo.find("Period").text()+'</p>';
-       info += '<p style="font-size: 14px" id="adminDistribution-SyncPackageServer-Description">Description : '+serverInfo.find("Description").text()+'</p>';
+       var info = '<h3 style="font-size: 16px" id="adminDistribution-syncPackageServer-url">Package server url : '+serverInfo.find("Url").text()+'</h3>';
+       info += '<p style="font-size: 14px" id="adminDistribution-syncPackageServer-period">Period : '+serverInfo.find("Period").text()+'</p>';
+       info += '<p style="font-size: 14px" id="adminDistribution-syncPackageServer-description">Description : '+serverInfo.find("Description").text()+'</p>';
                
-       $("#adminDistribution-SyncPackageServer").append(info);
+       $("#adminDistribution-syncPackageServer").append(info);
 }
 
 function adminDistributionFullBuild() {
        var changeInfoList = [];
        var changeInfoItem;
-       var distName = $("#adminDistributionSelect option:selected").val();
+       var distName = $("#adminDistribution-distribution-select option:selected").val();
 
        changeInfoItem = {"DistributionName":distName};
        changeInfoList.push(changeInfoItem);
index 60c7a16..9811bd6 100644 (file)
@@ -27,8 +27,8 @@ Contributors:
 */
 
 function adminGroupAddInit() {
-       document.getElementById('adminGroupAddPopup-Name').value = "";
-       document.getElementById('adminGroupAddPopup-Description').value = "";
+       $("#adminGroupAdd-name").val("");
+       $("#adminGroupAdd-description").val("");
 
        queryAllProject( function(xml) {
                var fullProjectList = $(xml).find("Data").find("Project");
@@ -38,60 +38,37 @@ function adminGroupAddInit() {
 }
 
 function adminGroupAddGenerateProjectSelect(projectList) {
-       fieldset = document.getElementById('popup:addProjectCheckbox');
-
-       /* remove all table rows */
-       while(fieldset.hasChildNodes())
-       {
-               fieldset.removeChild(fieldset.firstChild);
-       }
-
-       legend = document.createElement('legend');
-       legend.innerHTML = "Project list";
-       fieldset.appendChild(legend);
+       $("#adminGroupAdd-project").empty();
 
        projectList.each(function(){
                var projectName = $(this).find("Name").text();
                var projectId = $(this).find("Id").text();
                var projectDistName = $(this).find("DistName").text();
 
-               var input = document.createElement('input');
-               input.type = 'checkbox';
-               input.id = 'popup:addGroupProjectCheckbox:'+projectId;
-               input.name = 'popup:addGroupProjectCheckbox';
-               input.value = projectName;
-
-               var label = document.createElement('label');
-               label.setAttribute('for', 'popup:addGroupProjectCheckbox:'+projectId);
-               label.innerHTML = projectName + "[" + projectDistName + "]";
-               
-               fieldset.appendChild(input);
-               fieldset.appendChild(label);
+               var input = '<input type=checkbox id=adminGroupAdd-project-checkbox-'+projectId+' name=adminGroupAdd-project-checkbox value='+projectId+' />';
+               var label = '<label for=adminGroupAdd-project-checkbox-'+projectId+'> '+projectName+'['+projectDistName+'] <label>';
+               $("#adminGroupAdd-project").append(input);
+               $("#adminGroupAdd-project").append(label);
        });
 
-       $("[name='popup\\:addGroupProjectCheckbox']").checkboxradio();
+       $("input[name='adminGroupAdd-project-checkbox']").checkboxradio();
 }
 
 function adminGroupAddGroup() {
-       var selectArray = document.getElementsByName('popup:addGroupProjectCheckbox');
-       var groupName = document.getElementById('adminGroupAddPopup-Name').value;
-       var adminFlag = $("#adminGroupAddPopup-Admin option:selected").val();
-       var description = document.getElementById('adminGroupAddPopup-Description').value;
-       var selectProjectIdList = "";
+       var groupName = $("#adminGroupAdd-name").val();
+       var adminFlag = $("#adminGroupAdd-admin option:selected").val();
+       var description = $("#adminGroupAdd-description").val();
+       var selectProjectIdList = [];
        var changeInfoList = [];
        
+       var selectArray = $("input[name='adminGroupAdd-project-checkbox']");
        for(var i = 0; i < selectArray.length; i++) {
                if (selectArray[i].checked == true) {
-                       var projectId = selectArray[i].id.split(":")[2];
-                       selectProjectIdList = selectProjectIdList + "," + projectId;
+                       selectProjectIdList.push(selectArray[i].value);
                }
        }
-
-       if(selectProjectIdList.length > 0) {
-               selectProjectIdList = selectProjectIdList.substring(1,selectProjectIdList.length);
-       }
                
-       changeItem = {"GroupName" : groupName, "AdminFlag":adminFlag, "Description":description, "ProjectList" : selectProjectIdList};
+       changeItem = {"GroupName" : groupName, "AdminFlag":adminFlag, "Description":description, "ProjectList" : selectProjectIdList.toString()};
        changeInfoList.push(changeItem);
 
        addGroup(changeInfoList, function() {
index 17ed56e..51b4e65 100644 (file)
@@ -28,98 +28,76 @@ Contributors:
 
 function adminGroupModifyInit() {
        var index = localStorage.groupTableIndex;
-       var groupName = document.getElementById("groupTableName:"+index).innerHTML;
-       var description = document.getElementById("groupTableDescription:"+index).innerHTML;
-       var adminFlagText = document.getElementById("groupTableAdminFlag:"+index).innerHTML;
-
-       document.getElementById('adminGroupModifyPopup-Name').value = groupName;
-       document.getElementById('adminGroupModifyPopup-NewName').value = groupName;
-       document.getElementById('adminGroupModifyPopup-Description').value = description;
-       $("#adminGroupModifyPopup-Admin").empty();
-       var option; 
+       var groupName = $("#adminGroup-contents-"+index+"-name").html();
+       var adminFlagText = $("#adminGroup-contents-"+index+"-flag").html();
+       var description = $("#adminGroup-contents-"+index+"-description").html();
+
+       $("#adminGroupModify-oldName").val(groupName);
+       $("#adminGroupModify-newName").val(groupName);
+       $("#adminGroupModify-description").val(description);
+
+       $("#adminGroupModify-admin").empty();
        if(adminFlagText.toUpperCase() == "TRUE") {
-               option = '<option value="TRUE" selected="selected">TRUE</option>';
+               $("#adminGroupModify-admin").append('<option value="TRUE" selected="selected">TRUE</option>');
        } else {
-               option = '<option value="TRUE">TRUE</option>';
+               $("#adminGroupModify-admin").append('<option value="TRUE">TRUE</option>');
        }
-       $("#adminGroupModifyPopup-Admin").append(option);
        
        if(adminFlagText.toUpperCase() == "FALSE") {
-               option = '<option value="FALSE" selected="selected">FALSE</option>';
+               $("#adminGroupModify-admin").append('<option value="FALSE" selected="selected">FALSE</option>');
        } else {
-               option = '<option value="FALSE">FALSE</option>';
+               $("#adminGroupModify-admin").append('<option value="FALSE">FALSE</option>');
        }
-       $("#adminGroupModifyPopup-Admin").append(option);
-       $("#adminGroupModifyPopup-Admin").selectmenu("refresh");
+       $("#adminGroupModify-admin").selectmenu("refresh");
 
        queryGroupInfo(groupName, function(xml) {
                var fullProjectList = $(xml).find("Data").find("Project");
-               var projectIdList = $(xml).find("Data").find("Group").find("ProjectList").text().split(",");
+               var projectIdList = $(xml).find("Data").find("Group").find("ProjectIdList").text().split(",");
 
                adminGroupModifyGenerateProjectSelect(fullProjectList, projectIdList);
        });
 }
 
 function adminGroupModifyGenerateProjectSelect(fullProjectList, projectIdList) {
-       fieldset = document.getElementById('popup:modifyProjectSelect');
-       /* remove all table rows */
-       while(fieldset.hasChildNodes())
-       {
-               fieldset.removeChild(fieldset.firstChild);
-       }
-
-       legend = document.createElement('legend');
-       legend.innerHTML = "Project list";
-       fieldset.appendChild(legend);
-
+       $("#adminGroupModify-project").empty();
        fullProjectList.each(function(){
                var projectName = $(this).find("Name").text();
                var projectId = $(this).find("Id").text();
                var projectDistName = $(this).find("DistName").text();
 
-               var input = document.createElement('input');
-               input.type = 'checkbox';
-               input.id = 'popup:modifyProjectCheckbox:'+projectId;
-               input.name = 'popup:modifyProjectCheckbox';
-               input.value = projectName;
-
+               var input; 
                if(contains(projectIdList, projectId))
                {
-                       input.setAttribute('checked', 'checked');
-               }
+                       input = '<input type=checkbox id=adminGroupModify-project-checkbox-'+projectId+' name=adminGroupModify-project-checkbox value='+projectId+' checked=checked />';
+               } else {
+                       input = '<input type=checkbox id=adminGroupModify-project-checkbox-'+projectId+' name=adminGroupModify-project-checkbox value='+projectId+' />';
 
-               var label = document.createElement('label');
-               label.setAttribute('for', 'popup:modifyProjectCheckbox:'+projectId);
-               label.innerHTML = projectName + "[" + projectDistName + "]";
+               }
+               var label = '<label for=adminGroupModify-project-checkbox-'+projectId+'> '+projectName+'['+projectDistName+'] <label>';
                
-               fieldset.appendChild(input);
-               fieldset.appendChild(label);
+               $("#adminGroupModify-project").append(input);
+               $("#adminGroupModify-project").append(label);
        });
 
-       $("[name='popup\\:modifyProjectCheckbox']").checkboxradio();
+       $("input[name='adminGroupModify-project-checkbox']").checkboxradio();
 }
 
 function adminGroupModifyGroup() {
-       var selectArray = document.getElementsByName('popup:modifyProjectCheckbox');
-       var oldGroupName = document.getElementById('adminGroupModifyPopup-Name').value;
-       var groupName = document.getElementById('adminGroupModifyPopup-NewName').value;
-       var description = document.getElementById('adminGroupModifyPopup-Description').value;
-       var adminFlag = $("#adminGroupModifyPopup-Admin option:selected").val();
-       var selectProjectIdList = "";
+       var oldGroupName = $("#adminGroupModify-oldName").val();
+       var groupName = $("#adminGroupModify-newName").val();
+       var description = $("#adminGroupModify-description").val();
+       var adminFlag = $("#adminGroupModify-admin option:selected").val();
+       var selectProjectList = [];
        var changeInfoList = [];
        
+       var selectArray = $("input[name='adminGroupModify-project-checkbox']");
        for(var i = 0; i < selectArray.length; i++) {
                if (selectArray[i].checked == true) {
-                       var projectId = selectArray[i].id.split(":")[2];
-                       selectProjectIdList = selectProjectIdList + "," + projectId;
+                       selectProjectList.push(selectArray[i].value);
                }
        }
-
-       if(selectProjectIdList.length > 0) {
-               selectProjectIdList = selectProjectIdList.substring(1,selectProjectIdList.length);
-       }
                
-       changeItem = {"GroupName" : oldGroupName, "NewGroupName":groupName, "AdminFlag":adminFlag, "Description":description, "ProjectList" : selectProjectIdList};
+       changeItem = {"GroupName" : oldGroupName, "NewGroupName":groupName, "AdminFlag":adminFlag, "Description":description, "ProjectList":selectProjectList.toString()};
        changeInfoList.push(changeItem);
 
        changeGroup(changeInfoList, function() {
index 6f2104b..f897766 100644 (file)
@@ -27,7 +27,7 @@ Contributors:
 */
 
 function adminGroupInit() {
-       adminGroupInitTable();
+       $("#adminGroup-contents").empty();
 
        queryAllGroup( function(xml) {
                var header = $(xml).find("Header");
@@ -37,30 +37,14 @@ function adminGroupInit() {
        });
 }
 
-function adminGroupInitTable() {
-       var groupTable = document.getElementById("groupTable");
-
-       /* remove all table rows */
-       while(groupTable.hasChildNodes())
-       {
-               groupTable.removeChild(groupTable.firstChild);
-       }
-}
-
 function adminGroupFillTableInfo(groupList) {
-       var groupTable = document.getElementById("groupTable");
-
-       /* remove all table rows */
-       while(groupTable.hasChildNodes())
-       {
-               groupTable.removeChild(groupTable.firstChild);
-       }
+       var groupTable = document.getElementById("adminGroup-contents");
 
        /* create table header */
        var row = groupTable.insertRow(-1);
        var tableHeader = "<tr><th> Group name </th><th> Project list </th><th> Admin </th><th> Description </th><th> Modify </th><th> Delete </th></tr>";
        
-       $("#groupTable").append(tableHeader);
+       $("#adminGroup-contents").append(tableHeader);
 
        var index = 2;
 
@@ -75,7 +59,7 @@ function adminGroupFillTableInfo(groupList) {
                row.setAttribute('id', 'table:'+index);
 
                cell = row.insertCell(-1);
-               cell.setAttribute('id', 'groupTableName:'+index);
+               cell.setAttribute('id', 'adminGroup-contents-'+index+'-name');
                cell.innerHTML = groupName
 
                cell = row.insertCell(-1);
@@ -83,20 +67,20 @@ function adminGroupFillTableInfo(groupList) {
                cell.appendChild(div);
 
                cell = row.insertCell(-1);
-               cell.setAttribute('id', 'groupTableAdminFlag:'+index);
+               cell.setAttribute('id', 'adminGroup-contents-'+index+'-flag');
                cell.innerHTML = adminFlag;
 
                cell = row.insertCell(-1);
-               cell.setAttribute('id', 'groupTableDescription:'+index);
+               cell.setAttribute('id', 'adminGroup-contents-'+index+'-description');
                cell.innerHTML = description;
 
                cell = row.insertCell(-1);
                var button = document.createElement('a');
-               button.setAttribute('href','#adminGroupModifyPopup');
+               button.setAttribute('href','#adminGroupModify');
                button.setAttribute('data-role','button');
                button.setAttribute('data-rel','dialog');
-               button.setAttribute('onClick','adminGroupModifyPopupSetup(\"'+index+'\")');
-               button.setAttribute('class','groupTableCellButton');
+               button.setAttribute('onClick','adminGroupModifySetup(\"'+index+'\")');
+               button.setAttribute('class','adminGroup-contents-button');
                button.innerHTML = " "
                cell.appendChild(button);
 
@@ -104,17 +88,17 @@ function adminGroupFillTableInfo(groupList) {
                var button = document.createElement('input');
                button.setAttribute('type','button');
                button.setAttribute('onClick','adminGroupRemoveGroup('+index+')');
-               button.setAttribute('class','groupTableCellButton');
+               button.setAttribute('class','adminGroup-contents-button');
                cell.appendChild(button);
 
                index = index + 1;
        });
 
-       $(".groupProjectList").collapsible();
-       $(".groupTableCellButton").button();
+       $(".adminGroup-projectList").collapsible();
+       $(".adminGroup-contents-button").button();
 }
 
-function adminGroupModifyPopupSetup(index) {
+function adminGroupModifySetup(index) {
        localStorage.groupTableIndex = index;
 }
 
@@ -122,7 +106,7 @@ function adminGroupGenerateProjectListCell(projectList) {
        var div = document.createElement('div');
        div.setAttribute('data-role', 'collapsible');
        div.setAttribute('data-content-theme', 'b');
-       div.setAttribute('class', 'groupProjectList');
+       div.setAttribute('class', 'adminGroup-projectList');
        div.setAttribute('style', 'text-align: left');
 
        var header = document.createElement('h3');
@@ -145,7 +129,7 @@ function adminGroupGenerateProjectListCell(projectList) {
 }
 
 function adminGroupRemoveGroup(index) {
-       var groupName = document.getElementById("groupTableName:"+index).innerHTML;
+       var groupName = $("#adminGroup-contents-"+index+"-name").html();
 
        var r=confirm("User ["+groupName+"] will be removed!!!");
        if (r==false)
index 7251408..8aa5ddb 100644 (file)
@@ -27,110 +27,72 @@ Contributors:
 */
 
 function adminProjectAddGitInit() {
-       document.getElementById("popup:addGitProjectName").value = "";
-       document.getElementById("popup:addGitProjectPassword").value = "";
-       document.getElementById("popup:addGitAddress").value = "";
-       document.getElementById("popup:addGitBranch").value = "";
+       $("#adminProjectAddGit-name").val("");
+       $("#adminProjectAddGit-password").val("");
+       $("#adminProjectAddGit-address").val("");
+       $("#adminProjectAddGit-branch").val("");
 
        queryAllOS( function (xml) {
                var osList = $(xml).find("Data").find("OsName");
 
-               fieldset = document.getElementById('popup:addGitProjectOs');
-               /* remove all table rows */
-               while(fieldset.hasChildNodes())
-               {
-                       fieldset.removeChild(fieldset.firstChild);
-               }
-        
-               legend = document.createElement('legend');
-               legend.innerHTML = "Project os list";
-               fieldset.appendChild(legend);
+               $("#adminProjectAddGit-os").empty();
+               $("#adminProjectAddGit-os").append("<legend>os list</legend>");
         
                osList.each(function(){
                        var osName = $(this).text();
         
-                       var input = document.createElement('input');
-                       input.type = 'checkbox';
-                       input.id = 'popup:addGitProjectOsCheckbox:'+osName;
-                       input.name = 'popup:addGitProjectOsCheckbox';
-                       input.value = osName;
-                       input.setAttribute('class', 'popup:addGitProjectOsCheckbox');
-                       input.setAttribute('checked', 'checked');
-        
-                       var label = document.createElement('label');
-                       label.setAttribute('for', 'popup:addGitProjectOsCheckbox:'+osName);
-                       label.innerHTML = osName;
-                       
-                       fieldset.appendChild(input);
-                       fieldset.appendChild(label);
+                       var input = '<input type=checkbox id=adminProjectAddGit-os-checkbox-'+osName+' name=adminProjectAddGit-os-checkbox value='+osName+' checked=checked />'
+                       var label = '<label for=adminProjectAddGit-os-checkbox-'+osName+'> '+osName+'<label>';
+                       $("#adminProjectAddGit-os").append(input);
+                       $("#adminProjectAddGit-os").append(label);
                });
         
-               $('.popup\\:addGitProjectOsCheckbox').checkboxradio();
+               $('input[name="adminProjectAddGit-os-checkbox"]').checkboxradio();
        });
 }
 
 function adminProjectAddBinaryInit() {
-       document.getElementById("popup:addBinaryProjectName").value = "";
-       document.getElementById("popup:addBinaryProjectPassword").value = "";
-       document.getElementById("popup:addBinaryPackageName").value = "";
+       $("#adminProjectAddBinary-name").val("");
+       $("#adminProjectAddBinary-password").val("");
+       $("#adminProjectAddBinary-packagename").val("");
 
        queryAllOS( function (xml) {
                var osList = $(xml).find("Data").find("OsName");
 
-               fieldset = document.getElementById('popup:addBinaryProjectOs');
-               /* remove all table rows */
-               while(fieldset.hasChildNodes())
-               {
-                       fieldset.removeChild(fieldset.firstChild);
-               }
-        
-               legend = document.createElement('legend');
-               legend.innerHTML = "Project os list";
-               fieldset.appendChild(legend);
+               $("#adminProjectAddBinary-os").empty();
+               $("#adminProjectAddBinary-os").append("<legend>os list</legend>");
         
                osList.each(function(){
                        var osName = $(this).text();
         
-                       var input = document.createElement('input');
-                       input.type = 'checkbox';
-                       input.id = 'popup:addBinaryProjectOsCheckbox:'+osName;
-                       input.name = 'popup:addBinaryProjectOsCheckbox';
-                       input.value = osName;
-                       input.setAttribute('class', 'popup:addBinaryProjectOsCheckbox');
-                       input.setAttribute('checked', 'checked');
-        
-                       var label = document.createElement('label');
-                       label.setAttribute('for', 'popup:addBinaryProjectOsCheckbox:'+osName);
-                       label.innerHTML = osName;
-                       
-                       fieldset.appendChild(input);
-                       fieldset.appendChild(label);
+                       var input = '<input type=checkbox id=adminProjectAddBinary-os-checkbox-'+osName+' name=adminProjectAddBinary-os-checkbox value='+osName+' checked=checked />'
+                       var label = '<label for=adminProjectAddBinary-os-checkbox-'+osName+'> '+osName+'<label>';
+                       $("#adminProjectAddBinary-os").append(input);
+                       $("#adminProjectAddBinary-os").append(label);
                });
         
-               $('.popup\\:addBinaryProjectOsCheckbox').checkboxradio();
+               $('input[name="adminProjectAddBinary-os-checkbox"]').checkboxradio();
        });
 }
 
 function adminProjectAddGitProject() {
-       var distName = $("#adminProjectDistributionSelect option:selected").val();
        var changeInfoList = [];
        var changeInfoItem;
+       var distName = $("#adminProject-distribution-select option:selected").val();
        var type = "GIT";
-       var name = document.getElementById("popup:addGitProjectName").value;
-       var password = document.getElementById("popup:addGitProjectPassword").value;
-       var address = document.getElementById("popup:addGitAddress").value;
-       var branch = document.getElementById("popup:addGitBranch").value;
-       var selectArray = document.getElementsByName('popup:addGitProjectOsCheckbox');
+       var name = $("#adminProjectAddGit-name").val();
+       var password = $("#adminProjectAddGit-password").val();
+       var address = $("#adminProjectAddGit-address").val();
+       var branch = $("#adminProjectAddGit-branch").val();
        var selectOsList = [];
 
+       var selectArray = $("input[name='adminProjectAddGit-os-checkbox']");
        for(var i = 0; i < selectArray.length; i++) {
                if (selectArray[i].checked == true) {
-                       var osName = selectArray[i].id.split(":")[2];
-                       selectOsList.push(osName);
+                       selectOsList.push(selectArray[i].value);
                }
        }
 
-
        if(name == "" || password == "" || address == "" || branch == ""){
                alert("You must input full data(Project name, Git password, Git address, Branch)");
                return;
@@ -145,20 +107,19 @@ function adminProjectAddGitProject() {
 }
 
 function adminProjectAddBinaryProject() {
-       var distName = $("#adminProjectDistributionSelect option:selected").val();
        var changeInfoList = [];
        var changeInfoItem;
+       var distName = $("#adminProject-distribution-select option:selected").val();
        var type = "BINARY";
-       var name = document.getElementById("popup:addBinaryProjectName").value;
-       var password = document.getElementById("popup:addBinaryProjectPassword").value;
-       var pkgName = document.getElementById("popup:addBinaryPackageName").value;
-       var selectArray = document.getElementsByName('popup:addBinaryProjectOsCheckbox');
+       var name = $("#adminProjectAddBinary-name").val();
+       var password = $("#adminProjectAddBinary-password").val();
+       var pkgName = $("#adminProjectAddBinary-packagename").val();
        var selectOsList = [];
 
+       var selectArray = $("input[name='adminProjectAddBinary-os-checkbox']");
        for(var i = 0; i < selectArray.length; i++) {
                if (selectArray[i].checked == true) {
-                       var osName = selectArray[i].id.split(":")[2];
-                       selectOsList.push(osName);
+                       selectOsList.push(selectArray[i].value);
                }
        }
 
index 420d093..16930e2 100644 (file)
@@ -28,145 +28,113 @@ Contributors:
 
 function adminProjectModifyBinaryProjectInit() {
        var projectName = localStorage.projectName;
-       var packageName = document.getElementById('modifyBinaryPackageName:'+projectName).innerHTML;
+       var packageName = $("#adminProject-binary-packageName-"+projectName).html();
 
-       document.getElementById('popup:modifyBinaryOldProjectName').value = projectName;
-       document.getElementById('popup:modifyBinaryNewProjectName').value = projectName;
-       document.getElementById('popup:modifyBinaryProjectPassword').value = "";
-       document.getElementById('popup:modifyBinaryPackageName').value = packageName;
+       $("#adminProjectModifyBinary-oldName").val(projectName);
+       $("#adminProjectModifyBinary-newName").val(projectName);
+       $("#adminProjectModifyBinary-password").val("");
+       $("#adminProjectModifyBinary-packageName").val(packageName);
+       $("#adminProjectModifyBinary-os").empty();
+       $("#adminProjectModifyBinary-os").append("<legend> os list </legend>");
 
        queryAllOS( function (xml) {
                var osList = $(xml).find("Data").find("OsName");
                var selectedOsList = [];
                var projectName = localStorage.projectName;
        
-               var osListElement = document.getElementById('adminBINARYProjectTableOsList:'+projectName);
+               var osListElement = document.getElementById("adminProject-binary-"+projectName+"-osList");
                for(var i = 0; i < osListElement.childNodes.length; i++)
                {
                        selectedOsList.push(osListElement.childNodes[i].innerHTML);
                }
 
-               fieldset = document.getElementById('popup:modifyBinaryProjectOs');
-               /* remove all table rows */
-               while(fieldset.hasChildNodes())
-               {
-                       fieldset.removeChild(fieldset.firstChild);
-               }
-        
-               legend = document.createElement('legend');
-               legend.innerHTML = "Project os list";
-               fieldset.appendChild(legend);
-        
                osList.each(function(){
                        var osName = $(this).text();
-        
-                       var input = document.createElement('input');
-                       input.type = 'checkbox';
-                       input.id = 'popup:modifyBinaryProjectOs:'+osName;
-                       input.name = 'popup:modifyBinaryProjectOs'
-                       input.value = osName;
-                       input.setAttribute('class', 'popup:modifyBinaryProjectOs');
+                       var input;
                        if(contains(selectedOsList, osName))
                        {
-                               input.setAttribute('checked', 'checked');
+                               input = '<input type=checkbox id=adminProjectModifyBinary-os-checkbox-'+osName+' name=adminProjectModifyBinary-os-checkbox value='+osName+' checked=checked />';
+                       } else {
+                               input = '<input type=checkbox id=adminProjectModifyBinary-os-checkbox-'+osName+' name=adminProjectModifyBinary-os-checkbox value='+osName+' />';
+            
                        }
-        
-                       var label = document.createElement('label');
-                       label.setAttribute('for', 'popup:modifyBinaryProjectOs:'+osName);
-                       label.innerHTML = osName;
+                       var label = '<label for=adminProjectModifyBinary-os-checkbox-'+osName+'> '+osName+' <label>';
                        
-                       fieldset.appendChild(input);
-                       fieldset.appendChild(label);
+                       $("#adminProjectModifyBinary-os").append(input);
+                       $("#adminProjectModifyBinary-os").append(label);
                });
         
-               $('.popup\\:modifyBinaryProjectOs').checkboxradio();
+               $("input[name='adminProjectModifyBinary-os-checkbox']").checkboxradio();
        });
 }
 
 function adminProjectModifyGitProjectInit() {
        var projectName = localStorage.projectName;
-       var projectAddress = document.getElementById('modifyGitProjectAddress:'+projectName).innerHTML;
-       var projectBranch = document.getElementById('modifyGitProjectBranch:'+projectName).innerHTML;
+       var projectAddress = $("#adminProject-git-"+projectName+"-address").html();
+       var projectBranch = $("#adminProject-git-"+projectName+"-branch").html();
 
-       document.getElementById('popup:modifyGitOldProjectName').value = projectName;
-       document.getElementById('popup:modifyGitNewProjectName').value = projectName;
-       document.getElementById('popup:modifyGitProjectPassword').value = "";
-       document.getElementById('popup:modifyGitProjectAddress').value = projectAddress;
-       document.getElementById('popup:modifyGitProjectBranch').value = projectBranch;
+       $("#adminProjectModifyGit-oldName").val(projectName);
+       $("#adminProjectModifyGit-newName").val(projectName);
+       $("#adminProjectModifyGit-password").val("");
+       $("#adminProjectModifyGit-address").val(projectAddress);
+       $("#adminProjectModifyGit-branch").val(projectBranch);
+       $("#adminProjectModifyGit-os").empty();
+       $("#adminProjectModifyGit-os").append("<legend> os list </legend>");
 
        queryAllOS( function (xml) {
                var osList = $(xml).find("Data").find("OsName");
                var selectedOsList = [];
                var projectName = localStorage.projectName;
        
-               var osListElement = document.getElementById('adminGITProjectTableOsList:'+projectName);
+               var osListElement = document.getElementById("adminProject-git-"+projectName+"-osList");
                for(var i = 0; i < osListElement.childNodes.length; i++)
                {
                        selectedOsList.push(osListElement.childNodes[i].innerHTML);
                }
 
-               fieldset = document.getElementById('popup:modifyGitProjectOs');
-               /* remove all table rows */
-               while(fieldset.hasChildNodes())
-               {
-                       fieldset.removeChild(fieldset.firstChild);
-               }
-        
-               legend = document.createElement('legend');
-               legend.innerHTML = "Project os list";
-               fieldset.appendChild(legend);
-        
                osList.each(function(){
                        var osName = $(this).text();
-        
-                       var input = document.createElement('input');
-                       input.type = 'checkbox';
-                       input.id = 'popup:modifyGitProjectOs:'+osName;
-                       input.name = 'popup:modifyGitProjectOs'
-                       input.value = osName;
-                       input.setAttribute('class', 'popup:modifyGitProjectOs');
+                       var input;
                        if(contains(selectedOsList, osName))
                        {
-                               input.setAttribute('checked', 'checked');
+                               input = '<input type=checkbox id=adminProjectModifyGit-os-checkbox-'+osName+' name=adminProjectModifyGit-os-checkbox value='+osName+' checked=checked />';
+                       } else {
+                               input = '<input type=checkbox id=adminProjectModifyGit-os-checkbox-'+osName+' name=adminProjectModifyGit-os-checkbox value='+osName+' />';
+            
                        }
-        
-                       var label = document.createElement('label');
-                       label.setAttribute('for', 'popup:modifyGitProjectOs:'+osName);
-                       label.innerHTML = osName;
+                       var label = '<label for=adminProjectModifyGit-os-checkbox-'+osName+'> '+osName+' <label>';
                        
-                       fieldset.appendChild(input);
-                       fieldset.appendChild(label);
+                       $("#adminProjectModifyGit-os").append(input);
+                       $("#adminProjectModifyGit-os").append(label);
                });
         
-               $('.popup\\:modifyGitProjectOs').checkboxradio();
+               $("input[name='adminProjectModifyGit-os-checkbox']").checkboxradio();
        });
 }
 
 function adminProjectModfyBinaryProject() {
-       var distName = $("#adminProjectDistributionSelect option:selected").val();
+       var distName = $("#adminProject-distribution-select option:selected").val();
        var changeInfoList = [];
        var changeInfoItem;
-       var oldProjectName = document.getElementById('popup:modifyBinaryOldProjectName').value;
-       var newProjectName = document.getElementById('popup:modifyBinaryNewProjectName').value;
-       var projectType = document.getElementById('popup:modifyBinaryProjectType').value;
-       var projectPassword = document.getElementById('popup:modifyBinaryProjectPassword').value;
-       var packageName = document.getElementById('popup:modifyBinaryPackageName').value;
-       var selectArray = document.getElementsByName('popup:modifyBinaryProjectOs');
+       var oldProjectName = $("#adminProjectModifyBinary-oldName").val();
+       var newProjectName = $("#adminProjectModifyBinary-newName").val();
+       var projectPassword = $("#adminProjectModifyBinary-password").val();
+       var packageName = $("#adminProjectModifyBinary-packageName").val();
        var selectOsList = [];
 
+       var selectArray = $("input[name='adminProjectModifyBinary-os-checkbox']");
        for(var i = 0; i < selectArray.length; i++) {
                if (selectArray[i].checked == true) {
-                       var osName = selectArray[i].id.split(":")[2];
-                       selectOsList.push(osName);
+                       selectOsList.push(selectArray[i].value);
                }
        }
 
-       if(oldProjectName == "" || newProjectName == "" || projectPassword == "" || projectType == "" || packageName == ""){
+       if(oldProjectName == "" || newProjectName == "" || projectPassword == "" || packageName == ""){
                alert("You must input full data");
                return;
        }
                
-       changeInfoItem = {"Distribution":distName, "Name":oldProjectName, "NewProjectName":newProjectName, "ProjectType":projectType, "ProjectPass":projectPassword, "PackageName":packageName, "OSNameList":selectOsList.toString()};
+       changeInfoItem = {"Distribution":distName, "Name":oldProjectName, "NewProjectName":newProjectName, "ProjectType":"BINARY", "ProjectPass":projectPassword, "PackageName":packageName, "OSNameList":selectOsList.toString()};
        changeInfoList.push(changeInfoItem);
 
        modifyProject(changeInfoList, function () {
@@ -175,31 +143,29 @@ function adminProjectModfyBinaryProject() {
 }
 
 function adminProjectModfyGitProject() {
-       var distName = $("#adminProjectDistributionSelect option:selected").val();
+       var distName = $("#adminProject-distribution-select option:selected").val();
        var changeInfoList = [];
        var changeInfoItem;
-       var oldProjectName = document.getElementById('popup:modifyGitOldProjectName').value;
-       var newProjectName = document.getElementById('popup:modifyGitNewProjectName').value;
-       var projectType = document.getElementById('popup:modifyGitProjectType').value;
-       var projectPassword = document.getElementById('popup:modifyGitProjectPassword').value;
-       var projectAddress = document.getElementById('popup:modifyGitProjectAddress').value;
-       var projectBranch = document.getElementById('popup:modifyGitProjectBranch').value;
-       var selectArray = document.getElementsByName('popup:modifyGitProjectOs');
+       var oldProjectName = $("#adminProjectModifyGit-oldName").val();
+       var newProjectName = $("#adminProjectModifyGit-newName").val();
+       var projectPassword = $("#adminProjectModifyGit-password").val();
+       var projectAddress = $("#adminProjectModifyGit-address").val();
+       var projectBranch = $("#adminProjectModifyGit-branch").val();
        var selectOsList = [];
 
+       var selectArray = $("input[name='adminProjectModifyGit-os-checkbox']");
        for(var i = 0; i < selectArray.length; i++) {
                if (selectArray[i].checked == true) {
-                       var osName = selectArray[i].id.split(":")[2];
-                       selectOsList.push(osName);
+                       selectOsList.push(selectArray[i].value);
                }
        }
 
-       if(oldProjectName == "" || newProjectName == "" || projectPassword == "" || projectType == "" || projectAddress == "" || projectBranch == ""){
+       if(oldProjectName == "" || newProjectName == "" || projectPassword == "" || projectAddress == "" || projectBranch == ""){
                alert("You must input full data");
                return;
        }
                
-       changeInfoItem = {"Distribution":distName, "Name":oldProjectName, "NewProjectName":newProjectName, "ProjectType":projectType, "ProjectPass":projectPassword, "ProjectAddress":projectAddress, "ProjectBranch":projectBranch, "OSNameList":selectOsList.toString()};
+       changeInfoItem = {"Distribution":distName, "Name":oldProjectName, "NewProjectName":newProjectName, "ProjectType":"GIT", "ProjectPass":projectPassword, "ProjectAddress":projectAddress, "ProjectBranch":projectBranch, "OSNameList":selectOsList.toString()};
        changeInfoList.push(changeInfoItem);
 
        modifyProject(changeInfoList, function () {
index 03e06b7..f28ef05 100644 (file)
@@ -27,40 +27,29 @@ Contributors:
 */
 
 function adminProjectInit() {
-       queryAllDistribution( function (xml) {
-               var oldDistName = $("#adminProjectDistributionSelect option:selected").val();
-               var find = false;
-               var distributionList = $(xml).find("Data").find("DistributionName");
-
-               // remove old select options
-               $("#adminProjectDistributionSelect").empty();
-
-               distributionList.each(function(){
-                       var name = $(this).text();
-       
-                       if( oldDistName == name ) {
-                               $("#adminProjectDistributionSelect").append("<option value=\'"+name+"\' selected=\"selected\">"+name+"</option>");
-                               find = true;
-                               
-                       } else {
-                               $("#adminProjectDistributionSelect").append("<option value=\'"+name+"\'>"+name+"</option>");
-                       }
+       if( $("#adminProject-distribution-select").children().length == 0 ) {
+               queryDistribution( function(xml) {
+                       $(xml).find("Data").find("DistributionName").each(function(){
+                               var name = $(this).text();
+               
+                               $("#adminProject-distribution-select").append("<option value=\'"+name+"\'>"+name+"</option>");
+                       });
+               
+                       /* default distribution selection */
+                       $("#adminProject-distribution-select option:eq(0)").attr("selected", "selected");
+                       $("#adminProject-distribution-select").selectmenu('refresh');
+               
+                       // set project info
+                       adminProjectSetProjectInfo();
                });
-       
-               /* default distribution selection */
-               if(!find) {
-                       $("#adminProjectDistributionSelect option:eq(0)").attr("selected", "selected");
-               }
-
-               $("#adminProjectDistributionSelect").selectmenu('refresh');
-
+       } else {
                // set project info
                adminProjectSetProjectInfo();
-       });
+       }
 }
 
 function adminProjectSetProjectInfo() {
-       var distName = $("#adminProjectDistributionSelect option:selected").val();
+       var distName = $("#adminProject-distribution-select option:selected").val();
 
        queryProjectsInDistributionForAdmin( distName, function (xml) {
                var projectList = $(xml).find("Data").find("Project");
@@ -75,7 +64,7 @@ function popupModifyProject(projectName) {
 }
 
 function adminProjectRemoveProject(projectType, projectName ) {
-       var distName = $("#adminProjectDistributionSelect option:selected").val();
+       var distName = $("#adminProject-distribution-select option:selected").val();
 
        var r=confirm("Project ["+projectName+"] is removed!!!");
        if (r==false)
@@ -95,28 +84,22 @@ function adminProjectRemoveProject(projectType, projectName ) {
 
 function adminProjectUpdateTable(projectList) {
        /* project table */
-       var projectTable = document.getElementById("adminProjectTable");
+       var projectTable = document.getElementById("adminProject-git");
 
        /* binary project table */
-       var binaryProjectTable = document.getElementById("adminBinaryProjectTable");
+       var binaryProjectTable = document.getElementById("adminProject-binary");
 
        /* remove all table rows */
-       while(projectTable.hasChildNodes())
-       {
-               projectTable.removeChild(projectTable.firstChild);
-       }
-       while(binaryProjectTable.hasChildNodes())
-       {
-               binaryProjectTable.removeChild(binaryProjectTable.firstChild);
-       }
+       $("#adminProject-git").empty();
+       $("#adminProject-binary").empty();
 
        // Project table header
        var tableHeader = "<tr><th>Project</th><th>Git repos</th><th>Branch</th><th>OS list</th><th>Modify</th><th>Delete</th>";
-       $("#adminProjectTable").append(tableHeader);
+       $("#adminProject-git").append(tableHeader);
 
        // Binary project table header
        var tableHeader = "<tr><th>Project</th><th>Package name</th><th>OS list</th><th>Modify</th><th>Delete</th>";
-       $("#adminBinaryProjectTable").append(tableHeader);
+       $("#adminProject-binary").append(tableHeader);
 
        var projectIdx = 1;
        var binaryProjectIdx = 1;
@@ -133,17 +116,16 @@ function adminProjectUpdateTable(projectList) {
 
                        cell = row.insertCell(-1);
                        cell.setAttribute('style', 'text-align: left');
-                       cell.setAttribute('id',"modifyGitProjectName:"+name);
                        cell.innerHTML = name;
 
                        cell = row.insertCell(-1);
                        cell.setAttribute('style', 'text-align: left');
-                       cell.setAttribute('id',"modifyGitProjectAddress:"+name);
+                       cell.setAttribute('id',"adminProject-git-"+name+"-address");
                        cell.innerHTML = $(this).find("GitRepos").text();
 
                        cell = row.insertCell(-1);
                        cell.setAttribute('style', 'text-align: left');
-                       cell.setAttribute('id',"modifyGitProjectBranch:"+name);
+                       cell.setAttribute('id',"adminProject-git-"+name+"-branch");
                        cell.innerHTML = $(this).find("GitBranch").text();
 
                        cell = row.insertCell(-1);
@@ -152,7 +134,7 @@ function adminProjectUpdateTable(projectList) {
 
                        cell = row.insertCell(-1);
                        var button = document.createElement('a');
-                       button.setAttribute('href','#modifyGitProject');
+                       button.setAttribute('href','#adminProjectModifyGit');
                        button.setAttribute('data-role','button');
                        button.setAttribute('data-rel','dialog');
                        button.setAttribute('data-mini','true');
@@ -180,12 +162,11 @@ function adminProjectUpdateTable(projectList) {
 
                        cell = row.insertCell(-1);
                        cell.setAttribute('style', 'text-align: left');
-                       cell.setAttribute('id',"modifyBinaryProjectName:"+name);
                        cell.innerHTML = name;
 
                        cell = row.insertCell(-1);
                        cell.setAttribute('style', 'text-align: left');
-                       cell.setAttribute('id',"modifyBinaryPackageName:"+name);
+                       cell.setAttribute('id',"adminProject-binary-packageName-"+name);
                        cell.innerHTML = $(this).find("PackageName").text();
 
                        cell = row.insertCell(-1);
@@ -194,7 +175,7 @@ function adminProjectUpdateTable(projectList) {
 
                        cell = row.insertCell(-1);
                        var button = document.createElement('a');
-                       button.setAttribute('href','#modifyBinaryProject');
+                       button.setAttribute('href','#adminProjectModifyBinary');
                        button.setAttribute('data-role','button');
                        button.setAttribute('data-inline','true');
                        button.setAttribute('data-mini','true');
@@ -220,7 +201,7 @@ function adminProjectUpdateTable(projectList) {
        });
 
        $(".binaryProjectTableButton").button();
-       $(".groupProjectList").collapsible();
+       $(".adminProject-OsList").collapsible();
 }
 
 function adminProjectApendOsCell(osList, projectName, projectType) {
@@ -230,14 +211,14 @@ function adminProjectApendOsCell(osList, projectName, projectType) {
        div.setAttribute('data-role', 'collapsible');
        div.setAttribute('data-mini', 'true');
        div.setAttribute('data-content-theme', 'b');
-       div.setAttribute('class', 'groupProjectList');
+       div.setAttribute('class', 'adminProject-OsList');
 
        var header = document.createElement('h3');
        header.innerHTML = "OS list";
        div.appendChild(header);
 
        var ul = document.createElement('ul');
-       ul.setAttribute('id', 'admin'+projectType+'ProjectTableOsList:'+projectName);
+       ul.setAttribute('id', 'adminProject-'+projectType.toLowerCase()+'-'+projectName+'-osList');
 
        // if osList does not exist then just return 
        if (osList != undefined) {
index 18a47d2..3d46b09 100644 (file)
@@ -28,7 +28,7 @@ Contributors:
 
 function adminServerAddSupportedOsInit() {
        // Remove select option
-       $('#adminServer-AddSupportedOs-OsCategory').empty();
+       $("#adminServer-AddSupportedOs-OsCategory").empty();
 
        queryAllOSCategory(function(xml){
                $(xml).find("Data").find("OsCategoryName").each(function(){
@@ -45,8 +45,8 @@ function adminServerAddRemoteBuildServer() {
        var changeInfoList = [];
        var changeInfoItem;
 
-       var address = document.getElementById("adminServer-AddRemoteBuildServer-Address").value;
-       var description = document.getElementById("adminServer-AddRemoteBuildServer-Description").value;
+       var address = $("#adminServer-AddRemoteBuildServer-Address").val();
+       var description = $("#adminServer-AddRemoteBuildServer-Description").val();
 
        if(address == ""){
                alert("You must input server address");
@@ -57,8 +57,8 @@ function adminServerAddRemoteBuildServer() {
        changeInfoList.push(changeInfoItem);
        
        addRemoteBuildServer(changeInfoList, function () {
-               document.getElementById('adminServer-AddRemoteBuildServer-Address').value = "";
-               document.getElementById('adminServer-AddRemoteBuildServer-Description').value = "";
+               $("#adminServer-AddRemoteBuildServer-Address").val("");
+               $("#adminServer-AddRemoteBuildServer-Description").val("");
 
                $.mobile.changePage("#adminServer"); 
        });
@@ -68,7 +68,7 @@ function adminServerAddSupportedOs() {
        var changeInfoList = [];
        var changeInfoItem;
 
-       var osName = document.getElementById("adminServer-AddSupportedOs-OsName").value;
+       var osName = $("#adminServer-AddSupportedOs-OsName").val();
        var osCategory = $("#adminServer-AddSupportedOs-OsCategory option:selected").val();
 
        if(osName == ""){
@@ -80,7 +80,7 @@ function adminServerAddSupportedOs() {
        changeInfoList.push(changeInfoItem);
        
        addSupportedOS(changeInfoList, function () {
-               document.getElementById('adminServer-AddSupportedOs-OsName').value = "";
+               $("#adminServer-AddSupportedOs-OsName").val("");
 
                $.mobile.changePage("#adminServer"); 
        });
@@ -90,7 +90,7 @@ function adminServerAddOSCategory() {
        var changeInfoList = [];
        var changeInfoItem;
 
-       var categoryName = document.getElementById("adminServer-AddOsCategory-Name").value;
+       var categoryName = $("#adminServer-AddOsCategory-Name").val();
 
        if(categoryName == ""){
                alert("You must input category name");
@@ -101,15 +101,15 @@ function adminServerAddOSCategory() {
        changeInfoList.push(changeInfoItem);
        
        addOSCategory(changeInfoList, function () {
-               document.getElementById('adminServer-AddOsCategory-Name').value = "";
+               $("#adminServer-AddOsCategory-Name").val("");
 
                $.mobile.changePage("#adminServer"); 
        }); 
 } 
 
 function adminServerAddServerInfo() {
-       var property = document.getElementById('adminServer-addServerInfo-property').value;
-       var value = document.getElementById('adminServer-addServerInfo-value').value;
+       var property = $("#adminServer-addServerInfo-property").val();
+       var value = $("#adminServer-addServerInfo-value").val();
        var changeInfoList = [];
        var changeInfoItem;
 
index 28e9c97..26dae6d 100644 (file)
@@ -30,22 +30,22 @@ function adminServerModifyRemoteBuildServerInit() {
        var serverAddress = localStorage.remoteBuildServerAddress;
        var serverDescription = localStorage.remoteBuildServerDescription;
 
-       document.getElementById('adminServer-modifyRemoteBuildServer-OldAddress').value = serverAddress;
-       document.getElementById('adminServer-modifyRemoteBuildServer-newAddress').value = serverAddress;
-       document.getElementById('adminServer-modifyRemoteBuildServer-description').value = serverDescription 
+       $("#adminServer-modifyRemoteBuildServer-OldAddress").val(serverAddress);
+       $("#adminServer-modifyRemoteBuildServer-newAddress").val(serverAddress);
+       $("#adminServer-modifyRemoteBuildServer-description").val(serverDescription);
 }
 
 function adminServerModifyServerInfoInit(property, value) {
-       document.getElementById('adminServer-modifyServerInfo-property').value = property;
-       document.getElementById('adminServer-modifyServerInfo-value').value = value;
+       $("#adminServer-modifyServerInfo-property").val(property);
+       $("#adminServer-modifyServerInfo-value").val(value);
 }
 
 function adminServerModifySupportedOSInit(osName, osCategory) {
        // Remove select option
        $('#adminServer-ModifySupportedOs-OsCategory').empty();
 
-       document.getElementById('adminServer-ModifySupportedOs-OldOsName').value = osName;
-       document.getElementById('adminServer-MoidfySupportedOs-OsName').value = osName;
+       $("#adminServer-ModifySupportedOs-OldOsName").val(osName);
+       $("#adminServer-MoidfySupportedOs-OsName").val(osName);
 
        queryAllOSCategory( function(xml){
                $(xml).find("Data").find("OsCategoryName").each(function(){
@@ -67,9 +67,9 @@ function adminServerModifySupportedOSInit(osName, osCategory) {
 function adminServerModifyRemoteBuildServer() {
        var changeInfoList = [];
        var changeInfoItem;
-       var serverAddress = document.getElementById('adminServer-modifyRemoteBuildServer-OldAddress').value;
-       var newServerAddress = document.getElementById('adminServer-modifyRemoteBuildServer-newAddress').value;
-       var description = document.getElementById('adminServer-modifyRemoteBuildServer-description').value;
+       var serverAddress = $("#adminServer-modifyRemoteBuildServer-OldAddress").val();
+       var newServerAddress = $("#adminServer-modifyRemoteBuildServer-newAddress").val();
+       var description = $("#adminServer-modifyRemoteBuildServer-description").val();
 
        if(serverAddress == ""){
                alert("server address is invalid");
@@ -87,8 +87,8 @@ function adminServerModifyRemoteBuildServer() {
 function adminServerModifySupportedOS() {
        var changeInfoList = [];
        var changeInfoItem;
-       var oldOsName = document.getElementById('adminServer-ModifySupportedOs-OldOsName').value;
-       var osName = document.getElementById('adminServer-MoidfySupportedOs-OsName').value;
+       var oldOsName = $("#adminServer-ModifySupportedOs-OldOsName").val();
+       var osName = $("#adminServer-MoidfySupportedOs-OsName").val();
        var osCategory = $("#adminServer-ModifySupportedOs-OsCategory option:selected").val();
 
        changeInfoItem = {"Name":oldOsName, "NewName":osName, "OsCategory":osCategory};
@@ -100,8 +100,8 @@ function adminServerModifySupportedOS() {
 }
 
 function adminServerModifyServerInfo() {
-       var property = document.getElementById('adminServer-modifyServerInfo-property').value;
-       var value = document.getElementById('adminServer-modifyServerInfo-value').value;
+       var property = $("#adminServer-modifyServerInfo-property").val();
+       var value = $("#adminServer-modifyServerInfo-value").val();
        var changeInfoList = [];
        var changeInfoItem;
 
index db74a01..676ac99 100644 (file)
@@ -62,8 +62,8 @@ function adminServerRemoveOSCategory() {
 function adminServerRemoveSupportedOS() {
        var changeInfoList = [];
        var changeInfoItem;
-       var oldOsName = document.getElementById('adminServer-ModifySupportedOs-OldOsName').value;
-       var osName = document.getElementById('adminServer-MoidfySupportedOs-OsName').value;
+       var oldOsName = $('#adminServer-ModifySupportedOs-OldOsName').val();
+       var osName = $('#adminServer-MoidfySupportedOs-OsName').val();
 
        if(oldOsName != osName ){
                alert("Remove command must be same to original os name");
@@ -79,7 +79,7 @@ function adminServerRemoveSupportedOS() {
 }
 
 function adminServerRemoveServerInfo() {
-       var property = document.getElementById('adminServer-modifyServerInfo-property').value;
+       var property = $('#adminServer-modifyServerInfo-property').val();
        var changeInfoList = [];
        var changeInfoItem;
 
@@ -99,7 +99,7 @@ function adminServerRemoveServerInfo() {
 function adminServerRemoveRemoteBuildServer() {
        var changeInfoList = [];
        var changeInfoItem;
-       var serverAddress = document.getElementById('adminServer-modifyRemoteBuildServer-OldAddress').value;
+       var serverAddress = $('#adminServer-modifyRemoteBuildServer-OldAddress').val();
 
        if(serverAddress == ""){
                alert("server address is invalid");
index fd00e41..4add083 100644 (file)
@@ -26,43 +26,61 @@ Contributors:
 - S-Core Co., Ltd
 */
 
-function adminUserModifyPopupInit() {
-       var index = localStorage.userTableIndex;
-       var userName = document.getElementById("userTableName:"+index).innerHTML;
-       var email = document.getElementById("userTableEmail:"+index).innerHTML;
-       var group = document.getElementById("userTableGroup:"+index).innerHTML;
-
-       document.getElementById('popup:modifyUserName').value = userName;
-       mailElement = document.getElementById('popup:modifyUserEmail');
-       mailElement.value = email;
-       mailElement.setAttribute('disabled', 'disabled');
-
-       queryAllGroup( function(xml) {
-               var groupList = $(xml).find("Data").find("GroupName");
+function adminUserModifyInit() {
+       var userId = localStorage.userId;
+       var userName = $("#adminUser-contents-"+userId+"-name").html();
+       var email = $("#adminUser-contents-"+userId+"-email").html();
+
+       $("#adminUserModify-name").val(userName);
+       $("#adminUserModify-email").val(email);
+
+       queryUserInfoForAdmin(userId, function(xml) {
+               var fullGroupList = $(xml).find("Data").find("GroupInfo").find("Group");
+               var userGroupIdList = $(xml).find("Data").find("GroupInfo").find("GroupIdList").text().split(",");
                
-               $("#popup\\:modifyUserGroup").empty();
-
-               groupList.each( function(){
-                       var groupName = $(this).text();
-                       if( groupName == group ) {
-                               $("#popup\\:modifyUserGroup").append("<option value=\'"+groupName+"\' selected=\"selected\">"+groupName+"</option>");
-                       } else {
-                               $("#popup\\:modifyUserGroup").append("<option value=\'"+groupName+"\'>"+groupName+"</option>");
-                       }
-
-                       $("#popup\\:modifyUserGroup").selectmenu('refresh');
-               });
+               adminUserModifyGenerateGroupSelect(fullGroupList, userGroupIdList); 
        });
 }
 
-function adminUserModifyPopupModify() {
-       var userName = document.getElementById("popup:modifyUserName").value;
-       var email = document.getElementById("popup:modifyUserEmail").value;
-       var groupName = $("#popup\\:modifyUserGroup option:selected").val();
+function adminUserModifyGenerateGroupSelect(fullGroupList, userGroupIdList) {
+       $("#adminUserModify-group").empty();
+       fullGroupList.each(function(){
+               var groupName = $(this).find("Name").text();
+               var groupId = $(this).find("Id").text();
+
+               var input; 
+               if(contains(userGroupIdList, groupId))
+               {
+                       input = '<input type=checkbox id=adminUserModify-group-checkbox-'+groupId+' name=adminUserModify-group-checkbox value='+groupId+' checked=checked />';
+               } else {
+                       input = '<input type=checkbox id=adminUserModify-group-checkbox-'+groupId+' name=adminUserModify-group-checkbox value='+groupId+' />';
+
+               }
+               var label = '<label for=adminUserModify-group-checkbox-'+groupId+'> '+groupName+'<label>';
+               
+               $("#adminUserModify-group").append(input);
+               $("#adminUserModify-group").append(label);
+       });
 
+       $("input[name='adminUserModify-group-checkbox']").checkboxradio();
+}
+
+
+function adminUserModify() {
        var changeInfoList = [];
        var changeInfoItem;
-       changeInfoItem = {"Type":"ModifyUser", "Email":email, "UserName":userName, "GroupName":groupName};
+       var userName = $("#adminUserModify-name").val();
+       var email = $("#adminUserModify-email").val();
+       var selectGroupList = [];
+
+       var selectArray = $("input[name='adminUserModify-group-checkbox']");
+       for(var i = 0; i < selectArray.length; i++) {
+               if (selectArray[i].checked == true) {
+                       selectGroupList.push(selectArray[i].value);
+               }
+       }
+               
+       changeInfoItem = {"Type":"ModifyUser", "Email":email, "UserName":userName, "GroupIdList":selectGroupList.toString()};
        changeInfoList.push(changeInfoItem);
 
        changeUser(changeInfoList, function () {
index 73acf00..c41f888 100644 (file)
@@ -27,17 +27,11 @@ Contributors:
 */
 
 function adminUserInit() {
-       var userTable = document.getElementById("adminUserTable");
-
-       /* remove all table rows */
-       while(userTable.hasChildNodes())
-       {
-               userTable.removeChild(userTable.firstChild);
-       }
+       $("#adminUser-contents").empty();
 
        /* create table header */
        var tableHeader = "<tr><th>User name</th><th>Email</th><th>Group</th><th>Modify</th><th>Delete</th></tr>";
-       $("#adminUserTable").append(tableHeader);
+       $("#adminUser-contents").append(tableHeader);
 
        queryAllUser( function(xml) {
                var userList = $(xml).find("Data").find("User");
@@ -47,36 +41,35 @@ function adminUserInit() {
 }
 
 function adminUserFillTable(userList) {
-       var userTable = document.getElementById("adminUserTable");
-       var index = 2;
+       var userTable = document.getElementById("adminUser-contents");
 
-       userList.each(function(idx){
+       userList.each(function(){
                var row = userTable.insertRow(-1);
                var cell;
                var userName = $(this).find("Name").text();
-               var groupName = $(this).find("GroupName").text();
+               var groupList = $(this).find("GroupName");
                var email = $(this).find("Email").text();
+               var userId = $(this).find("Id").text();
 
-               row.setAttribute('id', 'userTable:'+index);
                cell = row.insertCell(-1);
-               cell.setAttribute('id',"userTableName:"+index);
+               cell.setAttribute('id',"adminUser-contents-"+userId+"-name");
                cell.innerHTML = userName;
 
                cell = row.insertCell(-1);
-               cell.setAttribute('id',"userTableEmail:"+index);
+               cell.setAttribute('id',"adminUser-contents-"+userId+"-email");
                cell.innerHTML = email;
 
                cell = row.insertCell(-1);
-               cell.setAttribute('id',"userTableGroup:"+index);
-               cell.innerHTML = groupName;
+               div = adminUserGenerateGroupListCell(groupList);
+               cell.appendChild(div);
 
                cell = row.insertCell(-1);
                var button = document.createElement('a');
-               button.setAttribute('href','#adminUserModifyPopup');
+               button.setAttribute('href','#adminUserModify');
                button.setAttribute('data-role','button');
                button.setAttribute('data-rel','dialog');
-               button.setAttribute('class','adminUserTableButton');
-               button.setAttribute('onClick','adminUserModifyPopupSetup(\"'+index+'\")');
+               button.setAttribute('class','adminUser-contentsButton');
+               button.setAttribute('onClick','adminUserModifySetup('+userId+')');
                button.innerHTML = " "
                cell.appendChild(button);
 
@@ -84,22 +77,32 @@ function adminUserFillTable(userList) {
                var button = document.createElement('input');
                button.setAttribute('type','button');
                button.setAttribute('name',email);
-               button.setAttribute('class','adminUserTableButton');
-               button.setAttribute('onClick','adminUserRemoveUser('+index+')');
+               button.setAttribute('class','adminUser-contentsButton');
+               button.setAttribute('onClick','adminUserRemoveUser('+userId+')');
                cell.appendChild(button);
-
-               index = index + 1;
        });
 
-       $(".adminUserTableButton").button();
+       $(".adminUser-groupList").collapsible();
+       $(".adminUser-contentsButton").button();
+}
+
+function adminUserGenerateGroupListCell(groupList) {
+       var div = document.createElement('div');
+
+       groupList.each(function(){
+               var item = document.createElement('li');
+               item.innerHTML = $(this).text();
+               div.appendChild(item);
+       });
+       return div;
 }
 
-function adminUserModifyPopupSetup(index) {
-       localStorage.userTableIndex = index;
+function adminUserModifySetup(id) {
+       localStorage.userId = id;
 }
 
-function adminUserRemoveUser(index) {
-       var email = document.getElementById("userTableEmail:"+index).innerHTML;
+function adminUserRemoveUser(userId) {
+       var email = $("#adminUser-contents-"+userId+"-email").val();
 
        var r=confirm("User ["+email+"] is removed!!!");
        if (r==false)
index c2efd25..f204833 100644 (file)
@@ -27,17 +27,17 @@ Contributors:
 */
 
 function buildInit() {
-       if( $("#select-distribution").children().length == 0 ) {
+       if( $("#build-distribution-select").children().length == 0 ) {
                queryDistribution( function(xml) {
                        $(xml).find("Data").find("DistributionName").each(function(){
                                var name = $(this).text();
                
-                               $("#select-distribution").append("<option value=\'"+name+"\'>"+name+"</option>");
+                               $("#build-distribution-select").append("<option value=\'"+name+"\'>"+name+"</option>");
                        });
                
                        /* default distribution selection */
-                       $("#select-distribution option:eq(0)").attr("selected", "selected");
-                       $("#select-distribution").selectmenu('refresh');
+                       $("#build-distribution-select option:eq(0)").attr("selected", "selected");
+                       $("#build-distribution-select").selectmenu('refresh');
                
                        // query Project list
                        buildQueryProjectList();
@@ -61,10 +61,12 @@ function buildInit() {
 }
 
 function buildQueryProjectList() {
-       var distName = $("#select-distribution option:selected").val();
+       var distName = $("#build-distribution-select option:selected").val();
 
        queryProjectsInDistribution( distName, function(xml) {
-               buildInitTable();
+               $("#build-git-table").empty();
+               $("#build-binary-table").empty();
+               
                var xmlBody = $(xml).find("Data");
                buildAddTableRow( xmlBody.find("BuildServerInfo").find("supportedOs"),
                                         xmlBody.find("Project"),
@@ -75,7 +77,7 @@ function buildQueryProjectList() {
 }
 
 function buildQueryRunningProjectList() {
-       var distName = $("#select-distribution option:selected").val();
+       var distName = $("#build-distribution-select option:selected").val();
 
        queryRunningProjectsInfoInDistribution( distName, function(xml) {
                var running_project = $(xml).find("RunProjectInfo");
@@ -115,30 +117,12 @@ function contains(a, obj) {
        return false; 
 }
 
-function buildInitTable() {
-       /* project table */
-       var projectTable = document.getElementById("projectTable");
-       
-       /* binary project table */
-       var binaryProjectTable = document.getElementById("binaryProjectTable");
-       
-       /* remove all table rows */
-       while(projectTable.hasChildNodes())
-       {
-               projectTable.removeChild(projectTable.firstChild);
-       }
-       while(binaryProjectTable.hasChildNodes())
-       {
-               binaryProjectTable.removeChild(binaryProjectTable.firstChild);
-       }
-}
-
 function buildAddTableRow(supportedOs, projectList, otherProjectList) {
        // Table header
        var idx = 0;
        var tableHeader = "";
        var osArray = new Array();
-       var projectTable = document.getElementById("projectTable");
+       var projectTable = document.getElementById("build-git-table");
 
        // Project table header
        tableHeader = "<tr><th>Project</th>";
@@ -151,7 +135,7 @@ function buildAddTableRow(supportedOs, projectList, otherProjectList) {
        });
 
        tableHeader = tableHeader + "<th>ALL</th></tr>";
-       $("#projectTable").append(tableHeader);
+       $("#build-git-table").append(tableHeader);
 
        // table row - projectList
        var index = 2;
@@ -232,7 +216,7 @@ function buildAddTableRow(supportedOs, projectList, otherProjectList) {
 }
 
 function buildAddBinaryTableRow(binaryProjectList, otherProjectList) {
-       var binaryProjectTable = document.getElementById("binaryProjectTable");
+       var binaryProjectTable = document.getElementById("build-binary-table");
        var row = binaryProjectTable.insertRow(-1);
        var thCell = document.createElement('th');
        thCell.innerHTML = "Project";
@@ -253,7 +237,7 @@ function buildAddBinaryTableRow(binaryProjectList, otherProjectList) {
                row += '<td bgcolor="#dcddc0" style="text-align:left"><a href="upload.html" onClick="buildUploadBinaryName(\'' +name+'\')" class="binary_project_button" data-role="button" data-ajax="false" data-mini="true">REGISTER</a>';
                row += '</tr>'
                
-               $("#binaryProjectTable tr:last").after(row);
+               $("#build-binary-table tr:last").after(row);
        });
 
        otherProjectList.each(function(){
@@ -289,8 +273,8 @@ function buildAddBinaryTableRow(binaryProjectList, otherProjectList) {
        });
 }
 
-function buildBuildProject(type) {
-       var distName = $("#select-distribution option:selected").val();
+function buildBuildProject() {
+       var distName = $("#build-distribution-select option:selected").val();
        var buildProjectList = [];
 
        //var node_list = document.getElementsByTagName('input');
@@ -303,7 +287,7 @@ function buildBuildProject(type) {
                                if (node.getAttribute('name') != "all-checkbox") {
                                        var prjName = node.id.split(":")[1];
                                        var osName = node.id.split(":")[2];
-                                       var buildData = { "distribution":distName, "buildType":type, "projectName" : prjName, "os" : osName };
+                                       var buildData = { "distribution":distName, "projectName" : prjName, "os" : osName };
                                        buildProjectList.push(buildData);
                                }
                        }
@@ -316,7 +300,7 @@ function buildBuildProject(type) {
 }
 
 function buildUploadBinaryName(project_name) {
-       localStorage.distibutionName = $("#select-distribution option:selected").val();
+       localStorage.distibutionName = $("#build-distribution-select option:selected").val();
        localStorage.uploadBinaryProjectName = project_name;
 }
 
@@ -338,7 +322,7 @@ function buildBatchFilePathSelector() {
 }
 
 function buildClear() {
-       $("#select-distribution").empty();
-       
-       buildInitTable();
+       $("#build-distribution-select").empty();
+       $("#build-git-table").empty();
+       $("#build-binary-table").empty();
 }
index 9802a71..4cbee8b 100644 (file)
@@ -133,6 +133,11 @@ function queryAllUser(successFunction) {
        getInfoFromServer(url, successFunction);
 }
 
+function queryUserInfoForAdmin(email, successFunction) {
+       var url = 'admin_user/queryUserInfo/' + email;
+       getInfoFromServer(url, successFunction);
+}
+
 function changeUser(changeInfoList, successFunction) {
        var url = 'admin_user/modifyUser';
        postForServer(url, changeInfoList, successFunction);
@@ -241,11 +246,6 @@ function modifyProject(changeInfoList, successFunction) {
 }
 
 // controller : admin_distribution
-function queryAllDistribution(successFunction) {
-       var url = 'admin_distribution/queryAllDistribution';
-       getInfoFromServer(url, successFunction);
-}
-
 function queryDistributionInfo(distName, successFunction) {
        var url = 'admin_distribution/queryDistributionInfo/' + distName;
        getInfoFromServer(url, successFunction);
index cde6c98..40c2047 100644 (file)
@@ -32,16 +32,16 @@ var request_list = new Array();
 var request_idx = 0;
 
 $(function() {
-       $('#jobSearchSelect input[type="radio"]').checkboxradio().click(function() {
+       $('#jobs-type-select input[type="radio"]').checkboxradio().click(function() {
                jobsSearchSelected();
        });
 
-       $('#jobStatusSelect input[type="radio"]').checkboxradio().click(function() {
+       $('#jobs-status-select input[type="radio"]').checkboxradio().click(function() {
                jobsStatusSelected();
        });
 
-       $("#jobSearchInputText").on("input", function(e) {
-               var selectedValue = $('#jobSearchSelect').find("input[type='radio']:checked").val();
+       $("#jobs-search-input-text").on("input", function(e) {
+               var selectedValue = $('#jobs-type-select').find("input[type='radio']:checked").val();
                switch(selectedValue) {
                        case "GROUP":
                        case "PROJECT":
@@ -52,13 +52,13 @@ $(function() {
                }
        });
 
-       $('#jobSearchInputText').keypress(function() {
+       $('#jobs-search-input-text').keypress(function() {
                if(event.keyCode == '13') {
                        searchJobInput();
                }
        });
 
-       $('#jobSearchDate').keypress(function() {
+       $('#jobs-search-date-value').keypress(function() {
                if(event.keyCode == '13') {
                        searchJobDate();
                }
@@ -72,7 +72,7 @@ function jobsInit() {
 function jobsSearchSelected() {
        clearSuggestJobSearchList();
 
-       var selectedValue = $('#jobSearchSelect').find("input[type='radio']:checked").val();
+       var selectedValue = $('#jobs-type-select').find("input[type='radio']:checked").val();
        switch(selectedValue) {
                case "ALL":
                        selectJobAll();
@@ -99,7 +99,7 @@ function jobsSearchSelected() {
 }
 
 function jobsStatusSelected() {
-       var selectedValue = $('#jobStatusSelect').find("input[type='radio']:checked").val();
+       var selectedValue = $('#jobs-status-select').find("input[type='radio']:checked").val();
        switch(selectedValue) {
                case "ALL":
                        jobsSearchSelected();
@@ -120,22 +120,22 @@ function jobsStatusSelected() {
 }
 
 function searchJobInput() {
-       var searchText = $("#jobSearchInputText").val()
+       var searchText = $("#jobs-search-input-text").val()
        if(searchText.length > 0) {
                searchJob(searchText);
        }
 }
 
 function searchJobDate() {
-       var searchText = $("#jobSearchDate").val()
+       var searchText = $("#jobs-search-date-value").val()
        if(searchText.length > 0) {
                searchJob(searchText);
        }
 }
 
 function searchJob(searchText) {
-       var distribution = $("#jobSelectDistribution option:selected").val(); 
-       var selectedValue = $('#jobSearchSelect').find("input[type='radio']:checked").val();
+       var distribution = $("#jobs-distribution-select option:selected").val(); 
+       var selectedValue = $('#jobs-type-select').find("input[type='radio']:checked").val();
        switch(selectedValue) {
                case "ALL":
                        alert("Can't search on ALL!!");
@@ -162,37 +162,37 @@ function searchJob(searchText) {
 }
 
 function selectJobAll() {
-       var distribution = $("#jobSelectDistribution option:selected").val(); 
-       $("#jobDivSearchDate").hide();
-       $("#jobDivSearchInput").hide();
+       var distribution = $("#jobs-distribution-select option:selected").val(); 
+       $("#jobs-search-date").hide();
+       $("#jobs-search-input").hide();
        queryJobListAll(distribution);
 }
 
 function selectJobId() {
-       $("#jobDivSearchDate").hide();
-       $("#jobDivSearchInput").show();
-       $("#jobSearchInputText").val("").textinput();
+       $("#jobs-search-date").hide();
+       $("#jobs-search-input").show();
+       $("#jobs-search-input-text").val("").textinput();
        clearJobList();
 }
 
 function selectUser() {
-       var distribution = $("#jobSelectDistribution option:selected").val(); 
-       $("#jobDivSearchDate").hide();
-       $("#jobDivSearchInput").show();
+       var distribution = $("#jobs-distribution-select option:selected").val(); 
+       $("#jobs-search-date").hide();
+       $("#jobs-search-input").show();
 
        var name = sessionStorage.sessionInfoName;
-       $("#jobSearchInputText").val(name).textinput();
+       $("#jobs-search-input-text").val(name).textinput();
 
        queryJobListUserName(distribution, name);
 }
 
 function selectGroup() {
-       var distribution = $("#jobSelectDistribution option:selected").val(); 
-       $("#jobDivSearchDate").hide();
-       $("#jobDivSearchInput").show();
+       var distribution = $("#jobs-distribution-select option:selected").val(); 
+       $("#jobs-search-date").hide();
+       $("#jobs-search-input").show();
 
        var group = sessionStorage.sessionInfoGroup;
-       $("#jobSearchInputText").val(group).textinput();
+       $("#jobs-search-input-text").val(group).textinput();
 
        jobsQueryGroupList("JOBS");
 
@@ -200,18 +200,18 @@ function selectGroup() {
 }
 
 function selectProject() {
-       var distribution = $("#jobSelectDistribution option:selected").val(); 
-       $("#jobDivSearchDate").hide();
-       $("#jobDivSearchInput").show();
+       var distribution = $("#jobs-distribution-select option:selected").val(); 
+       $("#jobs-search-date").hide();
+       $("#jobs-search-input").show();
        clearJobList();
 
-       $("#jobSearchInputText").val("").textinput();
+       $("#jobs-search-input-text").val("").textinput();
 
        jobsQueryProjectsList(distribution);
 }
 
 function selectDate() {
-       var distribution = $("#jobSelectDistribution option:selected").val(); 
+       var distribution = $("#jobs-distribution-select option:selected").val(); 
        var today = new Date();
        var yyyy = today.getFullYear();
        var mm = today.getMonth()+1; //January is 0!
@@ -224,16 +224,16 @@ function selectDate() {
        } 
 
        var date = yyyy+'-'+mm+'-'+dd;
-       $('#jobSearchDate').val(date);
+       $('#jobs-search-date-value').val(date);
 
-       $("#jobDivSearchInput").hide();
-       $("#jobDivSearchDate").show();
+       $("#jobs-search-input").hide();
+       $("#jobs-search-date").show();
        clearJobList();
        queryJobListDate(distribution, date);
 }
 
 function clearJobList() {
-       $("#jobList").empty();
+       $("#jobs-job-list").empty();
 }
 
 function queryJobListAll(distribution) {
@@ -263,7 +263,7 @@ function queryJobListDate(distribution, date) {
 function queryJobListByButton(condition, param, distribution, jobId) {
        clearJobList();
        clearRequestList();
-       var selectedStatus= $('#jobStatusSelect').find("input[type='radio']:checked").val();
+       var selectedStatus= $('#jobs-status-select').find("input[type='radio']:checked").val();
        var request = queryJobList("jobs/list", condition, param, distribution, selectedStatus, jobId);
        if(request != undefined) {
                request.done(function() {
@@ -274,21 +274,20 @@ function queryJobListByButton(condition, param, distribution, jobId) {
 }
 
 function jobQueryDistribution() {
-       if( $("#jobSelectDistribution").children().length == 0 ) {
+       if( $("#jobs-distribution-select").children().length == 0 ) {
                queryDistribution( function(xml) {
-                       // remove old select options
-                       $("#jobSelectDistribution").empty();
-                       $("#jobSelectDistribution").append("<option value='ALL'>ALL</option>");
+                       // append "ALL" distribution
+                       $("#jobs-distribution-select").append("<option value='ALL'>ALL</option>");
                
                        $(xml).find("Data").find("DistributionName").each(function(){
                                var name = $(this).text();
                
-                               $("#jobSelectDistribution").append("<option value=\'"+name+"\'>"+name+"</option>");
+                               $("#jobs-distribution-select").append("<option value=\'"+name+"\'>"+name+"</option>");
                        });
                
                        /* default distribution selection */
-                       $("#jobSelectDistribution option:eq(0)").attr("selected", "selected");
-                       $("#jobSelectDistribution").selectmenu('refresh');
+                       $("#jobs-distribution-select option:eq(0)").attr("selected", "selected");
+                       $("#jobs-distribution-select").selectmenu('refresh');
     
                        selectJobAll();
                });
@@ -313,7 +312,7 @@ function queryJobList(requestUrl, condition, param, queryDistribution, selectedS
                        var li = generateHtmlJobList($(this));
 
                        lastJobId = id;
-                       $("#jobList").append(li).listview('refresh');
+                       $("#jobs-job-list").append(li).listview('refresh');
 
                        $("#jobs-li-link-"+id).popupWindow({ 
                                height:900, 
@@ -328,20 +327,20 @@ function queryJobList(requestUrl, condition, param, queryDistribution, selectedS
                {
                        var moreJobListUrl = 'queryJobList("'+requestUrl+'", "'+condition+'", "'+param+'", "'+queryDistribution+'", "'+selectedStatus+'", "'+lastJobId+'")';
                        console.log(moreJobListUrl);
-                       $('#moreJobList').attr("onClick", moreJobListUrl);
-                       $('#moreJobList').removeClass('ui-disabled');
+                       $('#jobs-job-more').attr("onClick", moreJobListUrl);
+                       $('#jobs-job-more').removeClass('ui-disabled');
                }
                else
                {
-                       $('#moreJobList').addClass('ui-disabled');
+                       $('#jobs-job-more').addClass('ui-disabled');
                }
-               $('#moreJobList').button('refresh');
+               $('#jobs-job-more').button('refresh');
 
        }, errorProcess); 
 }
 
 function jobUpdateList(condition, param, distribution, selectedStatus) {
-       var latest_job_id= $("#jobList li").first().attr("title");
+       var latest_job_id= $("#jobs-job-list li").first().attr("title");
        if(latest_job_id == undefined) {
                latest_job_id = 0;
        }
@@ -349,7 +348,7 @@ function jobUpdateList(condition, param, distribution, selectedStatus) {
        item = {"Condition":condition, "Param":param, "Distribution":distribution, "Status":selectedStatus, "LatestId":latest_job_id, "WorkingJobId":working_job_list};
 
        var update_ajax = updateList(item, function(xml) {
-               var firstLi= $("#jobList li").first();
+               var firstLi= $("#jobs-job-list li").first();
 
                // Add new job list
                $(xml).find("JobList").find("Job").each(function(){
@@ -357,7 +356,7 @@ function jobUpdateList(condition, param, distribution, selectedStatus) {
                        var li = generateHtmlJobList($(this));
 
                        $(li).insertBefore(firstLi);
-                       $("#jobList").listview('refresh');
+                       $("#jobs-job-list").listview('refresh');
                        $("#jobs-li-link-"+id).popupWindow({ 
                                height:900, 
                                width:800, 
@@ -419,7 +418,7 @@ function jobUpdateList(condition, param, distribution, selectedStatus) {
                                var li = generateHtmlJobList($(this));
 
                                $(li).insertBefore(next_parent_job_li);
-                               $("#jobList").listview('refresh');
+                               $("#jobs-job-list").listview('refresh');
                                $("#jobs-li-link-"+job_id).popupWindow({ 
                                        height:900, 
                                        width:800, 
@@ -448,7 +447,7 @@ function jobUpdateList(condition, param, distribution, selectedStatus) {
 }
 
 function clearSuggestJobSearchList() {
-       $("#jobSearchList").empty();
+       $("#jobs-search-list").empty();
 }
 
 function jobsQueryGroupList() {
@@ -465,7 +464,7 @@ function jobsQueryGroupList() {
 }
 
 function suggestJobSearchList(inputText) {
-       var sugList = $("#jobSearchList");
+       var sugList = $("#jobs-search-list");
 
        if(inputText.length < 1) {
                sugList.html("");
@@ -487,8 +486,8 @@ function suggestJobSearchList(inputText) {
 }
 
 function jobSuggestListClick(suggestText) {
-       $("#jobSearchInputText").val(suggestText);
-       $("#jobSearchList").empty();
+       $("#jobs-search-input-text").val(suggestText);
+       $("#jobs-search-list").empty();
 
        var startIndex = suggestText.search(/\[/);
        var endIndex = suggestText.search('\]');
@@ -504,7 +503,7 @@ function jobSuggestListClick(suggestText) {
 }
 
 function jobsQueryProjectsList() {
-       var distribution = $("#jobSelectDistribution option:selected").val(); 
+       var distribution = $("#jobs-distribution-select option:selected").val(); 
        suggestion_list = [];
 
        if(distribution == "ALL") {
@@ -532,7 +531,7 @@ function jobsQueryProjectsList() {
 }
 
 function jobsClear() {
-       $("#jobSelectDistribution").empty();
+       $("#jobs-distribution-select").empty();
        clearJobList();
 }
 
@@ -602,7 +601,7 @@ function generateHtmlJobList(xml) {
                        + '<li id="jobs-li-'+id+'" class="jobs-list-data" title="'+id+'">'
                        + '<a href=log.html?jobid='+id+' id="jobs-li-link-'+id+'" class="logWindow" data-ajax="false">'
                        + '<p>USER : <strong>' +userName+ '</strong></p>'
-                       + '<p id="jobs-li-time-'+id+'">TIME: <strong>' +startTime+ ' ~ '+endTime+ '</strong></p>';
+                       + '<p id="jobs-li-time-'+id+'">TIME: <strong>' +startTime+ ' ~ '+endTime+ '</strong></p>'
                        + '<p id="jobs-li-attr-'+id+'" hidden="hidden">'+jobAttribute+'</p>';
                        
                        li = li + '<p id="jobs-li-status-'+id+'" class="ui-li-aside jobs-li-status" title="'+id+'"><strong><font color="'+font_color+'">'+jobStatus+'</strong></p>';
@@ -620,7 +619,7 @@ function generateHtmlJobList(xml) {
                        + '<p>ID : <strong>' +id+ '</strong></p>'
                        + '<p>TYPE : <strong>' +jobType+ '</strong></p>'
                        + '<p>OS : <strong>' +os+ '</strong></p>'
-                       + '<p id="jobs-li-time-'+id+'">TIME: <strong>' +startTime+ ' ~ '+endTime+ '</strong></p>';
+                       + '<p id="jobs-li-time-'+id+'">TIME: <strong>' +startTime+ ' ~ '+endTime+ '</strong></p>'
                        + '<p id="jobs-li-attr-'+id+'" hidden="hidden">'+jobAttribute+'</p>';
                        
                        li = li + '<p id="jobs-li-status-'+id+'" class="ui-li-aside jobs-list-status" title="'+id+'"><strong><font color="'+font_color+'">'+jobStatus+'</strong></p>';
@@ -636,7 +635,7 @@ function generateHtmlJobList(xml) {
 
 function searchWorkingList() {
        working_job_array = new Array();
-       $("#jobList .jobs-list-data").each(function(index) {
+       $("#jobs-job-list .jobs-list-data").each(function(index) {
                var job_attr = $(this).find(".jobs-li-hidden-attr").text();
                var job_id = $(this).find(".jobs-li-hidden-id").text();
                var job_status= $(this).find(".jobs-li-status").text();
index 607b68c..be17b7a 100644 (file)
@@ -106,34 +106,22 @@ function queryLog()
 
                /* Insert data */
                $(xml).find("Data").find("LogData").each(function() {
-                       var insertTable = document.getElementById("logTable");
-                       var insertRow = document.createElement("tr");
-                       var insertCel1 = document.createElement("td");
-                       var insertCel2 = document.createElement("td");
-       
                        var line_number = $(this).attr("Line");
                        var line_data =  $(this).text();
-       
-                       insertCel1.width = '30';
-                       insertCel1.style.textAlign = 'right';
-                       insertCel1.style.cellpacing = '5';
-                       insertCel1.innerHTML = line_number;
+
+                       var row = '<tr><td width="30" style="text-align: right;">' + line_number + '</td>'
+                               + '<td style="text-align: left;">' + line_data + '</td></tr>';
+                       $("#log-contents").append(row);
                        last_line = line_number;
-       
-                       insertCel2.style.textAlign = 'left';
-                       insertCel2.innerHTML = line_data;
-       
-                       insertRow.appendChild(insertCel1);
-                       insertRow.appendChild(insertCel2);
-       
-                       insertTable.appendChild(insertRow);
-       
                });
 
                if(working_status == 1){
                        console.log("scroll");
                        scrollToBottom();
                }
+               console.log("next_line :" +next_line);
+               console.log("conti :" +conti);
+               console.log("working_status :"+working_status);
        
                autoQueryLog(conti, working_status);
        });
@@ -143,8 +131,7 @@ function autoQueryLog(conti, working_status) {
        if(conti && stop) {
                queryLog();
        }
-
-       if(working_status == 1 && stop) {
+       else if(working_status == 1 && stop) {
                console.log("status is working. try request");
                setTimeout(function(){queryLog()}, 3000);
        }
index bb60f7f..245617c 100644 (file)
@@ -66,10 +66,10 @@ $( document ).bind( "pagechange", function( event, data ){
                        generateNavigationBar(id);
                        break;
                case "signup":
-                       clearFormData('signupForm');
+                       clearFormData('signup-form');
                        break;
                case "login":
-                       clearFormData('loginForm');
+                       clearFormData('login-form');
                        break;
                case "projects":
                        generateNavigationBar(id);
@@ -106,31 +106,31 @@ $( document ).bind( "pagechange", function( event, data ){
                        generateNavigationBar(id);
                        adminDistributionInit();
                        break;
-               case "modifyDistribution":
+               case "adminDistributionModify":
                        adminDistributionModifyPopupInit();
                        break;
-               case "adminUserModifyPopup":
-                       adminUserModifyPopupInit();
+               case "adminUserModify":
+                       adminUserModifyInit();
                        break;
-               case "modifyBinaryProject":
+               case "adminProjectModifyBinary":
                        adminProjectModifyBinaryProjectInit();
                        break;
-               case "modifyGitProject":
+               case "adminProjectModifyGit":
                        adminProjectModifyGitProjectInit();
                        break;
-               case "adminGroupAddPopup":
+               case "adminGroupAdd":
                        adminGroupAddInit();
                        break;
-               case "adminGroupModifyPopup":
+               case "adminGroupModify":
                        adminGroupModifyInit();
                        break;
                case "adminServerModifyRemoteBuildServer":
                        adminServerModifyRemoteBuildServerInit();
                        break;
-               case "addGitProject":
+               case "adminProjectAddGit":
                        adminProjectAddGitInit();
                        break;
-               case "addBinaryProject":
+               case "adminProjectAddBinary":
                        adminProjectAddBinaryInit();
                        break;
                case "adminServerAddSupportedOs":
index 2288665..e982f67 100644 (file)
@@ -27,43 +27,36 @@ Contributors:
 */
 
 function projectsInit() {
-       if( $("#projects-select-distribution").children().length == 0 ) {
+       if( $("#projects-distribution-select").children().length == 0 ) {
                queryDistribution( function(xml) {
-                       // remove old select options
-                       $("#projects-select-distribution").empty();
-               
                        $(xml).find("Data").find("DistributionName").each(function(){
                                var name = $(this).text();
                
-                               $("#projects-select-distribution").append("<option value=\'"+name+"\'>"+name+"</option>");
+                               $("#projects-distribution-select").append("<option value=\'"+name+"\'>"+name+"</option>");
                        });
                
                        /* default distribution selection */
-                       $("#projects-select-distribution option:eq(0)").attr("selected", "selected");
-                       $("#projects-select-distribution").selectmenu('refresh');
+                       $("#projects-distribution-select option:eq(0)").attr("selected", "selected");
+                       $("#projects-distribution-select").selectmenu('refresh');
                
                        projectsQueryProjectListType("MY"); 
-                       $('#projectsSearchSelect input[type="radio"]').attr("checked",false).checkboxradio("refresh");
-                       $('#projectsSearchSelect input[type="radio"]:first').attr("checked",true).checkboxradio("refresh");
+                       $('#projects-type-select input[type="radio"]').attr("checked",false).checkboxradio("refresh");
+                       $('#projects-type-select input[type="radio"]:first').attr("checked",true).checkboxradio("refresh");
                });
        } else {
                projectsQueryProjectListType("MY"); 
-               $('#projectsSearchSelect input[type="radio"]').attr("checked",false).checkboxradio("refresh");
-               $('#projectsSearchSelect input[type="radio"]:first').attr("checked",true).checkboxradio("refresh");
+               $('#projects-type-select input[type="radio"]').attr("checked",false).checkboxradio("refresh");
+               $('#projects-type-select input[type="radio"]:first').attr("checked",true).checkboxradio("refresh");
        }
 }
 
 function projectsQueryProjectListType(queryType) {
-       var distName = $("#projects-select-distribution option:selected").val();
+       var distName = $("#projects-distribution-select option:selected").val();
 
        queryProjectsInfoInDistribution( distName, function(xml) {
-               var projectList = document.getElementById("projects-project-list");
+               $("#projects-project-list").empty();
 
-               /* remove all list */
-               while(projectList.hasChildNodes())
-               {
-                       projectList.removeChild(projectList.firstChild);
-               }
+               var projectList = document.getElementById("projects-project-list");
 
                $(xml).find("Data").find("ProjectList").find("Project").each(function(){
                        switch(queryType) {
@@ -166,13 +159,7 @@ function projectsAppendProjectList( project, projectList ) {
 }
 
 function projectsClear() {
-       $("#projects-select-distribution").empty();
-
-       var projectList = document.getElementById("projects-project-list");
-       /* remove all list */
-       while(projectList.hasChildNodes())
-       {
-               projectList.removeChild(projectList.firstChild);
-       }
+       $("#projects-distribution-select").empty();
+       $("#projects-project-list").empty();
 }
 
index 12582dc..89c1e2b 100644 (file)
@@ -27,7 +27,7 @@ Contributors:
 */
 
 $(function() {
-       $('#login-password').keypress(function() {
+       $('#login-form-password').keydown(function() {
                if(event.keyCode == '13') {
                        sessionLogin();
                }
@@ -61,7 +61,7 @@ function checkSessionInfo(){
        if(email)
        {
                sessionHtml = '<div data-role="controlgroup" style="text-align: left; font-size: 12px" data-type="horizontal" class="ui-btn-right ui-btn-corner-all">';
-               sessionHtml += '<p data-direction="reverse" ><a href="#userModifyPopup" onClick="userQueryUserInfo()" data-rel="dialog">'+name+'</a> | ';
+               sessionHtml += '<p data-direction="reverse" ><a href="#userModify" onClick="userQueryUserInfo()" data-rel="dialog">'+name+'</a> | ';
                sessionHtml += '<a href=# onClick="logout()" data-direction="reverse">Log out</a></p></div>';
        }
        else
@@ -89,8 +89,8 @@ function expireSession(){
 function sessionLogin() {
        var infoList = [];
        var infoItem;
-       var email = $('#login-email').val();
-       var password = $('#login-password').val();
+       var email = $('#login-form-email').val();
+       var password = $('#login-form-password').val();
 
        if(email == ""){
                alert("Email is invalid");
@@ -127,20 +127,3 @@ function sessionLogin() {
                        }
        });
 } 
-
-function signupQueryGroupList() {
-       queryAllGroup( function(xml) {
-               $("#applyGroupRadio").children().remove();
-
-               var newHtml ='<fieldset data-role="controlgroup" data-mini="true"><legend>Apply for group :</legend>';
-               $(xml).find("Data").find("GroupName").each(function(){
-                       var name = $(this).text();
-                       newHtml += '<input type="radio" name="group" id="group-'+name+'" value="'+name+'" />';
-                       newHtml += '<label for="group-'+name+'">'+name+'</label>';
-               });
-               console.log(newHtml);
-               $("#applyGroupRadio").append(newHtml).trigger('create');
-               $("#applyGroupRadio div[role='heading']").attr("style","text-align: left; font-size: 12px");
-       }, errorProcess);
-}
-
index 70d8689..1e5efb8 100644 (file)
@@ -37,10 +37,10 @@ $(function() {
 function userSignUp() {
        var infoList = [];
        var infoItem;
-       var email = $('#user-email').val();
-       var name = $('#user-name').val();
-       var password = $('#user-password').val();
-       var password_confirm = $('#user-password-confirmation').val();
+       var email = $('#signup-form-email').val();
+       var name = $('#signup-form-name').val();
+       var password = $('#signup-form-password').val();
+       var password_confirm = $('#signup-form-password-confirmation').val();
        var emailCheckReg = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/
 
        if(email == "" || !emailCheckReg.test(email)){
@@ -95,18 +95,18 @@ function userQueryUserInfo() {
                var email = $(xml).find("Data").find("User").find("Email").text();
                var name = $(xml).find("Data").find("User").find("Name").text();
 
-               $("#popup-user-info-email").val(email).textinput();
-               $("#popup-user-info-name").val(name).textinput();
+               $("#userModify-email").val(email).textinput();
+               $("#userModify-name").val(name).textinput();
        });
 }
 
 function userModifyUserInfo() {
        var changeInfoList = [];
        var changeInfoItem;
-       var email = $('#popup-user-info-email').val();
-       var name = $('#popup-user-info-name').val();
-       var password = $('#popup-user-info-password').val();
-       var password_confirm = $('#popup-user-info-password-confirm').val();
+       var email = $('#userModify-email').val();
+       var name = $('#userModify-name').val();
+       var password = $('#userModify-password').val();
+       var password_confirm = $('#userModify-password-confirm').val();
 
        if(email == ""){
                alert("Email is invalid");
index ec4c4c4..d1992c6 100644 (file)
@@ -29,7 +29,7 @@ Contributors:
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 <html>
 <head>
-       <script src="javascripts/jquery-1.7.1.js"></script>
+       <script src="javascripts/jquery-1.7.1.min.js"></script>
 
        <script src="javascripts/dibs-api.js"></script>
        <script src="javascripts/session.js"></script>
@@ -103,7 +103,7 @@ Contributors:
                </div>
        </div>
        <div id="body">
-               <table id="logTable" style="width: 100%; border: #000000 1px solid; font-size:9pt">
+               <table id="log-contents" style="width: 100%; border: #000000 1px solid; font-size:9pt">
                </table> 
        <div id="footer" data-role="controlgroup" data-mini="true" data-type="horizontal">
                <input type="button" value="More" onClick=moreLog() / > 
diff --git a/dibs-web/public/stylesheets/style.css b/dibs-web/public/stylesheets/style.css
new file mode 100644 (file)
index 0000000..35d14f5
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ style.css
+
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+
+Contact:
+Sungmin Kim <dev.sungmin.kim@samsung.com>
+Taejun Ha <taejun.ha@samsung.com>
+Jiil Hyoun <jiil.hyoun@samsung.com>
+Donghyuk Yang <donghyuk.yang@samsung.com>
+DongHee Yang <donghee.yang@samsung.com>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Contributors:
+- S-Core Co., Ltd
+*/
+
+body {
+       
+}
+
+div.content-primary {
+       width: 65%;
+}
+
+div.content-secondary {
+       width: 25%;
+}
+
+#jobs-search-input .ui-input-search {
+    width: 80%;
+    display: inline-block;
+}
+
+#jobs-search-date .ui-input-text {
+    width: 80%;
+    display: inline-block;
+}
+
+table.imagetable {                                                                         
+    font-family: verdana,arial,sans-serif;                                                 
+    font-size:11px;                                                                        
+    color:#333333;                                                                         
+    border-width: 1px;                                                                     
+    border-color: #999999;                                                                 
+    border-collapse: collapse;                                                             
+    text-align : center;                                                                   
+}                                                                                          
+table.imagetable th {                                                                      
+    background:#b5cfd2;                                                                    
+    border-width: 1px;                                                                     
+    padding: 8px;                                                                          
+    border-style: solid;                                                                   
+    border-color: #999999;                                                                 
+    text-align: center;                                                                    
+}                                                                                          
+table.imagetable td {                                                                      
+    background:#dcddc0;                                                                    
+    border-width: 1px;                                                                     
+    padding: 8px;                                                                          
+    border-style: solid;                                                                   
+    border-color: #999999;                                                                 
+    max-width: 500px;                                                                      
+}     
+
+table.build-project-table {
+    font-family: verdana,arial,sans-serif;
+    font-size:11px;
+    border-width: 1px;
+    border-color: #999999;
+    border-collapse: collapse;
+}
+table.build-project-table th {
+    background:#b5cfd2;
+    border-width: 1px;
+    padding: 8px;
+    border-style: solid;
+    border-color: #999999;
+    text-align: center;
+}
+table.build-project-table td {
+    border-width: 1px;
+    padding: 8px;
+    border-style: solid;
+    border-color: #999999;
+}
+
+.alignleft {
+       float: left;
+}
+
+.alignright {
+       float: right;
+}
+
+#signup-form * {
+       text-align: left; 
+       font-size: 12px;
+}
+
+#login-form * {
+       text-align: left; 
+       font-size: 12px;
+}
+
index fb2ffb0..3d56aeb 100644 (file)
@@ -27,7 +27,7 @@ Contributors:
 -->
 
 <head>
-       <script type="text/javascript" src="javascripts/jquery-1.7.1.js"></script>
+       <script type="text/javascript" src="javascripts/jquery-1.7.1.min.js"></script>
 </head>
 <body>
        <form enctype="multipart/form-data">
index 8264341..4e6e1fd 100755 (executable)
@@ -22,5 +22,6 @@ install()
        cp -rf $SRCDIR/src $BIN_DIR/
        cp -rf $SRCDIR/dibs-web $BIN_DIR/
        cp -f $SRCDIR/upgrade $BIN_DIR/
+       cp -f $SRCDIR/web-svr $BIN_DIR/
        echo $VERSION > $BIN_DIR/VERSION
 }
index 8264341..d878892 100755 (executable)
@@ -21,6 +21,7 @@ install()
        cp -f $SRCDIR/build-* $BIN_DIR/
        cp -rf $SRCDIR/src $BIN_DIR/
        cp -rf $SRCDIR/dibs-web $BIN_DIR/
+       cp -f $SRCDIR/web-svr $BIN_DIR/
        cp -f $SRCDIR/upgrade $BIN_DIR/
        echo $VERSION > $BIN_DIR/VERSION
 }
index 8264341..d878892 100755 (executable)
@@ -21,6 +21,7 @@ install()
        cp -f $SRCDIR/build-* $BIN_DIR/
        cp -rf $SRCDIR/src $BIN_DIR/
        cp -rf $SRCDIR/dibs-web $BIN_DIR/
+       cp -f $SRCDIR/web-svr $BIN_DIR/
        cp -f $SRCDIR/upgrade $BIN_DIR/
        echo $VERSION > $BIN_DIR/VERSION
 }
index 2ccd4aa..834a7e7 100644 (file)
@@ -1,3 +1,29 @@
+* 2.1.5
+- bug fix : log file remove when job initializing 
+== hyoun jiil <jiil.hyoun@samsung.com> 2013-03-15
+* 2.1.4
+- several bug fix (for upgrade)
+== hyoun jiil <jiil.hyoun@samsung.com> 2013-03-15
+* 2.1.3
+- Fixed download cache bug
+- Update comm.protoco.version to 1.8.0
+== donghee yang <donghee.yang@samsung.com> 2013-03-14
+* 2.1.2
+- several bug fix
+- db version update
+- fixed disk full problem
+== hyoun jiil <jiil.hyoun@samsung.com> 2013-03-14
+* 2.1.1
+- Fixed a bug about setting external dependent package path
+== donghee yang <donghee.yang@samsung.com> 2013-03-14
+* 2.1.0
+- Version up
+== donghee yang <donghee.yang@samsung.com> 2013-03-12
+* 2.0.12
+== donghee yang <donghee.yang@samsung.com> 2013-03-12
+* 2.0.11
+- Fixed a bug in installing dep packages of local package
+== donghee yang <donghee.yang@samsung.com> 2013-01-23
 * 2.0.10
 - hot fix No method error
 == hyoun jiil <jiil.hyoun@samsung.com> 2013-01-23
index 60bd43c..f6a68c1 100644 (file)
@@ -1,5 +1,5 @@
 Source : dibs
-Version :2.0.10
+Version :2.1.5
 Maintainer : taejun ha<taejun.ha@samsung.com>, jiil hyoun <jiil.hyoun@samsung.com>, donghyuk yang <donghyouk.yang@samsung.com>, donghee yang <donghee.yang@samsung.com>, sungmin kim <dev.sungmin.kim@samsung.com
 
 Package : dibs
diff --git a/pkg-cli b/pkg-cli
index f2d2e8b..9cbb4c8 100755 (executable)
--- a/pkg-cli
+++ b/pkg-cli
@@ -62,53 +62,37 @@ if option[:os].nil? then
 end
 
 case option[:cmd]
-when "update" then
-       client = Client.new( option[:url], nil, nil )
-       #client.update()
 when "clean" then
-       client = Client.new( nil, option[:loc], nil )
+       client = Client.new( nil, option[:loc], nil, false )
        client.clean(option[:f])
 when "download" then
        client = Client.new( option[:url], option[:loc], nil )
-       #if not option[:url].nil? then
-       #    client.update()
-       #end
        file_loc = client.download( option[:pkg], option[:os], option[:t] )
 when "install" then
        client = Client.new( option[:url], option[:loc], nil )
-       #if not option[:url].nil? then
-       #    client.update()
-       #end
        client.install( option[:pkg], option[:os], option[:t], option[:f] )
 when "install-file" then
-       client = Client.new( option[:url], option[:loc], nil )
-       client.install_local_pkg( option[:pkg], option[:t], option[:f] )
+       if option[:t] then
+               client = Client.new( option[:url], option[:loc], nil )
+               client.install_local_pkg( option[:pkg], option[:t], option[:f] )
+       else
+               client = Client.new( nil, option[:loc], nil, false )
+               client.install_local_pkg( option[:pkg], option[:t], option[:f] )
+       end                     
 when "uninstall" then
-       client = Client.new( nil, option[:loc], nil )
+       client = Client.new( nil, option[:loc], nil, false )
        client.uninstall( option[:pkg], option[:t] )
 when "upgrade" then
        client = Client.new( option[:url], option[:loc], nil )
-       #if not option[:url].nil? then
-       #    client.update()
-       #end
        client.upgrade( option[:os], option[:t] )
 when "check-upgrade" then
        client = Client.new( option[:url], option[:loc], nil )
-       #if not option[:url].nil? then
-       #   client.update()
-       #end
        client.check_upgrade( option[:os] )
 when "show-rpkg" then
        client = Client.new( option[:url], nil, nil )
-       #if not option[:url].nil? then
-       #    client.update()
-       #end
        puts client.show_pkg_info( option[:pkg], option[:os] )
 when "list-rpkg" then
        client = Client.new( option[:url], nil, nil )
-       #if not option[:url].nil? then
-       #    client.update()
-       #end
        result = client.show_pkg_list( option[:os] )
        if not result.nil? and not result.empty? then
                result.each do |i|
@@ -119,10 +103,10 @@ when "list-rpkg" then
                end
        end
 when "show-lpkg" then
-       client = Client.new( nil, option[:loc], nil )
+       client = Client.new( nil, option[:loc], nil, false )
        puts client.show_installed_pkg_info( option[:pkg] )
 when "list-lpkg" then
-       client = Client.new( nil, option[:loc], nil )
+       client = Client.new( nil, option[:loc], nil, false )
        result = client.show_installed_pkg_list()
        if not result.nil? and not result.empty? then
                result.each do |i|
@@ -135,8 +119,12 @@ when "list-lpkg" then
                puts "Info: There is no any package."
        end
 when "build-dep" then
-       client = Client.new( nil, nil, nil )
+       client = Client.new( option[:url], nil, nil )
        result = client.get_build_dependent_packages( option[:pkg], option[:os], true )
+       if result.nil? then
+               puts "Error: Failed to get remote package list. try update first."
+               exit 1
+       end                     
        ret = ""
        result.each do |i|
                ret = ret + i + " --> "
@@ -145,8 +133,12 @@ when "build-dep" then
        ret[-3..-1] = ""
        puts ret
 when "install-dep" then
-       client = Client.new( nil, nil, nil )
+       client = Client.new( option[:url], nil, nil )
        result = client.get_install_dependent_packages( option[:pkg], option[:os], true, false )
+       if result.nil? then
+               puts "Error: Failed to get remote package list. try update first."
+               exit 1
+       end                     
        ret = ""
        result.each do |i|
                ret = ret + i + " --> "
@@ -154,6 +146,9 @@ when "install-dep" then
        ret = ret.strip
        ret[-3..-1] = ""
        puts ret
+when "register" then
+       client = Client.new( nil, nil, nil )
+       client.register(option[:address], option[:dist], option[:pkg], option[:passwd])
 else
        raise RuntimeError, "Input is incorrect : #{option[:cmd]}"
 end
diff --git a/pkg-svr b/pkg-svr
index 6c50176..c8bfae2 100755 (executable)
--- a/pkg-svr
+++ b/pkg-svr
@@ -107,7 +107,7 @@ begin
        when "start"
                server.start( option[:port], option[:passwd] )
        when "stop"
-               server.stop( option[:port], option[:passwd] )
+               server.stop( option[:passwd] )
        else
                raise RuntimeError, "input option incorrect : #{option[:cmd]}"
        end
index 63fb3da..d2c98a1 100644 (file)
@@ -32,7 +32,7 @@ require 'utils'
 
 class BuildClientUsage
        BUILD="build-cli build -N <project name> -d <server address> [-o <os>] [-w <password>] [--async] [-D <distribution name>] [-U user-email] [-V]"
-       RESOLVE="build-cli resolve -N <project name> -d <server address> [-o <os>] [-w <password>] [--async] [-D <distribution name>] [-U user-email] [-V]"
+       #RESOLVE="build-cli resolve -N <project name> -d <server address> [-o <os>] [-w <password>] [--async] [-D <distribution name>] [-U user-email] [-V]"
        QUERY="build-cli query -d <server address>"
        QUERY_SYSTEM="build-cli query-system -d <server address>"
        QUERY_PROJECT="build-cli query-project -d <server address>"
@@ -51,12 +51,12 @@ def option_error_check( options )
                        raise ArgumentError, "Usage: " + BuildClientUsage::BUILD
                end
 
-       when "resolve" then
-               if options[:project].nil? or options[:project].empty? or
-                       options[:domain].nil?  or options[:domain].empty? then
-                       raise ArgumentError, "Usage: " + BuildClientUsage::RESOLVE
-               end
-
+#      when "resolve" then
+#              if options[:project].nil? or options[:project].empty? or
+#                      options[:domain].nil?  or options[:domain].empty? then
+#                      raise ArgumentError, "Usage: " + BuildClientUsage::RESOLVE
+#              end
+#
        when "query" then
                if options[:domain].nil? or options[:domain].empty? then
                        raise ArgumentError, "Usage: " + BuildClientUsage::QUERY
@@ -103,7 +103,6 @@ def option_parse
                + "\n" + "Usage: build-cli <SUBCOMMAND> [OPTS] or build-cli (-h|-v)" + "\n" \
                + "\n" + "Subcommands:" + "\n" \
                + "\t" + "build         Build and create package." + "\n" \
-               + "\t" + "resolve       Request change to resolve-status for build-conflict." + "\n" \
                + "\t" + "query         Query information about build-server." + "\n" \
                + "\t" + "query-system  Query system information about build-server." + "\n" \
                + "\t" + "query-project Query project information about build-server." + "\n" \
@@ -112,7 +111,6 @@ def option_parse
                + "\t" + "register      Register the package to the build-server." + "\n" \
                + "\n" + "Subcommand usage:" + "\n" \
                + "\t" + BuildClientUsage::BUILD + "\n" \
-               + "\t" + BuildClientUsage::RESOLVE + "\n" \
                + "\t" + BuildClientUsage::QUERY + "\n" \
                + "\t" + BuildClientUsage::QUERY_SYSTEM + "\n" \
                + "\t" + BuildClientUsage::QUERY_PROJECT + "\n" \
@@ -120,6 +118,8 @@ def option_parse
                + "\t" + BuildClientUsage::CANCEL + "\n" \
                + "\t" + BuildClientUsage::REGISTER + "\n" \
                + "\n" + "Options:" + "\n"
+               #+ "\t" + "resolve       Request change to resolve-status for build-conflict." + "\n" \
+               #+ "\t" + BuildClientUsage::RESOLVE + "\n" \
 
        optparse = OptionParser.new(nil, 32, ' '*8) do|opts|
 
@@ -203,7 +203,7 @@ def option_parse
 
        cmd = ARGV[0]
 
-       if cmd.eql? "build" or cmd.eql? "resolve" or
+       if cmd.eql? "build" or #cmd.eql? "resolve" or
                cmd.eql? "query" or cmd.eql? "query-system" or
                cmd.eql? "query-project" or cmd.eql? "query-job" or
                cmd.eql? "cancel" or
@@ -226,4 +226,3 @@ def option_parse
 
        return options
 end
-
index 71c3485..8d9c8e4 100644 (file)
@@ -46,8 +46,8 @@ class BuildJob < CommonJob
 
        attr_accessor :pkginfo, :source_path
        attr_accessor :pkgsvr_client, :thread
-       attr_accessor :rev_fail_projects, :rev_success_jobs
-       attr_accessor :pending_ancestor, :cancel_state
+#      attr_accessor :rev_fail_projects, :rev_success_jobs
+#      attr_accessor :pending_ancestor
        attr_accessor :no_reverse
        attr_accessor :remote_id
 
@@ -58,22 +58,19 @@ class BuildJob < CommonJob
                @os = os
                @type = "BUILD"
 
-               @cancel_state = "NONE"
-               @resolve = false
+               #@resolve = false
                @host_os = Utils::HOST_OS
                if not @server.distmgr.nil? then
                        @pkgsvr_url = @server.distmgr.get_distribution(project.dist_name).pkgsvr_url
                        @pkgsvr_ip = @server.distmgr.get_distribution(project.dist_name).pkgsvr_ip
                        @pkgsvr_port = @server.distmgr.get_distribution(project.dist_name).pkgsvr_port
+                       @pkgsvr_password = @server.distmgr.get_distribution(project.dist_name).pkgsvr_password
                else
                        @pkgsvr_url = ""
                        @pkgsvr_ip = ""
                        @pkgsvr_port = ""
+                       @pkgsvr_password = ""
                end
-               @job_root = "#{@server.path}/jobs/#{@id}"
-               @source_path = @job_root+"/temp"
-               @job_working_dir=@job_root+"/works"
-               @buildroot_dir = "#{@job_root}/buildroot"
 
                # this item will be initialized on pre-verify
                @pkginfo = nil
@@ -83,13 +80,13 @@ class BuildJob < CommonJob
                @parent = nil # for job hierachy
 
                #for cancel operation
-               @pending_ancestor = nil # for cancel pending job
+               #@pending_ancestor = nil # for cancel pending job
                @remote_id = nil # for cancel remote_working job
                @build_dep_prjs = nil # for cacnel pending job
 
-               # for resolving build-break
-               @rev_fail_projects = [] # list of [project,os]
-               @rev_success_jobs = [] # list of job
+               ## for resolving build-break
+               #@rev_fail_projects = [] # list of [project,os]
+               #@rev_success_jobs = [] # list of job
 
                # remote build
                @remote_server = nil
@@ -138,6 +135,12 @@ class BuildJob < CommonJob
        def set_remote_job(server)
                @is_remote_job = true
                @remote_server=server
+               server.add_working_job(self)
+       end
+
+
+       def is_remote_job()
+               return (not @remote_server.nil?)
        end
 
 
@@ -157,10 +160,10 @@ class BuildJob < CommonJob
        end
 
 
-       # set option for waiting for resolve
-       def set_resolve_flag()
-               @resolve = true
-       end
+       ## set option for waiting for resolve
+       #def set_resolve_flag()
+       #       @resolve = true
+       #end
 
 
        # set force rebuild
@@ -173,13 +176,7 @@ class BuildJob < CommonJob
 
        # add external packages to overwrite before build
        def add_external_package( file_name )
-               @external_pkgs.push "#{@job_root}/external_pkgs/#{file_name}"
-       end
-
-
-       #terminate
-       def terminate()
-               #do noting
+               @external_pkgs.push file_name
        end
 
 
@@ -188,10 +185,15 @@ class BuildJob < CommonJob
                # kill sub process if exist?
                kill_sub_process()
 
+               # cancel all its sub jobs
+               @sub_jobs.select{|x| x.event == "NONE"}.each do |sub|
+                       sub.event = "CANCEL"
+               end
+
                # cancel all its reverse job
                @server.jobmgr.reverse_build_jobs.each do |job|
-                       if job.get_parent_job() == self and job.cancel_state == "NONE" then
-                               job.cancel_state = "INIT"
+                       if job.get_parent_job() == self and job.event == "NONE" then
+                               job.event = "CANCEL"
                        end
                end
 
@@ -215,36 +217,36 @@ class BuildJob < CommonJob
                                end
                                client.terminate
                        end
-               when "PENDING" then
-                       if @pending_ancestor.nil? then
-                               #resolve pending job
-                               pending_descendants = @server.jobmgr.jobs.select do |j|
-                                       (not j.pending_ancestor.nil?) and "#{j.pending_ancestor.id}" == "#{@id}"
-                               end
-                               pending_descendants.each do |pd|
-                                       pd.cancel_state = "INIT"
-                               end
-                       else
-                               # remove myself from success job if exist
-                               # and add myself into rev_fail_project list if not exist
-                               @pending_ancestor.remove_rev_success_job(self)
-                               @pending_ancestor.add_rev_fail_project( @project, @os )
-
-                               # remove the project that depends on me if exist
-                               # and add it into rev_fail_project list if not exist
-                               p_sub_jobs = @server.jobmgr.jobs.select do |j|
-                                       ( not j.pending_ancestor.nil? and
-                                        "#{j.pending_ancestor.id}" == "#{@pending_ancestor.id}" and
-                                        j.is_build_dependent_project(@project, @os) )
-                               end
-                               p_sub_jobs.each do |d|
-                                       @pending_ancestor.remove_rev_success_job(d)
-                                       @pending_ancestor.add_rev_fail_project( d.get_project, d.os )
-
-                                       if not d.thread.nil? then d.thread.terminate end
-                                       d.status = "WAITING"
-                               end
-                       end
+               #when "PENDING" then
+               #       if @pending_ancestor.nil? then
+               #               #resolve pending job
+               #               pending_descendants = @server.jobmgr.jobs.select do |j|
+               #                       (not j.pending_ancestor.nil?) and "#{j.pending_ancestor.id}" == "#{@id}"
+               #               end
+               #               pending_descendants.each do |pd|
+               #                       pd.cancel_state = "INIT"
+               #               end
+               #       else
+               #               # remove myself from success job if exist
+               #               # and add myself into rev_fail_project list if not exist
+               #               @pending_ancestor.remove_rev_success_job(self)
+               #               @pending_ancestor.add_rev_fail_project( @project, @os )
+
+               #               # remove the project that depends on me if exist
+               #               # and add it into rev_fail_project list if not exist
+               #               p_sub_jobs = @server.jobmgr.jobs.select do |j|
+               #                       ( not j.pending_ancestor.nil? and
+               #                        "#{j.pending_ancestor.id}" == "#{@pending_ancestor.id}" and
+               #                        j.is_build_dependent_project(@project, @os) )
+               #               end
+               #               p_sub_jobs.each do |d|
+               #                       @pending_ancestor.remove_rev_success_job(d)
+               #                       @pending_ancestor.add_rev_fail_project( d.get_project, d.os )
+
+               #                       if not d.thread.nil? then d.thread.terminate end
+               #                       d.status = "WAITING"
+               #               end
+               #       end
                when "WORKING", "WAITING" , "INITIALIZING" , "JUST_CREATED" then
                        #just log
                else # ERROR | FINISHED | RESOLVED
@@ -413,54 +415,54 @@ class BuildJob < CommonJob
        end
 
 
-       # remove job from reverse success job
-       def remove_rev_success_job( job )
-               @rev_success_jobs.delete job if @rev_success_jobs.include? job
-       end
+       ## remove job from reverse success job
+       #def remove_rev_success_job( job )
+       #       @rev_success_jobs.delete job if @rev_success_jobs.include? job
+       #end
 
 
-       # check [project,os] is in reverse fail project list
-       def is_rev_fail_project( prj, os )
-               # check the project already exist
-               @rev_fail_projects.each do |p|
-                       if p[0] == prj and p[1] == os then
-                               return true
-                       end
-               end
+       ## check [project,os] is in reverse fail project list
+       #def is_rev_fail_project( prj, os )
+       #       # check the project already exist
+       #       @rev_fail_projects.each do |p|
+       #               if p[0] == prj and p[1] == os then
+       #                       return true
+       #               end
+       #       end
 
-               return false
-       end
+       #       return false
+       #end
 
 
-       # add [project,os] to reverse fail project list
-       def add_rev_fail_project( prj, os )
-               # check the project already exist
-               @rev_fail_projects.each do |p|
-                       if p[0] == prj and p[1] == os then
-                               return
-                       end
-               end
-               # if not, add it
-               @rev_fail_projects.push [prj,os]
-       end
+       ## add [project,os] to reverse fail project list
+       #def add_rev_fail_project( prj, os )
+       #       # check the project already exist
+       #       @rev_fail_projects.each do |p|
+       #               if p[0] == prj and p[1] == os then
+       #                       return
+       #               end
+       #       end
+       #       # if not, add it
+       #       @rev_fail_projects.push [prj,os]
+       #end
 
 
-       # remove [project,os] from reverse fail project list
-       def remove_rev_fail_project( prj, os )
-               remove_list = []
+       ## remove [project,os] from reverse fail project list
+       #def remove_rev_fail_project( prj, os )
+       #       remove_list = []
 
-               # check project and os name
-               @rev_fail_projects.each do |p|
-                       if p[0] == prj and p[1] == os then
-                               remove_list.push p
-                       end
-               end
+       #       # check project and os name
+       #       @rev_fail_projects.each do |p|
+       #               if p[0] == prj and p[1] == os then
+       #                       remove_list.push p
+       #               end
+       #       end
 
-               # remove
-               remove_list.each do |r|
-                       @rev_fail_projects.delete r
-               end
-       end
+       #       # remove
+       #       remove_list.each do |r|
+       #               @rev_fail_projects.delete r
+       #       end
+       #end
 
 
        # get project that my job is dependent on
@@ -548,6 +550,8 @@ class BuildJob < CommonJob
                        return false
                end
 
+               lock_event
+
                # upload
                if not @is_rev_build_check_job and not @is_internal_job and
                        @parent.nil? and
@@ -673,44 +677,47 @@ class BuildJob < CommonJob
        # build clean
        def     build()
 
-               # check there are pending packages which wait for me
-               # it will return nil if not exist
-               # this process must be skip if it is sub-job
-               if not @is_rev_build_check_job and not @is_internal_job then
-                       @server.cancel_lock.synchronize do
-                               @pending_ancestor = get_pending_ancestor_job()
-                       end
-               end
+               ## check there are pending packages which wait for me
+               ## it will return nil if not exist
+               ## this process must be skip if it is sub-job
+               #if not @is_rev_build_check_job and not @is_internal_job then
+               #       @server.cancel_lock.synchronize do
+               #               @pending_ancestor = get_pending_ancestor_job()
+               #       end
+               #end
+
+               #if not @pending_ancestor.nil? then
+               #       # resolve other pending job
+               #       resolve()
+               #elsif @resolve then
+               #       # wait for being resolved by other jobs
+               #       # this condition must be placed after checking pending status
+               #       wait_resolve()
+               #else
+               #       # build
+               #       build_normal()
+               #end
 
-               if not @pending_ancestor.nil? then
-                       # resolve other pending job
-                       resolve()
-               elsif @resolve then
-                       # wait for being resolved by other jobs
-                       # this condition must be placed after checking pending status
-                       wait_resolve()
-               else
-                       # build
-                       build_normal()
-               end
+               # build
+               build_normal()
        end
 
 
-       # return pending job that wait for me
-       def get_pending_ancestor_job()
-               @server.jobmgr.get_pending_jobs.each do |job|
-                       # must have same distribution
-                       if get_distribution_name() != job.get_distribution_name() then
-                               next
-                       end
+       ## return pending job that wait for me
+       #def get_pending_ancestor_job()
+       #       @server.jobmgr.get_pending_jobs.each do |job|
+       #               # must have same distribution
+       #               if get_distribution_name() != job.get_distribution_name() then
+       #                       next
+       #               end
 
-                       if job.is_rev_fail_project(@project,@os) then
-                               return job
-                       end
-               end
+       #               if job.is_rev_fail_project(@project,@os) then
+       #                       return job
+       #               end
+       #       end
 
-               return nil
-       end
+       #       return nil
+       #end
 
 
        # check whether build this job or not
@@ -784,7 +791,9 @@ class BuildJob < CommonJob
                # if sub job, install dependent packages of parent-pkgs and not clean
                use_clean = true
                local_pkgs = []
-               local_pkgs += @external_pkgs
+               @external_pkgs.each do |p|
+                       local_pkgs.push "#{@job_root}/external_pkgs/#{p}"
+               end
                if not @parent.nil? then
                        use_clean = false
                        # get local packages to install
@@ -854,172 +863,172 @@ class BuildJob < CommonJob
        end
 
 
-       # wait to be resolved by other jobs
-       def wait_resolve()
-               @log.info( "Started to build this job and wait for being resolved...", Log::LV_USER)
-
-               # create builder
-               if @is_remote_job then
-                       builder = RemoteBuilder.new("JB#{@id}", @remote_server, @server.ftp_addr, @server.ftp_port, @server.ftp_username, @server.ftp_passwd)
-                       @log.info( "JobBuilder##{@id} is created", Log::LV_USER)
-                       @log.info( " - Remote Server : #{@remote_server.ip}:#{@remote_server.port}" )
-                       if not @server.ftp_addr.nil? then
-                               @log.info( " - FTP Server : #{@server.ftp_addr}" )
-                       end
-               else
-                       builder = Builder.create( "JB#{@id}", @pkgsvr_url, nil,
-                                                                        "#{@buildroot_dir}/#{@os}", @server.build_cache_dir )
-                       if builder.nil?
-                               @log.error( "Creating job builder failed", Log::LV_USER)
-                               return false
-                       end
-                       @log.info( "JobBuilder##{@id} is created", Log::LV_USER)
-                       @log.info( " - Package Server : #{@pkgsvr_url}" )
-                       @log.info( " - Build Cache Path : #{@server.build_cache_dir}" )
-               end
-               @log.info( " - Log Path : #{@log.path}" )
-
-               # build
-               if @is_remote_job then
-                       result = builder.build_job(self, [])
-               else
-                       result =  builder.build_job(self, true, [], false )
-               end
-               if not result then
-                       @log.error( "Building job failed", Log::LV_USER)
-                       write_log_url()
-                       return false
-               end
-
-               # check reverse dependecy
-               @rev_fail_projects = ReverseBuildChecker.check(self, false)
-               if @rev_fail_projects.empty? then
-                       # if no problem?, it OK
-                       return true
-               end
-
-               # pending
-               @status = "PENDING"
-               @log.info( "Entered the PENDING state ...", Log::LV_USER)
-               old_msg = ""
-               while @status == "PENDING"
-                       new_msg = @rev_fail_projects.map {|p| "#{p[0].name}(#{p[1]})"}.join(", ")
-                       if old_msg != new_msg then
-                               @log.error( " * Waiting for building next projects: #{new_msg}", Log::LV_USER)
-                               old_msg = new_msg
-                       end
-                       sleep 1
-               end
-
-               return true
-       end
-
-
-       # resolve other pending job
-       def     resolve()
-
-               # wait for other build-dependent projects are resolved
-               old_msg = ""
-               wait_prjs = @pending_ancestor.rev_fail_projects.select {|p| is_build_dependent_project(p[0], p[1])}
-               @log.info("Checking build dependency before RESOLVE", Log::LV_USER)
-               while not wait_prjs.empty?
-                       @status = "PENDING"
-                       new_msg = wait_prjs.map {|p| "#{p[0].name}(#{p[1]})"}.join(", ")
-                       if new_msg != old_msg then
-                               @log.info(" * Waiting for building next projects: #{new_msg}", Log::LV_USER)
-                               old_msg = new_msg
-                       end
-                       sleep 1
-                       wait_prjs = @pending_ancestor.rev_fail_projects.select {|p| is_build_dependent_project(p[0], p[1])}
-               end
-
-               # return back to "WORKING"
-               @status = "WORKING"
-
-               @log.info( "Started to build this job and resolve other pending job...", Log::LV_USER)
-
-               # create builder
-               if @is_remote_job then
-                       builder = RemoteBuilder.new("JB#{@id}", @remote_server, @server.ftp_addr, @server.ftp_port, @server.ftp_username, @server.ftp_passwd)
-                       @log.info( "JobBuilder##{@id} is created", Log::LV_USER)
-                       @log.info( " - Remote Server : #{@remote_server.ip}:#{@remote_server.port}" )
-                       if not @server.ftp_addr.nil? then
-                               @log.info( " - FTP Server : #{@server.ftp_addr}" )
-                       end
-               else
-                       builder = Builder.create( "JB#{@id}", @pkgsvr_url, nil,
-                                                                        "#{@buildroot_dir}/#{@os}", @server.build_cache_dir )
-                       if builder.nil?
-                               @log.error( "Creating job builder failed", Log::LV_USER)
-                               return false
-                       end
-                       @log.info( "JobBuilder##{@id} is created", Log::LV_USER)
-                       @log.info( " - Package Server : #{@pkgsvr_url}" )
-                       @log.info( " - Build Cache Path : #{@server.build_cache_dir}" )
-               end
-               @log.info( " - Log Path : #{@log.path}" )
-
-               # get local packages to overwite
-               # they must be composed of packages of pending jobs and its success list
-               local_pkgs=[]
-               local_pkgs += @external_pkgs
-               src_path = @pending_ancestor.source_path
-               ver = @pending_ancestor.pkginfo.get_version()
-               @pending_ancestor.pkginfo.get_target_packages(@os).each do |pkg|
-                       local_pkgs.push "#{src_path}/#{pkg.package_name}_#{ver}_#{@os}.zip"
-               end
-               @pending_ancestor.rev_success_jobs.each do |job|
-                       src_path = job.source_path
-                       ver = job.pkginfo.get_version()
-                       job.pkginfo.get_target_packages(@os).each do |pkg|
-                               local_pkgs.push "#{src_path}/#{pkg.package_name}_#{ver}_#{@os}.zip"
-                       end
-               end
-
-               # build
-               if @is_remote_job then
-                       result = builder.build_job(self, local_pkgs)
-               else
-                       result = builder.build_job(self, true, local_pkgs, false )
-               end
-               if not result then
-                       @log.error( "Building job failed", Log::LV_USER)
-                       write_log_url()
-                       return false
-               end
-
-               # check reverse dependecy and update parent rev_fail_project list
-               new_fail_projects = ReverseBuildChecker.check(self, false)
-               new_fail_projects.each do |p|
-                       @pending_ancestor.add_rev_fail_project(p[0], p[1])
-               end
-
-               # update the status of pending job
-               @status = "PENDING"
-               @pending_ancestor.remove_rev_fail_project(@project, @os)
-               @pending_ancestor.rev_success_jobs.push self
-               if @pending_ancestor.rev_fail_projects.empty? then
-                       @pending_ancestor.status = "RESOLVED"
-                       @pending_ancestor.rev_success_jobs.each do |job|
-                               job.status = "RESOLVED"
-                       end
-               else
-                       @log.info( "Entered the PENDING state ...", Log::LV_USER)
-                       old_msg = ""
-                       while @status == "PENDING"
-                               new_msg = @pending_ancestor.rev_fail_projects.map {|p| "#{p[0].name}(#{p[1]})"}.join(", ")
-
-                               if new_msg != old_msg then
-                                       @log.info(" * Waiting for building next projects: #{new_msg}", Log::LV_USER)
-                                       old_msg = new_msg
-                               end
-
-                               sleep 1
-                       end
-               end
-
-               return true
-       end
+       ## wait to be resolved by other jobs
+       #def wait_resolve()
+       #       @log.info( "Started to build this job and wait for being resolved...", Log::LV_USER)
+
+       #       # create builder
+       #       if @is_remote_job then
+       #               builder = RemoteBuilder.new("JB#{@id}", @remote_server, @server.ftp_addr, @server.ftp_port, @server.ftp_username, @server.ftp_passwd)
+       #               @log.info( "JobBuilder##{@id} is created", Log::LV_USER)
+       #               @log.info( " - Remote Server : #{@remote_server.ip}:#{@remote_server.port}" )
+       #               if not @server.ftp_addr.nil? then
+       #                       @log.info( " - FTP Server : #{@server.ftp_addr}" )
+       #               end
+       #       else
+       #               builder = Builder.create( "JB#{@id}", @pkgsvr_url, nil,
+       #                                                                "#{@buildroot_dir}/#{@os}", @server.build_cache_dir )
+       #               if builder.nil?
+       #                       @log.error( "Creating job builder failed", Log::LV_USER)
+       #                       return false
+       #               end
+       #               @log.info( "JobBuilder##{@id} is created", Log::LV_USER)
+       #               @log.info( " - Package Server : #{@pkgsvr_url}" )
+       #               @log.info( " - Build Cache Path : #{@server.build_cache_dir}" )
+       #       end
+       #       @log.info( " - Log Path : #{@log.path}" )
+
+       #       # build
+       #       if @is_remote_job then
+       #               result = builder.build_job(self, [])
+       #       else
+       #               result =  builder.build_job(self, true, [], false )
+       #       end
+       #       if not result then
+       #               @log.error( "Building job failed", Log::LV_USER)
+       #               write_log_url()
+       #               return false
+       #       end
+
+       #       # check reverse dependecy
+       #       @rev_fail_projects = ReverseBuildChecker.check(self, false)
+       #       if @rev_fail_projects.empty? then
+       #               # if no problem?, it OK
+       #               return true
+       #       end
+
+       #       # pending
+       #       @status = "PENDING"
+       #       @log.info( "Entered the PENDING state ...", Log::LV_USER)
+       #       old_msg = ""
+       #       while @status == "PENDING"
+       #               new_msg = @rev_fail_projects.map {|p| "#{p[0].name}(#{p[1]})"}.join(", ")
+       #               if old_msg != new_msg then
+       #                       @log.error( " * Waiting for building next projects: #{new_msg}", Log::LV_USER)
+       #                       old_msg = new_msg
+       #               end
+       #               sleep 1
+       #       end
+
+       #       return true
+       #end
+
+
+       ## resolve other pending job
+       #def    resolve()
+
+       #       # wait for other build-dependent projects are resolved
+       #       old_msg = ""
+       #       wait_prjs = @pending_ancestor.rev_fail_projects.select {|p| is_build_dependent_project(p[0], p[1])}
+       #       @log.info("Checking build dependency before RESOLVE", Log::LV_USER)
+       #       while not wait_prjs.empty?
+       #               @status = "PENDING"
+       #               new_msg = wait_prjs.map {|p| "#{p[0].name}(#{p[1]})"}.join(", ")
+       #               if new_msg != old_msg then
+       #                       @log.info(" * Waiting for building next projects: #{new_msg}", Log::LV_USER)
+       #                       old_msg = new_msg
+       #               end
+       #               sleep 1
+       #               wait_prjs = @pending_ancestor.rev_fail_projects.select {|p| is_build_dependent_project(p[0], p[1])}
+       #       end
+
+       #       # return back to "WORKING"
+       #       @status = "WORKING"
+
+       #       @log.info( "Started to build this job and resolve other pending job...", Log::LV_USER)
+
+       #       # create builder
+       #       if @is_remote_job then
+       #               builder = RemoteBuilder.new("JB#{@id}", @remote_server, @server.ftp_addr, @server.ftp_port, @server.ftp_username, @server.ftp_passwd)
+       #               @log.info( "JobBuilder##{@id} is created", Log::LV_USER)
+       #               @log.info( " - Remote Server : #{@remote_server.ip}:#{@remote_server.port}" )
+       #               if not @server.ftp_addr.nil? then
+       #                       @log.info( " - FTP Server : #{@server.ftp_addr}" )
+       #               end
+       #       else
+       #               builder = Builder.create( "JB#{@id}", @pkgsvr_url, nil,
+       #                                                                "#{@buildroot_dir}/#{@os}", @server.build_cache_dir )
+       #               if builder.nil?
+       #                       @log.error( "Creating job builder failed", Log::LV_USER)
+       #                       return false
+       #               end
+       #               @log.info( "JobBuilder##{@id} is created", Log::LV_USER)
+       #               @log.info( " - Package Server : #{@pkgsvr_url}" )
+       #               @log.info( " - Build Cache Path : #{@server.build_cache_dir}" )
+       #       end
+       #       @log.info( " - Log Path : #{@log.path}" )
+
+       #       # get local packages to overwite
+       #       # they must be composed of packages of pending jobs and its success list
+       #       local_pkgs=[]
+       #       local_pkgs += @external_pkgs
+       #       src_path = @pending_ancestor.source_path
+       #       ver = @pending_ancestor.pkginfo.get_version()
+       #       @pending_ancestor.pkginfo.get_target_packages(@os).each do |pkg|
+       #               local_pkgs.push "#{src_path}/#{pkg.package_name}_#{ver}_#{@os}.zip"
+       #       end
+       #       @pending_ancestor.rev_success_jobs.each do |job|
+       #               src_path = job.source_path
+       #               ver = job.pkginfo.get_version()
+       #               job.pkginfo.get_target_packages(@os).each do |pkg|
+       #                       local_pkgs.push "#{src_path}/#{pkg.package_name}_#{ver}_#{@os}.zip"
+       #               end
+       #       end
+
+       #       # build
+       #       if @is_remote_job then
+       #               result = builder.build_job(self, local_pkgs)
+       #       else
+       #               result = builder.build_job(self, true, local_pkgs, false )
+       #       end
+       #       if not result then
+       #               @log.error( "Building job failed", Log::LV_USER)
+       #               write_log_url()
+       #               return false
+       #       end
+
+       #       # check reverse dependecy and update parent rev_fail_project list
+       #       new_fail_projects = ReverseBuildChecker.check(self, false)
+       #       new_fail_projects.each do |p|
+       #               @pending_ancestor.add_rev_fail_project(p[0], p[1])
+       #       end
+
+       #       # update the status of pending job
+       #       @status = "PENDING"
+       #       @pending_ancestor.remove_rev_fail_project(@project, @os)
+       #       @pending_ancestor.rev_success_jobs.push self
+       #       if @pending_ancestor.rev_fail_projects.empty? then
+       #               @pending_ancestor.status = "RESOLVED"
+       #               @pending_ancestor.rev_success_jobs.each do |job|
+       #                       job.status = "RESOLVED"
+       #               end
+       #       else
+       #               @log.info( "Entered the PENDING state ...", Log::LV_USER)
+       #               old_msg = ""
+       #               while @status == "PENDING"
+       #                       new_msg = @pending_ancestor.rev_fail_projects.map {|p| "#{p[0].name}(#{p[1]})"}.join(", ")
+
+       #                       if new_msg != old_msg then
+       #                               @log.info(" * Waiting for building next projects: #{new_msg}", Log::LV_USER)
+       #                               old_msg = new_msg
+       #                       end
+
+       #                       sleep 1
+       #               end
+       #       end
+
+       #       return true
+       #end
 
 
        def upload()
@@ -1030,7 +1039,7 @@ class BuildJob < CommonJob
 
                # upload
                u_client = Client.new( @pkgsvr_url, nil, @log )
-               snapshot = u_client.upload( @pkgsvr_ip, @pkgsvr_port, binpkg_path_list, @server.ftp_addr, @server.ftp_port, @server.ftp_username, @server.ftp_passwd)
+               snapshot = u_client.upload( @pkgsvr_ip, @pkgsvr_port, binpkg_path_list, @server.ftp_addr, @server.ftp_port, @server.ftp_username, @server.ftp_passwd, @pkgsvr_password)
 
                if snapshot.nil? then
                        @log.info( "Upload failed...", Log::LV_USER)
index 7328abe..38e4bb7 100644 (file)
@@ -31,6 +31,7 @@ require 'fileutils'
 require 'dbi'
 require 'thread'
 $LOAD_PATH.unshift File.dirname(__FILE__)
+$LOAD_PATH.unshift File.dirname(File.dirname(__FILE__))+"/common"
 require "SocketJobRequestListener.rb"
 require "JobManager.rb"
 require "JobClean.rb"
@@ -38,6 +39,7 @@ require "RemoteBuildServer.rb"
 require "PackageSync.rb"
 require "ProjectManager.rb"
 require "DistributionManager.rb"
+require "db_utils.rb"
 
 class BuildServer
        attr_accessor :id, :path, :status, :host_os, :log
@@ -71,7 +73,7 @@ class BuildServer
                @req_listener = []
                @finish = false
                # status
-               @status = "RUNNING"
+               @status = "INITIALIZING"
                # host_os
                @host_os = HOST_OS
                # log
@@ -103,12 +105,11 @@ class BuildServer
                @db_dsn = "SQLite3:#{BuildServer::CONFIG_ROOT}/#{@id}/server.db"
                @db_user = nil
                @db_passwd = nil
-               @db_version = 1
+               @db_version = 2
                @sqlite3_db_mutex = Mutex.new
 
                #DB upgrade SQL command
                @db_migrate = []
-               #@db_migrate[0]= ["CREATE TABLE test(value INTEGER)", "INSERT INTO test (value) VALUES('3')"]
        end
 
        def send_mail
@@ -207,6 +208,11 @@ class BuildServer
        def db_now
                return (@db_dsn =~ /^Mysql/i) ? "NOW()" : "datetime('now')"
        end
+
+       def db_insert_id(db)
+               return (@db_dsn =~ /^Mysql/i) ? db.func(:insert_id) : db.select_one("SELECT last_insert_rowid()")[0]
+       end
+
        # start server daemon
        def start
                # set build cache dir
@@ -242,21 +248,20 @@ class BuildServer
                @pkg_sync =  PackageServerSynchronizer.new(self)
                @pkg_sync.start
 
+               # update friend server status
+               @log.info "Initializing Remote Servers..."
+               @remote_servers = get_remote_servers()
+               @remote_servers.each do |server|
+                       server.create_system_monitor()
+               end
+
                # main loop
                @log.info "Entering main loop..."
+               @status = "RUNNING"
                begin
                        if @test_time > 0 then start_time = Time.now end
                        while( not @finish )
 
-                               # update friend server status
-                               @remote_servers = get_remote_servers()
-                               @remote_servers.each do |server|
-                                       # update state
-                                       get_db_connection() do |db|
-                                               server.update_state(db)
-                                       end
-                               end
-
                                # handle jobs
                                @jobmgr.handle()
 
@@ -308,19 +313,22 @@ class BuildServer
 
        def get_remote_servers()
                get_db_connection() do |db|
-                       return RemoteBuildServer.load_all(db)
+                       return RemoteBuildServer.load_all(db, self)
                end
        end
 
 
        # add new remote friend server
        def add_remote_server( ip, port )
-
+               if @status == "RUNNING" then return false end
+               newsvr = nil
                get_db_connection() do |db|
-                       rs = RemoteBuildServer.load(ip, port, db)
+                       rs = RemoteBuildServer.load(ip, port, db, self)
                        if not rs.nil? then return false end
-                       RemoteBuildServer.new(ip, port, "").save(db)
+                       newsvr = RemoteBuildServer.new(ip, port, "", self)
+                       newsvr.save(db)
                end
+               @remote_servers.push newsvr
 
                return true
        end
@@ -328,6 +336,8 @@ class BuildServer
 
        # remove remote friend server
        def remove_remote_server( ip, port )
+               if @status == "RUNNING" then return false end
+
                get_db_connection() do |db|
                        rs = RemoteBuildServer.load(ip, port, db)
                        if rs.nil? then return false end
@@ -531,6 +541,7 @@ class BuildServer
        def db_upgrade
                result = true
                create = false
+               load_migrate_list
                begin
                        db = DBI.connect("DBI:#{@db_dsn}", @db_user, @db_passwd)
                        db_version = db.select_one("SELECT (value) FROM server_configs WHERE property = 'db_version'")[0].to_i
@@ -545,6 +556,7 @@ class BuildServer
                                                end
                                        end
                                end
+                               db.do("UPDATE server_configs SET value = '#{@db_version}' WHERE property = 'db_version'")
                        end
                rescue DBI::DatabaseError => e
                        puts e.errstr
@@ -556,53 +568,36 @@ class BuildServer
                return result
        end
 
+       def load_migrate_list
+               if @db_dsn =~ /^Mysql/i then
+                       @db_migrate[1]=["ALTER TABLE jobs CHANGE COLUMN id  id INTEGER AUTO_INCREMENT NOT NULL", 
+                                                       "ALTER TABLE distributions ADD pkgsvr_password VARCHAR(64)"]
+               else
+                       @db_migrate[1]=["ALTER TABLE distributions ADD pkgsvr_password VARCHAR(64)"]
+               end
+       end
+
        def gen_db()
-               case @db_dsn
-               when /^SQLite3:/ then puts "SQLite3 DB#{@db_dsn.split(':')[1]} generating"
-               when /^Mysql:/ then
-                       name = nil
-                       host = nil
-                       port = nil
-                       socket = nil
-                       flag = nil
-                       dsn = @db_dsn.split(':')
-                       if dsn[2].nil? then
-                               dsn[1].split(';').each do |attr|
-                                       case attr.split('=')[0].strip
-                                       when /database/i then
-                                               name = attr.split('=')[1].strip
-                                       when /host/i then
-                                               host = attr.split('=')[1].strip
-                                       when /port/i then
-                                               port = attr.split('=')[1].strip
-                                       when /socket/i then
-                                               socket = attr.split('=')[1].strip
-                                       when /flag/i then
-                                               flag = attr.split('=')[1].strip
-                                       else
-                                               etc = attr.split('=')[1].strip
-                                       end
-                               end
-                       else
-                               name = dsn[1].strip
-                               host = dsn[2].strip
-                       end
+               hash = DBUtils.dsn_parser @db_dsn
+               case hash[:database]
+               when "SQLite3" then puts "SQLite3 DB#{@db_dsn.split(':')[1]} generating"
+               when "Mysql" then
 
                        File.open("create_db.txt","w") do |f|
-                               f.puts "GRANT ALL ON #{name}.* TO '#{@db_user}'@'%' IDENTIFIED BY '#{@db_passwd}';"
-                               f.puts "CREATE DATABASE #{name};"
+                               f.puts "GRANT ALL ON #{hash[:name]}.* TO '#{@db_user}'@'%' IDENTIFIED BY '#{@db_passwd}';"
+                               f.puts "CREATE DATABASE #{hash[:name]};"
                        end
 
-                       if host.eql? "localhost" or host.eql? "127.0.0.1" then
+                       if hash[:host].eql? "localhost" or hash[:host].eql? "127.0.0.1" then
                                socket_str = ""
-                               socket_str = "--socket=#{socket}" if not socket.nil?
-                               puts "Mysql DB #{name} generating"
-                               system("mysql -h #{host} #{socket_str} -u #{@db_user} --password=#{@db_passwd} < create_db.txt")
+                               socket_str = "--socket=#{hash[:socket]}" if not hash[:socket].nil?
+                               puts "Mysql DB #{hash[:name]} generating"
+                               system("mysql -h #{hash[:host]} #{socket_str} -u #{@db_user} --password=#{@db_passwd} < create_db.txt")
                        else
                                port_str = ""
-                               port_str = "-P #{port}" if not port.nil?
-                               puts "Mysql DB #{name} generating"
-                               system("mysql -h #{host} #{port_str} -u #{@db_user} --password=#{@db_passwd} < create_db.txt")
+                               port_str = "-P #{hash[:port]}" if not port.nil?
+                               puts "Mysql DB #{hash[:name]} generating"
+                               system("mysql -h #{hash[:host]} #{port_str} -u #{@db_user} --password=#{@db_passwd} < create_db.txt")
                        end
                else puts "not support DB #{@db_dsn}"
                end
@@ -683,7 +678,7 @@ class BuildServer
                                CONSTRAINT fk_groups_has_projects_projects1 FOREIGN KEY ( project_id ) REFERENCES projects ( id ) )#{post_fix}"
 
                        # JOBS
-                       CommonJob.create_table(db, post_fix)
+                       CommonJob.create_table(db, inc, post_fix)
                end
 
                return result
@@ -762,5 +757,25 @@ class BuildServer
        def qualify_admin_to_access(prj_id)
                # nothing to do, admin can change everything on web admin tool
        end
+
+
+       def accept_system_monitor(conn)
+               sock_domain, remote_port, remote_hostname, remote_ip = conn.peeraddr
+               @log.info "Connected to system monitor from #{remote_ip}"
+               Thread.new do 
+                       begin
+                               while true
+                                       BuildCommServer.send(conn,
+                                       "=STATUS,#{@status},#{@host_os},#{@jobmgr.max_working_jobs}")
+                                       sleep 5
+                               end
+                       rescue => e
+                               @log.error e.message
+                       ensure
+                               BuildCommServer.disconnect(conn)
+                               @log.info "Disconnected from system monitor on #{remote_ip}"
+                       end
+               end
+       end
 end
 
index eabded1..8a79443 100644 (file)
@@ -337,13 +337,13 @@ class BuildServerController
 
 
        # add distribution
-       def self.add_distribution( id, dist_name, pkgsvr_url, pkgsvr_ip, pkgsvr_port )
+       def self.add_distribution( id, dist_name, pkgsvr_url, pkgsvr_ip, pkgsvr_port, pkgsvr_password )
                # get server
                server = get_server(id)
                migrate_db(server)
 
                # add
-               if server.distmgr.add_distribution( dist_name, pkgsvr_url, pkgsvr_ip, pkgsvr_port ) then
+               if server.distmgr.add_distribution( dist_name, pkgsvr_url, pkgsvr_ip, pkgsvr_port, pkgsvr_password ) then
                        puts "Distribution is added successfully!"
                        return true
                else
index 8faed9a..8c98f08 100644 (file)
@@ -14,7 +14,11 @@ class BuildServerException < Exception
                "ERR012" => "Project password not matched!",
                "ERR013" => "Project from file-name/distribution not found!",
                "ERR014" => "Job cancel failed!",
-               "ERR015" => "Server password not matched!"
+               "ERR015" => "Server password not matched!",
+               "ERR016" => "Can't received register file!",
+
+               "ERR900" => "Cancel event received!",
+               "ERR901" => "Job already upload status. Cancel failed!"
        }
 
        def initialize(code)
index 455a48b..0ab9726 100644 (file)
@@ -41,7 +41,7 @@ class BuildServerUsage
        REMOVE_SVR= "build-svr remove-svr -n <server name> -d <friend server address>"
        ADD_OS= "build-svr add-os -n <server name> -o <os>"
        REMOVE_OS="build-svr remove-os -n <server name> -o <os>"
-       ADD_DIST= "build-svr add-dist -n <server name> -D <distribution name> -u <package server url> -d <package server address>"
+       ADD_DIST= "build-svr add-dist -n <server name> -D <distribution name> -u <package server url> -d <package server address> [-w <password>]"
        REMOVE_DIST="build-svr remove-dist -n <server name> -D <distribution name>"
        LOCK_DIST="build-svr lock-dist -n <server name> -D <distribution name>"
        UNLOCK_DIST="build-svr unlock-dist -n <server name> -D <distribution name>"
index 5a624df..a352271 100644 (file)
@@ -35,20 +35,15 @@ require "utils.rb"
 class CommonJob
 
        attr_accessor :id, :server, :log, :status, :priority
-       attr_accessor :os, :type, :pre_jobs, :user_id
+       attr_accessor :os, :type, :pre_jobs, :user_id, :event, :sub_jobs
        USER_JOB_PRIORITY = 100
        AUTO_JOB_PRIORITY = 0
 
        # initialize
        public
        def initialize(server, id=nil)
+               @id = nil
                @server = server
-               if not server.jobmgr.nil? then
-                       @id = server.jobmgr.get_new_job_id()
-               else
-                       @id = 0
-               end
-
                @parent = nil
                @sub_jobs = []
                @priority = USER_JOB_PRIORITY # higher numbered job get priority
@@ -59,14 +54,21 @@ class CommonJob
                @user_id = 1
 
                @status = "JUST_CREATED"
+               @event = "NONE" # CANCEL/CANCELING
+               @event_lock = Mutex.new
+               @locked = false
                @log = nil
 
                @start_time = Time.now
                @end_time = nil
-
                @sub_pid = 0
        end
 
+       # event check
+       def check_event
+               # CANCEL/CANCELING
+               if (@event == "CANCELING") then raise BuildServerException.new("ERR900"),"Cancel event received JOB ##{@id}" end
+       end
 
        # set parent
        public
@@ -141,9 +143,15 @@ class CommonJob
 
                                # parent job will call sub job's terminate method
                                if not is_sub_job? then terminate() end
+                       rescue BuildServerException => e
+                               @log.error e.message
+                               if @status == "WORKING" then @status = "ERROR" end
                        rescue => e
                                @log.error e.message
                                @log.error e.backtrace.inspect
+                               if @status == "WORKING" then @status = "ERROR" end
+                       ensure
+                               @thread = nil
                        end
                end
 
@@ -161,12 +169,12 @@ class CommonJob
                #do noting
        end
 
-
        #cancel
        public
        def cancel()
-               # kill sub process if exist?
-               kill_sub_process()
+               if not @log.nil? then
+                       @log.info( "JOB is canceled by cancel operation !!", Log::LV_USER)
+               end
        end
 
 
@@ -194,15 +202,26 @@ class CommonJob
                end
                @sub_pid = 0
 
+               check_event
                # return
                return pid, status
        end
 
+       def lock_event(&block)
+               @event_lock.synchronize do
+                       if not @locked then
+                               yield if block_given?
+                               @locked = true
+                       else
+                               raise BuildServerException.new("ERR901"),"JOB ##{@id} alreay in Upload status\n - cancel failed"
+                       end
+               end
+       end
 
        public
-       def self.create_table(db, post_fix)
+       def self.create_table(db, inc, post_fix)
                db.do "CREATE TABLE jobs ( 
-                       id INTEGER PRIMARY KEY, 
+                       id INTEGER PRIMARY KEY #{inc}
                        project_id INTEGER, 
                        user_id INTEGER NOT NULL, 
                        supported_os_id INTEGER, 
@@ -229,14 +248,14 @@ class CommonJob
        def save(db, now)
 
                prj_id = @project.nil? ? "NULL" : @project.get_project_id()
-               row=db.select_one("SELECT * FROM jobs WHERE id=#{@id}")
-               if row.nil? then
+               if @id.nil? then
                        start_time = @start_time.strftime("%F %T")
                        os_id = BuildServer.get_supported_os_id(db, @os)
                        dist_id = PackageDistribution.get_distribution_id(db, get_distribution_name())
                        parent_id = @parent.nil? ? "NULL" : @parent.id
-                       db.do "INSERT INTO jobs(id,project_id,user_id,supported_os_id, distribution_id, parent_job_id,jtype,status,start_time) 
-                               VALUES (#{@id},#{prj_id},#{@user_id},#{os_id},#{dist_id},#{parent_id},'#{@type}','#{@status}',#{now})"
+                       db.do "INSERT INTO jobs(project_id,user_id,supported_os_id, distribution_id, parent_job_id,jtype,status,start_time) 
+                               VALUES (#{prj_id},#{@user_id},#{os_id},#{dist_id},#{parent_id},'#{@type}','#{@status}',#{now})"
+                       @id = @server.db_insert_id(db)
                else
                        remote_bs_id = (@type == "BUILD" and not get_remote_server().nil?) ? 
                                get_remote_server().id : "NULL"
@@ -254,6 +273,16 @@ class CommonJob
        end
 
 
+       def kill_sub_process()
+               if @sub_pid != 0 then
+                       if not @log.nil? then
+                               @log.info("Killing sub process! id = #{@sub_pid}")
+                       end
+                       Utils.kill_process(@sub_pid)
+               end
+       end
+
+
        #
        # PROTECTED METHODS
        #
@@ -263,15 +292,4 @@ class CommonJob
        def job_main
                # do nothing
        end
-
-
-       protected
-       def kill_sub_process()
-               if @sub_pid != 0 then
-                       if not @log.nil? then
-                               @log.info("Killing sub process! id = #{@sub_pid}")
-                       end
-                       Utils.kill_process(@sub_pid)
-               end
-       end
 end
index 2550496..1733558 100644 (file)
@@ -31,19 +31,19 @@ require 'thread'
 $LOAD_PATH.unshift File.dirname(__FILE__)
 $LOAD_PATH.unshift File.dirname(File.dirname(__FILE__))+"/pkg_server"
 require "SocketJobRequestListener.rb"
-require "RemoteBuildJob.rb"
 require "RegisterPackageJob.rb"
 require "packageServer.rb"
 
 class PackageDistribution
-       attr_accessor :name, :pkgsvr_url, :pkgsvr_ip, :pkgsvr_port, :status, :description, :id
+       attr_accessor :name, :pkgsvr_url, :pkgsvr_ip, :pkgsvr_port, :pkgsvr_password, :status, :description, :id
 
-       def initialize( name, pkgsvr_url, pkgsvr_ip, pkgsvr_port, status )
+       def initialize( name, pkgsvr_url, pkgsvr_ip, pkgsvr_port, pkgsvr_password, status )
                @id = -1
                @name = name
                @pkgsvr_url = pkgsvr_url
                @pkgsvr_ip = pkgsvr_ip
                @pkgsvr_port = pkgsvr_port
+               @pkgsvr_password = pkgsvr_password
                @status = status
                @description = ""
        end
@@ -55,6 +55,7 @@ class PackageDistribution
                        name VARCHAR(32) NOT NULL UNIQUE, 
                        pkgsvr_url VARCHAR(256), 
                        pkgsvr_addr VARCHAR(64), 
+                       pkgsvr_password VARCHAR(64), 
                        status VARCHAR(32) NOT NULL DEFAULT 'OPEN',
                        description VARCHAR(256) ) #{post_fix}"
        end
@@ -89,7 +90,7 @@ class PackageDistribution
        def self.load_row(row)
                pkgsvr_ip = row['pkgsvr_addr'].split(":")[0]
                pkgsvr_port = row['pkgsvr_addr'].split(":")[1].to_i
-               new_obj = new(row['name'], row['pkgsvr_url'], pkgsvr_ip, pkgsvr_port, row['status'])
+               new_obj = new(row['name'], row['pkgsvr_url'], pkgsvr_ip, pkgsvr_port, row['pkgsvr_password'], row['status'])
                new_obj.description = row['description']
                new_obj.id = row['id']
 
@@ -101,9 +102,9 @@ class PackageDistribution
                dist_addr = @pkgsvr_ip + ":" + @pkgsvr_port.to_s
                row = db.select_one("SELECT * FROM distributions WHERE name='#{@name}'")
                if row.nil? then
-                       db.do "INSERT INTO distributions(name, pkgsvr_url, pkgsvr_addr, status, description) VALUES ('#{@name}','#{@pkgsvr_url}','#{dist_addr}','#{@status}','#{@description}')"
+                       db.do "INSERT INTO distributions(name, pkgsvr_url, pkgsvr_addr, pkgsvr_password, status, description) VALUES ('#{@name}','#{@pkgsvr_url}','#{dist_addr}','#{@pkgsvr_password}','#{@status}','#{@description}')"
                else
-                       db.do "UPDATE distributions SET pkgsvr_url='#{@pkgsvr_url}', pkgsvr_addr='#{dist_addr}', status='#{@status}', description='#{@description}' WHERE name='#{@name}'"
+                       db.do "UPDATE distributions SET pkgsvr_url='#{@pkgsvr_url}', pkgsvr_addr='#{dist_addr}', pkgsvr_password='#{@pkgsvr_password}', status='#{@status}', description='#{@description}' WHERE name='#{@name}'"
                end
        end
 
@@ -152,14 +153,14 @@ class DistributionManager
 
 
        # add
-       def add_distribution(name, pkgsvr_url, pkgsvr_ip, pkgsvr_port)
+       def add_distribution(name, pkgsvr_url, pkgsvr_ip, pkgsvr_port, pkgsvr_password)
                @server.get_db_connection() do |db|
                        if not get_distribution_internal(name, db).nil? then
                                @server.log.info "The distribution \"#{name}\" already exists on server"
                                @server.log.error "Adding distribution failed!"
                                return false
                        end
-                       new_dist = PackageDistribution.new(name, pkgsvr_url, pkgsvr_ip, pkgsvr_port, "OPEN")
+                       new_dist = PackageDistribution.new(name, pkgsvr_url, pkgsvr_ip, pkgsvr_port, pkgsvr_password, "OPEN")
                        new_dist.save(db)
                end
                @server.log.info "Added a new distribution \"#{name}\""
index 301d810..34e0dde 100644 (file)
@@ -111,6 +111,11 @@ class GitBuildJob < BuildJob
 
        # verify
        def init
+               @job_root = "#{@server.path}/jobs/#{@id}"
+               @source_path = @job_root+"/temp"
+               @job_working_dir=@job_root+"/works"
+               @buildroot_dir = "#{@job_root}/buildroot"
+
                # mkdir job root
                if not File.exist? @job_root then FileUtils.mkdir_p @job_root end
 
index def8056..2dade44 100644 (file)
@@ -104,8 +104,8 @@ class JobLog < Log
                        error "Connection closed by remote client"
 
                        # cancel parent job
-                       if not @parent_job.nil? and @parent_job.cancel_state == "NONE" then
-                               @parent_job.cancel_state = "INIT"
+                       if not @parent_job.nil? and @parent_job.event == "NONE" then
+                               @parent_job.event = "CANCEL"
                        end
                end
        end
index dc6dbae..f8d890a 100644 (file)
@@ -31,7 +31,6 @@ require 'thread'
 $LOAD_PATH.unshift File.dirname(__FILE__)
 $LOAD_PATH.unshift File.dirname(File.dirname(__FILE__))+"/pkg_server"
 require "SocketJobRequestListener.rb"
-require "RemoteBuildJob.rb"
 require "RegisterPackageJob.rb"
 require "packageServer.rb"
 
@@ -91,23 +90,6 @@ class JobManager
        end
 
 
-       # get new id
-       def get_new_job_id
-               new_idx = 0
-               @latest_job_touch.synchronize do
-                       new_idx = @new_job_index
-
-                       file_path = "#{BuildServer::CONFIG_ROOT}/#{@server.id}/latest_job"
-                       File.open( file_path, "w" ) do |f|
-                               f.puts "#{@new_job_index}"
-                       end
-
-                       @new_job_index += 1
-               end
-
-               return new_idx
-       end
-
        def is_user_accessable(job,user_id)
                if job.type == "MULTIBUILD" then
                        job.get_sub_jobs().each do |subjob|
@@ -179,17 +161,20 @@ class JobManager
                        begin
                                # init
                                if not job.init or job.status == "ERROR" then
-                                       if job.cancel_state == "NONE" then job.status = "ERROR" end
+                                       if job.event == "NONE" then job.status = "ERROR" end
                                        @server.log.info "Adding the job \"#{job.id}\" is canceled"
                                        job.terminate()
                                        save_job_status(job)
                                        Thread.current.exit
                                end
-                               if job.status != "FINISHED" then
+                               job.check_event
+                               if job.status == "INITIALIZING" then
                                        job.status = "WAITING"
                                        save_job_status(job)
                                end
                                @server.log.info "Checking the job \"#{job.id}\" was finished!"
+                       rescue BuildServerException => e
+                               @server.log.error e.message
                        rescue => e
                                @server.log.error e.message
                                @server.log.error e.backtrace.inspect
@@ -228,15 +213,16 @@ class JobManager
        end
 
        def cancel_job( job)
-               job.cancel_state = "WORKING"
+               job.event = "CANCELING"
                @server.log.info "Creating thread for canceling the job \"#{job.id}\""
                Thread.new do
                        begin
-                               #terminate job thread
-                               if not job.thread.nil? then
-                                       job.thread.terminate
-                                       job.thread = nil
+                               job.kill_sub_process
+
+                               job.sub_jobs.select{|x| x.event == "NONE" and x.status != "FINISHED" and x.status != "ERROR" and x.status != "CANCELED" }.each do |sub|
+                                       sub.event = "CANCEL"
                                end
+                               job.thread.join if not job.thread.nil?
 
                                # job cacncel
                                job.cancel
@@ -257,7 +243,7 @@ class JobManager
        # handle
        def handle()
                # for cancel jobs
-               (@jobs + @internal_jobs + @reverse_build_jobs).select {|j| j.cancel_state == "INIT" }.each do |job|
+               (@jobs + @internal_jobs + @reverse_build_jobs).select {|j| j.event == "CANCEL" }.each do |job|
                        cancel_job( job )
                end
 
@@ -268,15 +254,15 @@ class JobManager
                        if job.status == "ERROR"
                                save_job_status(job)
                                @server.log.info "Job \"#{job.id}\" is stopped by ERROR"
-                               @reverse_build_jobs.delete job
+                               dispose_job(job)
                        elsif job.status == "FINISHED"
                                save_job_status(job)
                                @server.log.info "Job \"#{job.id}\" is removed by FINISH status"
-                               @reverse_build_jobs.delete job
+                               dispose_job(job)
                        elsif job.status == "CANCELED"
                                save_job_status(job)
                                @server.log.info "Job \"#{job.id}\" is removed by CANCELED status"
-                               @reverse_build_jobs.delete job
+                               dispose_job(job)
                        end
 
                        # if "JUST_CREATED", initialize it
@@ -292,15 +278,15 @@ class JobManager
                        if job.status == "ERROR"
                                save_job_status(job)
                                @server.log.info "Job \"#{job.id}\" is stopped by ERROR"
-                               @internal_jobs.delete job
+                               dispose_job(job)
                        elsif job.status == "FINISHED"
                                save_job_status(job)
                                @server.log.info "Job \"#{job.id}\" is removed by FINISH status"
-                               @internal_jobs.delete job
+                               dispose_job(job)
                        elsif job.status == "CANCELED"
                                save_job_status(job)
                                @server.log.info "Job \"#{job.id}\" is removed by CANCELED status"
-                               @internal_jobs.delete job
+                               dispose_job(job)
                        end
 
                        # if "JUST_CREATED", initialize it
@@ -316,15 +302,15 @@ class JobManager
                        if job.status == "ERROR"
                                save_job_status(job)
                                @server.log.info "Job \"#{job.id}\" is stopped by ERROR"
-                               @jobs.delete job
+                               dispose_job(job)
                        elsif job.status == "FINISHED"
                                save_job_status(job)
                                @server.log.info "Job \"#{job.id}\" is removed by FINISH status"
-                               @jobs.delete job
+                               dispose_job(job)
                        elsif job.status == "CANCELED"
                                save_job_status(job)
                                @server.log.info "Job \"#{job.id}\" is removed by CANCELED status"
-                               @jobs.delete job
+                               dispose_job(job)
                        end
 
                        # if "JUST_CREATED", initialize it
@@ -333,13 +319,13 @@ class JobManager
                        end
 
                        # check the connection if job is not asynchronous job
-                       if ( job.status == "WAITING" or job.status == "REMOTE_WORKING" or job.status == "PENDING") and
+                       if ( job.status == "WAITING" or job.status == "REMOTE_WORKING" ) and #or job.status == "PENDING") and
                                not job.is_asynchronous_job? and
                                not job.is_connected? then
 
                                job.status = "ERROR"
                                save_job_status(job)
-                               @jobs.delete( job )
+                               dispose_job( job )
                                @server.log.info "Job \"#{job.id}\" is disconnected by user. Removed!"
                        end
                end
@@ -363,6 +349,19 @@ class JobManager
        end
 
 
+       def dispose_job(job)
+               # if remote job, remove it from remote server's queue
+               if job.type == "BUILD" and job.is_remote_job then
+                       job.get_remote_server.remove_working_job(job)
+                       job.get_remote_server.update_db()
+               end
+
+               # remove from queue
+               @jobs.delete_if {|j| j.id == job.id}
+               @internal_jobs.delete_if {|j| j.id == job.id}
+               @reverse_build_jobs.delete_if {|j| j.id == job.id}
+       end
+
        # select the job whith no build-dependency problem
        def get_available_job
                # select reverse build job with round-robin method
@@ -478,14 +477,19 @@ class JobManager
        end
 
 
-       def get_pending_jobs
-               result = []
-               @jobs.each do |job|
-                       if job.status == "PENDING" then
-                               result.push job
-                       end
-               end
+       #def get_pending_jobs
+       #       result = []
+       #       @jobs.each do |job|
+       #               if job.status == "PENDING" then
+       #                       result.push job
+       #               end
+       #       end
+
+       #       return result
+       #end
 
+       def commit_job(job)
+               result = save_job_status(job)
                return result
        end
 
@@ -493,6 +497,9 @@ class JobManager
                now = @server.db_now
                result = @server.get_db_connection() do |db|
                        job.save(db, now)
+                       job.sub_jobs.each do |j|
+                               j.save(db, now)
+                       end
                end
 
                return result
@@ -508,9 +515,9 @@ class JobManager
                # gather all working jobs and full-build jobs
                check_dep_jobs = []
                jobs.each do |job|
-                       if job.cancel_state != "NONE" then next end
+                       if job.event != "NONE" then next end
 
-                       if job.status == "WORKING" or job.status == "REMOTE_WORKING" or job.status == "PENDING" then
+                       if job.status == "WORKING" or job.status == "REMOTE_WORKING" then # or job.status == "PENDING" then
                                check_dep_jobs.push job
                        elsif ( check_dep_wait and job.status == "WAITING") then
                                check_dep_jobs.push job
@@ -520,7 +527,7 @@ class JobManager
                # get candidates for waiting jobs
                candidate_jobs = []
                jobs.each do |job|
-                       if job.cancel_state != "NONE" then next end
+                       if job.event != "NONE" then next end
                        if job.status != "WAITING" then next end
 
                        # check build dependency against working job
@@ -531,10 +538,10 @@ class JobManager
                                if (cjob.status == "WORKING" or cjob.status == "REMOTE_WORKING" ) and
                                        (job.has_build_dependency?( cjob ) or job.is_compatible_with?( cjob)) then
                                        pre_jobs.push cjob
-                                       # In case that "PENDING" job is depends on me (not depended )
-                               elsif cjob.status == "PENDING"  and (not job.does_depend_on? cjob) and
-                                       (job.has_build_dependency?( cjob ) or job.is_compatible_with?( cjob)) then
-                                       pre_jobs.push cjob
+                       #       # In case that "PENDING" job is depends on me (not depended )
+                       #       elsif cjob.status == "PENDING"  and (not job.does_depend_on? cjob) and
+                       #               (job.has_build_dependency?( cjob ) or job.is_compatible_with?( cjob)) then
+                       #               pre_jobs.push cjob
                                elsif check_dep_wait and cjob.status == "WAITING" and
                                        (job.does_depend_on? cjob or
                                         (job.id > cjob.id and job.is_compatible_with? cjob) ) then
index 5e5d98e..8bcf6a5 100644 (file)
@@ -42,7 +42,7 @@ require "CommonJob.rb"
 
 class MultiBuildJob < CommonJob
 
-       attr_accessor :source_path, :cancel_state
+       attr_accessor :source_path
        attr_accessor :pkgsvr_client, :thread
 
        # initialize
@@ -55,12 +55,7 @@ class MultiBuildJob < CommonJob
                @pkgsvr_url = nil
                @pkgsvr_ip = nil
                @pkgsvr_port = nil
-               @job_root = "#{@server.path}/jobs/#{@id}"
-               @source_path = @job_root+"/temp"
-               @job_working_dir=@job_root+"/works"
-               @buildroot_dir = "#{@job_root}/buildroot"
-               @cancel_state = "NONE"
-
+               @pkgsvr_password = nil
        end
 
 
@@ -84,22 +79,16 @@ class MultiBuildJob < CommonJob
                end
        end
 
-       # cnacel
-       def cancel()
-               @sub_jobs.select{|x| x.cancel_state == "NONE"}.each do |sub|
-                       sub.cancel_state = "INIT"
-               end
-               if not @log.nil? then
-                       @log.info( "JOB is canceled by cancel operation !!", Log::LV_USER)
-               end
-       end
 
        #
        def init
-               # mkdir
-               if not File.exist? @job_root then
-                       FileUtils.mkdir_p @job_root
-               end
+               @job_root = "#{@server.path}/jobs/#{@id}"
+               @source_path = @job_root+"/temp"
+               @job_working_dir=@job_root+"/works"
+               @buildroot_dir = "#{@job_root}/buildroot"
+
+               # mkdir job root
+               if not File.exist? @job_root then FileUtils.mkdir_p @job_root end
 
                # create logger
                if @log.nil? then
@@ -114,6 +103,7 @@ class MultiBuildJob < CommonJob
                end
 
                # initialize all sub jobs and add them to "internal_jobs"
+               tstatus = @status
                @sub_jobs.each do |job|
                        # initialize job
                        if not job.init or job.status == "ERROR" then
@@ -126,10 +116,17 @@ class MultiBuildJob < CommonJob
                                job.status = "WAITING"
                        else
                                job.status = "ERROR"
-                               @status = "ERROR"
+                               tstatus = "ERROR"
                        end
                end
-               if @status == "ERROR" then
+               if tstatus == "ERROR" then
+                       # Changed the status of initialized sub-jobs if parent is in ERROR status
+                       @sub_jobs.each do |job|
+                               if job.status == "WAITING" then
+                                       job.status = "CANCELED"
+                               end 
+                       end
+                       @status = tstatus
                        return false
                end
 
@@ -139,6 +136,7 @@ class MultiBuildJob < CommonJob
                @pkgsvr_url = @server.distmgr.get_distribution(first_project.dist_name).pkgsvr_url
                @pkgsvr_ip = @server.distmgr.get_distribution(first_project.dist_name).pkgsvr_ip
                @pkgsvr_port = @server.distmgr.get_distribution(first_project.dist_name).pkgsvr_port
+               @pkgsvr_password = @server.distmgr.get_distribution(first_project.dist_name).pkgsvr_password
                @pkgsvr_client =  Client.new(@pkgsvr_url, @job_working_dir, @log)
 
                return true
@@ -383,9 +381,9 @@ class MultiBuildJob < CommonJob
                                        # cancel all other un-finished jobs
                                        @sub_jobs.each do |sub|
                                                if sub.status != "ERROR" and sub.status != "FINISHED" and
-                                                       sub.status != "CANCELED" and sub.cancel_state == "NONE" then
+                                                       sub.status != "CANCELED" and sub.event == "NONE" then
                                                        @log.info(" * Sub-Job \"#{sub.get_project().name}(#{sub.os})\" has entered \"CANCELING\" state. (#{sub.id})", Log::LV_USER)
-                                                       sub.cancel_state = "INIT"
+                                                       sub.event = "CANCEL"
                                                end
                                        end
 
@@ -393,9 +391,7 @@ class MultiBuildJob < CommonJob
                                        break
                                end
                        end
-
-                       #
-                       sleep 1
+                       check_event
                end
 
                if stop_status == "ERROR" or stop_status == "CANCELED" then
@@ -403,6 +399,8 @@ class MultiBuildJob < CommonJob
                        return
                end
 
+               lock_event
+
                # upload
                if not upload() then
                        @status = "ERROR"
@@ -424,7 +422,7 @@ class MultiBuildJob < CommonJob
 
                # upload
                u_client = Client.new( @pkgsvr_url, nil, @log )
-               snapshot = u_client.upload( @pkgsvr_ip, @pkgsvr_port, binpkg_path_list, @server.ftp_addr, @server.ftp_port, @server.ftp_username, @server.ftp_passwd)
+               snapshot = u_client.upload( @pkgsvr_ip, @pkgsvr_port, binpkg_path_list, @server.ftp_addr, @server.ftp_port, @server.ftp_username, @server.ftp_passwd, @pkgsvr_password)
 
                if snapshot.nil? then
                        @log.info( "Upload failed...", Log::LV_USER)
index afc2598..0695349 100644 (file)
@@ -108,9 +108,11 @@ class PackageSyncAction < Action
                                        next
                                end
                                new_job.priority = CommonJob::AUTO_JOB_PRIORITY
-                               new_job.create_logger( nil )
 
-                               # add
+                               # add job
+                               @server.jobmgr.commit_job(new_job)
+                               # create logger, this step must be done after 'commit'
+                               new_job.create_logger( nil )
                                @server.jobmgr.add_job( new_job )
                                registered_jobs.push new_job
                        end
index b745a3c..53f9104 100644 (file)
@@ -44,7 +44,7 @@ class RegisterPackageJob < CommonJob
 
        attr_accessor :source_path
        attr_accessor :pkgsvr_client, :thread, :pkg_type
-       attr_accessor :pkg_name, :pkginfo, :cancel_state
+       attr_accessor :pkg_name, :pkginfo
        attr_accessor :no_reverse
 
 
@@ -60,16 +60,13 @@ class RegisterPackageJob < CommonJob
                        @pkgsvr_url = @server.distmgr.get_distribution(project.dist_name).pkgsvr_url
                        @pkgsvr_ip = @server.distmgr.get_distribution(project.dist_name).pkgsvr_ip
                        @pkgsvr_port = @server.distmgr.get_distribution(project.dist_name).pkgsvr_port
+                       @pkgsvr_password = @server.distmgr.get_distribution(project.dist_name).pkgsvr_password
                else
                        @pkgsvr_url = @server.distmgr.get_distribution(dist_name).pkgsvr_url
                        @pkgsvr_ip = @server.distmgr.get_distribution(dist_name).pkgsvr_ip
                        @pkgsvr_port = @server.distmgr.get_distribution(dist_name).pkgsvr_port
+                       @pkgsvr_password = @server.distmgr.get_distribution(dist_name).pkgsvr_password
                end
-               @job_root = "#{@server.path}/jobs/#{@id}"
-               @source_path = @job_root+"/temp"
-               @job_working_dir=@job_root+"/works"
-               @buildroot_dir = "#{@job_root}/buildroot"
-               @cancel_state = "NONE"
 
                @local_path=local_path
                @file_path = nil
@@ -121,23 +118,28 @@ class RegisterPackageJob < CommonJob
                @no_reverse = true
        end
 
+       def execute_shell(cmd)
+               ret = Utils.execute_shell(cmd)
+               check_event
+               return ret
+       end
+
 
        #
        def init
-               # mkdir
-               if not File.exist? @job_root then
-                       FileUtils.mkdir_p @job_root
-               end
+               @job_root = "#{@server.path}/jobs/#{@id}"
+               @source_path = @job_root+"/temp"
+               @job_working_dir=@job_root+"/works"
+               @buildroot_dir = "#{@job_root}/buildroot"
 
-               if @cancel_state != "NONE" then return false end
+               # mkdir job root
+               if not File.exist? @job_root then FileUtils.mkdir_p @job_root end
 
                # create logger
                if @log.nil? then
                        @log = JobLog.new(self, nil )
                end
 
-               if @cancel_state != "NONE" then return false end
-
                @log.info( "Initializing job...", Log::LV_USER)
 
                # create dummy source path
@@ -161,13 +163,9 @@ class RegisterPackageJob < CommonJob
                        end
                end
 
-               if @cancel_state != "NONE" then return false end
-
                # set up pkgsvr_client
                @pkgsvr_client =  Client.new(@pkgsvr_url, @job_working_dir, @log)
 
-               if @cancel_state != "NONE" then return false end
-
                # check if the os is supported by build server
                if @pkg_type == "BINARY" and
                        not @server.supported_os_list.include? @os then
@@ -176,20 +174,16 @@ class RegisterPackageJob < CommonJob
                        return false
                end
 
-               if @cancel_state != "NONE" then return false end
-
                # checking version if not reverse-build job
                if @pkg_type == "BINARY" then
                        # extrac pkg file
                        cmd = "cd \"#{@source_path}\";unzip #{@file_path}"
-                       if not Utils.execute_shell(cmd) then
+                       if not execute_shell(cmd) then
                                @log.error( "Extracting package file failed!", Log::LV_USER)
                                @status = "ERROR"
                                return false
                        end
 
-                       if @cancel_state != "NONE" then return false end
-
                        # set up pkg info
                        begin
                                @pkginfo = PackageManifest.new("#{@source_path}/pkginfo.manifest")
@@ -204,16 +198,12 @@ class RegisterPackageJob < CommonJob
                        #       return false
                        #end
 
-                       if @cancel_state != "NONE" then return false end
-
                        if not check_package_version() then
                                @status = "ERROR"
                                return false
                        end
                end
 
-               if @cancel_state != "NONE" then return false end
-
                return true
        end
 
@@ -424,6 +414,8 @@ class RegisterPackageJob < CommonJob
                        end
                end
 
+               lock_event
+
                # upload
                if not upload() then
                        @status = "ERROR"
@@ -510,7 +502,7 @@ class RegisterPackageJob < CommonJob
 
                # upload
                u_client = Client.new( @pkgsvr_url, nil, @log )
-               snapshot = u_client.upload( @pkgsvr_ip, @pkgsvr_port, binpkg_path_list, @server.ftp_addr, @server.ftp_port, @server.ftp_username, @server.ftp_passwd)
+               snapshot = u_client.upload( @pkgsvr_ip, @pkgsvr_port, binpkg_path_list, @server.ftp_addr, @server.ftp_port, @server.ftp_username, @server.ftp_passwd, @pkgsvr_password)
 
                if snapshot.nil? then
                        @log.info( "Upload failed...", Log::LV_USER)
diff --git a/src/build_server/RemoteBuildJob.rb b/src/build_server/RemoteBuildJob.rb
deleted file mode 100644 (file)
index 4645786..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-=begin
-
- RemoteBuildJob.rb
-
-Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-
-Contact:
-Taejun Ha <taejun.ha@samsung.com>
-Jiil Hyoun <jiil.hyoun@samsung.com>
-Donghyuk Yang <donghyuk.yang@samsung.com>
-DongHee Yang <donghee.yang@samsung.com>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Contributors:
-- S-Core Co., Ltd
-=end
-
-$LOAD_PATH.unshift File.dirname(__FILE__)
-$LOAD_PATH.unshift File.dirname(File.dirname(__FILE__))+"/common"
-require "BuildJob.rb"
-require "utils.rb"
-
-
-class RemoteBuildJob < BuildJob
-       attr_accessor :id
-
-       # initialize
-       def initialize (id,server)
-               super(nil,nil,server)
-               # overide id
-               @id = id
-               @type = nil
-       end
-end
index b038be1..d7c7a37 100644 (file)
@@ -28,7 +28,6 @@ Contributors:
 
 require 'fileutils'
 $LOAD_PATH.unshift File.dirname(__FILE__)
-require "RemoteBuildJob.rb"
 require "BuildComm.rb"
 require 'thread'
 
@@ -39,7 +38,7 @@ class RemoteBuildServer
        attr_accessor :jobmgr, :distmgr
 
        # initialize
-       def initialize(ip, port, desc)
+       def initialize(ip, port, desc, parent)
                @id = -1
                @ip = ip
                @port = port
@@ -48,14 +47,14 @@ class RemoteBuildServer
                @host_os = Utils::HOST_OS
                @max_working_jobs = 2
                @working_jobs = []
-               @working_job_count = 0
                @waiting_jobs = []
-               @waiting_job_count = 0
                @path = ""
                @file_transfer_cnt_mutex = Mutex.new
                @file_transfer_cnt = 0
                @jobmgr = nil
                @distmgr = nil
+               @monitor_thread = nil
+               @parent = parent
        end
 
 
@@ -71,94 +70,85 @@ class RemoteBuildServer
        end
 
 
-       # query remote server info & update server state
-       def update_state(db)
+       # create monitor to check remote build server status
+       def create_system_monitor()
+               @parent.log.info " * Creating system monitor for #{@ip}:#{@port}..."
+               @monitor_thread = Thread.new do 
+                       while true
+                               begin
+                                       client = BuildCommClient.create( @ip, @port )
+                                       if not client.nil? and client.send("MONITOR|SYSTEM") then
+                                               result = client.read_lines(15,15) do |l|
+                                                       tok = l.split(",").map { |x| x.strip }
+                                                       status = tok[1]
+                                                       host_os = tok[2]
+                                                       max_working_jobs = tok[3].to_i
+                                                       if status != @status or max_working_jobs != @max_working_jobs then
+                                                               @status = status
+                                                               @max_working_jobs = max_working_jobs
+                                                               @host_os = host_os
+                                                               update_db()
+                                                       end     
+                                               end
+                                       end
+                               rescue => e
+                                       @parent.log.error "Remote server connection failed! : #{e.message}"
+                               ensure
+                                       if not client.nil? then client.terminate end
+                               end
 
-               # send
-               #@status = "DISCONNECTED"
-               client = BuildCommClient.create( @ip, @port )
-               if client.nil? then
-                       @status = "DISCONNECTED"
-                       db.do "UPDATE remote_build_servers SET status = 'DISCONNECTED', max_job_count = 0, working_job_count = 0, waiting_job_count = 0 WHERE id = #{@id}"
-                       return
-               end
-               if client.send("QUERY|SYSTEM") then
-                       result = client.read_lines do |l|
-                               tok = l.split(",").map { |x| x.strip }
-                               @host_os = tok[0]
-                               @max_working_jobs = tok[1].to_i
-                               @status = "RUNNING"
-                       end
-                       if not result then @status = "DISCONNECTED" end
-               else
-                       @status = "DISCONNECTED"
-               end
-               client.terminate
-               if @status == "DISCONNECTED" then
-                       db.do "UPDATE remote_build_servers SET status = 'DISCONNECTED', max_job_count = 0, working_job_count = 0, waiting_job_count = 0 WHERE id = #{@id}"
-                       return
-               end
+                               @status = "DISCONNECTED"
+                               update_db()
 
-               # send
-               @working_jobs = []
-               @waiting_jobs = []
-               client = BuildCommClient.create( @ip, @port )
-               if client.nil? then
-                       @status = "DISCONNECTED"
-                       db.do "UPDATE remote_build_servers SET status = 'DISCONNECTED', max_job_count = 0, working_job_count = 0, waiting_job_count = 0 WHERE id = #{@id}"
-                       return
-               end
-               if client.send("QUERY|JOB") then
-                       result = client.read_lines do |l|
-                               tok = l.split(",").map { |x| x.strip }
-
-                               job_status = tok[0]
-                               job_id = tok[1]
-                               new_job = RemoteBuildJob.new(job_id,self)
-                               case job_status
-                               when "WAITING", "JUST_CREATED", "INITIALIZING"
-                                       @waiting_jobs.push new_job
-                               when "WORKING"
-                                       @working_jobs.push new_job
-                               else
-                                       #puts "Uncontrolled status"
-                               end
+                               # after 1 min, try to reconnect
+                               sleep 60
                        end
-                       if not result then @status = "DISCONNECTED" end
-               else
-                       @status = "DISCONNECTED"
                end
-               client.terminate
-               if @status == "DISCONNECTED" then
-                       db.do "UPDATE remote_build_servers SET status = 'DISCONNECTED', max_job_count = 0, working_job_count = 0, waiting_job_count = 0 WHERE id = #{@id}"
-               else
-                       @working_job_count = @working_jobs.count
-                       @waiting_job_count = @waiting_jobs.count
+
+               @parent.log.info "Created system monitor for #{@ip}:#{@port}"
+       end
+
+
+       def update_db()
+               @parent.get_db_connection() do |db|
+                       working_job_count = @working_jobs.count
+                       waiting_job_count = @waiting_jobs.count
+
                        db.do "UPDATE remote_build_servers SET
                                status = '#{@status}',
                                supported_os_id = (SELECT supported_os.id FROM supported_os WHERE supported_os.name = '#{@host_os}'),
                                max_job_count = #{@max_working_jobs},
-                               working_job_count = #{@working_job_count},
-                               waiting_job_count = #{@waiting_job_count} WHERE id = #{@id}"
+                               working_job_count = #{working_job_count},
+                               waiting_job_count = #{waiting_job_count} WHERE id = #{@id}"
                end
        end
 
 
+       def add_working_job(job)
+               @working_jobs.push job
+       end
+
+
+       def remove_working_job(job)
+               @working_jobs.delete job
+       end
+
+
        # return available working slot
        def get_number_of_empty_room
-               return @max_working_jobs - @working_job_count
+               return @max_working_jobs - @working_jobs.count
        end
 
 
        # check there are working jobs
        def has_working_jobs
-               return (@working_job_count > 0)
+               return (@working_jobs.count > 0)
        end
 
 
        # check there are waiting jobs
        def has_waiting_jobs
-               return (@waiting_job_count > 0)
+               return (@waiting_jobs.count > 0)
        end
 
 
@@ -198,39 +188,44 @@ class RemoteBuildServer
        end
 
 
-       def self.load(ip, port, db)
+       def self.load(ip, port, db, parent)
                saddr="#{ip}:#{port}"
                row = db.select_one("SELECT remote_build_servers.*,supported_os.name as host_os_name FROM remote_build_servers, supported_os WHERE svr_addr='#{saddr}' and remote_build_servers.supported_os_id = supported_os.id")
                if not row.nil? then
-                       return load_row(row)
+                       return load_row(row, parent)
                end
 
                return nil
        end
 
 
-       def self.load_all(db)
+       def self.load_all(db, parent)
                result = []
                rows = db.select_all("SELECT *,'' as host_os_name FROM remote_build_servers WHERE supported_os_id IS NULL
                                                         UNION ALL
                                                         SELECT remote_build_servers.*, supported_os.name as host_os_name FROM remote_build_servers, supported_os WHERE remote_build_servers.supported_os_id = supported_os.id")
                rows.each do |row|
-                       result.push load_row(row)
+                       result.push load_row(row, parent)
                end
 
                return result
        end
 
 
-       def self.load_row(row)
+       def self.load_row(row, parent)
                svr_ip,svr_port=row['svr_addr'].strip.split(":")
-               new_obj = new(svr_ip, svr_port, row['description'] )
+               new_obj = new(svr_ip, svr_port, row['description'], parent )
                new_obj.set_id( row['id'] )
                new_obj.status = row['status']
-               new_obj.max_working_jobs =row['max_job_count']
+               if row['max_job_count'].nil? then
+                       new_obj.max_working_jobs = 0
+               else
+                       new_obj.max_working_jobs = row['max_job_count'].to_i
+               end
                new_obj.working_job_count =row['working_job_count']
                new_obj.waiting_job_count =row['waiting_job_count']
                new_obj.host_os = row['host_os_name']
+
                return new_obj
        end
 
index 49dde68..5fe2ea2 100644 (file)
@@ -81,22 +81,23 @@ class ReverseBuildChecker
 
                        # if not "GIT" project, ignore it
                        if rev_prj.type != "GIT" then next end
-
-                       # if job on resolve process, its unresolved project
-                       #of pending ancestor must be excluded.
-                       if job.type == "BUILD" and not job.pending_ancestor.nil? then
-                               found = false
-                               job.pending_ancestor.rev_fail_projects.each do  |fp|
-                                       f_prj = fp[0]
-                                       f_os =  fp[1]
-
-                                       if rev_prj == f_prj and rev_os == f_os then
-                                               found = true
-                                               break
-                                       end
-                               end
-                               if found then next end
-                       end
+                       found = false
+
+                       ## if job on resolve process, its unresolved project
+                       ##of pending ancestor must be excluded.
+                       #if job.type == "BUILD" and not job.pending_ancestor.nil? then
+                       #       found = false
+                       #       job.pending_ancestor.rev_fail_projects.each do  |fp|
+                       #               f_prj = fp[0]
+                       #               f_os =  fp[1]
+
+                       #               if rev_prj == f_prj and rev_os == f_os then
+                       #                       found = true
+                       #                       break
+                       #               end
+                       #       end
+                       #       if found then next end
+                       #end
 
                        # if this is sub job, all other sibling job must be excluded
                        if job.is_sub_job? then
@@ -140,6 +141,9 @@ class ReverseBuildChecker
                failure_list = []
                cancel_other_jobs = false
                while not rev_build_finished
+
+                       job.check_event
+
                        rev_build_finished = true
                        rev_build_jobs.each do |rev_job|
                                rev_prj = rev_job.get_project()
@@ -159,9 +163,9 @@ class ReverseBuildChecker
                                                cancel_other_jobs = true
                                                rev_build_jobs.each do |j|
                                                        if j.status != "ERROR" and j.status != "FINISHED" and
-                                                               j.status != "CANCELED" and j.cancel_state == "NONE" then
+                                                               j.status != "CANCELED" and j.event == "NONE" then
 
-                                                               j.cancel_state = "INIT"
+                                                               j.event = "CANCEL"
                                                        end
                                                end
                                                break
index dc18da6..a6dbba1 100644 (file)
@@ -126,8 +126,8 @@ class SocketJobRequestListener
                case  cmd
                when "BUILD"
                        handle_cmd_build( req_line, req )
-               when "RESOLVE"
-                       handle_cmd_resolve( req_line, req )
+               #when "RESOLVE"
+               #       handle_cmd_resolve( req_line, req )
                when "QUERY"
                        handle_cmd_query( req_line, req )
                when "CANCEL"
@@ -140,6 +140,8 @@ class SocketJobRequestListener
                        handle_cmd_fullbuild( req_line, req )
                when "REGISTER"
                        handle_cmd_register( req_line, req )
+               when "MONITOR"
+                       handle_cmd_monitor( req_line, req )
                when "DOWNLOAD"
                        Thread.new do
                                begin
@@ -307,6 +309,8 @@ class SocketJobRequestListener
                # check reverse build
                if no_reverse then new_job.set_no_reverse end
 
+               @parent_server.jobmgr.commit_job(new_job)
+
                # create logger and set
                if async then
                        new_job.create_logger( nil, verbose)
@@ -348,104 +352,104 @@ class SocketJobRequestListener
        end
 
 
-       # "RESOLVE"
-       def handle_cmd_resolve( line, req )
-               @log.info "Received REQ: #{line}"
-
-               begin
-                       handle_cmd_resolve_internal( line, req )
-               rescue BuildServerException => e
-                       @log.error(e.message)
-                       BuildCommServer.send(req, e.err_message())
-                       BuildCommServer.send_end(req)
-                       BuildCommServer.disconnect(req)
-               end
-
-               @log.info "Handled REQ: #{line}"
-       end
-
-
-       def handle_cmd_resolve_internal( line ,req)
-               tok = line.split("|").map { |x| x.strip }
-               if tok.count < 3 then
-                       raise BuildServerException.new("ERR001"), line
-               end
-
-               case tok[1]
-                       # RESOLVE|GIT|project_name|passwd|os|async|dist_name|user_email|verbose
-               when "GIT"
-
-                       # parse
-                       project_name=tok[2]
-                       passwd=tok[3]
-                       os=tok[4]
-                       async = tok[5].eql? "YES"
-                       dist_name = tok[6]
-                       user_email = (not tok[7].nil? and not tok[7].empty?) ? tok[7].strip : ""
-                       verbose = tok[8].eql? "YES"
-                       if (dist_name.nil? or dist_name.empty?) then
-                               dist_name = @parent_server.distmgr.get_default_distribution_name()
-                       end
-
-                       # check distribution
-                       check_distribution(dist_name, req)
-
-                       # check project
-                       prj = check_project_exist(project_name, dist_name, req)
-
-                       # check passwd
-                       check_project_password(prj, passwd, req)
-
-                       # check os
-                       os_list = check_supported_os( [os] , req )
-                       os = os_list[0]
-
-                       # check user email
-                       user_id = @parent_server.check_user_id_from_email( user_email )
-                       if user_id == -1 then
-                               raise BuildServerException.new("ERR004"), user_email
-                       end
-
-                       # check user accessable
-                       if not check_project_user_id(project_name,dist_name,user_id) then
-                               raise BuildServerException.new("ERR005"), "#{user_email} -> #{project_name}"
-                       end
-
-                       # create new job
-                       new_job = create_new_job( project_name, os, dist_name )
-                       if new_job.nil? then
-                               raise BuildServerException.new("ERR006"), "Resolve job #{project_name} #{os}"
-                       end
-                       @log.info "Received a request for resolving this project : #{project_name}, #{os}"
-
-                       new_job.user_id = user_id
-
-                       # resolve
-                       new_job.set_resolve_flag()
-
-                       # create logger and set
-                       if async then
-                               new_job.create_logger( nil, verbose)
-                               BuildCommServer.send(req,"Info: Added new job \"#{new_job.id}\" for #{new_job.os}!")
-                               if not @parent_server.job_log_url.empty? then
-                                       BuildCommServer.send(req,"Info:  * Log URL : #{@parent_server.job_log_url}/#{new_job.id}/log")
-                               end
-                               BuildCommServer.send(req,"Info: Above job(s) will be processed asynchronously!")
-                               BuildCommServer.send_end(req)
-                               BuildCommServer.disconnect(req)
-                       else
-                               logger = new_job.create_logger( req, verbose)
-                               logger.info( "Added new job \"#{new_job.id}\" for #{new_job.os}!", Log::LV_USER)
-                               if not @parent_server.job_log_url.empty? then
-                                       logger.info( " * Log URL : #{@parent_server.job_log_url}/#{new_job.id}/log", Log::LV_USER)
-                               end
-                       end
-
-                       @parent_server.jobmgr.add_job( new_job )
-               else
-                       raise BuildServerException.new("ERR001"), line
-               end
-       end
+       ## "RESOLVE"
+       #def handle_cmd_resolve( line, req )
+       #       @log.info "Received REQ: #{line}"
+
+       #       begin
+       #               handle_cmd_resolve_internal( line, req )
+       #       rescue BuildServerException => e
+       #               @log.error(e.message)
+       #               BuildCommServer.send(req, e.err_message())
+       #               BuildCommServer.send_end(req)
+       #               BuildCommServer.disconnect(req)
+       #       end
+
+       #       @log.info "Handled REQ: #{line}"
+       #end
+
+
+       #def handle_cmd_resolve_internal( line ,req)
+       #       tok = line.split("|").map { |x| x.strip }
+       #       if tok.count < 3 then
+       #               raise BuildServerException.new("ERR001"), line
+       #       end
+
+       #       case tok[1]
+       #               # RESOLVE|GIT|project_name|passwd|os|async|dist_name|user_email|verbose
+       #       when "GIT"
+
+       #               # parse
+       #               project_name=tok[2]
+       #               passwd=tok[3]
+       #               os=tok[4]
+       #               async = tok[5].eql? "YES"
+       #               dist_name = tok[6]
+       #               user_email = (not tok[7].nil? and not tok[7].empty?) ? tok[7].strip : ""
+       #               verbose = tok[8].eql? "YES"
+       #               if (dist_name.nil? or dist_name.empty?) then
+       #                       dist_name = @parent_server.distmgr.get_default_distribution_name()
+       #               end
+
+       #               # check distribution
+       #               check_distribution(dist_name, req)
+
+       #               # check project
+       #               prj = check_project_exist(project_name, dist_name, req)
+
+       #               # check passwd
+       #               check_project_password(prj, passwd, req)
+
+       #               # check os
+       #               os_list = check_supported_os( [os] , req )
+       #               os = os_list[0]
+
+       #               # check user email
+       #               user_id = @parent_server.check_user_id_from_email( user_email )
+       #               if user_id == -1 then
+       #                       raise BuildServerException.new("ERR004"), user_email
+       #               end
+
+       #               # check user accessable
+       #               if not check_project_user_id(project_name,dist_name,user_id) then
+       #                       raise BuildServerException.new("ERR005"), "#{user_email} -> #{project_name}"
+       #               end
+
+       #               # create new job
+       #               new_job = create_new_job( project_name, os, dist_name )
+       #               if new_job.nil? then
+       #                       raise BuildServerException.new("ERR006"), "Resolve job #{project_name} #{os}"
+       #               end
+       #               @log.info "Received a request for resolving this project : #{project_name}, #{os}"
+
+       #               new_job.user_id = user_id
+
+       #               # resolve
+       #               new_job.set_resolve_flag()
+
+       #               # create logger and set
+       #               if async then
+       #                       new_job.create_logger( nil, verbose)
+       #                       BuildCommServer.send(req,"Info: Added new job \"#{new_job.id}\" for #{new_job.os}!")
+       #                       if not @parent_server.job_log_url.empty? then
+       #                               BuildCommServer.send(req,"Info:  * Log URL : #{@parent_server.job_log_url}/#{new_job.id}/log")
+       #                       end
+       #                       BuildCommServer.send(req,"Info: Above job(s) will be processed asynchronously!")
+       #                       BuildCommServer.send_end(req)
+       #                       BuildCommServer.disconnect(req)
+       #               else
+       #                       logger = new_job.create_logger( req, verbose)
+       #                       logger.info( "Added new job \"#{new_job.id}\" for #{new_job.os}!", Log::LV_USER)
+       #                       if not @parent_server.job_log_url.empty? then
+       #                               logger.info( " * Log URL : #{@parent_server.job_log_url}/#{new_job.id}/log", Log::LV_USER)
+       #                       end
+       #               end
+
+       #               @parent_server.jobmgr.add_job( new_job )
+       #       else
+       #               raise BuildServerException.new("ERR001"), line
+       #       end
+       #end
 
 
        # "QUERY"
@@ -490,20 +494,21 @@ class SocketJobRequestListener
                        job_list.each do |job|
                                status = job.status
                                if status == "REMOTE_WORKING" then status = "REMOTE" end
-                               if job.cancel_state != "NONE" then status = "CANCEL" end
+                               if job.event != "NONE" then status = "CANCEL" end
 
                                case job.type
                                when "BUILD"
-                                       if status == "PENDING" then
-                                               if job.pending_ancestor.nil? then
-                                                       ids = "/"
-                                               else
-                                                       ids = job.pending_ancestor.id
-                                               end
-                                               BuildCommServer.send(req,"#{status}:#{ids},#{job.id},#{job.get_project().name},#{job.os} #{job.progress},#{job.get_distribution_name}")
-                                       else
-                                               BuildCommServer.send(req,"#{status},#{job.id},#{job.get_project().name},#{job.os} #{job.progress},#{job.get_distribution_name}")
-                                       end
+                                       #if status == "PENDING" then
+                                       #       if job.pending_ancestor.nil? then
+                                       #               ids = "/"
+                                       #       else
+                                       #               ids = job.pending_ancestor.id
+                                       #       end
+                                       #       BuildCommServer.send(req,"#{status}:#{ids},#{job.id},#{job.get_project().name},#{job.os} #{job.progress},#{job.get_distribution_name}")
+                                       #else
+                                       #       BuildCommServer.send(req,"#{status},#{job.id},#{job.get_project().name},#{job.os} #{job.progress},#{job.get_distribution_name}")
+                                       #end
+                                       BuildCommServer.send(req,"#{status},#{job.id},#{job.get_project().name},#{job.os} #{job.progress},#{job.get_distribution_name}")
                                when "REGISTER"
                                        if job.pkg_type == "BINARY" and not job.get_project().nil? then
                                                BuildCommServer.send(req,"#{status},#{job.id},#{job.get_project().name},#{job.os} #{job.progress},#{job.get_distribution_name}")
@@ -553,7 +558,7 @@ class SocketJobRequestListener
                when "FRIEND"
                        # print GIT projects
                        @parent_server.remote_servers.each do |server|
-                               BuildCommServer.send(req,"#{server.status},#{server.host_os},#{server.waiting_job_count},#{server.working_job_count},#{server.max_working_jobs},#{server.get_file_transfer_cnt}")
+                               BuildCommServer.send(req,"#{server.status},#{server.host_os},#{server.waiting_jobs.count},#{server.working_jobs.count},#{server.max_working_jobs},#{server.get_file_transfer_cnt}")
                        end
                        BuildCommServer.send_end(req)
                        BuildCommServer.disconnect(req)
@@ -573,6 +578,10 @@ class SocketJobRequestListener
                rescue BuildServerException => e
                        @log.error(e.message)
                        BuildCommServer.send(req, e.err_message())
+               rescue => e
+                       @log.error(e.message)
+                       BuildCommServer.send(req, e.err_message())
+               ensure
                        BuildCommServer.send_end(req)
                        BuildCommServer.disconnect(req)
                end
@@ -604,37 +613,37 @@ class SocketJobRequestListener
 
                if cancel_job.nil? then
                        raise BuildServerException.new("ERR014"), "Job #{tok[1]} not found."
-               else
-                       if cancel_job.cancel_state == "NONE" then
-                               # check passwd
-                               if not @parent_server.jobmgr.is_user_accessable(cancel_job,user_id) then
-                                       raise BuildServerException.new("ERR014"), "Access denied #{tok[3]}"
-                               end
-                               if cancel_job.type == "MULTIBUILD" then
-                                       cancel_job.get_sub_jobs().select{|x| x.cancel_state == "NONE" }.each do |sub|
-                                               check_project_password( sub.get_project, tok[2], req)
-                                       end
+               end
 
-                                       BuildCommServer.send(req, "\"#{cancel_job.id}, #{cancel_job.get_sub_jobs().map{|x| x.id}.join(", ")}\" will be canceled")
-                                       cancel_job.cancel_state = "INIT"
-                                       BuildCommServer.send_end(req)
-                                       BuildCommServer.disconnect(req)
-                               else
-                                       prj = cancel_job.get_project()
-                                       if not prj.nil? then
-                                               check_project_password( prj, tok[2], req)
-
-                                               BuildCommServer.send(req, "\"#{cancel_job.id}\" will be canceled")
-                                               cancel_job.cancel_state = "INIT"
-                                               BuildCommServer.send_end(req)
-                                               BuildCommServer.disconnect(req)
-                                       else
-                                               raise BuildServerException.new("ERR014"), "No project infomation"
-                                       end
-                               end
-                       else
-                               raise BuildServerException.new("ERR014"), "Job already canceled."
+               if cancel_job.event != "NONE" then
+                       raise BuildServerException.new("ERR014"), "Job already canceled."
+               end
+
+               # check passwd
+               if not @parent_server.jobmgr.is_user_accessable(cancel_job,user_id) then
+                       raise BuildServerException.new("ERR014"), "Access denied #{tok[3]}"
+               end
+
+               if cancel_job.type == "MULTIBUILD" then
+                       cancel_job.get_sub_jobs().select{|x| x.event == "NONE" }.each do |sub|
+                               check_project_password( sub.get_project, tok[2], req)
                        end
+
+                       BuildCommServer.send(req, "\"#{cancel_job.id}, #{cancel_job.get_sub_jobs().map{|x| x.id}.join(", ")}\" will be canceled")
+
+               else
+                       prj = cancel_job.get_project()
+                       if prj.nil? then
+                               raise BuildServerException.new("ERR014"), "No project infomation"
+                       end
+
+                       check_project_password( prj, tok[2], req)
+
+                       BuildCommServer.send(req, "\"#{cancel_job.id}\" will be canceled")
+               end
+
+               cancel_job.lock_event do
+                       cancel_job.event = "CANCEL"
                end
        end
 
@@ -752,6 +761,8 @@ class SocketJobRequestListener
                # create full build job
                new_job = @parent_server.prjmgr.create_new_full_build_job(dist_name)
 
+               @parent_server.jobmgr.commit_job(new_job)
+
                # set logger
                new_job.create_logger( req ) 
 
@@ -764,14 +775,21 @@ class SocketJobRequestListener
        def handle_cmd_register( line, req )
                @log.info "Received REQ: #{line}"
 
-               begin
-                       handle_cmd_register_internal( line, req )
-               rescue BuildServerException => e
-                       @log.error(e.message)
-                       BuildCommServer.send(req, e.err_message())
-                       BuildCommServer.send_end(req)
-                       BuildCommServer.disconnect(req)
+               Thread.new do
+                       begin
+                               handle_cmd_register_internal( line, req )
+                       rescue BuildServerException => e
+                               @log.error(e.message)
+                               BuildCommServer.send(req, e.err_message())
+                               BuildCommServer.send_end(req)
+                               BuildCommServer.disconnect(req)
+                       rescue => e
+                               @log.error "Transfering file failed!"
+                               @log.error e.message
+                               @log.error e.backtrace.inspect
+                       end
                end
+               
 
                @log.info "Handled REQ: #{line}"
        end
@@ -837,6 +855,15 @@ class SocketJobRequestListener
                        # check passwd
                        check_project_password(prj, passwd, req)
 
+                       # save thread and wait uplaod
+                       BuildCommServer.send(req, "WAITFORUPLOAD")
+                       req_line = req.gets
+                       if req_line.nil? or not req_line.strip.eql?("REGISTERCONTINUE") then 
+                               raise BuildServerException.new("ERR016"), req_line
+                       else
+                               @log.info "register file is received successfully"
+                       end
+
                        # create new job
                        @log.info "Received a request for uploading binaries : #{filename}"
                        new_job = create_new_upload_job( prj.name, filename, dock, dist_name, req )
@@ -849,6 +876,8 @@ class SocketJobRequestListener
                        # check reverse build
                        if no_reverse then new_job.set_no_reverse end
 
+                       @parent_server.jobmgr.commit_job(new_job)
+
                        # create logger and set
                        logger = new_job.create_logger(req)
 
@@ -867,6 +896,39 @@ class SocketJobRequestListener
        end
 
 
+       # "MONITOR"
+       def handle_cmd_monitor( line, req )
+               @log.info "Received REQ: #{line}"
+
+               begin
+                       handle_cmd_monitor_internal( line, req )
+               rescue BuildServerException => e
+                       @log.error(e.message)
+                       BuildCommServer.send(req, e.err_message())
+                       BuildCommServer.send_end(req)
+                       BuildCommServer.disconnect(req)
+               end
+
+               @log.info "Handled REQ: #{line}"
+       end
+
+
+       def handle_cmd_monitor_internal( line, req )
+               tok = line.split("|").map { |x| x.strip }
+               if tok.count < 2 then
+                       raise BuildServerException.new("ERR001"), line
+               end
+
+               case tok[1]
+               # MONITOR,SYSTEM
+               when "SYSTEM"
+                       @parent_server.accept_system_monitor(req)
+               else
+                       raise BuildServerException.new("ERR001"), line
+               end
+       end
+
+
        # "UPLOAD"
        def handle_cmd_upload( line, req )
                @log.info "Received File transfer REQ : #{line}"
index 386cb94..5774c31 100644 (file)
@@ -296,12 +296,18 @@ class Builder
                if not execute_build_command("build", src_path, build_root_dir, os, pkginfo.get_version) then
                        return false
                end
+
                # execute install script
                @log.info( "Make install...", Log::LV_USER)
                if not execute_build_command("install", src_path, build_root_dir, os, pkginfo.get_version) then
                        return false
                end
 
+               # check uncompressed directory size
+               if not check_uncompressed_size(pkginfo, os, src_path ) then
+                       return false
+               end
+
                # write pkginfo
                @log.info( "Generatiing pkginfo.manifest...", Log::LV_USER)
                if not write_pkginfo_files(pkginfo,os,src_path) then
@@ -744,4 +750,22 @@ VERSION=\"#{version}\" "
                # execute
                return execute_build_command("clean", src_path, build_root_dir, target_os, pkginfo.get_version)
        end
+
+       def check_uncompressed_size(pkginfo, os, src_path)
+
+               pkginfo.packages.each do |pkg|
+                       # skip if not support the target os
+                       if not pkg.os_list.include? os
+                               next
+                       end
+                       
+                       size = Utils.get_directory_size("#{src_path}/package/#{pkg.package_name}.package.#{os}")
+                       if not size.nil? then
+                               pkg.uncompressed_size = "#{size}"
+                       end
+               end
+
+               return true
+
+       end
 end
index f80a9e2..2f3817b 100644 (file)
@@ -39,7 +39,7 @@ require "FileTransferViaDirect"
 ATTEMPTS = ["first", "second", "third"]
 
 class BuildCommServer
-       VERSION = "1.7.0"
+       VERSION = "1.8.0"
 
        private_class_method :new
 
@@ -330,8 +330,8 @@ end
 
 
 class BuildCommClient
-       VERSION = "1.7.0"
-       FIRST_REPONSE_TIMEOUT = 120
+       VERSION = "1.8.0"
+       FIRST_RESPONSE_TIMEOUT = 120
 
        private_class_method :new
 
@@ -396,7 +396,7 @@ class BuildCommClient
 
                begin
                        l = nil
-                       timeout(FIRST_REPONSE_TIMEOUT) do
+                       timeout(FIRST_RESPONSE_TIMEOUT) do
                                l = @socket.gets()
                        end
 
@@ -432,12 +432,16 @@ class BuildCommClient
 
 
        # handle
-       def read_lines
+       def read_lines(begin_timeout = nil, data_timeout = nil)
 
                begin
                        # get first line
                        l = nil
-                       timeout(FIRST_REPONSE_TIMEOUT) do
+                       if begin_timeout.nil? then
+                               begin_timeout = FIRST_RESPONSE_TIMEOUT
+                       end
+
+                       timeout( begin_timeout ) do
                                l = @socket.gets()
                        end
 
@@ -454,7 +458,16 @@ class BuildCommClient
 
                        # get contents
                        result = true
-                       while line = @socket.gets()
+                       while true
+                               line = nil
+                               if not data_timeout.nil? then
+                                       timeout( data_timeout ) do
+                                               line = @socket.gets()
+                                       end
+                               else
+                                       line = @socket.gets()
+                               end
+                               if line.nil? then break end
                                if line.strip == "=END" then break end
                                if line.strip == "=CHK" then next end
 
@@ -480,7 +493,7 @@ class BuildCommClient
 
                begin
                        l = nil
-                       timeout(FIRST_REPONSE_TIMEOUT) do
+                       timeout(FIRST_RESPONSE_TIMEOUT) do
                                l = @socket.gets()
                        end
 
index d45f79e..744c6f6 100644 (file)
@@ -59,6 +59,9 @@ class FileTransferDirect
                        case cmd
                        when "SEND_REQ"
                                conn.puts "FILE_INFO,#{filename},#{size},#{checksum}"
+
+                               full_size = size
+                               old_progress = 0
                                # read file contents
                                # send via tcp/ip
                                File.open(src_file, "rb") do |io|
@@ -66,6 +69,12 @@ class FileTransferDirect
                                                buf = io.read(size > 1024*1024 ? 1024*1024 : size)
                                                conn.write( buf )
                                                size -= buf.length
+
+                                               progress = ((( full_size - size ) * 10 ) / full_size )
+                                               if not progress.eql? old_progress then
+                                                       @log.info "File transfer : #{progress}0 %"
+                                                       old_progress = progress
+                                               end
                                        end
                                end
 
index 7d7921d..d7cce79 100644 (file)
@@ -35,4 +35,7 @@ class Version < Array
        def compare x
                self <=> x
        end
+       def to_s
+               return self.join(".")
+       end
 end
diff --git a/src/common/db_utils.rb b/src/common/db_utils.rb
new file mode 100644 (file)
index 0000000..7606420
--- /dev/null
@@ -0,0 +1,64 @@
+=begin
+
+ db_utils.rb
+
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+
+Contact:
+Taejun Ha <taejun.ha@samsung.com>
+Jiil Hyoun <jiil.hyoun@samsung.com>
+Donghyuk Yang <donghyuk.yang@samsung.com>
+DongHee Yang <donghee.yang@samsung.com>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Contributors:
+- S-Core Co., Ltd
+=end
+
+class DBUtils
+       def DBUtils.dsn_parser (db_dsn)
+               dsn_hash={}
+               case db_dsn
+               when /^SQLite3:/ then 
+                       dsn_hash[:database] = "SQLite3"
+                       dsn = db_dsn.split(':')
+                       dsn_hash[:name] = dsn[1].strip
+               when /^Mysql:/ then
+                       dsn_hash[:database] = "Mysql"
+                       dsn = db_dsn.split(':')
+                       if dsn[2].nil? then
+                               dsn[1].split(';').each do |attr|
+                                       case attr.split('=')[0].strip
+                                       when /database/i then
+                                               dsn_hash[:name] = attr.split('=')[1].strip
+                                       when /host/i then
+                                               dsn_hash[:host] = attr.split('=')[1].strip
+                                       when /port/i then
+                                               dsn_hash[:port] = attr.split('=')[1].strip
+                                       when /socket/i then
+                                               dsn_hash[:socket] = attr.split('=')[1].strip
+                                       when /flag/i then
+                                               dsn_hash[:flag] = attr.split('=')[1].strip
+                                       else
+                                               dsn_hash[:etc] = attr.split('=')[1].strip
+                                       end
+                               end
+                       else
+                               dsn_hash[:name] = dsn[1].strip
+                               dsn_hash[:host] = dsn[2].strip
+                       end
+               end
+               return dsn_hash
+       end
+end
index 893885f..3ea5ef4 100644 (file)
@@ -96,7 +96,6 @@ class Log
                @cnt = @cnt + 1
        end
 
-
        def close
                @second_out= nil
        end
index a7c139f..b05b3c8 100644 (file)
@@ -27,11 +27,11 @@ Contributors:
 =end
 
 class Package
-       attr_accessor :package_name, :label, :version, :os, :build_host_os, :maintainer, :attribute, :install_dep_list, :build_dep_list, :source_dep_list, :conflicts, :source, :src_path, :path, :origin, :checksum, :size, :description, :os_list, :custom, :change_log
+       attr_accessor :package_name, :label, :os, :build_host_os, :maintainer, :attribute, :install_dep_list, :build_dep_list, :source_dep_list, :conflicts, :source, :src_path, :path, :origin, :checksum, :size, :uncompressed_size, :description, :os_list, :custom, :change_log
        def initialize (package_name)
                @package_name = package_name
                @label = ""
-               @version = ""
+               @version = nil
                @os = ""
                @os_list = []
                @build_host_os = []
@@ -47,6 +47,7 @@ class Package
                @origin = ""
                @checksum = ""
                @size = ""
+               @uncompressed_size = ""
                @description = ""
                @custom = ""
                @change_log = {}
@@ -56,10 +57,18 @@ class Package
                puts self.to_s
        end
 
+       def version
+               return @version.to_s
+       end
+
+       def version= (str)
+               @version = Version.new(str)
+       end
+
        def to_s
                string =  "Package : " + @package_name
                if not @label.empty? then string = string + "\n" +  "Label : " + @label end
-               if not @version.empty? then string = string + "\n" +  "Version : " + @version end
+               if not @version.nil? then string = string + "\n" +  "Version : " + @version.to_s end
                if not @os_list.empty? then string = string + "\n" + "OS : " + @os_list.join(", ") end
                if not @build_host_os.empty? then string = string + "\n" + "Build-host-os : " + @build_host_os.join(", ") end
                if not @maintainer.empty? then string = string + "\n" + "Maintainer : " + @maintainer end
@@ -82,6 +91,7 @@ class Package
                if not @origin.empty? then string = string + "\n" + "Origin : " + @origin end
                if not @checksum.empty? then string = string + "\n" + "SHA256 : " + @checksum end
                if not @size.empty? then string = string + "\n" + "Size : " + @size end
+               if not @uncompressed_size.empty? then string = string + "\n" + "Uncompressed-size : " + @uncompressed_size end
                if not @custom.empty? then string = string + "\n" + @custom end
                if not @description.empty? then string = string + "\n" + "Description : " + @description end
                return string
@@ -96,7 +106,7 @@ class Package
 
                string = ""
                @change_log.sort.each do |list|
-                       string = "* " + list[0] + "\n" + list[1] + "\n" + string
+                       string = "* " + list[0].to_s + "\n" + list[1] + "\n" + string
                end
                return "#Change log\n" + string
        end
index 87949e0..58f4b4a 100644 (file)
@@ -86,7 +86,7 @@ class Parser
                                        when /^\*[ \t]*([0-9][0-9]*.[0-9][0-9]*.[0-9][0-9]*)[ \t]*$/ then
                                                state = "CHANGELOG"
                                                change_log[change_version] = change_contents.strip if not change_version.nil?
-                                               change_version = $1
+                                               change_version = Version.new($1)
                                                change_contents = ""
                                        when /^Include$/i then
                                                pfile = File.dirname(file) + "/" + l.sub(/^[ \t]*Include[ \t]*:[ \t]*/i,"").strip
@@ -193,6 +193,9 @@ class Parser
                                        when /^Size$/i then
                                                package.size = l.sub(/^[ \t]*Size[ \t]*:[ \t]*/i,"").strip
                                                multi_line = nil
+                                       when /^Uncompressed-size$/i then
+                                               package.uncompressed_size = l.sub(/^[ \t]*Uncompressed-size[ \t]*:[ \t]*/i,"").strip
+                                               multi_line = nil
                                        when /^Description$/i then
                                                package.description = l.sub(/^[ \t]*Description[ \t]*:[ \t]*/i,"").strip
                                                multi_line = "Description"
@@ -228,7 +231,7 @@ class Parser
                                                        else raise RuntimeError, "change log version is duplicated in \"#{file}\" file \n\t#{l}"
                                                        end
                                                end
-                                               change_version = $1
+                                               change_version = Version.new($1)
                                                change_contents = ""
                                        else
                                                change_contents = change_contents + "\n" + l.rstrip
@@ -241,7 +244,7 @@ class Parser
                        if not package.nil? then pkglist.push package end
                        if not change_version.nil? then
                                if change_log[change_version].nil? then change_log[change_version] = change_contents.strip
-                               else raise RuntimeError, "change log version is duplicated in \"#{file}\" file \n\t#{change_version}"
+                               else raise RuntimeError, "change log version is duplicated in \"#{file}\" file \n\t#{change_version.to_s}"
                                end
                        end
                        pkglist.each {|pkg| pkg.change_log = change_log }
index abae33c..e7804dd 100644 (file)
@@ -26,6 +26,7 @@ Contributors:
 - S-Core Co., Ltd
 =end
 require 'rbconfig'
+require 'find'
 
 class Utils
        STARTUP_INFO_SIZE = 68
@@ -624,6 +625,42 @@ class Utils
        end
 
 
+       def Utils.get_sub_files_info(path_list) # return [PATH,size,ctime,mtime] list
+               list = []
+               path_list.each do |path|
+                       Find.find(path) do |dep_path|
+                               if (File.exist?(dep_path) and not File.directory? dep_path)
+                                       fsize = File.size(dep_path)
+                                       ctime = File.new(dep_path).ctime
+                                       mtime = File.new(dep_path).mtime
+                                       list.push [dep_path,fsize,ctime,mtime]
+                               end
+                       end
+               end
+               return list
+       end
+
+
+       def Utils.get_directory_size(path)
+
+               os_category = get_os_category(HOST_OS)
+               if os_category == "macos" then
+                       cmd = "du -sk \"#{path}\""
+                       ret = Utils.execute_shell_return(cmd);
+                       if not ret.nil? and not ret[0].nil? then
+                               return ret[0].split(" ")[0].to_i * 1024
+                       end
+               else
+                       cmd = "du --block-size=1 -s \"#{path}\""
+                       ret = Utils.execute_shell_return(cmd);
+                       if not ret.nil? and not ret[0].nil? then
+                               return ret[0].split(" ")[0].to_i
+                       end
+               end
+
+               return nil
+       end
+
 
        if defined?(HOST_OS).nil? then
                HOST_OS = Utils.identify_current_OS()
index 9982274..14ac7a3 100644 (file)
@@ -163,19 +163,20 @@ class SocketRegisterListener
                BuildCommServer.send_begin(req)
 
                tok = line.split("|").map { |x| x.strip }
-               if tok.count < 3 then
+               if tok.count < 4 then
                        @log.error "Received Wrong REQ : #{line}"
                        BuildCommServer.send(req, "ERROR|Invalid REQ format")
                        return
                end
                dist_name = tok[1].strip
+               password = tok[2].strip
 
-               if tok[2].start_with? "DOCK" then
-                       dock_name = tok[3]
-                       idx = 4
+               if tok[3].start_with? "DOCK" then
+                       dock_name = tok[4]
+                       idx = 5
                else
                        dock_name = ""
-                       idx = 2
+                       idx = 3
                end
 
                file_path_list = []
@@ -188,6 +189,28 @@ class SocketRegisterListener
                        end
                        idx = idx + 1
                end
+               # password check 
+               if @parent_server.passwd.eql? password then
+                       @log.info "Register command password check pass"
+               else
+                       @log.error "Received register command, but passwd mismatched : [#{password}]"
+                       BuildCommServer.send(req,"ERROR|Password mismatched!")
+                       BuildCommServer.send_end(req)
+                       BuildCommServer.disconnect(req)
+                       return 
+               end
+
+               BuildCommServer.send(req, "WAITFORUPLOAD")
+               req_line = req.gets
+               if req_line.nil? or not req_line.strip.eql?("REGISTERCONTINUE") then 
+                       BuildCommServer.send(req,"ERROR|Invalid message received : [#{req_line}]")
+                       BuildCommServer.send_end(req)
+                       BuildCommServer.disconnect(req)
+                       return 
+               else
+                       @log.info "register file is received successfully"
+               end
+
                # register mutex
                $register_mutex.synchronize do
                        begin
@@ -230,7 +253,7 @@ class SocketRegisterListener
                        @log.info "Package server stop flag set"
                        BuildCommServer.send(req,"SUCC")
                else
-                       @log.info "Received stop command, but passwd mismatched : #{passwd}"
+                       @log.error "Received stop command, but passwd mismatched : #{passwd}"
                        BuildCommServer.send(req,"ERROR|Password mismatched!")
                end
                BuildCommServer.send_end(req)
index a3e3815..b864fe9 100644 (file)
@@ -43,11 +43,12 @@ require "Version"
 require "BuildComm"
 require "FileTransferViaFTP"
 require "FileTransferViaDirect"
+require 'digest'
 
 
 $update_mutex = Mutex.new
 $get_snapshot_mutex = Mutex.new
-$filemove_mutex = Mutex.new
+$cache_mutex = Mutex.new
 class Client
 
        # constant
@@ -56,7 +57,7 @@ class Client
        CONFIG_PATH = "#{PackageServerConfig::CONFIG_ROOT}/client"
        PACKAGE_INFO_DIR = ".info"
        DEFAULT_INSTALL_DIR = "#{Utils::HOME}/build_root"
-       DEFAULT_SERVER_ADDR = "http://172.21.17.55/dibs/unstable"
+       #DEFAULT_SERVER_ADDR = "http://172.21.17.55/dibs/unstable"
        OS_INFO_FILE = "os_info"
        ARCHIVE_PKG_LIST_FILE = "archive_pkg_list"
 
@@ -67,7 +68,7 @@ class Client
        # create "remote package hash" and "installed package hash"
        # @server_addr = server address (can be included distribution, snapshot)
        # @location = client location (download and install file to this location)
-       def initialize(server_addr, location, logger)
+       def initialize(server_addr, location, logger, access_svr = true)
 
                # set log
                if logger.nil? or logger.class.to_s.eql? "String" then
@@ -78,56 +79,130 @@ class Client
 
                # create directory
                if not File.exist? CONFIG_PATH then FileUtils.mkdir_p "#{CONFIG_PATH}" end
-
-               # set default server address, location
-               if server_addr.nil? then server_addr = get_default_server_addr() end
+               # set location
                if location.nil? then location = get_default_inst_dir() end
 
-               # chop server address, if end with "/"
-               if server_addr.strip.end_with? "/" then server_addr = server_addr.chop end
-
+               @location = location
                @snapshot_path = nil
                @snapshot_url = false
-
-               if is_snapshot_url(server_addr) then
-                       @snapshot_url = true
-                       @server_addr, @snapshot_path = split_addr_and_snapshot(server_addr)
-               else
-                       @server_addr = server_addr
-               end
-
-               @location = location
                @pkg_hash_os = {}
                @installed_pkg_hash_loc = {}
                @archive_pkg_list = []
                @all_dep_list = []
-               @is_server_remote = Utils.is_url_remote(server_addr)
                @support_os_list = []
-               @config_dist_path = CONFIG_PATH + "/" + get_flat_serveraddr
-               @download_path = @config_dist_path + "/downloads"
-               @tmp_path = @config_dist_path + "/tmp"
-               @snapshots_path = @config_dist_path + "/snapshots"
+               @server_addr = nil
 
-               # create directory
-               if not File.exist? @config_dist_path then FileUtils.mkdir_p "#{@config_dist_path}" end
-               if not File.exist? @download_path then FileUtils.mkdir_p "#{@download_path}" end
-               if not File.exist? @snapshots_path then FileUtils.mkdir_p "#{@snapshots_path}" end
-               if not File.exist? @tmp_path then FileUtils.mkdir_p "#{@tmp_path}" end
+
+               # if client should access remote server, set server information
+               if access_svr then
+                       if not server_addr.nil? then
+                               # chop server address, if end with "/"
+                               if server_addr.strip.end_with? "/" then server_addr = server_addr.chop end
+
+                               if is_snapshot_url(server_addr) then
+                                       @snapshot_url = true
+                                       @server_addr, @snapshot_path = split_addr_and_snapshot(server_addr)
+                               else
+                                       @server_addr = server_addr
+                               end
+                               @is_server_remote = Utils.is_url_remote(server_addr)
+                               @config_dist_path = CONFIG_PATH + "/" + get_flat_serveraddr
+                               @download_path = @config_dist_path + "/downloads"
+                               @tmp_path = @config_dist_path + "/tmp"
+                               @snapshots_path = @config_dist_path + "/snapshots"
+       
+                               # create directory
+                               if not File.exist? @config_dist_path then FileUtils.mkdir_p "#{@config_dist_path}" end
+                               if not File.exist? @download_path then FileUtils.mkdir_p "#{@download_path}" end
+                               if not File.exist? @snapshots_path then FileUtils.mkdir_p "#{@snapshots_path}" end
+                               if not File.exist? @tmp_path then FileUtils.mkdir_p "#{@tmp_path}" end
+                       end             
+
+                       # read remote pkg list, and hash list
+                       @log.info "Update remote package list and supported os list.."
+                       if update() then 
+                               @log.info "Initialize - #{server_addr}, #{location}" 
+                       else 
+                               @log.error "Failed to update remote package list."                                      
+                       end
+               end
 
                # read installed pkg list, and create hash
                if not File.exist? @location then FileUtils.mkdir_p "#{@location}" end
                @log.info "Update local package list.. [#{@location}]"
                read_installed_pkg_list()
 
-               # read remote pkg list, and hash list
-               @log.info "Update remote package list and supported os list.."
-               update()
-               @log.info "Initialize - #{server_addr}, #{location}"
+               @configs = {}
+               #default cache size = 4G
+               @configs[:CACHE_SIZE] = "4000"
+       end
+
+
+       # make cache clean
+       private
+       def remove_old_files_in_cache
+               #get dir info
+               cache_list = get_cache_dir_list
+               cache_info_list = Utils.get_sub_files_info(cache_list).sort {|a,b| a[3] <=> b[3]} # [path,size,ctime,mtime]
+               cache_size = 0
+               cache_info_list.each {|file| cache_size += file[1]}
+
+               read_configs
+               max_cache_size = get_config_max_cache_size
+
+               extra_size = cache_size - max_cache_size
+
+               if extra_size < 0 then return end
+
+               remove_list = []
+               while extra_size > 0 do
+                       old_package = cache_info_list.shift
+                       remove_list.push old_package[0]
+                       extra_size -= old_package[1]
+               end
+
+               if not remove_list.empty? then
+                       @log.info "Removed oldest package files.. (Now not fully caching)"
+                       @log.info "  * #{remove_list.map{|path| File.basename(path)}.join(", ")}"
+                       $cache_mutex.synchronize do
+                               FileUtils.rm_rf remove_list
+                       end
+               end
        end
 
+       private
+       def get_cache_dir_list
+               return Dir.entries(CONFIG_PATH).select{|dir| not dir.start_with? "." and File.directory? CONFIG_PATH + "/#{dir}/downloads" }.map{|dir| CONFIG_PATH + "/#{dir}/downloads"}
+       end
+
+       private
+       def get_config_max_cache_size
+               return (@configs[:CACHE_SIZE] =~ /^([0-9][0-9]*)$/i)?  ($1.to_i * 1024 * 1024)  :  (4 * 1024 * 1024 * 1024) #default size 4G : unit = MB
+       end
+
+       private
+       def read_configs
+               file_path = CONFIG_PATH + "/config"
+               if not File.exist? file_path then return end
+
+               File.open file_path, "r" do |f|
+                       f.each_line do |l|
+                               row = l.split(":")
+                               @configs[row[0].strip.to_sym] = row[1..-1].join(":").strip
+                       end
+               end
+       end
+
+
        public
        # update package list from server
        def update()
+
+               if @server_addr.nil? then
+                       @log.warn "Server address is null"
+                       return false
+               end                             
+
                if not @snapshot_url then
                        $get_snapshot_mutex.synchronize do
                                @snapshot_path = get_lastest_snapshot(@is_server_remote)
@@ -135,7 +210,7 @@ class Client
                end
                @log.info "The lastest snapshot : #{@snapshot_path}"
                if @snapshot_path.nil? then
-                       @log.warn "Failed to get the lastest package list"
+                       @log.warn "Failed to get the lastest package list."
                        @snapshot_path = ""
                end
 
@@ -144,12 +219,12 @@ class Client
                        @log.info "Snapshot information is already cached [#{get_pkglist_path()}]"
                        exists_snapshot = true
                else
-                       @log.info "Snapshot information is not cached"
+                       @log.info "Snapshot information is not cached."
                end
 
                list_path = get_pkglist_path()
                if list_path.nil? then
-                       @log.error "Failed to get package list path"
+                       @log.error "Failed to get package list path."
                        return false
                end
 
@@ -188,10 +263,7 @@ class Client
                        end
                end
 
-               $update_mutex.synchronize do
-                       create_default_config(@server_addr)
-                       @log.info "Update package list from \"#{@server_addr}\".. OK"
-               end
+               @log.info "Update package list from \"#{@server_addr}\".. OK"
 
                return true
        end
@@ -233,19 +305,31 @@ class Client
                        pkg_checksum = get_attr_from_pkg(p, os, "checksum")
                        pkg_size = get_attr_from_pkg(p, os, "size")
                        if pkg_path.nil? or pkg_ver.nil? then
-                               @log.error "\"#{p}\" package does not exist in package server. If it exist in package server, then try \"pkg-cli update\""
+                               @log.error "\"#{p}\" package does not exist in package server. Check if it exist in package server"
                                return nil
                        end
                        url = surl + pkg_path
-                       filename = pkg_path.split('/')[-1]
+                       filename = File.basename pkg_path
 
-                       if not FileDownLoader.download(url, loc, @log) then
-                               @log.error "File Download Failed!!"
-                               @log.error "* #{url} -> #{loc}"
-                               return nil
-                       end
+                       file_path = get_file_from_cache(filename, pkg_checksum, pkg_size, loc)
+                       if file_path.nil? then
 
-                       file_path = File.join(loc, filename)
+                               if not FileDownLoader.download(url, loc, @log) then
+                                       @log.error "File Download Failed!!"
+                                       @log.error "* #{url} -> #{loc}"
+                                       return nil
+                               end
+
+                               file_path = File.join(loc, filename)
+                               if validatePkgFile(file_path, pkg_checksum, pkg_size) then
+                                       add_file_to_cache(file_path)
+                               else
+                                       @log.error "File Validation Failed!!"
+                                       return nil                                              
+                               end                                             
+                       else
+                               @log.info "Cached #{pkg_name} package file.. OK"
+                       end
                        file_local_path.push(file_path)
                end
 
@@ -258,40 +342,52 @@ class Client
        end
 
        private
-       def remove_downloaded_pkgs(pkg_name, os)
-               pkg_file_prefix = "#{@download_path}/#{pkg_name}_*_#{os}.zip"
-               pkg_files = Dir[pkg_file_prefix].sort_by { |f| File.mtime(f) }.reverse
+       def validatePkgFile(filepath, orig_checksum, orig_size)
+               checksum = Digest::SHA256.file(filepath).hexdigest
+               size = File.size filepath
+               if checksum.to_s.eql? orig_checksum and size.to_s.eql? orig_size then
+                       return true
+               else
+                       return false                            
+               end                             
+       end     
 
-               if not pkg_files.nil? and pkg_files.length >= 4 then
-                       Utils.execute_shell("rm -rf #{pkg_files[3..-1].join(" ")}")
-                       @log.info "Removed old package files.."
-                       @log.info "  * #{pkg_files[3..-1].join(", ")}"
+       private
+       def get_file_from_cache(filename, pkg_checksum, pkg_size, location)
+               downloaded_file_path = nil
+               $cache_mutex.synchronize do
+                       cached_filepath = get_cached_filepath(filename, pkg_checksum, pkg_size)
+                       if not cached_filepath.nil? then
+                               FileUtils.cp(cached_filepath, location)
+                               downloaded_file_path = File.join(location, File.basename(cached_filepath))
+                       end
                end
+               if not downloaded_file_path.nil? and not File.exist? downloaded_file_path then
+                       downloaded_file_path = nil
+               end
+               return downloaded_file_path
        end
 
        private
-       def move_downloaded_pkg(filepath, distpath)
-               if filepath.nil? or filepath == "" then return nil end
-               filename = filepath.split('/')[-1]
-               if not File.exist? distpath then FileUtils.mkdir_p "#{distpath}" end
-               distfile = File.join(distpath, filename)
+       def add_file_to_cache(filepath)
+               if filepath.nil? or filepath.empty? then return end
+               if not File.exist? @download_path then FileUtils.mkdir_p "#{download_path}" end
+
+               filename = File.basename(filepath)
+               cachefile = File.join(@download_path, filename)
+
                @log.info "Moving \"#{filename}\" to download cache directory"
-               @log.info "  [path: #{distpath}]"
-               $filemove_mutex.synchronize do
-                       if not File.exist? distfile then
-                               Utils.execute_shell("mv #{filepath} #{distfile}")
-                       else
-                               Utils.execute_shell("rm -f #{filepath}")
-                               return distfile
-                       end
+               @log.info "  [path: #{@download_path}]"
+
+               if not File.exist? cachefile then
+                       FileUtils.cp(filepath, @download_path)
                end
 
-               if File.exist? distfile then return distfile
-               else
-                       @log.info "Failed to move [#{filenamae}] to "
-                       @log.info "  [#{distpath}]"
-                       return nil
+               if not File.exist? cachefile then
+                       @log.info "Failed to move [#{filename}] to "
+                       @log.info "  [#{download_path}]"
                end
+               remove_old_files_in_cache
        end
 
        private
@@ -308,13 +404,13 @@ class Client
 
        private
        def get_cached_filepath(pkg_filename, pkg_checksum, pkg_size)
-
                cached_filepath = "#{@download_path}/#{pkg_filename}"
                if File.exist? cached_filepath then
-                       checksum = `sha256sum #{cached_filepath}`.split(" ")[0]
-                       size = `du -b #{cached_filepath}`.split[0].strip
-                       if checksum.eql? pkg_checksum and size.eql? pkg_size then
+                       if validatePkgFile(cached_filepath, pkg_checksum, pkg_size) then
+                               FileUtils.touch cached_filepath                                 
                                return cached_filepath
+                       else
+                               return nil
                        end
                end
                return nil
@@ -336,9 +432,30 @@ class Client
                return file_local_path
        end
 
+       private
+       def upload_request(ip, port, dock, transporter, binary_path_list)
+               binary_path_list.each do |bpath|
+                       client2 = BuildCommClient.create(ip, port, @log)
+                       begin
+                               if client2.nil? then
+                                       raise RuntimeError, "Failed to create BuildCommClient instance.."
+                               end
+                
+                               @log.info "Send UPLOAD REQ..  [UPLOAD|#{dock}]"
+                               result = client2.send("UPLOAD|#{dock}")
+                               if not result then
+                                       raise RuntimeError, "Failed to send ready REQ.."
+                               end
+                               result = client2.send_file(bpath, transporter)
+                       ensure
+                               client2.terminate
+                       end
+               end
+       end
+
        public
        # upload package
-       def upload(ip, port, binary_path_list, ftp_addr=nil, ftp_port=nil, ftp_username=nil, ftp_passwd=nil)
+       def upload(ip, port, binary_path_list, ftp_addr=nil, ftp_port=nil, ftp_username=nil, ftp_passwd=nil, password="")
 
                # check ip and port
                if ip.nil? or port.nil? then
@@ -352,88 +469,89 @@ class Client
                        return nil
                end
 
-               # create unique dock number
-               dock = Utils.create_uniq_name()
-
-               # upload file
-               binary_list = []
-               binary_path_list.each do |bpath|
-                       filename = File.basename(bpath)
-                       client = BuildCommClient.create(ip, port, @log)
-
-                       if client.nil? then
-                               @log.error "Failed to create BuildCommClient instance.."
-                               return nil
-                       end
-
-                       @log.info "Send ready REQ..  [UPLOAD]"
-                       result = client.send("UPLOAD|#{dock}")
-                       if not result then
-                               @log.error "Failed to send ready REQ.."
-                               return nil
-                       end
-
-                       begin
-                               if not ftp_addr.nil? then
-                                       transporter=FileTransferFTP.new(@log, ftp_addr, ftp_port, ftp_username, ftp_passwd)
-                               else
-                                       transporter=FileTransferDirect.new(@log)
-                               end
-
-                               result = client.send_file(bpath, transporter)
-                       rescue => e
-                               @log.error "FTP failed to put file (exception)"
-                               @log.error "#{e.message}"
-                               @log.error e.backtrace.inspect
-                               return nil
+               begin
+                       if not ftp_addr.nil? then
+                               transporter=FileTransferFTP.new(@log, ftp_addr, ftp_port, ftp_username, ftp_passwd)
+                       else
+                               transporter=FileTransferDirect.new(@log)
                        end
-
-                       if not result then
-                               @log.error "FTP failed to put file (result is false)"
+               rescue => e
+                       @log.error "FTP failed to put file (exception)"
+                       @log.error "#{e.message}"
+                       @log.error e.backtrace.inspect
+                       return nil
+               end
+                       
+               binary_list = []
+               binary_path_list.each do |binary_path|
+                       if File.exist? binary_path then
+                               binary_list.push(File.basename(binary_path))
+                       else
+                               @log.error "Binary file does not exist"
                                return nil
                        end
+               end
 
-                       client.terminate
-                       binary_list.push(filename)
+               client = BuildCommClient.create(ip, port, @log)
+               if client.nil? then
+                       @log.error "Can't access server #{ip}:#{port}"
+                       return nil
                end
 
-               # register file
-               if not binary_list.empty? then
-                       client = BuildCommClient.create(ip, port, @log)
+               begin
+                       # create unique dock number
+                       dock = Utils.create_uniq_name()
+                       
                        dist = get_distribution
                        if dist.empty? then
                                @log.error "Distribution is empty.."
                                return nil
                        end
 
-                       @log.info "Send register message..  [REGISTER|#{dist}|DOCK|#{dock}|#{binary_list.join("|")}]"
+                       @log.info "Send register message..  [REGISTER|#{dist}|#{password}|DOCK|#{dock}|#{binary_list.join("|")}]"
                        snapshot = nil
-                       if client.send "REGISTER|#{dist}|DOCK|#{dock}|#{binary_list.join("|")}" then
-                               result = client.read_lines do |l|
-                                       line = l.split("|")
-                                       if line[0].strip == "ERROR" then
-                                               @log.error l.strip
-                                               break
-                                       elsif line[0].strip == "SUCC" then
-                                               snapshot = line[1].strip
-                                       end
-                               end
 
-                               if not result or snapshot.nil? then
-                                       @log.error "Failed to register! #{client.get_error_msg()}"
+                       client.send "REGISTER|#{dist}|#{password}|DOCK|#{dock}|#{binary_list.join("|")}" 
+
+                       client.read_lines do |line|
+                               if line.eql?("WAITFORUPLOAD") then
+                                       # upload
+                                       @log.info "Get WAITFORUPLOAD message"
+                                       thread = Thread.new do
+                                               begin 
+                                                       upload_request(ip, port, dock, transporter, binary_path_list)
+                                               rescue => e
+                                                       puts "Transfering file failed!"
+                                                       puts e.message
+                                               end
+                                       end
+            
+                                       thread.join
+                                       client.send("REGISTERCONTINUE")
+                               elsif line.start_with? "SUCC" then
+                                       snapshot = line.split("|")[1]
+                               elsif line.start_with? "ERROR" then
+                                       @log.error line.strip
                                        return nil
+                               else
+                                       @log.error "Unknown message received : #{l}"
                                end
                        end
-
+               ensure
                        client.terminate
+               end
+
+               if not snapshot.nil? and not snapshot.empty? then
                        snapshot = @server_addr + "/snapshots/" + snapshot
                        @log.info "Registered successfully!  [#{binary_path_list.join("|")}]"
                        if snapshot.empty? then
                                @log.error "Failed to generate snapshot"
                        end
+            
+                       return snapshot
+               else
+                       return nil
                end
-
-               return snapshot
        end
 
        private
@@ -619,8 +737,8 @@ class Client
        private
        def install_local_pkg_internal(pkg_path, trace, force, repos_paths)
 
-               file_name = File.basename(pkg_path)
-               pkg_name = file_name.split('_')[0]
+               pkg_name = Utils.get_package_name_from_package_file( pkg_path )
+               pkg_os = Utils.get_os_from_package_file( pkg_path )
 
                if not File.exist? pkg_path then
                        @log.error "\"#{pkg_path}\" file does not exist"
@@ -629,7 +747,7 @@ class Client
                filename = File.basename(pkg_path)
                ext = File.extname(filename)
                if not ext.eql? ".zip" then
-                       @log.error "\"#{file_name}\" is not zip file. binary package file should have .zip ext"
+                       @log.error "\"#{filename}\" is not zip file. binary package file should have .zip ext"
                        return false
                end
                pkg_name = filename.split("_")[0]
@@ -646,6 +764,7 @@ class Client
                        manifest_path = File.join(path, manifest_file)
                        pkg = Parser.read_single_pkginfo_from manifest_path
                        new_pkg_ver = pkg.version
+                       pkg_conflicts = pkg.conflicts
                        FileUtils.remove_dir(path, true)
                rescue Interrupt
                        @log.error "Client: Interrupted.."
@@ -676,9 +795,16 @@ class Client
                        uninstall(pkg_name, false)
                end
 
+               # TODO: Resolve conflicts
+               if not resolve_conflicts_internal(pkg_conflicts) then
+                       @log.error "Failed to resolve conflicts [#{pkg_name}]"
+                       return false
+               end             
+
+
                if trace then
                        install_dep_pkgs = pkg.install_dep_list
-                       new_pkg_os = pkg.os
+                       new_pkg_os = pkg_os
                        install_dep_pkgs.each do |p|
                                # check local path first
                                if not repos_paths.nil? then
@@ -760,7 +886,7 @@ class Client
                remote_pkg_hash = pkg_hash_os[os]
 
                if remote_pkg_hash.nil? then
-                       @log.error "There is no remote package list for #{os}. please pkg-cli update"
+                       @log.error "There is no remote package list for #{os}."
                        return nil
                end
 
@@ -789,52 +915,11 @@ class Client
        end
 
        public
-       def get_default_server_addr()
-               filepath = "#{CONFIG_PATH}/config"
-               server_addr = nil
-
-               if not File.exist? filepath then create_default_config(nil) end
-               if not File.exist? filepath then
-                       @log.error "There is no default server address in #{filepath}"
-                       return nil
-               end
-
-               File.open filepath, "r" do |f|
-                       f.each_line do |l|
-                               if l.strip.start_with? "DEFAULT_SERVER_ADDR :" then
-                                       server_addr = l.split("DEFAULT_SERVER_ADDR :")[1].strip
-                                       break
-                               else next end
-                       end
-               end
-
-               if server_addr.nil? then create_default_config(DEFAULT_SERVER_ADDR) end
-               return server_addr
-       end
-
-       public
        # get default path for installing
        def get_default_inst_dir()
                return Dir.pwd
        end
 
-       private
-       # create default config file (Utils::HOME/.build_tools/client/config)
-       def create_default_config(server_addr)
-               filepath = "#{CONFIG_PATH}/config"
-               if server_addr.nil? then server_addr = DEFAULT_SERVER_ADDR end
-
-               if File.exist? filepath then
-                       FileUtils.rm_f(filepath)
-               end
-
-               if server_addr.strip.end_with? "/" then server_addr = server_addr.chop end
-
-               File.open(filepath, "a+") do |file|
-                       file.puts "DEFAULT_SERVER_ADDR : #{server_addr}"
-               end
-       end
-
        public
        # uninstall package
        # trace : if true, uninstall all dependent packages
@@ -1172,6 +1257,7 @@ class Client
                when "attribute" then return pkg.attribute
                when "checksum" then return pkg.checksum
                when "size" then return pkg.size
+               when "conflicts" then return pkg.conflicts                              
 
                end
        end
@@ -1349,6 +1435,28 @@ class Client
        end
 
        private
+       def resolve_conflicts_internal(conflicts_pkgs)
+               if conflicts_pkgs.nil? then return true end                     
+               conflicts_pkgs.each do |pkg|
+                       if check_installed_pkg(pkg.package_name) then                           
+                               if not uninstall(pkg.package_name, true) then
+                                       @log.error "Failed to uninstall [#{pkg.package_name}] package for resolving"                                    
+                                       return false
+                               else
+                                       @log.info "Resolved conflict package [#{pkg.package_name}]"                                     
+                               end
+                       end                             
+               end     
+               return true
+       end                     
+
+       private
+       def resolve_conflicts(pkg_name, os)
+               conflicts = get_attr_from_pkg(pkg_name, os, "conflicts")
+               return resolve_conflicts_internal(conflicts)
+       end     
+
+       private
        # install a package to @location after uninstalling and downloading
        def install_pkg(pkg_name, os, force)
 
@@ -1364,10 +1472,6 @@ class Client
                # below code should be changed
                type = path.split('/')[-2]
                new_pkg_ver = get_attr_from_pkg(pkg_name, os, "version")
-               pkg_checksum = get_attr_from_pkg(pkg_name, os, "checksum")
-               pkg_size = get_attr_from_pkg(pkg_name, os, "size")
-               pkg_path = get_attr_from_pkg(pkg_name, os, "path")
-               filename = pkg_path.split('/')[-1]
 
                # compare version with installed package versiona
                compare_result = compare_version_with_installed_pkg(pkg_name, new_pkg_ver)
@@ -1390,26 +1494,25 @@ class Client
                        end
                end
 
-               # install package
-               cached_filepath = nil
-               if Utils.is_linux_like_os( Utils::HOST_OS ) then
-                       cached_filepath = get_cached_filepath(filename, pkg_checksum, pkg_size)
+               # resolve conflict packages
+               if not resolve_conflicts(pkg_name, os) then
+                       @log.error "Failed to resolve conflicts [#{pkg_name}]"
+                       return false
                end
-               if not cached_filepath.nil? then
-                       @log.info "Cached #{pkg_name} package file.. OK"
-                       ret = FileInstaller.install(pkg_name, cached_filepath, type, @location, @log)
-               else
-                       filepath = download(pkg_name, os, false, @tmp_path)
-                       if filepath.nil? then
-                               return false
-                       end
-                       filepath = move_downloaded_pkg(filepath[0], @download_path)
-                       if filepath.nil? then
-                               return false
-                       end
-                       ret = FileInstaller.install(pkg_name, filepath, type, @location, @log)
-                       remove_downloaded_pkgs(pkg_name, os)
+
+               # install package
+               #download
+               tmp_location = File.join(@tmp_path,Utils.create_uniq_name)
+               filepath = download(pkg_name, os, false, tmp_location)
+               if filepath.nil? or filepath[0].nil? then
+                       return false
                end
+
+               #install
+               ret = FileInstaller.install(pkg_name, filepath[0], type, @location, @log)
+
+               #remove garbage
+               FileUtils.rm_rf tmp_location
                return ret
        end
 
@@ -1737,4 +1840,31 @@ class Client
                if attr[0].strip.upcase.eql? "META" then return true
                else return false end
        end
+
+       public
+       def register(address, distribution, pkg_file_path, password)
+               # check file exist
+               if not File.exist? pkg_file_path then
+                       puts "The file does not exist!.. #{pkg_file_path}"
+                       return false
+               end
+    
+               result = Utils.parse_server_addr(address)
+               if result.nil? then
+                       puts "Server address is incorrect. (#{address})"
+                       puts "Tune as following format."
+                       puts " <ip>:<port>"
+                       exit 1
+               end
+               bs_ip = result[0]
+               bs_port = result[1]
+
+               pkg_file_path_list = []
+               pkg_file_path_list.push(pkg_file_path)
+               # set distribution
+               @server_addr = distribution
+               ret = upload(bs_ip, bs_port, pkg_file_path_list, nil, nil, nil, nil, password)
+
+               if ret then @log.info "Snapshot is generated : #{ret}" end
+       end
 end
index fff8924..dd5caa8 100644 (file)
@@ -40,27 +40,33 @@ def option_error_check( options )
 
        case options[:cmd]
 
-       when "update" then
-
        when "clean" then
 
        when "upgrade" then
+               if options[:url].nil? or options[:url].empty? then
+                       raise ArgumentError, "Usage: pkg-cli upgrade -u <package server url> [-l <location>] [-o <os>] [--trace]"                               
+               end                             
 
        when "check-upgrade" then
-
+               if options[:url].nil? or options[:url].empty? then
+                       raise ArgumentError, "Usage: pkg-cli check-upgrade -u <package server url> [-l <location>] [-o <os>]"                           
+               end
+               
        when "download" then
-               if options[:pkg].nil? or options[:pkg].empty? then
-                       raise ArgumentError, "Usage: pkg-cli download -P <package name> [-o <os>] [-l <location>] [-u <package server url>] [--trace]"
+               if options[:pkg].nil? or options[:pkg].empty? or
+                               options[:url].nil? or options[:url].empty? then
+                       raise ArgumentError, "Usage: pkg-cli download -P <package name> -u <package server url> [-o <os>] [-l <location>] [--trace]"
                end
 
        when "install" then
-               if options[:pkg].nil? or options[:pkg].empty? then
-                       raise ArgumentError, "Usage: pkg-cli install -P <package name> [-o <os>] [-l <location>] [-u <package server url>] [--trace] [--force]"
+               if options[:pkg].nil? or options[:pkg].empty? or
+                               options[:url].nil? or options[:url].empty? then
+                       raise ArgumentError, "Usage: pkg-cli install -P <package name> -u <package server url> [-o <os>] [-l <location>] [--trace] [--force]"
                end
 
        when "install-file" then
                if options[:pkg].nil? or options[:pkg].empty? then
-                       raise ArgumentError, "Usage: pkg-cli install-lpkg -P <package file> [-l <location>] [-u <package server url>] [--trace] [--force]"
+                       raise ArgumentError, "Usage: pkg-cli install-file -P <package file> [-l <location>] [-u <package server url>] [--trace] [--force]"
                end
 
        when "uninstall" then
@@ -69,11 +75,15 @@ def option_error_check( options )
                end
 
        when "show-rpkg" then
-               if options[:pkg].nil? or options[:pkg].empty? then
-                       raise ArgumentError, "Usage: pkg-cli show-rpkg -P <package name> [-o <os>] [-u <package server url>]"
+               if options[:pkg].nil? or options[:pkg].empty? or
+                               options[:url].nil? or options[:url].empty? then
+                       raise ArgumentError, "Usage: pkg-cli show-rpkg -P <package name> -u <package server url> [-o <os>]"
                end
 
        when "list-rpkg" then
+               if options[:url].nil? or options[:url].empty? then
+                       raise ArgumentError, "Usage: pkg-cli list-rpkg -u <package server url> [-o <os>]"                       
+               end
 
        when "show-lpkg" then
                if options[:pkg].nil? or options[:pkg].empty? then
@@ -83,13 +93,21 @@ def option_error_check( options )
        when "list-lpkg" then
 
        when "build-dep" then
-               if options[:pkg].nil? or options[:pkg].empty? then
-                       raise ArgumentError, "Usage: pkg-cli build-dep -P <package name> [-o <os>]"
+               if options[:pkg].nil? or options[:pkg].empty? or
+                               options[:url].nil? or options[:url].empty? then
+                       raise ArgumentError, "Usage: pkg-cli build-dep -P <package name> -u <package server url> [-o <os>]"
                end
 
        when "install-dep" then
-               if options[:pkg].nil? or options[:pkg].empty? then
-                       raise ArgumentError, "Usage: pkg-cli install-dep -P <package name> [-o <os>]"
+               if options[:pkg].nil? or options[:pkg].empty? or
+                               options[:url].nil? or options[:url].empty? then
+                       raise ArgumentError, "Usage: pkg-cli install-dep -P <package name> -u <package server url> [-o <os>]"
+               end
+
+       when "register"
+               if      options[:pkg].nil? or options[:pkg].empty? or options[:address].nil? or options[:address].empty? or
+                               options[:dist].nil? or options[:dist].empty? then
+                       raise ArgumentError, "Usage: pkg-cli register -P <package file path> -a <server address> -d <distribution name> -w <password>"
                end
 
        else
@@ -102,7 +120,6 @@ def option_parse
        banner = "Requiest service to package-server and control packages service command-line tool." + "\n" \
                + "\n" + "Usage: pkg-cli <SUBCOMMAND> [OPTS] or pkg-cli (-h|-v)" + "\n" \
                + "\n" + "Subcommands:" + "\n" \
-               + "\t" + "update        Update to the latest package in your SDK environment." + "\n" \
                + "\t" + "clean         Delete the package in your SDK environment." + "\n" \
                + "\t" + "download      Download the package in your SDK environment." + "\n" \
                + "\t" + "install       Download the package from package-server and install the package in your SDK environment." + "\n" \
@@ -117,20 +134,20 @@ def option_parse
                + "\t" + "build-dep     Show build-dependency packages" + "\n" \
                + "\t" + "install-dep   Show install-dependency packages" + "\n" \
                + "\n" + "Subcommand usage:" + "\n" \
-               + "\t" + "pkg-cli update [-u <remote server url>]" + "\n" \
                + "\t" + "pkg-cli clean [-l <location>] [--force]" + "\n" \
-               + "\t" + "pkg-cli download -P <package name> [-o <os>] [-l <location>] [-u <package server url>] [--trace]" + "\n" \
-               + "\t" + "pkg-cli install -P <package name> [-o <os>] [-l <location>] [-u <package server url>] [--trace] [--force]" + "\n" \
+               + "\t" + "pkg-cli download -P <package name> -u <package server url> [-o <os>] [-l <location>] [--trace]" + "\n" \
+               + "\t" + "pkg-cli install -P <package name> -u <package server url> [-o <os>] [-l <location>] [--trace] [--force]" + "\n" \
                + "\t" + "pkg-cli install-file -P <package file> [-l <location>] [-u <package server url>] [--trace] [--force]" + "\n" \
                + "\t" + "pkg-cli uninstall -P <package name> [-l <location>] [--trace]" + "\n" \
-               + "\t" + "pkg-cli upgrade [-l <location>] [-o <os>] [-u <package server url>] [--trace]" + "\n" \
-               + "\t" + "pkg-cli check-upgrade [-l <location>] [-o <os>] [-u <package server url>]" + "\n" \
-               + "\t" + "pkg-cli show-rpkg -P <package name> [-o <os>] [-u <package server url>]" + "\n"  \
-               + "\t" + "pkg-cli list-rpkg [-o <os>] [-u <package server url>]" + "\n" \
+               + "\t" + "pkg-cli upgrade -u <package server url> [-l <location>] [-o <os>] [--trace]" + "\n" \
+               + "\t" + "pkg-cli check-upgrade -u <package server url> [-l <location>] [-o <os>]" + "\n" \
+               + "\t" + "pkg-cli show-rpkg -P <package name> -u <package server url> [-o <os>]" + "\n"  \
+               + "\t" + "pkg-cli list-rpkg -u <package server url> [-o <os>]" + "\n" \
                + "\t" + "pkg-cli show-lpkg -P <package name> [-l <location>]" + "\n"  \
                + "\t" + "pkg-cli list-lpkg [-l <location>]" + "\n" \
-               + "\t" + "pkg-cli build-dep -P <package name> [-o <os>]" + "\n" \
-               + "\t" + "pkg-cli install-dep -P <package name> [-o <os>]" + "\n" \
+               + "\t" + "pkg-cli build-dep -P <package name> -u <package server url> [-o <os>]" + "\n" \
+               + "\t" + "pkg-cli install-dep -P <package name> -u <package server url> [-o <os>]" + "\n" \
+               + "\t" + "pkg-cli register -P <package file path> -a <server address> -d <distribution name> -w <password>" + "\n" \
                + "\n" + "Options:" + "\n"
 
        optparse = OptionParser.new(nil, 32, ' '*8) do|opts|
@@ -147,6 +164,10 @@ def option_parse
                        options[:os] = os
                end
 
+               opts.on( '-d', '--dist <distribution name>', 'distribution name' ) do |dist|
+                       options[:dist] = dist 
+               end
+
                opts.on( '-u', '--url <server url>', 'package server url: http://127.0.0.1/dibs/unstable' ) do |url|
                        options[:url] = url
                end
@@ -155,6 +176,14 @@ def option_parse
                        options[:loc] = loc
                end
 
+               opts.on( '-w', '--passwd <password>', 'password' ) do |passwd|
+                       options[:passwd] = passwd
+               end
+
+               opts.on( '-a', '--address <server address>', 'package server address : 127.0.0.1:2224' ) do |address|
+                       options[:address] = address
+               end
+
                opts.on( '--trace', 'enable trace dependent packages' ) do
                        options[:t] = true
                end
@@ -172,10 +201,11 @@ def option_parse
                        puts "DIBS(Distributed Intelligent Build System) version " + Utils.get_version()
                        exit
                end
+
        end
 
        cmd = ARGV[0]
-       if cmd.eql? "update" or cmd.eql? "download" or
+       if  cmd.eql? "download" or
                cmd.eql? "install" or cmd.eql? "show-rpkg" or
                cmd.eql? "list-rpkg" or
                cmd.eql? "uninstall" or cmd.eql? "show-lpkg" or
@@ -183,6 +213,7 @@ def option_parse
                cmd.eql? "install-file" or cmd.eql? "clean" or
                cmd.eql? "upgrade" or cmd.eql? "check-upgrade" or
                cmd.eql? "build-dep" or cmd.eql? "install-dep" or
+               cmd.eql? "register" or
                cmd =~ /(-v)|(--version)/  or
                cmd =~ /(help)|(-h)|(--help)/  then
 
index b5dd1ec..9d28540 100644 (file)
@@ -45,9 +45,14 @@ class FileDownLoader
 
                logger.info "Downloading #{url}"
                if is_remote then
-                       pid,status = Utils.execute_shell_with_log( "wget #{url} -O #{fullpath} -nv --tries=3", logger.path )
-                       ret = (not status.nil? and status.exitstatus != 0) ? false : true
-                       #ret = Utils.execute_shell( "wget #{url} -O #{fullpath} -q")
+                       if logger.path.nil? or logger.path.empty? then
+                               ret = system "wget #{url} -O #{fullpath} -nv --tries=3"
+                       else                            
+                               pid,status = Utils.execute_shell_with_log( "wget #{url} -O #{fullpath} -nv --tries=3", logger.path )
+                               if not status.nil? then
+                                       ret = (status.exitstatus != 0) ? false : true
+                               end
+                       end                             
                else
                        if not File.exist? url then
                                logger.error "\"#{url}\" file does not exist"
index e490275..5c803b4 100644 (file)
@@ -477,6 +477,11 @@ class PackageServer
                # set port number. default port is 3333
                @port = port
 
+               # write package server port
+               File.open(@run_file_path, "w") do |f|
+                       f.puts @port
+               end
+
                # set job request listener
                @log.info "Setting listener..."
                listener = SocketRegisterListener.new(self)
@@ -510,11 +515,18 @@ class PackageServer
        end
 
        # stop server daemon
-       def stop( port, passwd )
+       def stop( passwd )
                # set port number. default port is 3333
-               @port = port
                @finish = false
 
+               # read package server port
+               if File.exist? @run_file_path
+                       file = File.open @run_file_path 
+                       @port = file.read.strip
+               else
+                       raise RuntimeError, "Error : Can't find package server port information"
+               end
+
                client = BuildCommClient.create("127.0.0.1", @port, @log)
                if client.nil? then
                        raise RuntimeError, "Server does not listen in #{@port} port"
@@ -533,6 +545,7 @@ class PackageServer
                end
                client.terminate
 
+               File.delete(@run_file_path)
        end
 
        def self.list_id
@@ -545,10 +558,10 @@ class PackageServer
 
                @@log.output( "=== server ID list ===", Log::LV_USER)
                s.each do |id|
-                       if File.basename(id).include?(".log") then next end
-
-                       server_list.push id
-                       @@log.output( id, Log::LV_USER)
+                       if File.directory?("#{SERVER_ROOT}/#{id}") then 
+                               server_list.push id
+                               @@log.output( id, Log::LV_USER)
+                       end
                end
                @@log.close
                FileUtils.rm_rf("#{SERVER_ROOT}/.log")
@@ -752,6 +765,7 @@ class PackageServer
                @config_dir = "#{SERVER_ROOT}/#{@id}"
                @log_file_path = "#{SERVER_ROOT}/#{@id}.log"
                @config_file_path = "#{@config_dir}/config"
+               @run_file_path = "#{@config_dir}/run"
                @incoming_path = "#{@config_dir}/incoming"
                @server_lock_file_path = "#{@config_dir}/.server_lock"
        end
index f37d68b..753a428 100644 (file)
@@ -92,9 +92,6 @@ def option_error_check( options )
                        raise ArgumentError, "Usage: pkg-svr start -n <server name> -p <port> [-w <password>]"
                end
        when "stop"
-               if options[:port].empty? then
-                       raise ArgumentError, "Usage: pkg-svr stop -n <server name> -p <port> [-w <password>]"
-               end
        when "sync"
        when "list"
        when "clean"
@@ -135,7 +132,7 @@ def option_parse
                + "\t" + "pkg-svr sync -n <server name> -d <distribution> -s <snapshot_name> [--force] " + "\n"  \
                + "\t" + "pkg-svr clean -n <server name> -d <distribution> [-s <snapshot list>] " + "\n" \
                + "\t" + "pkg-svr start -n <server name> -p <port> [-w <password>]" + "\n" \
-               + "\t" + "pkg-svr stop -n <server name> -p <port> [-w <password>]" + "\n" \
+               + "\t" + "pkg-svr stop -n <server name> " + "\n" \
                + "\t" + "pkg-svr list [-n <server name>] " + "\n" \
                + "\n" + "Options:" + "\n"
 
index 90e5080..8461051 100644 (file)
@@ -9,7 +9,6 @@ Usage: build-cli <SUBCOMMAND> [OPTS] or build-cli (-h|-v)
 
 Subcommands:
 build         Build and create package.
-resolve       Request change to resolve-status for build-conflict.
 query         Query information about build-server.
 query-system  Query system information about build-server.
 query-project Query project information about build-server.
@@ -19,7 +18,6 @@ register      Register the package to the build-server.
 
 Subcommand usage:
 build-cli build -N <project name> -d <server address> [-o <os>] [-w <password>] [--async] [-D <distribution name>] [-U user-email] [-V]
-build-cli resolve -N <project name> -d <server address> [-o <os>] [-w <password>] [--async] [-D <distribution name>] [-U user-email] [-V]
 build-cli query -d <server address>
 build-cli query-system -d <server address>
 build-cli query-project -d <server address>
index beb3e82..83311d4 100644 (file)
@@ -4,7 +4,7 @@ echo "if there doe not exist server to build, error"
 ../../build-cli build -N testa -d 127.0.0.1:2223 -o windows-32
 #POST-EXEC
 #EXPECT
-Info: Added new job "5" for windows-32!
+Info: Added new job
 Info: Initializing job...
 Error: No servers that are able to build your packages.
 Error: Host-OS (windows-32) is not supported in build server.
index 72cf1fe..39fd9ab 100755 (executable)
@@ -24,7 +24,7 @@ mysql -u root -p --password=$DB_PASSWD -h localhost < a
 ${RUBY} ../../../build-svr migrate -n testserver3 --dsn Mysql:testserver3:localhost --dbuser root --dbpassword $DB_PASSWD
 rm -f a
 cd ..
-${RUBY} ../../build-svr add-dist -n testserver3 -D BASE -u `pwd`/pkgsvr01/unstable -d 127.0.0.1:3333
+${RUBY} ../../build-svr add-dist -n testserver3 -D BASE -u `pwd`/pkgsvr01/unstable -d 127.0.0.1:3333 -w score
 ${RUBY} ../../build-svr add-svr -n testserver3 -d 127.0.0.1:2224
 ${RUBY} ../../build-svr add-os -n testserver3 -o ubuntu-32
 ${RUBY} ../../build-svr add-os -n testserver3 -o windows-32
index 6973d9e..280ee40 100755 (executable)
@@ -7,4 +7,4 @@ rm -rf `pwd`/pkgsvr01
 ${RUBY} ../../pkg-svr create -n pkgsvr01 -d unstable
 ${RUBY} ../../pkg-svr add-os -n pkgsvr01 -d unstable -o ubuntu-32
 ${RUBY} ../../pkg-svr add-os -n pkgsvr01 -d unstable -o windows-32
-${RUBY} ../../pkg-svr start -n pkgsvr01 -p 3333
+${RUBY} ../../pkg-svr start -n pkgsvr01 -p 3333 -w score
index b5b5903..478f804 100644 (file)
@@ -10,7 +10,6 @@ build-cli-09.testcase
 build-cli-10.testcase
 build-cli-11.testcase
 build-cli-12.testcase
-build-cli-12_1.testcase
 build-cli-13.testcase
 build-cli-14.testcase
 build-cli-15.testcase
index 9b0af28..e4d9802 100755 (executable)
@@ -19,7 +19,7 @@ rm -rf ~/.build_tools/build_server/testserver3
 ../../build-svr remove -n testserver3
 mkdir buildsvr01
 cd buildsvr01
-${RUBY} ../../../build-svr create -n testserver3 -t ftp://ftpuser:ftpuser@127.0.0.1
+${RUBY} ../../../build-svr create -n testserver3 #-t ftp://ftpuser:ftpuser@127.0.0.1
 echo "DROP DATABASE testserver3;" > a
 mysql -u root -p --password=$DB_PASSWD -h localhost < a
 ${RUBY} ../../../build-svr migrate -n testserver3 --dsn Mysql:testserver3:localhost --dbuser root --dbpassword $DB_PASSWD
index b0859c9..fd6a79c 100755 (executable)
@@ -18,7 +18,7 @@ rm -rf ~/.build_tools/build_server/testserver3
 ../../build-svr remove -n testserver3
 mkdir buildsvr01
 cd buildsvr01
-${RUBY} ../../../build-svr create -n testserver3 -t ftp://ftpuser:ftpuser@127.0.0.1
+${RUBY} ../../../build-svr create -n testserver3 #-t ftp://ftpuser:ftpuser@127.0.0.1
 echo "DROP DATABASE testserver3;" > a
 mysql -u root -p --password=$DB_PASSWD -h localhost < a
 ${RUBY} ../../../build-svr migrate -n testserver3 --dsn Mysql:testserver3:localhost --dbuser root --dbpassword $DB_PASSWD
index be7df44..fd3d663 100644 (file)
@@ -1,6 +1,6 @@
 #PRE-EXEC
 #EXEC
-../../build-cli register -d 127.0.0.1:2223 -P bin/bin_0.0.0_ubuntu-32.zip -D unstable2 -t ftp://ftpuser:ftpuser@127.0.0.1
+../../build-cli register -d 127.0.0.1:2223 -P bin/bin_0.0.0_ubuntu-32.zip -D unstable2 #-t ftp://ftpuser:ftpuser@127.0.0.1
 #POST-EXEC
 #EXPECT
 I, [
@@ -8,14 +8,6 @@ I, [
 I, [
 I, [
 I, [
-I, [
-I, [
-I, [
-I, [
-I, [
-I, [
-I, [
-I, [
 Info: Added new job
 Info: Initializing job...
 Info: Checking package version ...
index 5d4bc03..11e9162 100755 (executable)
@@ -18,7 +18,7 @@ rm -rf ~/.build_tools/build_server/testserver3
 ../../build-svr remove -n testserver3
 mkdir buildsvr01
 cd buildsvr01
-${RUBY} ../../../build-svr create -n testserver3 -t ftp://ftpuser:ftpuser@127.0.0.1
+${RUBY} ../../../build-svr create -n testserver3 #-t ftp://ftpuser:ftpuser@127.0.0.1
 echo "DROP DATABASE testserver3;" > a
 mysql -u root -p --password=$DB_PASSWD -h localhost < a
 ${RUBY} ../../../build-svr migrate -n testserver3 --dsn Mysql:testserver3:localhost --dbuser root --dbpassword $DB_PASSWD
diff --git a/test/pkg-cli-update.testcase b/test/pkg-cli-update.testcase
deleted file mode 100644 (file)
index 3c6fa52..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#PRE-EXEC
-#EXEC
-../pkg-cli update -u http://172.21.111.132/testserver3/unstable
-#POST-EXEC
-#EXPECT
-Update package list from "http://172.21.111.132/testserver3/unstable".. OK
index 21c2fe0..a29c240 100644 (file)
@@ -1,4 +1,3 @@
-pkg-cli-update.testcase
 pkg-cli-listrpkg.testcase
 pkg-cli-showrpkg.testcase
 pkg-cli-download.testcase
diff --git a/web-svr b/web-svr
new file mode 100755 (executable)
index 0000000..abb900a
--- /dev/null
+++ b/web-svr
@@ -0,0 +1,364 @@
+#!/usr/bin/ruby
+=begin
+
+ web-svr
+
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+
+Contact:
+Sungmin Kim <dev.sungmin.kim@samsung.com>
+Taejun Ha <taejun.ha@samsung.com>
+Jiil Hyoun <jiil.hyoun@samsung.com>
+Donghyuk Yang <donghyuk.yang@samsung.com>
+DongHee Yang <donghee.yang@samsung.com>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Contributors:
+- S-Core Co., Ltd
+=end
+
+require 'fileutils'
+require 'optparse'
+require 'yaml'
+$LOAD_PATH.unshift File.dirname(__FILE__)+"/src/common"
+$LOAD_PATH.unshift File.dirname(__FILE__)+"/src/build_server"
+require "log.rb"
+require 'utils'
+require 'db_utils'
+require "BuildServer"
+require "BuildServerController"
+
+class OptParse
+       #Sub command usage
+       START = "dibs-web start -n <server name> [-p <port number>] [-m <DB mode>] [-d]"
+       STOP = "dibs-web stop -n <server name>"
+       CREATE = "dibs-web create -n <server name> [-e <engine name] [-p <port number>] [-m <DB mode>] [-i]"
+
+       def self.option_error_check( options )
+               case options[:cmd]
+                       when "start" then
+                               if options[:name].nil? then
+                                       raise ArgumentError, "Usage: " + START
+                               end
+                       when "stop" then
+                               if options[:name].nil? then
+                                       raise ArgumentError, "Usage: " + STOP
+                               end
+                       when "create" then
+                               if options[:name].nil? then
+                                       raise ArgumentError, "Usage: " + CREATE
+                               end
+                       else
+                               raise ArgumentError, "Input is incorrect : #{options[:cmd]}"
+           end
+       end
+       
+       def self.option_parse
+           options = {}
+           banner = "DIBS web service command-line tool." + "\n" \
+               + "\n" + "Usage: dibs-web <SUBCOMMAND> [OPTS] or dibs-web (-h|-v)" + "\n" \
+               + "\n" + "SubCommands:" + "\n" \
+               + "\t" + "start         Start web server." + "\n" \
+               + "\t" + "stop          Stop web server." + "\n" \
+               + "\t" + "create        Create web server configuration." + "\n" \
+               + "\n" + "Subcommand usage:" + "\n" \
+               + "\t" + START+ "\n" \
+               + "\t" + STOP+ "\n" \
+               + "\t" + CREATE + "\n" \
+               + "\n" + "Options:" + "\n"
+       
+           optparse = OptionParser.new(nil, 32, ' '*8) do|opts|
+                       opts.banner = banner
+       
+                       options[:locate] = File.dirname(__FILE__)
+               opts.on( '-n', '--name <server name>', 'build server name' ) do|name|
+                   options[:name] = name
+               end
+       
+               options[:engine] = "WEBRick" 
+               opts.on( '-e', '--engine <engine name>', 'web server engine : WEBrick | Passenger' ) do|engine|
+                   options[:engine] = engine
+               end
+       
+               options[:port] = 3000
+                       opts.on( '-p', '--port <port number>', 'default server port' ) do|port|
+                   options[:port] = port
+               end
+       
+               options[:mode] = "production"
+                       opts.on( '-m', '--mode <mode>', 'DB mode : production | test | development' ) do|mode|
+                   options[:mode] = mode.strip
+               end
+       
+               options[:port] = "3000" 
+                       opts.on( '-p', '--port <port>', 'server port number: 3000' ) do|port|
+                   options[:port] = port.strip.to_i
+               end
+       
+                       opts.on( '-i', '--import', 'import configuration from build-server' ) do|import|
+                   options[:import] = true
+               end
+
+                       opts.on( '-d', '--daemon', 'daemon process' ) do|import|
+                   options[:daemon] = true
+               end
+       
+                       opts.on( '-h', '--help', 'display this information' ) do
+                               opts.help.split("\n").each {|op| puts op if not op.include? "--noreverse"}
+                               exit
+               end
+               end
+
+               cmd = ARGV[0]
+
+               if cmd.eql? "create" or cmd.eql? "start" or cmd.eql? "stop" or
+                       cmd =~ /(-v)|(--version)/ or cmd =~ /(help)|(-h)|(--help)/ then
+
+                       if cmd.eql? "help" then
+                               ARGV[0] = "-h"
+                       end
+
+                       options[:cmd] = ARGV[0]
+               else
+                       raise ArgumentError, "Usage: build-cli <SUBCOMMAND> [OPTS] or build-cli -h"
+               end
+       
+           optparse.parse!
+       
+           option_error_check options
+       
+           return options
+       end
+end
+
+class ControlWebServer
+       CONFIG_ROOT = "#{Utils::HOME}/.build_tools/web_server"
+       BUILD_SERVER_CONFIG_ROOT = "#{Utils::HOME}/.build_tools/build_server"
+       SERVER_ROOT =  File.dirname(__FILE__)+"/dibs-web"
+       SERVER_CONFIG =  File.dirname(__FILE__)+"/dibs-web/config/database.yml"
+
+       def self.check_config_file(svr_name)
+               if File.exist? "#{CONFIG_ROOT}/#{svr_name}/server.yml"
+                       return true
+               else
+                       return false
+               end
+       end
+
+       def self.get_server_config(svr_name)
+               config = YAML.load_file("#{CONFIG_ROOT}/#{svr_name}/server.yml")
+       end
+       
+       def self.get_build_server_config(svr_name)
+               config_file = "#{ControlWebServer::BUILD_SERVER_CONFIG_ROOT}/#{svr_name}/server.cfg"
+               config = {}
+
+               #check build-server config-file
+               if not File.exist? config_file
+                       raise RuntimeError, "Creating server failed. The build server is not exist"
+               end
+
+               #parse build-server config-file
+               File.open( config_file, "r" ) do |f|
+                       f.each_line do |l|
+                               if l.strip.start_with?("#") then next end
+                               idx = l.index("=") + 1
+                               length = l.length - idx
+
+                               if l.start_with?("DB_DSN=")
+                                       case l[idx,length].strip
+                                       when /^SQLite3:(.*)/i then
+                                               if $1.strip.empty? then db_dsn = "SQLite3:#{BuildServer::CONFIG_ROOT}/#{id}/server.db"
+                                               else config[:db_dsn] = "SQLite3:#{$1.strip}"
+                                               end
+                                       when /^Mysql:(.*)/i then
+                                               config[:db_dsn] = "Mysql:#{$1}"
+                                       else
+                                               config[:db_dsn] = "SQLite3:#{BuildServer::CONFIG_ROOT}/#{id}/server.db"
+                                       end
+                               elsif l.start_with?("DB_USER=")
+                                       config[:db_user] = l[idx,length].strip if not l[idx,length].strip.empty?
+                               elsif l.start_with?("DB_PASSWORD=")
+                                       config[:db_passwd] = l[idx,length].strip if not l[idx,length].strip.empty?
+                               else
+                                       next
+                               end
+                       end
+               end
+
+               #parse dsn
+               db = DBUtils.dsn_parser(config[:db_dsn])
+
+               config[:database] = db[:database]
+               config[:db_name] = db[:name]
+               config[:db_host] = db[:host]
+               config[:db_port] = db[:port]
+               config[:db_socket] = db[:socket]
+               config[:db_flag] = db[:flag]
+
+               return config
+       end
+end
+
+#option parsing
+begin
+       option = OptParse.option_parse
+rescue => e
+       puts e.message
+       exit 0
+end
+
+# main
+begin
+       test = {}
+       production = {}
+       development = {}
+
+       case option[:cmd]
+               when "create"
+                       # check configuration directory
+                       if not File.exist? ControlWebServer::CONFIG_ROOT
+                               puts "Creating new server configuration... #{ControlWebServer::CONFIG_ROOT}"
+                               FileUtils.mkdir_p "#{ControlWebServer::CONFIG_ROOT}"
+                       end
+
+                       # check config-file
+                       if ControlWebServer.check_config_file(option[:name])
+                               raise RuntimeError, "Creating server failed. The server id is already exist"
+                       else
+                               FileUtils.mkdir_p "#{ControlWebServer::CONFIG_ROOT}/#{option[:name]}"
+                       end
+
+                       # check build-server config-file
+                       if option[:import]
+                               db = ControlWebServer.get_build_server_config(option[:name])
+
+                               if db[:database].upcase == "Mysql".upcase
+                                       db[:adapter] = "mysql2"
+                                       db[:encoding] = "utf8"
+                                       db[:pool] = 5
+                                       db[:timeout] = 5000
+                                       case option[:mode]
+                                               when "production"
+                                                       production = db
+                                               when "test"
+                                                       test = db
+                                               when "development"
+                                                       development = db
+                                       else
+                                               raise RuntimeError, "The mode \"#{option[:mode]}\" is invalid!"
+                                       end
+                               end
+                       end
+
+                       # write config-file
+                       File.open( "#{ControlWebServer::CONFIG_ROOT}/#{option[:name]}/server.yml", "w" ) do |f|
+                               f.puts "server: "
+                               f.puts "   engine: #{option[:engine]}"
+                               f.puts "   port: #{option[:port]}"
+                               f.puts "   db_mode: #{option[:mode]}" 
+                               f.puts "database: "
+                               f.puts " test:"
+                               f.puts "   adapter: #{test[:adapter]}"
+                               f.puts "   encoding: #{test[:encoding]}"
+                               f.puts "   host: #{test[:db_host]}"
+                               f.puts "   port: #{test[:db_port]}"
+                               f.puts "   database: #{test[:db_name]}"
+                               f.puts "   username: #{test[:db_user]}"
+                               f.puts "   password: #{test[:db_passwd]}"
+                               f.puts "   pool: #{test[:pool]}"
+                               f.puts "   timeout: #{test[:timeout]}"
+                               f.puts "" 
+                               f.puts " production: "
+                               f.puts "   adapter: #{production[:adapter]}"
+                               f.puts "   encoding: #{production[:encoding]}"
+                               f.puts "   host: #{production[:db_host]}"
+                               f.puts "   port: #{production[:db_port]}"
+                               f.puts "   database: #{production[:db_name]}"
+                               f.puts "   username: #{production[:db_user]}"
+                               f.puts "   password: #{production[:db_passwd]}"
+                               f.puts "   pool: #{production[:pool]}"
+                               f.puts "   timeout: #{production[:timeout]}"
+                               f.puts "" 
+                               f.puts " development: "
+                               f.puts "   adapter: #{development[:adapter]}"
+                               f.puts "   encoding: #{development[:encoding]}"
+                               f.puts "   host: #{development[:db_host]}"
+                               f.puts "   port: #{development[:db_port]}"
+                               f.puts "   database: #{development[:db_name]}"
+                               f.puts "   username: #{development[:db_user]}"
+                               f.puts "   password: #{development[:db_passwd]}"
+                               f.puts "   pool: #{development[:pool]}"
+                               f.puts "   timeout: #{development[:timeout]}"
+                       end
+               when "start"
+                       # check server config
+                       if not ControlWebServer.check_config_file(option[:name])
+                               raise RuntimeError, "The server \"#{option[:name]}\" does not exist!"
+                       end
+
+                       # parsing config
+                       config = ControlWebServer.get_server_config(option[:name])
+                       server = config['server']
+                       database = config['database']
+
+                       # copy config about database
+                       File.open("#{ControlWebServer::SERVER_CONFIG}", 'w') do |f|
+                               f.write(YAML.dump(database))
+                       end
+                       
+                       # run web-server
+                       if option[:daemon]
+                               daemon = "-d"
+                       end
+
+                       case server['engine'].upcase
+                               when 'WEBRick'.upcase
+                                       cmd = "rails server -p #{server['port']} #{daemon} -e #{server['db_mode']}"
+                               when 'Passenger'.upcase
+                                       cmd = "passenger start -p #{server['port']} #{daemon} -e #{server['db_mode']}"
+                       else
+                               raise RuntimeError, "The engine is not supported. #{server['engine']}"
+                       end
+                        Dir.chdir(ControlWebServer::SERVER_ROOT)
+
+                        system(cmd)
+
+               when "stop"
+                       # check server config
+                       if not ControlWebServer.check_config_file(option[:name])
+                               raise RuntimeError, "The server \"#{option[:name]}\" does not exist!"
+                       end
+
+                       # parsing config
+                       config = ControlWebServer.get_server_config(option[:name])
+                       server = config['server']
+
+                       # stop web-server
+                       case server['engine'].upcase
+                               when 'WEBRick'.upcase
+                                       puts "WEBRick stopping is not support. Try kill process"
+                               when 'Passenger'.upcase
+                                       cmd = "passenger stop --pid-file #{ControlWebServer::SERVER_ROOT}/tmp/pids/passenger.#{server['port']}.pid"
+                                       system(cmd)
+                       else
+                               raise RuntimeError, "The engine is not supported. #{server['engine']}"
+                       end
+       else
+               raise RuntimeError, "input option incorrect : #{option[:cmd]}"
+       end
+rescue => e
+       puts e.message
+end
+