com.baidu.ueditor.define.AppInfo Java Examples

The following examples show how to use com.baidu.ueditor.define.AppInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OSSStorageManager.java    From cms with Apache License 2.0 6 votes vote down vote up
public static State saveFileByInputStream(InputStream is, String path,
                                              long maxSize) {
        State state = null;

        try {
            if(is.available() > maxSize) {
                return new BaseState(false, AppInfo.MAX_SIZE);
            }
            return saveFileByInputStream(is,path);

//            OSSUploadUtils.upload(path,is);
//            state = new BaseState(true);
//            state.putInfo( "size", is.available() );
//            state.putInfo( "title", "" );
//            return state;
        } catch (IOException e) {
        }

        return new BaseState(false, AppInfo.IO_ERROR);
    }
 
Example #2
Source File: Base64Uploader.java    From hsweb-framework with Apache License 2.0 6 votes vote down vote up
public static State save(String content, Map<String, Object> conf) {

        byte[] data = decode(content);

        long maxSize = (Long) conf.get("maxSize");

        if (!validSize(data, maxSize)) {
            return new BaseState(false, AppInfo.MAX_SIZE);
        }
        String suffix = FileType.getSuffix(FileType.JPG);
        try {
            FileService fileService = Context.FILE_SERVICE;
            String path = fileService.saveStaticFile(new ByteArrayInputStream(data), System.currentTimeMillis() + suffix);
            State state = new BaseState(true);
            state.putInfo("size", data.length);
            state.putInfo("title", "");
            state.putInfo("url", path);
            state.putInfo("type", suffix);
            return state;
        } catch (Exception e) {
            log.error("上传base64文件失败",e);
        }
        return new BaseState(false, AppInfo.IO_ERROR);
    }
 
Example #3
Source File: StorageManager.java    From sdb-mall with Apache License 2.0 5 votes vote down vote up
public static State saveFileByInputStream(InputStream is, String path) {
	State state = null;

	File tmpFile = getTmpFile();

	byte[] dataBuf = new byte[ 2048 ];
	BufferedInputStream bis = new BufferedInputStream(is, StorageManager.BUFFER_SIZE);

	try {
		BufferedOutputStream bos = new BufferedOutputStream(
				new FileOutputStream(tmpFile), StorageManager.BUFFER_SIZE);

		int count = 0;
		while ((count = bis.read(dataBuf)) != -1) {
			bos.write(dataBuf, 0, count);
		}
		bos.flush();
		bos.close();

		state = saveTmpFile(tmpFile, path);

		if (!state.isSuccess()) {
			tmpFile.delete();
		}

		return state;
	} catch (IOException e) {
	}
	return new BaseState(false, AppInfo.IO_ERROR);
}
 
Example #4
Source File: StorageManager.java    From ueditor with Apache License 2.0 5 votes vote down vote up
private static State valid(File file) {
	File parentPath = file.getParentFile();

	if ((!parentPath.exists()) && (!parentPath.mkdirs())) {
		return new BaseState(false, AppInfo.FAILED_CREATE_FILE);
	}

	if (!parentPath.canWrite()) {
		return new BaseState(false, AppInfo.PERMISSION_DENIED);
	}

	return new BaseState(true);
}
 
Example #5
Source File: StorageManager.java    From ueditor with Apache License 2.0 5 votes vote down vote up
public static State saveFileByInputStream(InputStream is, String path) {
	State state = null;

	File tmpFile = getTmpFile();

	byte[] dataBuf = new byte[ 2048 ];
	BufferedInputStream bis = new BufferedInputStream(is, StorageManager.BUFFER_SIZE);

	try {
		BufferedOutputStream bos = new BufferedOutputStream(
				new FileOutputStream(tmpFile), StorageManager.BUFFER_SIZE);

		int count = 0;
		while ((count = bis.read(dataBuf)) != -1) {
			bos.write(dataBuf, 0, count);
		}
		bos.flush();
		bos.close();

		state = saveTmpFile(tmpFile, path);

		if (!state.isSuccess()) {
			tmpFile.delete();
		}

		return state;
	} catch (IOException e) {
	}
	return new BaseState(false, AppInfo.IO_ERROR);
}
 
Example #6
Source File: StorageManager.java    From ueditor with Apache License 2.0 5 votes vote down vote up
public static State saveFileByInputStream(InputStream is, String path,
		long maxSize) {
	State state = null;

	File tmpFile = getTmpFile();

	byte[] dataBuf = new byte[ 2048 ];
	BufferedInputStream bis = new BufferedInputStream(is, StorageManager.BUFFER_SIZE);

	try {
		BufferedOutputStream bos = new BufferedOutputStream(
				new FileOutputStream(tmpFile), StorageManager.BUFFER_SIZE);

		int count = 0;
		while ((count = bis.read(dataBuf)) != -1) {
			bos.write(dataBuf, 0, count);
		}
		bos.flush();
		bos.close();

		if (tmpFile.length() > maxSize) {
			tmpFile.delete();
			return new BaseState(false, AppInfo.MAX_SIZE);
		}

		state = saveTmpFile(tmpFile, path);

		if (!state.isSuccess()) {
			tmpFile.delete();
		}

		return state;
		
	} catch (IOException e) {
	}
	return new BaseState(false, AppInfo.IO_ERROR);
}
 
Example #7
Source File: OSSBase64Uploader.java    From cms with Apache License 2.0 5 votes vote down vote up
public static State save(String content, Map<String, Object> conf) {

        byte[] data = decode(content);

        long maxSize = ((Long) conf.get("maxSize")).longValue();

        if (!validSize(data, maxSize)) {
            return new BaseState(false, AppInfo.MAX_SIZE);
        }

        String suffix = FileType.getSuffix("JPG");

        String savePath = PathFormat.parse((String) conf.get("savePath"),
                (String) conf.get("filename"));

        savePath = savePath + suffix;
        //String physicalPath = (String) conf.get("rootPath") + savePath;

        //State storageState = StorageManager.saveBinaryFile(data, physicalPath);
        State storageState = OSSStorageManager.saveBinaryFile(data, savePath);
        if (storageState.isSuccess()) {
            storageState.putInfo("url", PathFormat.format(savePath));
            storageState.putInfo("type", suffix);
            storageState.putInfo("original", "");
        }

        return storageState;
    }
 
Example #8
Source File: OSSStorageManager.java    From cms with Apache License 2.0 5 votes vote down vote up
public static State saveBinaryFile(byte[] data, String path) {
    //File file = new File(path);

    //State state = valid(file);

    //if (!state.isSuccess()) {
    //    return state;
    //}
    File file =getTmpFile();

    try {
        BufferedOutputStream bos = new BufferedOutputStream(
                new FileOutputStream(file));
        bos.write(data);
        bos.flush();
        bos.close();

        InputStream is = new FileInputStream(file);
        OSSUploadUtils.upload(path,is);

        file.delete();
    } catch (IOException ioe) {
        return new BaseState(false, AppInfo.IO_ERROR);
    }
    State state = new BaseState(true, path);
    //State state = new BaseState(true, file.getAbsolutePath());
    state.putInfo( "size", data.length );
    state.putInfo( "title", file.getName() );
    return state;
}
 
Example #9
Source File: LocalBase64Uploader.java    From cms with Apache License 2.0 5 votes vote down vote up
public static State save(String content, Map<String, Object> conf) {

        byte[] data = decode(content);

        long maxSize = ((Long) conf.get("maxSize")).longValue();

        if (!validSize(data, maxSize)) {
            return new BaseState(false, AppInfo.MAX_SIZE);
        }

        String suffix = FileType.getSuffix("JPG");

        String savePath = PathFormat.parse((String) conf.get("savePath"),
                (String) conf.get("filename"));

        savePath = savePath + suffix;
        String physicalPath = (String) conf.get("rootPath") + savePath;

        /* date:2017-10-7 14:34:27
            *  xzjie
            *  修改保存文件路径
            * */
        if(StringUtils.isNotBlank(Configuration.getLocalPath())){
            physicalPath=Configuration.getLocalPath() + savePath;
        }

        State storageState = StorageManager.saveBinaryFile(data, physicalPath);

        if (storageState.isSuccess()) {
            storageState.putInfo("url", PathFormat.format(savePath));
            storageState.putInfo("type", suffix);
            storageState.putInfo("original", "");
        }

        return storageState;
    }
 
Example #10
Source File: StorageManager.java    From cms with Apache License 2.0 5 votes vote down vote up
private static State valid(File file) {
	File parentPath = file.getParentFile();

	if ((!parentPath.exists()) && (!parentPath.mkdirs())) {
		return new BaseState(false, AppInfo.FAILED_CREATE_FILE);
	}

	if (!parentPath.canWrite()) {
		return new BaseState(false, AppInfo.PERMISSION_DENIED);
	}

	return new BaseState(true);
}
 
Example #11
Source File: StorageManager.java    From cms with Apache License 2.0 5 votes vote down vote up
public static State saveFileByInputStream(InputStream is, String path) {
	State state = null;

	File tmpFile = getTmpFile();

	byte[] dataBuf = new byte[ 2048 ];
	BufferedInputStream bis = new BufferedInputStream(is, StorageManager.BUFFER_SIZE);

	try {
		BufferedOutputStream bos = new BufferedOutputStream(
				new FileOutputStream(tmpFile), StorageManager.BUFFER_SIZE);

		int count = 0;
		while ((count = bis.read(dataBuf)) != -1) {
			bos.write(dataBuf, 0, count);
		}
		bos.flush();
		bos.close();

		state = saveTmpFile(tmpFile, path);

		if (!state.isSuccess()) {
			tmpFile.delete();
		}

		return state;
	} catch (IOException e) {
	}
	return new BaseState(false, AppInfo.IO_ERROR);
}
 
Example #12
Source File: StorageManager.java    From cms with Apache License 2.0 5 votes vote down vote up
public static State saveFileByInputStream(InputStream is, String path,
		long maxSize) {
	State state = null;

	File tmpFile = getTmpFile();

	byte[] dataBuf = new byte[ 2048 ];
	BufferedInputStream bis = new BufferedInputStream(is, StorageManager.BUFFER_SIZE);

	try {
		BufferedOutputStream bos = new BufferedOutputStream(
				new FileOutputStream(tmpFile), StorageManager.BUFFER_SIZE);

		int count = 0;
		while ((count = bis.read(dataBuf)) != -1) {
			bos.write(dataBuf, 0, count);
		}
		bos.flush();
		bos.close();

		if (tmpFile.length() > maxSize) {
			tmpFile.delete();
			return new BaseState(false, AppInfo.MAX_SIZE);
		}

		state = saveTmpFile(tmpFile, path);

		if (!state.isSuccess()) {
			tmpFile.delete();
		}

		return state;
		
	} catch (IOException e) {
	}
	return new BaseState(false, AppInfo.IO_ERROR);
}
 
Example #13
Source File: StorageManager.java    From hsweb-framework with Apache License 2.0 5 votes vote down vote up
private static State valid(File file) {
    File parentPath = file.getParentFile();

    if ((!parentPath.exists()) && (!parentPath.mkdirs())) {
        return new BaseState(false, AppInfo.FAILED_CREATE_FILE);
    }

    if (!parentPath.canWrite()) {
        return new BaseState(false, AppInfo.PERMISSION_DENIED);
    }

    return new BaseState(true);
}
 
Example #14
Source File: StorageManager.java    From hsweb-framework with Apache License 2.0 5 votes vote down vote up
public static State saveFileByInputStream(InputStream is, String path,
                                          long maxSize) {

    File tmpFile = getTmpFile();

    byte[] dataBuf = new byte[2048];

    try (BufferedInputStream bis = new BufferedInputStream(is, StorageManager.BUFFER_SIZE);
         BufferedOutputStream bos = new BufferedOutputStream(
                 new FileOutputStream(tmpFile), StorageManager.BUFFER_SIZE)) {

        int count = 0;
        while ((count = bis.read(dataBuf)) != -1) {
            bos.write(dataBuf, 0, count);
        }
        bos.flush();
        bos.close();

        if (tmpFile.length() > maxSize) {
            tmpFile.delete();
            return new BaseState(false, AppInfo.MAX_SIZE);
        }

        State state = saveTmpFile(tmpFile, path);

        if (!state.isSuccess()) {
            tmpFile.delete();
        }

        return state;

    } catch (IOException e) {
    }
    return new BaseState(false, AppInfo.IO_ERROR);
}
 
Example #15
Source File: StorageManager.java    From sdb-mall with Apache License 2.0 5 votes vote down vote up
public static State saveFileByInputStream(InputStream is, String path,
		long maxSize) {
	State state = null;

	File tmpFile = getTmpFile();

	byte[] dataBuf = new byte[ 2048 ];
	BufferedInputStream bis = new BufferedInputStream(is, StorageManager.BUFFER_SIZE);

	try {
		BufferedOutputStream bos = new BufferedOutputStream(
				new FileOutputStream(tmpFile), StorageManager.BUFFER_SIZE);

		int count = 0;
		while ((count = bis.read(dataBuf)) != -1) {
			bos.write(dataBuf, 0, count);
		}
		bos.flush();
		bos.close();

		if (tmpFile.length() > maxSize) {
			tmpFile.delete();
			return new BaseState(false, AppInfo.MAX_SIZE);
		}

		state = saveTmpFile(tmpFile, path);

		if (!state.isSuccess()) {
			tmpFile.delete();
		}

		return state;
		
	} catch (IOException e) {
	}
	return new BaseState(false, AppInfo.IO_ERROR);
}
 
Example #16
Source File: StorageManager.java    From sdb-mall with Apache License 2.0 5 votes vote down vote up
private static State valid(File file) {
	File parentPath = file.getParentFile();

	if ((!parentPath.exists()) && (!parentPath.mkdirs())) {
		return new BaseState(false, AppInfo.FAILED_CREATE_FILE);
	}

	if (!parentPath.canWrite()) {
		return new BaseState(false, AppInfo.PERMISSION_DENIED);
	}

	return new BaseState(true);
}
 
Example #17
Source File: StorageManager.java    From wangmarket with Apache License 2.0 5 votes vote down vote up
public static State saveFileByInputStream(InputStream is, String path,
		long maxSize) {
	State state = null;

	File tmpFile = getTmpFile();

	byte[] dataBuf = new byte[ 2048 ];
	BufferedInputStream bis = new BufferedInputStream(is, StorageManager.BUFFER_SIZE);

	try {
		BufferedOutputStream bos = new BufferedOutputStream(
				new FileOutputStream(tmpFile), StorageManager.BUFFER_SIZE);

		int count = 0;
		while ((count = bis.read(dataBuf)) != -1) {
			bos.write(dataBuf, 0, count);
		}
		bos.flush();
		bos.close();

		if (tmpFile.length() > maxSize) {
			tmpFile.delete();
			return new BaseState(false, AppInfo.MAX_SIZE);
		}

		state = saveTmpFile(tmpFile, path);

		if (!state.isSuccess()) {
			tmpFile.delete();
		}

		return state;
		
	} catch (IOException e) {
	}
	return new BaseState(false, AppInfo.IO_ERROR);
}
 
Example #18
Source File: StorageManager.java    From wangmarket with Apache License 2.0 5 votes vote down vote up
public static State saveFileByInputStream(InputStream is, String path) {
	State state = null;

	File tmpFile = getTmpFile();

	byte[] dataBuf = new byte[ 2048 ];
	BufferedInputStream bis = new BufferedInputStream(is, StorageManager.BUFFER_SIZE);

	try {
		BufferedOutputStream bos = new BufferedOutputStream(
				new FileOutputStream(tmpFile), StorageManager.BUFFER_SIZE);

		int count = 0;
		while ((count = bis.read(dataBuf)) != -1) {
			bos.write(dataBuf, 0, count);
		}
		bos.flush();
		bos.close();

		state = saveTmpFile(tmpFile, path);

		if (!state.isSuccess()) {
			tmpFile.delete();
		}

		return state;
	} catch (IOException e) {
	}
	return new BaseState(false, AppInfo.IO_ERROR);
}
 
Example #19
Source File: StorageManager.java    From wangmarket with Apache License 2.0 5 votes vote down vote up
private static State valid(File file) {
	File parentPath = file.getParentFile();

	if ((!parentPath.exists()) && (!parentPath.mkdirs())) {
		return new BaseState(false, AppInfo.FAILED_CREATE_FILE);
	}

	if (!parentPath.canWrite()) {
		return new BaseState(false, AppInfo.PERMISSION_DENIED);
	}

	return new BaseState(true);
}
 
Example #20
Source File: StorageManager.java    From hsweb-framework with Apache License 2.0 5 votes vote down vote up
public static State saveFileByInputStream(InputStream is, String path) {
    State state;

    File tmpFile = getTmpFile();

    byte[] dataBuf = new byte[2048];

    try (BufferedInputStream bis = new BufferedInputStream(is, StorageManager.BUFFER_SIZE);
         BufferedOutputStream bos = new BufferedOutputStream(
                 new FileOutputStream(tmpFile), StorageManager.BUFFER_SIZE)) {

        int count = 0;
        while ((count = bis.read(dataBuf)) != -1) {
            bos.write(dataBuf, 0, count);
        }
        bos.flush();
        bos.close();

        state = saveTmpFile(tmpFile, path);

        if (!state.isSuccess()) {
            tmpFile.delete();
        }

        return state;
    } catch (IOException e) {
        return new BaseState(false, AppInfo.IO_ERROR);
    }
}
 
Example #21
Source File: ActionEnter.java    From sdb-mall with Apache License 2.0 4 votes vote down vote up
public String exec () {
	
	String callbackName = this.request.getParameter("callback");
	
	if ( callbackName != null ) {

		if ( !validCallbackName( callbackName ) ) {
			return new BaseState( false, AppInfo.ILLEGAL ).toJSONString();
		}
		
		return callbackName+"("+this.invoke()+");";
		
	} else {
		return this.invoke();
	}

}
 
Example #22
Source File: MyActionEnter.java    From ueditor with Apache License 2.0 4 votes vote down vote up
public String invoke() {

        if (actionType == null || !ActionMap.mapping.containsKey(actionType)) {
            return new BaseState(false, AppInfo.INVALID_ACTION).toJSONString();
        }

        if (this.configManager == null || !this.configManager.valid()) {
            return new BaseState(false, AppInfo.CONFIG_ERROR).toJSONString();
        }

        State state = null;

        int actionCode = ActionMap.getType(this.actionType);

        Map<String, Object> conf = null;

        switch (actionCode) {

        case ActionMap.CONFIG:
            return this.configManager.getAllConfig().toString();

        case ActionMap.UPLOAD_IMAGE:
        case ActionMap.UPLOAD_SCRAWL:
        case ActionMap.UPLOAD_VIDEO:
        case ActionMap.UPLOAD_FILE:
            conf = this.configManager.getConfig(actionCode);
            state = new Uploader(request, conf).doExec();
            break;

        case ActionMap.CATCH_IMAGE:
            conf = configManager.getConfig(actionCode);
            String[] list = this.request.getParameterValues((String) conf.get("fieldName"));
            state = new ImageHunter(conf).capture(list);
            break;

        case ActionMap.LIST_IMAGE:
        case ActionMap.LIST_FILE:
            conf = configManager.getConfig(actionCode);
            int start = this.getStartIndex();
            state = new FileManager(conf).listFile(start);
            break;

        }

        return state.toJSONString();

    }
 
Example #23
Source File: MyActionEnter.java    From ueditor with Apache License 2.0 4 votes vote down vote up
public String exec() {

        String callbackName = this.request.getParameter("callback");

        if (callbackName != null) {

            if (!validCallbackName(callbackName)) {
                return new BaseState(false, AppInfo.ILLEGAL).toJSONString();
            }

            return callbackName + "(" + this.invoke() + ");";

        } else {
            return this.invoke();
        }

    }
 
Example #24
Source File: ActionEnter.java    From ueditor with Apache License 2.0 4 votes vote down vote up
public String invoke() {
	
	if ( actionType == null || !ActionMap.mapping.containsKey( actionType ) ) {
		return new BaseState( false, AppInfo.INVALID_ACTION ).toJSONString();
	}
	
	if ( this.configManager == null || !this.configManager.valid() ) {
		return new BaseState( false, AppInfo.CONFIG_ERROR ).toJSONString();
	}
	
	State state = null;
	
	int actionCode = ActionMap.getType( this.actionType );
	
	Map<String, Object> conf = null;
	
	switch ( actionCode ) {
	
		case ActionMap.CONFIG:
			return this.configManager.getAllConfig().toString();
			
		case ActionMap.UPLOAD_IMAGE:
		case ActionMap.UPLOAD_SCRAWL:
		case ActionMap.UPLOAD_VIDEO:
		case ActionMap.UPLOAD_FILE:
			conf = this.configManager.getConfig( actionCode );
			state = new Uploader( request, conf ).doExec();
			break;
			
		case ActionMap.CATCH_IMAGE:
			conf = configManager.getConfig( actionCode );
			String[] list = this.request.getParameterValues( (String)conf.get( "fieldName" ) );
			state = new ImageHunter( conf ).capture( list );
			break;
			
		case ActionMap.LIST_IMAGE:
		case ActionMap.LIST_FILE:
			conf = configManager.getConfig( actionCode );
			int start = this.getStartIndex();
			state = new FileManager( conf ).listFile( start );
			break;
			
	}
	
	return state.toJSONString();
	
}
 
Example #25
Source File: ActionEnter.java    From ueditor with Apache License 2.0 4 votes vote down vote up
public String exec () {
	
	String callbackName = this.request.getParameter("callback");
	
	if ( callbackName != null ) {

		if ( !validCallbackName( callbackName ) ) {
			return new BaseState( false, AppInfo.ILLEGAL ).toJSONString();
		}
		
		return callbackName+"("+this.invoke()+");";
		
	} else {
		return this.invoke();
	}

}
 
Example #26
Source File: ActionEnter.java    From wangmarket with Apache License 2.0 4 votes vote down vote up
public String invoke() {
//		Log.debug("invoke--into");
//		Log.debug("actionType -- "+actionType);
//		Log.debug("configManager -- "+this.configManager);
		if ( actionType == null || !ActionMap.mapping.containsKey( actionType ) ) {
			return new BaseState( false, AppInfo.INVALID_ACTION ).toJSONString();
		}
		
		if ( this.configManager == null || !this.configManager.valid() ) {
			return new BaseState( false, AppInfo.CONFIG_ERROR ).toJSONString();
		}
		
		State state = null;
		
		int actionCode = ActionMap.getType( this.actionType );
		
		Map<String, Object> conf = null;
		
//		Log.debug("invoke--switch before actionCode: "+actionCode);
		switch ( actionCode ) {
		
			case ActionMap.CONFIG:
				return this.configManager.getAllConfig().toString();
				
			case ActionMap.UPLOAD_IMAGE:
			case ActionMap.UPLOAD_SCRAWL:
			case ActionMap.UPLOAD_VIDEO:
			case ActionMap.UPLOAD_FILE:
//				Log.debug("invoke--UPLOAD_IMAGE--actionCode: "+actionCode);
				conf = this.configManager.getConfig( actionCode );
				state = new Uploader( request, conf ).doExec();
				break;
				
			case ActionMap.CATCH_IMAGE:
				conf = configManager.getConfig( actionCode );
				String[] list = this.request.getParameterValues( (String)conf.get( "fieldName" ) );
				state = new ImageHunter( conf ).capture( list );
				break;
				
			case ActionMap.LIST_IMAGE:
			case ActionMap.LIST_FILE:
				conf = configManager.getConfig( actionCode );
				int start = this.getStartIndex();
				state = new FileManager( conf ).listFile( start );
				break;
				
		}
		
		return state.toJSONString();
		
	}
 
Example #27
Source File: ActionEnter.java    From sdb-mall with Apache License 2.0 4 votes vote down vote up
public String invoke() {
	
	if ( actionType == null || !ActionMap.mapping.containsKey( actionType ) ) {
		return new BaseState( false, AppInfo.INVALID_ACTION ).toJSONString();
	}
	
	if ( this.configManager == null || !this.configManager.valid() ) {
		return new BaseState( false, AppInfo.CONFIG_ERROR ).toJSONString();
	}
	
	State state = null;
	
	int actionCode = ActionMap.getType( this.actionType );
	
	Map<String, Object> conf = null;
	
	switch ( actionCode ) {
	
		case ActionMap.CONFIG:
			return this.configManager.getAllConfig().toString();
			
		case ActionMap.UPLOAD_IMAGE:
		case ActionMap.UPLOAD_SCRAWL:
		case ActionMap.UPLOAD_VIDEO:
		case ActionMap.UPLOAD_FILE:
			conf = this.configManager.getConfig( actionCode );
			state = new Uploader( request, conf ).doExec();
			break;
			
		case ActionMap.CATCH_IMAGE:
			conf = configManager.getConfig( actionCode );
			String[] list = this.request.getParameterValues( (String)conf.get( "fieldName" ) );
			state = new ImageHunter( conf ).capture( list );
			break;
			
		case ActionMap.LIST_IMAGE:
		case ActionMap.LIST_FILE:
			conf = configManager.getConfig( actionCode );
			int start = this.getStartIndex();
			state = new FileManager( conf ).listFile( start );
			break;
			
	}
	
	return state.toJSONString();
	
}
 
Example #28
Source File: ActionEnter.java    From hsweb-framework with Apache License 2.0 4 votes vote down vote up
public String exec() {

        String callbackName = this.request.getParameter("callback");

        if (callbackName != null) {

            if (!validCallbackName(callbackName)) {
                return new BaseState(false, AppInfo.ILLEGAL).toJSONString();
            }

            return callbackName + "(" + this.invoke() + ");";

        } else {
            return this.invoke();
        }

    }
 
Example #29
Source File: ActionEnter.java    From hsweb-framework with Apache License 2.0 4 votes vote down vote up
public String invoke() {

        if (actionType == null || !ActionMap.mapping.containsKey(actionType)) {
            return new BaseState(false, AppInfo.INVALID_ACTION).toJSONString();
        }

        if (this.configManager == null || !this.configManager.valid()) {
            return new BaseState(false, AppInfo.CONFIG_ERROR).toJSONString();
        }

        State state = null;

        int actionCode = ActionMap.getType(this.actionType);

        Map<String, Object> conf ;

        switch (actionCode) {

            case ActionMap.CONFIG:
                return this.configManager.getAllConfig().toString();

            case ActionMap.UPLOAD_IMAGE:
            case ActionMap.UPLOAD_SCRAWL:
            case ActionMap.UPLOAD_VIDEO:
            case ActionMap.UPLOAD_FILE:
                conf = this.configManager.getConfig(actionCode);
                state = new Uploader(request, conf).doExec();
                break;

            case ActionMap.CATCH_IMAGE:
                conf = configManager.getConfig(actionCode);
                String[] list = this.request.getParameterValues((String) conf.get("fieldName"));
                state = new ImageHunter(conf).capture(list);
                break;

            case ActionMap.LIST_IMAGE:
            case ActionMap.LIST_FILE:
                conf = configManager.getConfig(actionCode);
                int start = this.getStartIndex();
                state = new FileManager(conf).listFile(start);
                break;

        }

        return state == null ? "{}" : state.toJSONString();

    }
 
Example #30
Source File: ActionEnter.java    From cms with Apache License 2.0 4 votes vote down vote up
public String invoke() {
	
	if ( actionType == null || !ActionMap.mapping.containsKey( actionType ) ) {
		return new BaseState( false, AppInfo.INVALID_ACTION ).toJSONString();
	}
	
	if ( this.configManager == null || !this.configManager.valid() ) {
		return new BaseState( false, AppInfo.CONFIG_ERROR ).toJSONString();
	}
	
	State state = null;
	
	int actionCode = ActionMap.getType( this.actionType );
	
	Map<String, Object> conf = null;
	
	switch ( actionCode ) {
	
		case ActionMap.CONFIG:
			return this.configManager.getAllConfig().toString();
			
		case ActionMap.UPLOAD_IMAGE:
		case ActionMap.UPLOAD_SCRAWL:
		case ActionMap.UPLOAD_VIDEO:
		case ActionMap.UPLOAD_FILE:
			conf = this.configManager.getConfig( actionCode );
			state = new Uploader( request, conf ).doExec();
			break;
			
		case ActionMap.CATCH_IMAGE:
			conf = configManager.getConfig( actionCode );
			String[] list = this.request.getParameterValues( (String)conf.get( "fieldName" ) );

			if(Configuration.useStatus()) {//使用阿里云oss 存储
				state = new OSSImageHunter(conf).capture(list);
			}else {
				//state = new ImageHunter(conf).capture(list);
				state = new LocalImageHunter(conf).capture(list);
			}
			break;
			
		case ActionMap.LIST_IMAGE:
		case ActionMap.LIST_FILE:
			conf = configManager.getConfig( actionCode );
			int start = this.getStartIndex();

			if(Configuration.useStatus()){//使用阿里云oss 存储
				state = new OSSFileManager( conf ).listFile( start );
			}else {
				state = new FileManager(conf).listFile(start);
			}
			break;
			
	}
	
	return state.toJSONString();
	
}