@Override
 public void create(List<CreateResourceParameter> resources) throws BadRequestBusinessException {
   logger.debug("resources=" + resources);
   if (resources == null || resources.isEmpty() || resources.size() == 0) {
     throw new BadRequestBusinessException("失败,parameter为空");
   }
   for (CreateResourceParameter resource : resources) {
     validateCreateOrUpdateParameter(resource, Constant.VALIDATION_CREATE);
   }
   for (CreateResourceParameter resource : resources) {
     resource.setId(idGenerator.next().toString());
     resourceDao.create(resource);
     List<String> tagNames = resource.getTags();
     if (tagNames != null && !tagNames.isEmpty() && tagNames.size() > 0) {
       for (String tagName : tagNames) {
         CreateResourceTagParameter parameter = new CreateResourceTagParameter();
         parameter.setId(idGenerator.next().toString());
         parameter.setResourceId(resource.getId());
         Tag tag = tagDao.findByName(tagName);
         if (tag == null || tag.equals(null)) {
           CreateTagParameter createTagParameter = new CreateTagParameter(tagName);
           createTagParameter.setId(idGenerator.next().toString());
           tagDao.create(createTagParameter);
           parameter.setTagId(createTagParameter.getId());
         } else {
           parameter.setTagId(tag.getId());
         }
         resourceTagDao.create(parameter);
       }
     }
   }
 }
 private void validateCreateOrUpdateParameter(CreateResourceParameter resource, String operate)
     throws BadRequestBusinessException {
   if (operate.equals(Constant.VALIDATION_UPDATE)) {
     Integer type = resource.getType();
     if (type != null) {
       if (type != ResourceType.TEXT
           && type != ResourceType.PICTURE
           && type != ResourceType.AUDIO
           && type != ResourceType.VIDEO) {
         throw new BadRequestBusinessException("失败," + JSON.toJSONString(resource) + ",资源类型错误");
       }
     }
     return;
   }
   String nodeId = resource.getNodeId();
   if (nodeId == null || nodeId.trim().equals("")) {
     throw new BadRequestBusinessException("失败," + JSON.toJSONString(resource) + ",nodeId为空");
   }
   if (nodeDao.findById(nodeId) == null || nodeDao.findById(nodeId).equals(null)) {
     throw new BadRequestBusinessException("失败," + JSON.toJSONString(resource) + ",节点不存在");
   }
   Integer type = resource.getType();
   if (type == null || type.toString().trim().equals("")) {
     throw new BadRequestBusinessException("失败," + JSON.toJSONString(resource) + ",type为空");
   }
   if (type != ResourceType.TEXT
       && type != ResourceType.PICTURE
       && type != ResourceType.AUDIO
       && type != ResourceType.VIDEO) {
     throw new BadRequestBusinessException("失败," + JSON.toJSONString(resource) + ",资源类型错误");
   }
   String name = resource.getName();
   if (name == null || name.trim().equals("") || name.trim().length() == 0) {
     throw new BadRequestBusinessException("失败," + JSON.toJSONString(resource) + ",name为空");
   }
   String key = resource.getKeyWord();
   if (key == null || key.trim().equals("") || key.trim().length() == 0) {
     throw new BadRequestBusinessException("失败," + JSON.toJSONString(resource) + ",路径为空");
   }
   List<String> tagNames = resource.getTags();
   if (tagNames != null && !tagNames.isEmpty() && tagNames.size() > 0) {
     Integer size = tagNames.size();
     for (int i = 0; i < size; i++) {
       String tagName = tagNames.get(i);
       if (tagName.trim().length() == 0 || tagName.trim().equals("")) {
         throw new BadRequestBusinessException("失败,tagName[" + (i + 1) + "]为空");
       }
     }
   }
 }