Пример #1
0
 private int handleGlobalMessage(User user) {
   List<MessageSend> messages = null;
   List<MessageSend> all = (List<MessageSend>) globalMessageCache.get(GLOBAL_MESSAGE);
   Map<String, Object> map = (Map<String, Object>) messageCache.get(user.getId());
   if (map == null) {
     map = new HashMap<String, Object>();
   }
   if (!map.containsKey(GLOBAL_MESSAGE)) {
     messages =
         messageSendDao.selectUnSendMessageByTypeAndUser(MessageType.GLOBAL, user, maxCount);
   } else {
     List<MessageSend> received = (List<MessageSend>) map.get(GLOBAL_MESSAGE);
     if (!Validators.isEmptyOrNull(received)) {
       messages = getUnrecieve(received, all);
     } else {
       messages = all;
     }
   }
   if (!messages.isEmpty()) {
     List<MessageReceive> receives = new ArrayList<MessageReceive>(messages.size());
     for (MessageSend send : messages) {
       MessageReceive receive = new MessageReceive();
       receive.setMessage(send);
       receive.setIsRead(false);
       receive.setReceiver(user);
       receive.setStatus(MessageStatus.COMMON);
       receives.add(receive);
     }
     messageReceiveDao.inserts(receives);
   }
   map.put(GLOBAL_MESSAGE, new ArrayList<MessageSend>(all));
   messageCache.put(user.getId(), map);
   return messages.size();
 }
Пример #2
0
 @Override
 public void afterPropertiesSet() throws Exception {
   if (Validators.isEmptyOrNull(domainAndPort, true)) {
     throw new SystemException("domainAndPort不能为空");
   }
   if (Validators.isEmptyOrNull(protocol, true)) {
     throw new SystemException("protocol不能为空");
   }
   if (contextPath == null) {
     throw new SystemException("contextPath不能为null");
   }
   if (Validators.isEmptyOrNull(staticResourcesPrefixs)) {
     staticResourcesPrefixs = new String[] {protocol + "://" + domainAndPort + "/static"};
   }
   prefixMaxIndex = staticResourcesPrefixs.length - 1;
 }
Пример #3
0
 private LocalFileStorage seek(int id) {
   if (stores == null) {
     stores = SpringContextHolder.getBeansOfType(LocalFileStorage.class).values();
   }
   if (Validators.isEmptyOrNull(stores)) {
     throw new InvalidParamException();
   }
   for (LocalFileStorage storage : stores) {
     if (storage.id() == id) {
       return storage;
     }
   }
   throw new InvalidParamException();
 }
Пример #4
0
 private Resize parseSize(String _size) {
   if (Validators.isEmptyOrNull(_size, true)) {
     return null;
   } else {
     boolean force = false;
     int pos = _size.indexOf("!");
     if (pos != -1) {
       force = true;
     }
     String strSize = pos == -1 ? _size : _size.substring(0, pos);
     try {
       int size = Integer.parseInt(strSize);
       Resize resize = new Resize();
       resize.setForce(force);
       resize.setSize(size);
       return resize;
     } catch (Exception e) {
       throw new InvalidParamException();
     }
   }
 }