/*
このファイルの中身は、NTT オープンソースライセンス　バージョン 1.0（「本
契約」という）の適用を受けます。
本契約を遵守しない限り、このファイルを使用してはなりません。
本契約のコピーは、次のＵＲＬから入手できます。
【配布サイトのURL】 http://www.oss.ecl.ntt.co.jp/lms/

本契約に基づき頒布されるソフトウェアは、現状のまま、明示又は黙示のあらゆ
る種類の保証なしで、頒布されます。本契約に基づく権利及び制限を律する特定
の文言については、本契約を参照してください。

「オリジナルコード」は、 NTT Cyber Space Laboratories Code です。 
「オリジナルコード」の「初期開発者」は、日本電信電話株式会社です。  
日本電信電話株式会社により創作された部分は、Copyright (C) 2004 
日本電信電話株式会社 です。
全ての権利が留保されます。 
「コントリビュータ」：_____________________________________ 


The contents of this file are subject to the NTT Opensource License
Version 1.0 (the License); you may not use this file except in
compliance with the License. You may obtain a copy of the License at
【配布サイトのURL】 http://www.oss.ecl.ntt.co.jp/lms/

Software distributed under the License is distributed on an AS IS
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific language governing rights and limitations
under the License.

The Original Code is NTT Cyber Space Laboratories Code .

The Initial Developer of the Original Code is NIPPON TELEGRAPH AND 
TELEPHONE CORPORATION.
Portions created by the NIPPON TELEGRAPH AND TELEPHONE CORPORATION 
are Copyright (C) 2004 NIPPON TELEGRAPH AND TELEPHONE CORPORATION. 
All Rights Reserved.

Contributor(s) ______________________________________.
*/
//********************************************************************************
// 更新日  ：2004.01.08 新規作成
//********************************************************************************
import java.awt.*;
import java.applet.*;
import java.net.*;
import java.io.*;

public class Wbt extends Applet{

	//アプレットの構築
	public Wbt() {
	}

	//変数宣言
	String GVstrPath1 = "";
	String GVstrPath2 = "";
	String GVstrSessionID = "";

	//アプレットの初期化
	public void init() {

		GVstrSessionID = "";
		GVstrPath1 = getParameter("path");
		GVstrPath2 = getParameter("path2");

	}

	/**
	 * XMSⅡグループツリー構造取得用
	 */
	public String getChildList( String strParentID ) {
		StringBuffer strGetLine = new StringBuffer();

		try{
			URL objUrl = new URL(GVstrPath1 + "?ParentID=" + strParentID );
			BufferedReader objBr = new BufferedReader(new InputStreamReader(objUrl.openStream()));
			String strLine = "";
			int 	i = 0;

			while((strLine = objBr.readLine()) != null){
				strGetLine.append( strLine );
				strGetLine.append( "\n" );
				i++;
			}
		}
		catch(Exception e) {
			e.printStackTrace();
			strGetLine = new StringBuffer();
			strGetLine.append( "ERR" );
		}
		return strGetLine.toString().trim();
	}

	/**
	 * XMSⅡグループツリー構造取得用
	 */
	public String getChildList( String strParentID, String strUserID ) {
		StringBuffer strGetLine = new StringBuffer();

		try{
			String strURL = "";
			strURL = GVstrPath1 + "?ParentID=" + strParentID + "&userId=" + strUserID;

			URL objUrl = new URL(strURL);
			BufferedReader objBr = new BufferedReader(new InputStreamReader(objUrl.openStream()));
			String strLine = "";
			int 	i = 0;

			while((strLine = objBr.readLine()) != null){
				strGetLine.append( strLine );
				strGetLine.append( "\n" );
				i++;
			}
		}
		catch(Exception e) {
			e.printStackTrace();
			strGetLine = new StringBuffer();
			strGetLine.append( "ERR" );
		}
		return strGetLine.toString().trim();
	}

	/**
	 * XMSⅡ教材構造取得用
	 */
	public String getMaterialStructure( String strMaterialPath ) {
		StringBuffer strGetLine = new StringBuffer();

		try{
			String strURL = GVstrPath2 + "?MaterialPath=" + strMaterialPath;
			URL objUrl = new URL(strURL);
			BufferedReader objBr = new BufferedReader(new InputStreamReader(objUrl.openStream()));
			String strLine = "";
			int 	i = 0;

			while((strLine = objBr.readLine()) != null){
				strGetLine.append( strLine );
				strGetLine.append( "\n" );
				i++;
			}
		}
		catch(Exception e) {
			e.printStackTrace();
			strGetLine = new StringBuffer();
			strGetLine.append( "ERR" );
		}
		return strGetLine.toString().trim();
	}

	/**
	 * XMSⅡ メニュー取得メソッド
	 * @param strLoID LOID
	 * @param strLearner ユーザID
	 * @param strIniMenu 学習者フラグ
	 * @param strTreePath ツリーパス
	 * @param strOpenInfo ツリー展開情報
	 */
	public String getMenuList(	String strLoID,
								String strAUID,
								String strGroupUserID,
								String strParentID,
								String strSelectID,
								String strTreeViewType,
								String strIniMenu,
								String strTreePath,
								String strOpenInfo,
								String strPopupType ) {
		StringBuffer strGetLine = new StringBuffer();
		try{
			String strURL = GVstrPath1 + "?loID=" + strLoID +
							"&auID=" + strAUID +
							"&GroupUserID=" + strGroupUserID +
							"&parentID=" + strParentID +
							"&tree_view_type=" + strTreeViewType +
							"&selectID=" + strSelectID +
							"&ini_menu=" + strIniMenu +
							"&treepath=" + strTreePath +
							"&open_info=" + strOpenInfo +
							"&popupType=" + strPopupType;

			URL objUrl = new URL(strURL);
			BufferedReader objBr = new BufferedReader(new InputStreamReader(objUrl.openStream()));
			String strLine = "";
			int 	i = 0;

			while((strLine = objBr.readLine()) != null){
				strGetLine.append( strLine );
				strGetLine.append( "\n" );
				i++;
			}
		}
		catch(Exception e) {
			e.printStackTrace();
			strGetLine = new StringBuffer();
			strGetLine.append( "ERR" );
		}
		return strGetLine.toString().trim();
	}

	/**
	 * XMSⅡ LOメニュー取得メソッド
	 * @param strLoID LOID
	 * @param strLearner ユーザID
	 * @param strIniMenu 学習者フラグ
	 * @param strTreePath ツリーパス
	 * @param strOpenInfo ツリー展開情報
	 */
	public String getLoMenuList( String strLoID, String strAUID, String strGroupUserID, String strIniMenu, String strTreePath, String strOpenInfo ) {
		StringBuffer strGetLine = new StringBuffer();
		try{
			String strURL = GVstrPath1 + "?loID=" + strLoID + "&auID=" + strAUID + "&GroupUserID=" + strGroupUserID + "&ini_menu=" + strIniMenu + "&treepath=" + strTreePath + "&open_info=" + strOpenInfo;
			URL objUrl = new URL(strURL);
			BufferedReader objBr = new BufferedReader(new InputStreamReader(objUrl.openStream()));
			String strLine = "";
			int 	i = 0;

			while((strLine = objBr.readLine()) != null){
				strGetLine.append( strLine );
				strGetLine.append( "\n" );
				i++;
			}
		}
		catch(Exception e) {
			e.printStackTrace();
			strGetLine = new StringBuffer();
			strGetLine.append( "ERR" );
		}
		return strGetLine.toString().trim();
	}

	/**
	 * XMSⅡ 教材一覧取得
	 * @param strLoType LO種別
	 */
	public String getMaterialList( String strLoType ) {

		StringBuffer strGetLine = new StringBuffer();
		try{
			URL objUrl = new URL(GVstrPath1 + "?LoType=" + strLoType);
			BufferedReader objBr = new BufferedReader(new InputStreamReader(objUrl.openStream()));
			String strLine = "";
			int 	i = 0;

			while((strLine = objBr.readLine()) != null){
				strGetLine.append( strLine );
				strGetLine.append( "\n" );
				i++;
			}
		}
		catch(Exception e) {
			e.printStackTrace();
			strGetLine = new StringBuffer();
			strGetLine.append( "ERR" );
		}
		return strGetLine.toString().trim();
	}


	/**
	 * XMSⅡＬＯツリー構造取得用
	 * ＬＯアサイン用アプレット
	 * ＬＯの登録または削除を行う
	 */
	public String setAssignmentsInfo( String strTreeViewType, String strMode, String strParentID, String strSelectID, String strParentLoID, String strLoID, String strInsertMode, String strLearnAuthority, String strManageAuthority, String strSendMailFlag) {	
		StringBuffer strGetLine = new StringBuffer();

		try{
			URL objUrl = new URL(GVstrPath1 + "?tree_view_type=" + strTreeViewType + "&Mode=" + strMode + "&ParentID=" + strParentID  + "&SelectID=" + strSelectID + "&ParentLoID=" + strParentLoID + "&LoID=" + strLoID + "&insert_mode=" + strInsertMode + "&LearnAuthority=" + strLearnAuthority + "&ManageAuthority=" + strManageAuthority + "&SendMailFlag=" + strSendMailFlag);	
			BufferedReader objBr = new BufferedReader(new InputStreamReader(objUrl.openStream()));
			String strLine = "";
			int 	i = 0;

			while((strLine = objBr.readLine()) != null){
				strGetLine.append( strLine );
				strGetLine.append( "\n" );
				i++;
			}
		}
		catch(Exception e) {
			e.printStackTrace();
			strGetLine = new StringBuffer();
			strGetLine.append( "ERR" );
		}
		return strGetLine.toString().trim();
	}


	/**
	 * XMSⅡ権限構造取得用
	 * 権限アサイン用アプレット
	 * 権限の登録または削除を行う
	 */
	public String setRoleAssignmentsInfo( String strMode, String strParentID, String strSelectID, String strRoleID, String strParentGruopID, String strGruopID ) {
		StringBuffer strGetLine = new StringBuffer();

		try{
			URL objUrl = new URL(GVstrPath1 + "?Mode=" + strMode + "&ParentID=" + strParentID  + "&SelectID=" + strSelectID + "&RoleID=" + strRoleID + "&ParentGruopID=" + strParentGruopID + "&GruopID=" + strGruopID);
			BufferedReader objBr = new BufferedReader(new InputStreamReader(objUrl.openStream()));
			String strLine = "";
			int 	i = 0;

			while((strLine = objBr.readLine()) != null){
				strGetLine.append( strLine );
				strGetLine.append( "\n" );
				i++;
			}
		}
		catch(Exception e) {
			e.printStackTrace();
			strGetLine = new StringBuffer();
			strGetLine.append( "ERR" );
		}
		return strGetLine.toString().trim();
	}

	/**
	 * Assignments メニュー取得メソッド
	 * @param strSelectID 選択ID
	 */
	public String getAssignmentsMenuList(	String strSelectID ) {
		StringBuffer strGetLine = new StringBuffer();
		try{
			String strURL = GVstrPath1 + "?SelectID=" + strSelectID;
			
			URL objUrl = new URL(strURL);
			BufferedReader objBr = new BufferedReader(new InputStreamReader(objUrl.openStream()));
			String strLine = "";
			int 	i = 0;
			
			while((strLine = objBr.readLine()) != null){
				strGetLine.append( strLine );
				strGetLine.append( "\n" );
				i++;
			}
		}
		catch(Exception e) {
			e.printStackTrace();
			strGetLine = new StringBuffer();
			strGetLine.append( "ERR" );
		}
		return strGetLine.toString().trim();
	}

}

//********************************************************************************
//          Unpublished Copyright (C) 2003 NTT
//********************************************************************************
