001    /*
002     * Copyright (c) 2009 The openGion Project.
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     *     http://www.apache.org/licenses/LICENSE-2.0
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
013     * either express or implied. See the License for the specific language
014     * governing permissions and limitations under the License.
015     */
016    package org.opengion.fukurou.transfer;
017    
018    import org.opengion.fukurou.util.StringUtil;
019    
020    /**
021     * ä¼é?è¦æ±‚ã«å¯¾ã—ã¦ã®HTTPçµŒç”±ã§æ—§ä¼é?DB(CB01)ã®èª­å–を行ã„ã¾ã™ã?
022     *
023     * 読å–対象ã¯ã€?ãƒ??タコーãƒ? (é€ã‚Šå…? (ãƒ?‚­ã‚¹ãƒˆç¨®åˆ¥) ([プロトコル]://[ホストå]:[ãƒã?ト番å·]/[コンãƒ?‚­ã‚¹ãƒˆå]/)
024     * ã®å½¢å¼ã§æŒ?®šã—ã¾ã™ã?
025     *
026     * ä¾?読å–対象 : 3 D9 B991 http://localhost:8824/gf/
027     *
028     * ãã?ä»–ã?処ç??容ã«ã¤ã?¦ã¯ã€{@link org.opengion.fukurou.transfer.TransferRead_HTTP}åŠã?
029     * {@link org.opengion.fukurou.transfer.TransferRead_CB01}ã®JavaDocã‚’å‚ç…§ã—ã¦ä¸‹ã•ã??
030     *
031     * @og.group ä¼é?シスãƒ?ƒ 
032     *
033     * @version  5.0
034     * @author   Hiroki.Nakamura
035     * @since    JDK1.6
036     */
037    public class TransferRead_HTTP_CB01 extends TransferRead_HTTP {
038    
039            private String remoteHost = null;               // リモート接続å?URL
040            private String remoteReadObj = null;    // リモート接続å?ã®èª­å–対象
041    
042            /**
043             * ローカルã®èª­å–対象をã?リモート接続å?ã®èª­å–対象ã¨ãƒªãƒ¢ãƒ¼ãƒˆæŽ¥ç¶šå?URLã«åˆ?§£ã—ã¾ã™ã?
044             *
045             * @param localReadObj ローカルã®èª­å–対象
046             */
047            @Override
048            protected void splitReadObj( final String localReadObj ) {
049                    String[] obj = StringUtil.csv2Array( localReadObj, ' ' );
050                    if( obj.length < 4 ) {
051                            String errMsg = "読å–対象ã¯ã€?ãƒ??タコーãƒ? (é€ã‚Šå…? (ãƒ?‚­ã‚¹ãƒˆç¨®åˆ¥) ([プロトコル]://[ホストå]:[ãƒã?ト番å·]/[コンãƒ?‚­ã‚¹ãƒˆå]/) ã®å½¢å¼ã§æŒ?®šã—ã¦ä¸‹ã•ã??[READOBJ=" + localReadObj + "]";
052                            throw new RuntimeException( errMsg );
053                    }
054                    String hcdd = obj[0];
055                    String hto = obj[1];
056                    String hsyu = obj[2];
057                    remoteHost = obj[3];
058                    if( hcdd == null || hcdd.length() == 0
059                     || hto  == null || hto.length()  == 0
060                     || hsyu == null || hsyu.length() == 0
061                     || remoteHost == null || remoteHost.length() == 0 ) {
062                            String errMsg = "読å–対象ã¯ã€?ãƒ??タコーãƒ? (é€ã‚Šå…? (ãƒ?‚­ã‚¹ãƒˆç¨®åˆ¥) ([プロトコル]://[ホストå]:[ãƒã?ト番å·]/[コンãƒ?‚­ã‚¹ãƒˆå]/) ã¯å¿??ã§ã™ã?[READOBJ=" + localReadObj + "]";
063                            throw new RuntimeException( errMsg );
064                    }
065    
066                    remoteReadObj = hcdd + " " + hto + " " + hsyu;
067            }
068    
069            /**
070             * リモート接続å?URLã‚’è¿”ã—ã¾ã™ã?
071             * ã“ã?メソãƒ?ƒ‰ã¯ã€{@link #splitReadObj(String)}ã®å¾Œã«å‘¼ã³å‡ºã—ã™ã‚‹å¿?¦ãŒã‚りã¾ã™ã?
072             *
073             * @return リモート接続å?URL
074             */
075            @Override
076            public String getRemoteHost() {
077                    if( remoteHost == null || remoteHost.length() == 0 ) {
078                            String errMsg = "å…ˆã«#splitReadObj(String)を実行ã—ã¦ä¸‹ã•ã?;
079                            throw new RuntimeException( errMsg );
080                    }
081                    return remoteHost;
082            }
083    
084            /**
085             * リモート接続å?ã®èª­å–対象を返ã—ã¾ã™ã?
086             * ã“ã?メソãƒ?ƒ‰ã¯ã€{@link #splitReadObj(String)}ã®å¾Œã«å‘¼ã³å‡ºã—ã™ã‚‹å¿?¦ãŒã‚りã¾ã™ã?
087             *
088             * @return 接続URL
089             */
090            @Override
091            public String getRemoteReadObj() {
092                    if( remoteHost == null || remoteHost.length() == 0 ) {
093                            String errMsg = "å…ˆã«#splitReadObj(String)を実行ã—ã¦ä¸‹ã•ã?;
094                            throw new RuntimeException( errMsg );
095                    }
096                    return remoteReadObj;
097            }
098    }