Package com.baidu.ueditor.define

Examples of com.baidu.ueditor.define.BaseState


  }
 
  private State getState ( Object[] files ) {
   
    MultiState state = new MultiState( true );
    BaseState fileState = null;
   
    File file = null;
   
    for ( Object obj : files ) {
      if ( obj == null ) {
        break;
      }
      file = (File)obj;
      fileState = new BaseState( true );
      fileState.putInfo( "url", PathFormat.format( this.getPath( file ) ) );
      state.addState( fileState );
    }
   
    return state;
   
View Full Code Here


   
    try {
      url = new URL( urlStr );

      if ( !validHost( url.getHost() ) ) {
        return new BaseState( false, AppInfo.PREVENT_HOST );
      }
     
      connection = (HttpURLConnection) url.openConnection();
   
      connection.setInstanceFollowRedirects( true );
      connection.setUseCaches( true );
   
      if ( !validContentState( connection.getResponseCode() ) ) {
        return new BaseState( false, AppInfo.CONNECTION_ERROR );
      }
     
      suffix = MIMEType.getSuffix( connection.getContentType() );
     
      if ( !validFileType( suffix ) ) {
        return new BaseState( false, AppInfo.NOT_ALLOW_FILE_TYPE );
      }
     
      if ( !validFileSize( connection.getContentLength() ) ) {
        return new BaseState( false, AppInfo.MAX_SIZE );
      }
     
      String savePath = this.getPath( this.savePath, this.filename, suffix );
      String physicalPath = this.rootPath + savePath;

      State state = StorageManager.saveFileByInputStream( connection.getInputStream(), physicalPath );
     
      if ( state.isSuccess() ) {
        state.putInfo( "url", PathFormat.format( savePath ) );
        state.putInfo( "source", urlStr );
      }
     
      return state;
     
    } catch ( Exception e ) {
      return new BaseState( false, AppInfo.REMOTE_FAIL );
    }
   
  }
View Full Code Here

TOP

Related Classes of com.baidu.ueditor.define.BaseState

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.