コード例 #1
0
  public LocalService(Model model) {
    super(StringUtils.capitalize(model.getPrefix()) + model.getServiceName());

    this.projectPath = model.getProjectPath();
    this.classPath = model.getClassPath();
    this.serviceName = StringUtils.capitalize(model.getPrefix()) + model.getServiceName();
    this.normalize = model.getNormalize();
    setDescription(model.getDescription());
  }
コード例 #2
0
 @Override
 public void setAttribute(OPFContext ctx) {
   String sessionToken = ctx.getSessionToken();
   if (StringUtils.isBlank(sessionToken)) {
     logger.warn("Business context session token is blank.");
   } else {
     getContextMap().putIfAbsent(sessionToken, ctx);
   }
 }
コード例 #3
0
  @Override
  public ServiceResponse<NavigationElementTree> perform(ServiceRequest<NamedValues> request)
      throws Exception {
    String lookup = (String) request.getData().get("lookup");
    boolean lazyLoadResource = (Boolean) request.getData().get("lazyLoadResource");

    List<NavigationElementTree> navigationElementTrees = new ArrayList<NavigationElementTree>();
    if (ConfigContainer.isAppInstalled() && StringUtils.isNotBlank(lookup)) {
      String packageLookup = StringUtils.getPackageLookup(lookup);
      if (packageLookup == null) {
        logger.warn(MSG_WRONG_LOOKUP);
      } else {
        OPFContext context = OPFContext.getContext();
        INavElementContainer navElementContainer = context.getNavElementContainer();
        List<NavigationElement> navElementListByPackage =
            navElementContainer.getNavElementListByPackage(packageLookup);
        if (navElementListByPackage == null || navElementListByPackage.isEmpty()) {
          logger.warn(MSG_APPROPRIATE_NAVIGATION_ELEMENTS_WERE_FOUND);
        } else {
          NavigationElementTree navigationElementTree = null;
          NavigationElement parent = null;
          for (NavigationElement vo : navElementListByPackage) {
            if (vo.getLookup().equalsIgnoreCase(lookup)) {
              parent = vo;
              navigationElementTree = convert(parent);
              break;
            }
          }
          if (parent == null) {
            logger.warn(MSG_NO_SUCH_PARENT_NAVIGATION_WAS_FOUND);
          } else {
            buildTree(navigationElementTree, parent, navElementListByPackage, lazyLoadResource);
            navigationElementTrees = navigationElementTree.getChildren();
          }
        }
      }
    }
    return new ServiceResponse<NavigationElementTree>(
        navigationElementTrees, "Return tree navigation elements.", true);
  }
コード例 #4
0
  @Override
  protected ServiceResponse<SecuredRecord> perform(ServiceRequest<NamedValues> request)
      throws Exception {
    ServiceResponse<SecuredRecord> response;

    Long entityId = (Long) request.getData().get(PARAM_ENTITY_ID);
    String entityStringId = (String) request.getData().get(PARAM_ENTITY_STRING_ID);
    String name = (String) request.getData().get(PARAM_ENTITY_NAME);
    String lookup = (String) request.getData().get(PARAM_ENTITY_TYPE);
    Long parentId = (Long) request.getData().get(PARAM_PARENT_ID);
    String parentLookup = (String) request.getData().get(PARAM_PARENT_TYPE);
    if ((entityId == null && StringUtils.isBlank(entityStringId))
        || StringUtils.isBlank(name)
        || StringUtils.isBlank(lookup)) {
      throw new IllegalArgumentException(
          "Required parameters(id, name, type) should not be blank.");
    }
    RegistryNodeModel registryNode = registryNodeStore.findByLookup(lookup);

    if (registryNode != null) {
      SecuredRecordModel parentSecuredRecord = null;
      if (StringUtils.isNotBlank(parentLookup)) {
        RegistryNodeModel parentRegistryNode = registryNodeStore.findByLookup(parentLookup);
        if (parentRegistryNode != null) {
          parentSecuredRecord = store.findByExternalIdAndRegistryNode(parentId, parentRegistryNode);
        } else {
          throw new ObjectNotFoundException();
        }
      }

      String parentPath = null;
      if (parentSecuredRecord != null) {
        parentSecuredRecord.setParentSecuredRecords(null);
        parentPath =
            securedRecordPathHelper.addIdToPaths(
                parentSecuredRecord.getId(), parentSecuredRecord.getPaths());
      }

      SecuredRecordModel securedRecord;
      if (entityId == null) {
        securedRecord = store.findByExternalStringIdAndRegistryNode(entityStringId, registryNode);
      } else {
        securedRecord = store.findByExternalIdAndRegistryNode(entityId, registryNode);
      }
      if (securedRecord == null) {
        securedRecord = new SecuredRecordModel();
        if (entityId == null) {
          securedRecord.setExternalStringId(entityStringId);
        } else {
          securedRecord.setExternalNumberId(entityId);
        }
        securedRecord.setRegistryNode(registryNode);

        if (parentPath != null) {
          securedRecord.setPaths(parentPath);
        } else {
          securedRecord.setPaths(SecuredRecordPathHelper.EMPTY_PATH);
        }
      } else {
        if (parentPath == null) {
          parentPath = SecuredRecordPathHelper.EMPTY_PATH;
        }
        if (SecuredRecordPathHelper.EMPTY_PATH.equals(securedRecord.getPaths())) {
          securedRecord.setPaths(parentPath);
        } else {
          String paths =
              securedRecordPathHelper.addPathToPaths(parentPath, securedRecord.getPaths());
          securedRecord.setPaths(paths);
        }
      }
      securedRecord.setName(name);
      securedRecord.addParentSecuredRecords(parentSecuredRecord);

      store.saveOrUpdateRecursive(securedRecord);

      SecuredRecord sr = factory.convertTo(SecuredRecord.class, securedRecord);
      response =
          new ServiceResponse<SecuredRecord>(sr, "Secured record has created successfully", true);
    } else {
      response =
          new ServiceResponse<SecuredRecord>(
              "Secured record has not created. Can't find RegistryNode by lookup:[" + lookup + "]",
              false);
    }
    return response;
  }