#
# Creates the default WebSphere configuration (the default objects
# automatically created in the repository when the install.initial.config property
# is set to true in the admin.config file).
#
# The file init.tcl must be loaded prior to running this script.

#
# WebResources
#
set host "/VirtualHost:default_host/"
foreach path {/ /servlet/snoop /servlet/snoop2 /servlet/hello /ErrorReporter /servlet /*.jsp} {
    set uri "${host}WebResource:$path"
    # Create a WebResource with rootURI of / 
	set attrs "{PathName $path} {RootURI /}"
	set cmd {WebResource create $uri -attribute $attrs}
	if {$VERBOSE} {puts [subst "# $cmd"]}
	eval $cmd
    
}

foreach path {/admin /admin/install /admin/*.jsp /admin/ /admin/servlet /admin/ErrorReporter} {
    set uri "${host}WebResource:$path"
    # Create a WebResource with rootURI of /admin
	set attrs "{PathName $path} {RootURI /admin}"
	set cmd {WebResource create $uri -attribute $attrs}
	if {$VERBOSE} {puts [subst "# $cmd"]}
	eval $cmd
    
}

foreach path {/webapp/examples /webapp/examples/simpleJSP.servlet /webapp/examples/simpleJSP /webapp/examples/ErrorServlet /webapp/examples/ping /webapp/examples/SourceCodeViewer /webapp/examples/showCfg /webapp/examples/HitCount /webapp/examples/verify /webapp/examples/*.jsp /webapp/examples/} {
    set uri "${host}WebResource:$path"
    # Create a WebResource with rootURI of /webapp/examples
	set attrs "{PathName $path} {RootURI /webapp/examples}"
	set cmd {WebResource create $uri -attribute $attrs}
	if {$VERBOSE} {puts [subst "# $cmd"]}
	eval $cmd
    
}

#
# ApplicationServer
#
set serv "${NODE}ApplicationServer:Default Server/"
# Create the default ApplicationServer
    set attrs "{MaxStartupAttempts 5} {CommandLineArgs {{}{}}} {Stdout ${WAS_HOME}${FILE_SEPARATOR}logs${FILE_SEPARATOR}default_server_stdout.log} {Stderr ${WAS_HOME}${FILE_SEPARATOR}logs${FILE_SEPARATOR}default_server_stderr.log} {PingInitialTimeout 300} {PingInterval 60} {PingTimeout 200} {SelectionPolicy roundrobinpreferlocal} {ThreadPoolSize 5} {TranInactivityTimeout 60000} {TranTimeout 120} {TraceSpec *=all=disabled} {DebugEnabled False} {OLTEnabled False} {SecurityEnabled False}"
    set cmd {ApplicationServer create $serv -attribute $attrs}
    if {$VERBOSE} {puts [subst "# $cmd"]}
    eval $cmd


#
# EJBContainer
#
set cont "${serv}EJBContainer:Default Container/"
# Create the default EJBContainer
    set attrs "{CacheConfig {{cacheSweepInterval 1000}{passivationDirectory {}} {cacheHardLimit 2047} {cacheSize 2047} {cacheSoftLimit 2000}}}"
    set cmd {EJBContainer create $cont -attribute $attrs}
    if {$VERBOSE} {puts [subst "# $cmd"]}
    eval $cmd


#
# EnterpriseBean
#
set bean "${cont}EnterpriseBean:RemoteSRP/"
# Create the RemoteSRP bean
    set jar "${WAS_HOME}${FILE_SEPARATOR}lib${FILE_SEPARATOR}ibmwebas.jar"
    set attrs "{JarFile $jar} {DeploymentDescriptor com.ibm.servlet.engine.ejs.RemoteSRP@$jar} {CreateDbTable True} {FindForUpdate False} {MinPoolSize 2} {MaxPoolSize 100} {PrimaryKeyCheck False} {DbExclusiveAccess False}"
    set cmd {EnterpriseBean create $bean -attribute $attrs}
    if {$VERBOSE} {puts [subst "# $cmd"]}
    eval $cmd


#
# ServletEngine
#
set engine "${serv}ServletEngine:servletEngine/"
# Create the default servletEngine
    set attrs "{Enabled True} {MaxCon 50} {TransportAttributes {{linkType 0}{cloneIndex 1}{logFile ${WAS_HOME}${FILE_SEPARATOR}logs${FILE_SEPARATOR}default_server_native.log}{logFileMask 8}{queueName ibmoselink}}} {TransportPort 8110} {TransportType 0}"
    set cmd {ServletEngine create $engine -attribute $attrs}
    if {$VERBOSE} {puts [subst "# $cmd"]}
    eval $cmd


#
# WebApplication
#
set group "${engine}WebApplication:default_app/"
# Create the default web application
    set attrs "{AutoReload True} {Classpath {${WAS_HOME}${FILE_SEPARATOR}hosts${FILE_SEPARATOR}default_host${FILE_SEPARATOR}default_app${FILE_SEPARATOR}servlets ${WAS_HOME}${FILE_SEPARATOR}servlets}} {Description {default application}} {DocRoot {$(DOCROOT)}} {Enabled True} {ErrorPage /ErrorReporter} {ReloadInterval 3000} {SharedContext False} {SharedContextJNDIName SrdSrvltCtxHome} {URIPath default_host/}"
    set cmd {WebApplication create $group -attribute $attrs}
    if {$VERBOSE} {puts [subst "# $cmd"]}
    eval $cmd


#
# Servlets
#
set servlet "${group}Servlet:snoop/"
# Create the snoop servlet
    set attrs "{Code SnoopServlet} {DebugMode 0} {Description {snoop servlet}} {Enabled True} {InitParams {{param1 test-value1}}} {LoadAtStartup False} {URIPaths {}}"
    set cmd {Servlet create $servlet -attribute $attrs}
    if {$VERBOSE} {puts [subst "# $cmd"]}
    eval $cmd


set servlet "${group}Servlet:hello/"
# Create the hello servlet
    set attrs "{Code HelloWorldServlet} {DebugMode 0} {Description {hello servlet}} {Enabled True} {LoadAtStartup False} {URIPaths {}}"
    set cmd {Servlet create $servlet -attribute $attrs}
    if {$VERBOSE} {puts [subst "# $cmd"]}
    eval $cmd


set servlet "${group}Servlet:ErrorReporter/"
#  Create the ErrorReporter servlet
    set attrs "{Code com.ibm.servlet.engine.webapp.DefaultErrorReporter} {DebugMode 0} {Description {Default error reporter servlet}} {Enabled True} {LoadAtStartup True} {URIPaths {}}"
    set cmd {Servlet create $servlet -attribute $attrs}
    if {$VERBOSE} {puts [subst "# $cmd"]}
    eval $cmd

set servlet "${group}Servlet:invoker/"
# Create the invoker servlet
    set attrs "{Code com.ibm.servlet.engine.webapp.InvokerServlet} {DebugMode 0} {Description {Auto-registration servlet}} {Enabled True} {LoadAtStartup True} {URIPaths {}}"
    set cmd {Servlet create $servlet -attribute $attrs}
    if {$VERBOSE} {puts [subst "# $cmd"]}
    eval $cmd

set servlet "${group}Servlet:jsp/"
# Create the JSP support servlet
    set attrs "{Code com.ibm.servlet.jsp.http.pagecompile.PageCompileServlet} {DebugMode 0} {Description {JSP support servlet}} {Enabled True} {LoadAtStartup True} {URIPaths {}}"
    set cmd {Servlet create $servlet -attribute $attrs}
    if {$VERBOSE} {puts [subst "# $cmd"]}
    eval $cmd


#
# Admin WebApplication
#
set admin "${engine}WebApplication:admin/"
# Create the admin application
    set attrs "{AutoReload True} {Classpath {${WAS_HOME}${FILE_SEPARATOR}hosts${FILE_SEPARATOR}default_host${FILE_SEPARATOR}admin${FILE_SEPARATOR}servlets}} {Description {Install WAS Admin Client}} {DocRoot {${WAS_HOME}${FILE_SEPARATOR}hosts${FILE_SEPARATOR}default_host${FILE_SEPARATOR}admin${FILE_SEPARATOR}web}} {Enabled True} {ErrorPage /ErrorReporter} {ReloadInterval 3000} {SharedContext False} {SharedContextJNDIName SrdSrvltCtxHome} {URIPath default_host/admin}"
    set cmd {WebApplication create $admin -attribute $attrs}
    if {$VERBOSE} {puts [subst "# $cmd"]}
    eval $cmd


#
# Servlets
#
set servlet "${admin}Servlet:install/"
# Create the install servlet
    set attrs "{Code com.ibm.servlet.engine.webapp.AdminClientServlet} {DebugMode 0} {Description {Install the WAServer Admin GUI}} {Enabled True} {InitParams {{install/install/IBMWebASv3_NT_AdminClient.jar adminclient.for.nt} {install/install/IBMWebASv3_AIX_AdminClient.jar adminclient.for.aix} {install/install/IBMWebASv3_SUN_AdminClient.jar adminclient.for.sun}}} {LoadAtStartup False} {URIPaths {}}"
    set cmd {Servlet create $servlet -attribute $attrs}
    if {$VERBOSE} {puts [subst "# $cmd"]}
    eval $cmd

set servlet "${admin}Servlet:jsp/"
# Create the JSP support servlet
    set attrs "{Code com.sun.jsp.runtime.JspServlet} {DebugMode 0} {Description {JSP support servlet}} {Enabled True} {LoadAtStartup True} {URIPaths {}}"
    set cmd {Servlet create $servlet -attribute $attrs}
    if {$VERBOSE} {puts [subst "# $cmd"]}
    eval $cmd

set servlet "${admin}Servlet:file/"
# Create the file serving servlet
    set attrs "{Code com.ibm.servlet.engine.webapp.SimpleFileServlet} {DebugMode 0} {Description {File serving servlet}} {Enabled True} {InitParams {{{}{}}}} {LoadAtStartup True} {URIPaths {}}"
    set cmd {Servlet create $servlet -attribute $attrs}
    if {$VERBOSE} {puts [subst "# $cmd"]}
    eval $cmd

set servlet "${admin}Servlet:invoker/"
# Create the invoker servlet
    set attrs "{Code com.ibm.servlet.engine.webapp.InvokerServlet} {DebugMode 0} {Description {Auto-registration servlet}} {Enabled True} {LoadAtStartup True} {URIPaths {}}"
    set cmd {Servlet create $servlet -attribute $attrs}
    if {$VERBOSE} {puts [subst "# $cmd"]}
    eval $cmd

set servlet "${admin}Servlet:ErrorReporter/"
# Create the ErrorReporter servlet
    set attrs "{Code com.ibm.servlet.engine.webapp.DefaultErrorReporter} {DebugMode 0} {Description {Default error reporter servlet}} {Enabled True} {LoadAtStartup True} {URIPaths {}}"
    set cmd {Servlet create $servlet -attribute $attrs}
    if {$VERBOSE} {puts [subst "# $cmd"]}
    eval $cmd



#
# Examples WebApplication
#
set example "${engine}WebApplication:examples/"
# Create the examples application
    set attrs "{AutoReload True} {Classpath {${WAS_HOME}${FILE_SEPARATOR}hosts${FILE_SEPARATOR}default_host${FILE_SEPARATOR}examples${FILE_SEPARATOR}servlets}} {Description {example servlets}} {DocRoot {${WAS_HOME}${FILE_SEPARATOR}hosts${FILE_SEPARATOR}default_host${FILE_SEPARATOR}examples${FILE_SEPARATOR}web}} {Enabled True} {ErrorPage /debug_error.jsp} {ReloadInterval 3000} {SharedContext False} {SharedContextJNDIName SrdSrvltCtxHome} {URIPath default_host/webapp/examples}"
    set cmd {WebApplication create $example -attribute $attrs}
    if {$VERBOSE} {puts [subst "# $cmd"]}
    eval $cmd


#
# Servlets
#
set servlet "${example}Servlet:simpleJSP/"
# Create the simple JSP servlet
    set attrs "{Code SimpleJSPServlet} {DebugMode 0} {Description {Simple JSP Servlet}} {Enabled True} {InitParams {{{}{}}}} {LoadAtStartup False} {URIPaths {}}"
    set cmd {Servlet create $servlet -attribute $attrs}
    if {$VERBOSE} {puts [subst "# $cmd"]}
    eval $cmd

set servlet "${example}Servlet:error/"
# Create the error servlet
    set attrs "{Code ErrorServlet} {DebugMode 0} {Description {Calls the response.sendError() method}} {Enabled True} {LoadAtStartup False} {URIPaths {}}"
    set cmd {Servlet create $servlet -attribute $attrs}
    if {$VERBOSE} {puts [subst "# $cmd"]}
    eval $cmd

set servlet "${example}Servlet:ping/"
# Create the ping servlet
    set attrs "{Code PingServlet} {DebugMode 0} {Description {Base line response time checker}} {Enabled True} {LoadAtStartup False} {URIPaths {}}"
    set cmd {Servlet create $servlet -attribute $attrs}
    if {$VERBOSE} {puts [subst "# $cmd"]}
    eval $cmd

set servlet "${example}Servlet:SourceCodeViewer/"
# Create the SourceCodeViewer servlet
    set attrs "{Code SourceCodeViewer} {DebugMode 0} {Description {Allows remote viewing of source code}} {Enabled True} {LoadAtStartup False} {InitParams {{sourcecode.viewing.enabled false}}} {URIPaths {}}"
    set cmd {Servlet create $servlet -attribute $attrs}
    if {$VERBOSE} {puts [subst "# $cmd"]}
    eval $cmd

set servlet "${example}Servlet:showCfg/"
# Create the Configuration Dumper servlet
    set attrs "{Code ServletEngineConfigDumper} {DebugMode 0} {Description {Configuration Dumper servlet}} {Enabled True} {LoadAtStartup False} {URIPaths {}}"
    set cmd {Servlet create $servlet -attribute $attrs}
    if {$VERBOSE} {puts [subst "# $cmd"]}
    eval $cmd

set servlet "${example}Servlet:HitCount/"
# Create the Hit Count servlet
    set attrs "{Code HitCount} {DebugMode 0} {Description {Hit Count Servlet - Server Verification}} {Enabled True} {LoadAtStartup False} {URIPaths {}}"
    set cmd {Servlet create $servlet -attribute $attrs}
    if {$VERBOSE} {puts [subst "# $cmd"]}
    eval $cmd

set servlet "${example}Servlet:jsp/"
# Create the JSP support servlet
    set attrs "{Code com.ibm.servlet.jsp.http.pagecompile.PageCompileServlet} {DebugMode 0} {Description {JSP support servlet}} {Enabled True} {LoadAtStartup True} {URIPaths {}}"
    set cmd {Servlet create $servlet -attribute $attrs}
    if {$VERBOSE} {puts [subst "# $cmd"]}
    eval $cmd

set servlet "${example}Servlet:file/"
# Create the file serving servlet
    set attrs "{Code com.ibm.servlet.engine.webapp.SimpleFileServlet} {DebugMode 0} {Description {File serving servlet}} {Enabled True} {InitParams {{{}{}}}} {LoadAtStartup True} {URIPaths {}}"
    set cmd {Servlet create $servlet -attribute $attrs}
    if {$VERBOSE} {puts [subst "# $cmd"]}
    eval $cmd


#
# NOTE: The following objects are created automatically, either by the admin
# server itself, or as a side-effect of creating the other sample objects.
# They are included here to demonstrate the syntax that would be used if the
# objects had to be created manually.
#
if {0} {
#
# Node
#
# Create a node
    set attrs "{DependentClasspath {}} {DeployedJarDirectory {${WAS_HOME}${FILE_SEPARATOR}deployedEJBs}}"
    set cmd {Node create $name -attribute $attrs}
    if {$VERBOSE} {puts [subst "# $cmd"]}
    eval $cmd


#
# VirtualHost
#
# Create default_host VirtualHost
    set attrs "{AliasList {localhost 127.0.0.1 $HOSTNAME $HOST_IP}}"
    set attrs "$attrs {MimeTable {{wk4 application/vnd.lotus-1-2-3}{aiff audio/x-aiff}{wk3 application/vnd.lotus-1-2-3}{ief image/ief}{wk1 application/x-123}{txt text/plain}{aifc audio/x-aiff}{xsl application/xml}{mpg video/mpeg}{cc text/plain}{SOL application/solids}{mpe video/mpeg}{asm text/x-asm}{t application/x-troff}{cpio application/x-cpio}{s text/css}{htmls text/x-ssi-html}{tiff image/tiff}{UNV application/i-deas}{CCAD application/clariscad}{mjpg video/x-motion-jpeg}{sh application/x-sh}{jpeg image/jpeg}{rtx text/richtext}{VDA application/vda}{xwd image/x-xwindowdump}{m text/plain}{snd audio/basic}{gif image/gif}{mov video/quicktime}{h text/plain}{for text/plain}{xbm image/x-xbitmap}{uil text/x-uil}{STEP application/STEP}{src application/x-wais-source}{dtd text/xml}{dxf application/dxf}{c text/plain}{js application/x-javascript}{tcl application/x-tcl}{set application/set}{tsv text/tab-separated-values}{rtf application/x-rtf}{MPG video/mpeg}{sam application/vnd.lotus-wordpro}{MPE video/mpeg}{pdf application/pdf}{IGES application/iges}{ppm image/x-portable-pixmap}{zip multipart/x-zip}{shar application/x-shar}{nc application/x-netcdf}{avi video/x-msvideo}{mpeg video/mpeg}{au audio/basic}{list text/plain}{DXF application/dxf}{mime www/mime}{igs application/iges}{org application/vnd.lotus-organizer}{latex application/x-latex}{sv4crc application/x-sv4crc}{SET application/set}{dwg application/acad}{ksh application/x-ksh}{rgb image/x-rgb}{gtar application/x-gtar}{C text/plain}{etx text/x-setext}{pcl application/x-pcl}{ms application/x-troff-ms}{eps application/postscript}{ai application/postscript}{pgm image/x-portable-graymap}{qt video/quicktime}{java text/plain}{conf text/plain}{vew application/vnd.lotus-approach}{xml text/xml}{uu text/x-uuencode}{bsh application/x-bsh}{aif audio/x-aiff}{step application/STEP}{sv4cpio application/x-sv4cpio}{me application/x-troff-me}{stp application/STEP}{123 application/vnd.lotus-1-2-3}{movie video/x-sgi-movie}{mar text/plain}{*.* www/unknown}{IGS application/iges}{cxx text/plain}{stl application/SLA}{tex application/x-tex}{DWG application/acad}{man application/x-troff-man}{tar multipart/x-tar}{cdf application/x-netcdf}{* www/unknown}{dvi application/x-dvi}{iges application/iges}{JPEG image/jpeg}{prz application/vnd.lotus-freelance}{pbm image/x-portable-bitmap}{DRW application/drafting}{ustar multipart/x-ustar}{sdml text/plain}{jpg image/jpeg}{der application/x-x509-ca-cert}{ps application/postscript}{prt application/pro_eng}{jpe image/jpeg}{xpm image/x-xpixmap}{prs application/x-freelance}{apr application/vnd.lotus-approach}{scm application/vnd.lotus-screencam}{lst text/plain}{tr application/x-troff}{ras image/cmu-raster}{pnm image/x-portable-anymap}{hh text/plain}{tif image/tiff}{STP application/STEP}{PS application/postscript}{hdf application/x-hdf}{shtml text/x-ssi-html}{bcpio application/x-bcpio}{lwp application/vnd.lotus-wordpro}{roff application/x-troff}{STL application/SLA}{or3 application/vnd.lotus-organizer}{def text/plain}{or2 application/vnd.lotus-organizer}{wrl x-world/x-vrml}{htm text/html}{log text/plain}{f90 text/plain}{pre application/vnd.lotus-freelance}{class application/octet-stream}{unv application/i-deas}{gz multipart/x-gzip}{css text/css}{oda application/oda}{com text/plain}{vda application/vda}{texinfo application/x-texinfo}{wav audio/x-wav}{bin application/octet-stream}{texi application/x-texinfo}{bmp image/bmp}{JPG image/jpeg}{PRT application/pro_eng}{JPE image/jpeg}{MPEG video/mpeg}{csh application/x-csh}{html text/html}}}"
    set cmd {VirtualHost create $host -attribute $attrs}
    if {$VERBOSE} {puts [subst "# $cmd"]}
    eval $cmd


#
# ServletRedirector
#
set red "${NODE}ServletRedirector:Remote Servlet Redirector/"
# Create the remote ServletRedirector
    set attrs "{MaxStartupAttempts 5} {Stdout ${WAS_HOME}${FILE_SEPARATOR}logs${FILE_SEPARATOR}redirector_stdout.log} {Stderr ${WAS_HOME}${FILE_SEPARATOR}logs${FILE_SEPARATOR}redirector_stderr.log} {PingInitialTimeout 300} {PingInterval 60} {PingTimeout 200} {SelectionPolicy roundrobin} {MaxCon 50} {StartupTraceSpec *=all=disabled} {TransportAttributes {{linkType 0}{logfileMask 8}{cloneIndex 1}{logFile redirector.log}{queueName redirector}}} {TransportPort 9357} {TransportType 0}"
    set cmd {ServletRedirector create $red -attribute $attrs}
    if {$VERBOSE} {puts [subst "# $cmd"]}
    eval $cmd


#
# SessionManager
#
set mgr "${engine}SessionManager:Session Manager/"
# Create the session manager
    set attrs "{CookieComment {servlet session support}} {CookieDomain {}} {CookieMaximum -1} {CookieName sesessionid} {CookiePath /} {CookieSecure False} {DbDriver COM.ibm.db2.jdbc.app.DB2Driver} {DbLocation jdbc:db2:was} {DbNumberConnections 30} {EnableCookies True} {EnableProtSwitchRewriting False} {EnableSessions True} {EnableStatCollection True} {EnableUrlRewriting False} {IntervalInvalidateTime 1800} {PersistentSessions False} {PersistentType directodb} {UsingCache False} {UsingManualUpdate False} {UsingMultirow False} {UsingNativeAccess False}"
    set cmd {SessionManager create $mgr -attribute $attrs}
    if {$VERBOSE} {puts [subst "# $cmd"]}
    eval $cmd


#
# UserProfile
#
set profile "${engine}UserProfile:User Profile Manager/"
# Create the user profile manager
    set attrs "{DataWrapper com.ibm.servlet.personalization.userprofile.UserProfile} {EnableUserProfile False} {HomeInterfaceRO com.ibm.servlet.personalization.userprofile.UP_ReadOnlyHome} {HomeInterfaceRW com.ibm.servlet.personalization.userprofile.UP_ReadWriteHome} {JndiRO UP_ReadOnlyHome} {JndiRW UP_ReadWriteHome} {RemoteInterfaceRO com.ibm.servlet.personalization.userprofile.UP_ReadOnly} {RemoteInterfaceRW com.ibm.servlet.personalization.userprofile.UP_ReadWrite}"
    set cmd {UserProfile create $profile -attribute $attrs}
    if {$VERBOSE} {puts [subst "# $cmd"]}
    eval $cmd


#
# AdminApplication
#
set appl "/EnterpriseApplication:AdminApplication/"
# Create the AdminApplication
    set cmd {EnterpriseApplication create $appl}
    if {$VERBOSE} {puts [subst "# $cmd"]}
    eval $cmd


} ;# end of "if {0}"

#
# Types not created as part of the samples: 
#     DataSource, JDBCDriver, Model, GenericServer
#