Просмотр исходного кода

优化及去掉不必要systemout

KeYuan 8 лет назад
Родитель
Сommit
becacdad12

+ 2 - 1
bin/install-lose-jar.bat

@@ -1,4 +1,5 @@
 @echo [信息] 安装中央仓库缺失jar。
 call mvn install:install-file -Dfile=../lib/QRCode.jar -DgroupId=net.qrcode -DartifactId=qrcode -Dversion=1.0 -Dpackaging=jar
 call mvn install:install-file -Dfile=../lib/spssw-1.66.jar -DgroupId=net.spssw -DartifactId=spssw -Dversion=1.66 -Dpackaging=jar
-call mvn install:install-file -Dfile=../lib/xssProtect-0.1.jar -DgroupId=net.xssprotect -DartifactId=xssprotest -Dversion=1.0 -Dpackaging=jar
+call mvn install:install-file -Dfile=../lib/xssProtect-0.1.jar -DgroupId=net.xssprotect -DartifactId=xssprotest -Dversion=1.0 -Dpackaging=jar
+call mvn install:install-file -Dfile=../lib/ueditor-1.1.2.jar -DgroupId=com.baidu -DartifactId=ueditor -Dversion=1.1.2 -Dpackaging=jar

+ 2 - 1
bin/install-lose-jar.sh

@@ -3,4 +3,5 @@
 echo [信息] 安装中央仓库缺失jar。
 mvn install:install-file -Dfile=../lib/QRCode.jar -DgroupId=net.qrcode -DartifactId=qrcode -Dversion=1.0 -Dpackaging=jar
 mvn install:install-file -Dfile=../lib/spssw-1.66.jar -DgroupId=net.spssw -DartifactId=spssw -Dversion=1.66 -Dpackaging=jar
-mvn install:install-file -Dfile=../lib/xssProtect-0.1.jar -DgroupId=net.xssprotect -DartifactId=xssprotest -Dversion=1.0 -Dpackaging=jar
+mvn install:install-file -Dfile=../lib/xssProtect-0.1.jar -DgroupId=net.xssprotect -DartifactId=xssprotest -Dversion=1.0 -Dpackaging=jar
+mvn install:install-file -Dfile=../lib/ueditor-1.1.2.jar -DgroupId=com.baidu -DartifactId=ueditor -Dversion=1.1.2 -Dpackaging=jar

+ 2 - 13
src/main/java/com/baidu/ueditor/ActionEnter.java

@@ -240,22 +240,11 @@ public final class ConfigManager {
 				
 				String path = this.getConfigPath();
 				String newContent = builder.toString();
-				if("local".equals(DiaowenProperty.DWSTORAGETYPE)){
-//					newContent = newContent.replaceAll( "http://file.diaowen.net", DiaowenProperty.STORAGE_URL_PREFIX);
-					newContent = newContent.replaceAll( "http://file.diaowen.net/", InitAppliction.contextPath );
-//					newContent = newContent.replaceAll( "http://file.diaowen.net", "../" );
-				}else{
-					newContent = newContent.replaceAll( "http://file.diaowen.net/", DiaowenProperty.STORAGE_URL_PREFIX);
-				}
-				// "imageUrlPrefix": "http://file.diaowen.net/", /* 图片访问路径前缀 */
-//				String newContent = newContent.replaceAll( "http://file.diaowen.net", DiaowenProperty.STORAGE_URL_PREFIX);
+				newContent = newContent.replaceAll( "http://file.diaowen.net/", InitAppliction.contextPath );
 				OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(path), "UTF-8");
 				writer.write(newContent);
 				writer.close();
-				
-				
-//				System.out.println(ServletActionContext.getContext());
-				
+
 			} catch ( UnsupportedEncodingException e ) {
 				e.printStackTrace();
 			} catch (Exception e) {

+ 22 - 102
src/main/java/com/baidu/ueditor/Encoder.java

@@ -36,38 +36,32 @@ public class FileManager {
 	}
 	
 	public State listFile ( int index ) {
-		
-		if("local".equals(DiaowenProperty.DWSTORAGETYPE)) {
-			File dir = new File( this.rootPath + this.dir );
 
-			State state = null;
+		File dir = new File( this.rootPath + this.dir );
 
-			if ( !dir.exists() ) {
-				return new BaseState( false, AppInfo.NOT_EXIST );
-			}
-			
-			if ( !dir.isDirectory() ) {
-				return new BaseState( false, AppInfo.NOT_DIRECTORY );
-			}
-			
-			Collection<File> list = FileUtils.listFiles( dir, this.allowFiles, true );
+		State state = null;
 
-			if ( index < 0 || index > list.size() ) {
-				state = new MultiState( true );
-			} else {
-				Object[] fileList = Arrays.copyOfRange( list.toArray(), index, index + this.count );
-				state = this.getState( fileList );
-			}
-			
-			state.putInfo( "start", index );
-			state.putInfo( "total", list.size() );
-			
-			return state;
-		}else{
-			
-			return listFileByYun(index);
-			
+		if ( !dir.exists() ) {
+			return new BaseState( false, AppInfo.NOT_EXIST );
+		}
+
+		if ( !dir.isDirectory() ) {
+			return new BaseState( false, AppInfo.NOT_DIRECTORY );
 		}
+
+		Collection<File> list = FileUtils.listFiles( dir, this.allowFiles, true );
+
+		if ( index < 0 || index > list.size() ) {
+			state = new MultiState( true );
+		} else {
+			Object[] fileList = Arrays.copyOfRange( list.toArray(), index, index + this.count );
+			state = this.getState( fileList );
+		}
+
+		state.putInfo( "start", index );
+		state.putInfo( "total", list.size() );
+
+		return state;
 		
 	}
 	
@@ -133,79 +127,5 @@ public class FileManager {
 		
 	}
 	
-	/*
-	 * yun实现的操作
-	 */
-	public State listFileByYun ( int index ) {
-		dir=dir.substring(1);
-		
-		//得到当前用户
-		String userId=PathFormat.getUserId();
-		dir=dir+userId+"/";
-		State state = null;
-		try{
-			Collection list = null;
-			if("aliyunOSS".equals(DiaowenProperty.DWSTORAGETYPE)){
-				// 阿里云支持 
-				list = AliyunOSS.getObjectList(DiaowenProperty.UPLOADFILE_BACKET, dir,index+count,count);
-			}else if("baiduBOS".equals(DiaowenProperty.DWSTORAGETYPE)){
-				list = BaiduBOS.getObjectList(DiaowenProperty.UPLOADFILE_BACKET, dir,index+count,count);
-				
-			}
-
-			if ( index < 0 || index > list.size() ) {
-				state = new MultiState( true );
-			} else {
-				Object[] fileList = Arrays.copyOfRange( list.toArray(), index, index + this.count );
-				state = this.getStateByYun( fileList );
-			}
-			
-			state.putInfo( "start", index );
-			state.putInfo( "total", list.size() );
-			
-		}catch(Exception e){
-			state = new BaseState( false, AppInfo.NOT_EXIST );
-			e.printStackTrace();
-		}
-		
-		return state;
-		
-	}
-	
-	private State getStateByYun ( Object[] files ) {
-		
-		MultiState state = new MultiState( true );
-		BaseState fileState = null;
-		
-		
-		for ( Object obj : files ) {
-			if ( obj == null ) {
-				break;
-			}
-			
-			if(obj instanceof OSSObjectSummary ){
-				OSSObjectSummary file = (OSSObjectSummary)obj;
-
-				fileState = new BaseState( true );
-//				fileState.putInfo( "url", "http://file.diaowen.net/"+PathFormat.format( file.getKey() ) );
-				fileState.putInfo( "url", PathFormat.format( file.getKey() ) );
-				state.addState( fileState );
-				
-			}else{
-				//obj instanceof BosObjectSummary 
-				BosObjectSummary file = (BosObjectSummary)obj;
-				
-				fileState = new BaseState( true );
-//				fileState.putInfo( "url", "http://file.diaowen.net/"+PathFormat.format( file.getKey() ) );
-				fileState.putInfo( "url", PathFormat.format( file.getKey() ) );
-				state.addState( fileState );
-			}
-			
-		}
-		
-		return state;
-		
-	}
-	
 	
 }

+ 1 - 5
src/main/java/com/baidu/ueditor/hunter/ImageHunter.java

@@ -28,14 +28,10 @@ public final class Base64Uploader {
 				(String) conf.get("filename"));
 		
 		savePath = savePath + suffix;
-//		String physicalPath = (String) conf.get("rootPath") + savePath;
-//		State storageState = StorageManager.saveBinaryFile(data, savePath);
-		State storageState = StorageManager.saveBinaryFile(data, (String) conf.get("rootPath"), savePath); 
-//		State storageState = StorageManager.saveBinaryFileToYun(data, savePath);
+		State storageState = StorageManager.saveBinaryFile(data, (String) conf.get("rootPath"), savePath);
 
 		if (storageState.isSuccess()) {
 			storageState.putInfo("url", PathFormat.format(savePath));
-//			storageState.putInfo("url", "http://file.diaowen.net"+PathFormat.format(savePath));
 			storageState.putInfo("type", suffix);
 			storageState.putInfo("original", "");
 		}

+ 0 - 1
src/main/java/com/baidu/ueditor/upload/BinaryUploader.java

@@ -89,7 +89,6 @@ public class BinaryUploader {
 			
 			if (storageState.isSuccess()) {
 				storageState.putInfo("url", PathFormat.format(savePath));
-//				storageState.putInfo("url", "http://file.diaowen.net"+PathFormat.format(savePath));
 				storageState.putInfo("type", suffix);
 				storageState.putInfo("original", originFileName + suffix);
 			}

+ 3 - 85
src/main/java/com/baidu/ueditor/upload/StorageManager.java

@@ -25,9 +25,6 @@ public class StorageManager {
 	}
 	
 	public static State saveBinaryFile(byte[] data, String rootPath, String path) {
-		
-		if("local".equals(DiaowenProperty.DWSTORAGETYPE)){
-//			File file = new File(path);
 			File file = new File(rootPath+path);
 			State state = valid(file);
 			if (!state.isSuccess()) {
@@ -47,16 +44,12 @@ public class StorageManager {
 			state.putInfo( "size", data.length );
 			state.putInfo( "title", file.getName() );
 			return state;
-		}else{
-			return saveBinaryFileToYun(data, path);
-		}
-		
 	}
 	
 
 	public static State saveFileByInputStream(InputStream is, String rootPath, String path,
 			long maxSize) {
-		if("local".equals(DiaowenProperty.DWSTORAGETYPE)){
+
 			State state = null;
 
 			File tmpFile = getTmpFile();
@@ -89,14 +82,10 @@ public class StorageManager {
 			} catch (IOException e) {
 				e.printStackTrace();
 			}
-			return new BaseState(false, AppInfo.IO_ERROR);	
-		}else{
-			return saveFileByInputStreamToYun(is, path);
-		}
+			return new BaseState(false, AppInfo.IO_ERROR);
 	}
 
 	public static State saveFileByInputStream(InputStream is,String rootPath, String path) {
-		if("local".equals(DiaowenProperty.DWSTORAGETYPE)){
 			State state = null;
 
 			File tmpFile = getTmpFile();
@@ -125,10 +114,7 @@ public class StorageManager {
 				e.printStackTrace();
 			}
 			return new BaseState(false, AppInfo.IO_ERROR);
-		}else{
-			return saveFileByInputStreamToYun(is, path);
-		}
-	
+
 	}
 	
 
@@ -172,76 +158,8 @@ public class StorageManager {
 
 		return new BaseState(true);
 	}
-
-	
-	
-	/**
-	 * SaveToYun
-	 */
-	
-
-	public static State saveBinaryFileToYun(byte[] data, String savePath) {
-		State state = null;
-		
-		File tmpFile = getTmpFile();
-		
-		try {
-			BufferedOutputStream bos = new BufferedOutputStream(
-					new FileOutputStream(tmpFile));
-			bos.write(data);
-			bos.flush();
-			bos.close();
-			
-			
-			if("aliyunOSS".equals(DiaowenProperty.DWSTORAGETYPE)){
-				// 阿里云支持 将文件写入到aliyun oss
-				AliyunOSS.putObject(DiaowenProperty.UPLOADFILE_BACKET, tmpFile, savePath);
-				tmpFile.delete();	
-			}else if("baiduBOS".equals(DiaowenProperty.DWSTORAGETYPE)){
-				BaiduBOS.putObject(DiaowenProperty.UPLOADFILE_BACKET,tmpFile, savePath);
-				tmpFile.delete();
-			}
-			
-			
-		} catch (IOException ioe) {
-			ioe.printStackTrace();
-			return new BaseState(false, AppInfo.IO_ERROR);
-		}
-
-		state = new BaseState(true, tmpFile.getAbsolutePath());
-		state.putInfo( "size", data.length );
-		state.putInfo( "title", tmpFile.getName() );
-		return state;
-	}
 	
 
-	public static State saveFileByInputStreamToYun(InputStream inputStream,
-			String savePath) {
-		State state = null;
-		
-		savePath=savePath.substring(1);
-		
-		try {
-//			AliyunOSS.pubObjects(AliyunOSS.UPLOADFILE_BACKET, inputStream, savePath);
-
-			if("aliyunOSS".equals(DiaowenProperty.DWSTORAGETYPE)){
-				// 阿里云支持 将文件写入到aliyun oss
-				AliyunOSS.putObject(DiaowenProperty.UPLOADFILE_BACKET, inputStream, savePath);
-			}else if("baiduBOS".equals(DiaowenProperty.DWSTORAGETYPE)){
-				BaiduBOS.putObject(DiaowenProperty.UPLOADFILE_BACKET,inputStream, savePath);
-			}
-			
-			state = new BaseState(true);
-			
-			//state.putInfo( "size", inputStream.length() );
-//			state.putInfo( "title", inputStream.getName() );
-			return state;
-		} catch (FileNotFoundException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
-		return new BaseState(false, AppInfo.IO_ERROR);
-	}
 	
 
 }

+ 0 - 0
src/main/java/com/baidu/ueditor/upload/Uploader.java