2016-07-20 8 views
0

IBM Connectionsでファイルアップロード・イベントをトラップして、何らかのアクションを実行したいとします。特定の基準が満たされた場合、ファイルはシステム内に保存する必要があります。そうでない場合は、メッセージで拒否する必要があります。事前イベント・ハンドラー - IBM Connections

これについては、IBM Connections SPI(Pre-Event Handlerフック)を検討していました。私はjarを作成し、デプロイして設定を変更するために文書ごとに必要な手順に従っていますが、ファイルがConnectionsにアップロードされるときに自分のコードが呼び出されないようです。

わかりませんが、どこに問題があるのですか、私にはエラーもありません。

PS:Postイベントハンドラフックを試してみましたが、正常に動作しました。続き

はスニペット

public class PreHandlerEvents implements PreEventHandler{ 
    @Override 
    public void destroy() { 
     // TODO Auto-generated method stub 

    } 

    @Override 
    public void handleEvent(MutableEvent arg0) throws EventHandlerException { 

     String content = "This is the content to write into file"; 
     File file = new File("filenamePre.txt"); 

     // if file doesnt exists, then create it 
     if (!file.exists()) { 
      try { 
       file.createNewFile(); 
      } catch (IOException e) { 
       // TODO Auto-generated catch block 
       e.printStackTrace(); 
      } 
     } 

     FileWriter fw; 
     try { 
      fw = new FileWriter(file.getAbsoluteFile()); 
      BufferedWriter bw = new BufferedWriter(fw); 
      bw.write(content); 
      bw.close(); 
     } catch (IOException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } 
    } 

イベント-config.xmlの


<preHandler enabled="true" name="PreHandlerEvents" class="com.connections.PreHandlerEvents"> 
     <subscriptions> 
      <subscription source="*" type="*" eventName="*"/> 
     </subscriptions> 
    </preHandler> 
</preHandlers> 
+0

。私と私たちの両方の顧客は独立して働くことを試みましたが、私たちのどちらも管理しませんでした。 Posteventhandlerは完全にうまくいった。 – subrunner

答えて

0

おそらくではなく、PreEventHandlerあり、あなたはあなたの<preHandler .../>に代わりEventHandlerを使用することができます?

コード例:私のために同じ

public class CustomEventHandler implements EventHandler { 

    public void init() throws EventHandlerInitException {} 

    public void destroy() {} 

    @Override 
    public void handleEvent(Event event) throws EventHandlerException { 
     System.out.println(" +++ Event: " + event.getName()); 
    } 
} 
関連する問題