5656import us .kbase .workspace .database .mongo .exceptions .BlobStoreCommunicationException ;
5757import us .kbase .workspace .kbase .KBaseWorkspaceConfig .ListenerConfig ;
5858import us .kbase .workspace .kbase .BytestreamIdHandlerFactory .BytestreamClientCloner ;
59+ import us .kbase .workspace .kbase .admin .AdministrationCommandSetInstaller ;
5960import us .kbase .workspace .kbase .admin .AdministratorHandler ;
6061import us .kbase .workspace .kbase .admin .AdministratorHandlerException ;
6162import us .kbase .workspace .kbase .admin .DefaultAdminHandler ;
6263import us .kbase .workspace .kbase .admin .KBaseAuth2AdminHandler ;
6364import us .kbase .workspace .kbase .admin .WorkspaceAdministration ;
65+ import us .kbase .workspace .kbase .admin .WorkspaceAdministration .UserValidator ;
6466import us .kbase .workspace .listener .ListenerInitializationException ;
6567import us .kbase .workspace .listener .WorkspaceEventListener ;
6668import us .kbase .workspace .listener .WorkspaceEventListenerFactory ;
@@ -78,9 +80,6 @@ public class InitWorkspaceServer {
7880
7981 public static final String COL_S3_OBJECTS = "s3_objects" ;
8082
81- private static final int ADMIN_CACHE_MAX_SIZE = 100 ; // seems like more than enough admins
82- private static final int ADMIN_CACHE_EXP_TIME_MS = 5 * 60 * 1000 ; // cache admin role for 5m
83-
8483 private static int maxUniqueIdCountPerCall = 100000 ;
8584
8685 private static int instanceCount = 0 ;
@@ -105,27 +104,20 @@ public boolean isFailed() {
105104 }
106105
107106 public static class WorkspaceInitResults {
108- private final Workspace ws ;
109107 private final WorkspaceServerMethods wsmeth ;
110108 private final WorkspaceAdministration wsadmin ;
111- private final Types types ;
109+ private final TypeServerMethods types ;
112110
113111 public WorkspaceInitResults (
114- final Workspace ws ,
115112 final WorkspaceServerMethods wsmeth ,
116113 final WorkspaceAdministration wsadmin ,
117- final Types types ) {
114+ final TypeServerMethods types ) {
118115 super ();
119- this .ws = ws ;
120116 this .wsmeth = wsmeth ;
121117 this .wsadmin = wsadmin ;
122118 this .types = types ;
123119 }
124120
125- public Workspace getWs () {
126- return ws ;
127- }
128-
129121 public WorkspaceServerMethods getWsmeth () {
130122 return wsmeth ;
131123 }
@@ -134,7 +126,7 @@ public WorkspaceAdministration getWsAdmin() {
134126 return wsadmin ;
135127 }
136128
137- public Types getTypes () {
129+ public TypeServerMethods getTypes () {
138130 return types ;
139131 }
140132 }
@@ -189,23 +181,25 @@ public static WorkspaceInitResults initWorkspaceServer(
189181 return null ;
190182 }
191183 rep .reportInfo (String .format ("Initialized %s backend" , cfg .getBackendType ().name ()));
192- final Types types = new Types (wsdeps .typeDB );
184+ // TODO CODE maybe merge these 2 classes?
185+ final LocalTypeServerMethods types = new LocalTypeServerMethods (new Types (wsdeps .typeDB ));
193186 final IdReferenceHandlerSetFactoryBuilder builder = IdReferenceHandlerSetFactoryBuilder
194187 .getBuilder (maxUniqueIdCountPerCall )
195188 .withFactory (new HandleIdHandlerFactory (hsc ))
196189 .withFactory (wsdeps .shockFac )
197190 .withFactory (wsdeps .sampleFac )
198191 .build ();
199- WorkspaceServerMethods wsmeth = new WorkspaceServerMethods (ws , types , builder , auth );
200- WorkspaceAdministration wsadmin = new WorkspaceAdministration (
201- ws , wsmeth , types , ah , ADMIN_CACHE_MAX_SIZE , ADMIN_CACHE_EXP_TIME_MS );
192+ final WorkspaceServerMethods wsmeth = new WorkspaceServerMethods (ws , builder , auth );
193+ final UserValidator userVal = (user , token ) -> wsmeth .validateUser (user , token );
194+ final WorkspaceAdministration wsadmin = AdministrationCommandSetInstaller .install (
195+ WorkspaceAdministration .getBuilder (ah , userVal ), wsmeth , types ).build ();
202196 final String mem = String .format (
203197 "Started workspace server instance %s. Free mem: %s Total mem: %s, Max mem: %s" ,
204198 ++instanceCount , Runtime .getRuntime ().freeMemory (),
205199 Runtime .getRuntime ().totalMemory (),
206200 Runtime .getRuntime ().maxMemory ());
207201 rep .reportInfo (mem );
208- return new WorkspaceInitResults (ws , wsmeth , wsadmin , types );
202+ return new WorkspaceInitResults (wsmeth , wsadmin , types );
209203 }
210204
211205 private static AdministratorHandler getAdminHandler (
0 commit comments