Exemplo n.º 1
0
  private static LiferayDescriptorHelper[] getDescriptorHelpers(
      IProject project, Class<? extends IDescriptorOperation> type) {
    List<LiferayDescriptorHelper> retval = new ArrayList<LiferayDescriptorHelper>();

    project = CoreUtil.getLiferayProject(project);

    if (project == null || !project.exists()) {
      return null;
    }

    final LiferayDescriptorHelper[] allHelpers =
        LiferayDescriptorHelperReader.getInstance().getAllHelpers();

    for (LiferayDescriptorHelper helper : allHelpers) {
      helper.setProject(project);

      final IFile descriptorFile = helper.getDescriptorFile();

      if (descriptorFile != null && descriptorFile.exists()) {
        if (helper.getDescriptorOperation(type) != null) {
          retval.add(helper);
        }
      }
    }

    return retval.toArray(new LiferayDescriptorHelper[0]);
  }
Exemplo n.º 2
0
  public static IStatus operate(
      IProject project, Class<? extends IDescriptorOperation> type, Object... params) {
    IStatus status = Status.OK_STATUS;

    LiferayDescriptorHelper[] helpers = getDescriptorHelpers(project, type);

    for (LiferayDescriptorHelper helper : helpers) {
      status = helper.getDescriptorOperation(type).execute(params);

      if (!status.isOK()) {
        return status;
      }
    }

    return status;
  }