コード例 #1
0
  @Override
  public void login(IPCUser user) throws RemoteException {

    if ("".equals(user.getUserName())) {
      onUserStateChanged(user.getUserName(), GSUserState.Logoff, GSError.UNKNOWN_ERROR);

      return;
    }

    synchronized (this) {
      if (this.userState != GSUserState.Logoff) {

        if (this.userState == GSUserState.Login
            && user.getUserName().equals(this.client.getUser())) {
          onUserStateChanged(user.getUserName(), GSUserState.Login, GSError.SUCCESS);

          return;
        }

        logger.warn("other login({}) processing {}", this.client.getUser(), this.userState);

        onUserStateChanged(user.getUserName(), GSUserState.Logoff, GSError.OTHER_USER_LOGIN);

        return;
      }

      logger.debug("login with user({})", user.getUserName());

      this.client.setUser(user.getUserName());

      this.userState = GSUserState.LoginProcessing;

      onUserStateChanged(GSError.SUCCESS);

      try {

        this.imGateway.Login(this.client.getUser());

        coreService.updateClient(this.client);

        this.binderDataBase.openUserDataBase(client.getUser());

      } catch (Exception e) {

        this.userState = GSUserState.Logoff;

        onUserStateChanged(GSError.UNKNOWN_ERROR);

        logger.error("login catch exception", e);
      }
    }
  }
コード例 #2
0
ファイル: Plugin.java プロジェクト: jri/deepamehta3-core
 /**
  * Creates a Plugin topic in the DB, if not already exists.
  *
  * <p>A Plugin topic represents an installed plugin and is used to track its version.
  *
  * @return <code>true</code> if a Plugin topic has been created (means: this is a plugin clean
  *     install), <code>false</code> otherwise.
  */
 private boolean initPluginTopic() {
   pluginTopic = findPluginTopic();
   if (pluginTopic != null) {
     logger.info("Do NOT create topic for plugin \"" + pluginName + "\" -- already exists");
     return false;
   } else {
     logger.info(
         "Creating topic for plugin \"" + pluginName + "\" -- this is a plugin clean install");
     Map properties = new HashMap();
     properties.put("de/deepamehta/core/property/PluginID", pluginId);
     properties.put("de/deepamehta/core/property/PluginMigrationNr", 0);
     // FIXME: clientContext=null
     pluginTopic = dms.createTopic("de/deepamehta/core/topictype/Plugin", properties, null);
     return true;
   }
 }
コード例 #3
0
ファイル: Plugin.java プロジェクト: jri/deepamehta3-core
 /** Determines the migrations to be run for this plugin and run them. */
 private void runPluginMigrations(boolean isCleanInstall) {
   int migrationNr =
       (Integer) pluginTopic.getProperty("de/deepamehta/core/property/PluginMigrationNr");
   int requiredMigrationNr = Integer.parseInt(getConfigProperty("requiredPluginMigrationNr", "0"));
   int migrationsToRun = requiredMigrationNr - migrationNr;
   logger.info(
       "migrationNr="
           + migrationNr
           + ", requiredMigrationNr="
           + requiredMigrationNr
           + " -- running "
           + migrationsToRun
           + " plugin migrations");
   for (int i = migrationNr + 1; i <= requiredMigrationNr; i++) {
     dms.runPluginMigration(this, i, isCleanInstall);
   }
 }
コード例 #4
0
ファイル: Plugin.java プロジェクト: jri/deepamehta3-core
 private void initPlugin() {
   RuntimeException ex = null;
   Transaction tx = dms.beginTx();
   try {
     logger.info("----- Initializing plugin \"" + pluginName + "\" -----");
     boolean isCleanInstall = initPluginTopic();
     runPluginMigrations(isCleanInstall);
     if (isCleanInstall) {
       postInstallPluginHook(); // trigger hook
       introduceTypesToPlugin();
     }
     registerPlugin();
     tx.success();
   } catch (Throwable e) {
     logger.warning("ROLLBACK!");
     ex = new RuntimeException("Plugin \"" + pluginName + "\" can't be activated. Reason:", e);
   } finally {
     tx.finish();
     if (ex != null) {
       throw ex;
     }
   }
 }
コード例 #5
0
  /**
   * create core service binder
   *
   * @param coreService core service
   * @param client client
   */
  public CoreServiceBinder(CoreService coreService, Client client) {

    this.binderDataBase =
        new CoreServiceBinderDataBase(coreService.getApplicationContext(), client.getUrl());

    this.coreService = coreService;

    this.client = new Client(client);

    this.channel = new IMChannel(this);

    this.channel.connect();

    this.imGateway = new IMGateway(this, new IMGatewayRPC(this.channel, Service.GW.getValue()));

    this.imServer = new IMServer(this, new IMServerRPC(this.channel, Service.GS.getValue()));

    if (!emptyUser()) {

      this.binderDataBase.openUserDataBase(this.client.getUser());

      this.autoLogin();
    }
  }
コード例 #6
0
ファイル: Plugin.java プロジェクト: jri/deepamehta3-core
 private void introduceTypesToPlugin() {
   for (String typeUri : dms.getTopicTypeUris()) {
     // trigger hook
     modifyTopicTypeHook(dms.getTopicType(typeUri, null), null); // clientContext=null
   }
 }
コード例 #7
0
ファイル: Plugin.java プロジェクト: jri/deepamehta3-core
 private Topic findPluginTopic() {
   return dms.getTopic("de/deepamehta/core/property/PluginID", pluginId);
 }
コード例 #8
0
ファイル: Plugin.java プロジェクト: jri/deepamehta3-core
 private void unregisterPlugin() {
   if (isActivated) {
     logger.info("Unregistering plugin \"" + pluginName + "\" at DeepaMehta core service");
     dms.unregisterPlugin(pluginId);
   }
 }
コード例 #9
0
ファイル: Plugin.java プロジェクト: jri/deepamehta3-core
 private void registerPlugin() {
   logger.info("Registering plugin \"" + pluginName + "\" at DeepaMehta core service");
   dms.registerPlugin(this);
   isActivated = true;
 }