use of com.generallycloud.baseio.component.Parameters in project baseio by generallycloud.
the class MQBrowserServlet method doAccept.
@Override
public void doAccept(SocketSession session, ParamedProtobaseFuture future, MQSessionAttachment attachment) throws Exception {
Parameters param = future.getParameters();
String messageId = param.getParameter("messageId");
Message message = NullMessage.NULL_MESSAGE;
MQContext context = getMQContext();
String cmd = param.getParameter("cmd");
if (StringUtil.isNullOrBlank(cmd)) {
message = ErrorMessage.CMD_NOT_FOUND_MESSAGE;
} else {
if (SIZE.equals(cmd)) {
future.write(String.valueOf(context.messageSize()));
} else if (BROWSER.equals(cmd)) {
if (!StringUtil.isNullOrBlank(messageId)) {
message = context.browser(messageId);
if (message == null) {
message = NullMessage.NULL_MESSAGE;
future.write(message.toString());
} else {
int msgType = message.getMsgType();
String content = message.toString();
future.write(content);
if (msgType == 3) {
TextByteMessage byteMessage = (TextByteMessage) message;
byte[] bytes = byteMessage.getByteArray();
future.writeBinary(bytes);
}
}
}
} else if (ONLINE.equals(cmd)) {
boolean bool = context.isOnLine(param.getParameter("queueName"));
future.write(String.valueOf(bool));
}
}
session.flush(future);
}
use of com.generallycloud.baseio.component.Parameters in project baseio by generallycloud.
the class FileReceiveUtil method accept.
public void accept(SocketSession session, ParamedProtobaseFuture future, boolean callback) throws Exception {
Parameters parameters = future.getParameters();
OutputStream outputStream = (OutputStream) session.getAttribute(ACCEPT_FILE);
if (outputStream == null) {
String fileName = prefix + parameters.getParameter(FILE_NAME);
outputStream = new FileOutputStream(new File(fileName));
session.setAttribute(ACCEPT_FILE, outputStream);
logger.info("accept...................open,file={}", fileName);
}
byte[] data = future.getReadBinary();
outputStream.write(data, 0, future.getReadBinarySize());
logger.info("accept...................{},{}", future.getReadBinarySize(), (num++));
boolean isEnd = parameters.getBooleanParameter(IS_END);
if (isEnd) {
logger.info("accept...................close,stream={}", outputStream);
CloseUtil.close(outputStream);
session.removeAttribute(ACCEPT_FILE);
if (callback) {
future.write("传输成功!");
session.flush(future);
}
}
}
use of com.generallycloud.baseio.component.Parameters in project baseio by generallycloud.
the class AuthorityFilter method accept.
@Override
protected void accept(SocketSession session, NamedFuture future) throws Exception {
AuthorityContext authorityContext = AuthorityContext.getInstance();
AuthoritySessionAttachment attachment = authorityContext.getSessionAttachment(session);
AuthorityManager authorityManager = attachment.getAuthorityManager();
if (authorityManager == null) {
RoleManager roleManager = authorityContext.getRoleManager();
authorityManager = roleManager.getAuthorityManager(Authority.GUEST);
attachment.setAuthorityManager(authorityManager);
}
if (!authorityManager.isInvokeApproved(future.getFutureName())) {
future.write(RESMessage.UNAUTH.toString());
session.flush(future);
String futureName = future.getFutureName();
String remoteAddr = session.getRemoteAddr();
String readText = future.getReadText();
if (!StringUtil.isNullOrBlank(readText)) {
logger.info("refuse connection, ip:{}, service name:{}, content: {}", new String[] { remoteAddr, futureName, readText });
return;
}
if (future instanceof ParametersFuture) {
Parameters parameters = ((ParametersFuture) future).getParameters();
if (parameters.size() > 0) {
logger.info("refuse connection, ip:{}, service name:{}, content: {}", new String[] { remoteAddr, futureName, parameters.toString() });
return;
}
}
logger.info("refuse connection, ip:{}, service name:{}", remoteAddr, futureName);
}
}
use of com.generallycloud.baseio.component.Parameters in project baseio by generallycloud.
the class LoggerFilter method accept.
@Override
protected void accept(SocketSession session, NamedFuture future) throws Exception {
String futureName = future.getFutureName();
if (noneLoggerUrlSet.contains(futureName) || endContains(futureName)) {
return;
}
String remoteAddr = session.getRemoteAddr();
String readText = future.getReadText();
if (!StringUtil.isNullOrBlank(readText)) {
logger.info("request ip:{}, service name:{}, content: {}", new String[] { remoteAddr, futureName, readText });
return;
}
if (future instanceof ParametersFuture) {
Parameters parameters = ((ParametersFuture) future).getParameters();
if (parameters.size() > 0) {
logger.info("request ip:{}, service name:{}, content: {}", new String[] { remoteAddr, futureName, parameters.toString() });
return;
}
}
logger.info("request ip:{}, service name:{}", remoteAddr, futureName);
}
Aggregations