public static InputStream getInputStreamByTemplateLocation(String location) throws IOException {
    InputStream in = null;
    IRepository repository = RepositoryFacade.getInstance().getRepository();
    org.eclipse.dirigible.repository.api.IResource resource = repository.getResource(location);
    if (resource != null) {
      in = new ByteArrayInputStream(resource.getContent());
    }

    return in;
  }
  private static IResource getFromRepository(IFile file) {
    IRepository repository = RepositoryFacade.getInstance().getRepository();

    String resourcePath =
        IRepositoryPaths.DB_DIRIGIBLE_USERS
            + CommonIDEParameters.getUserName()
            + IRepositoryPaths.SEPARATOR
            + IRepositoryPaths.WORKSPACE_FOLDER_NAME
            + file.getFullPath();
    IResource resource = repository.getResource(resourcePath);
    return resource;
  }
Example #3
0
  @Override
  protected void execute(ExecutionEvent event, SortedSet<IEntity> resources) {
    if (resources.size() == 0) {
      return;
    }

    if (!CommonIDEParameters.isRolesEnabled()) {
      // assume trial instance, hence disable this function
      MessageDialog.openInformation(null, PASTE_ERROR, PASTE_FUNCTION_IS_DISABLED_IN_THIS_INSTANCE);
      return;
    }

    IRepository repository = RepositoryFacade.getInstance().getRepository();

    String targetReposiotryPath = resources.first().getPath().toString();

    Clipboard clipboard = Clipboard.getInstance();

    String command = clipboard.getCommand();

    Throwable throwable = null;
    if (CUT.equals(command) || COPY.equals(command)) {

      for (Object name : clipboard) {
        IEntity resource = (IEntity) name;
        String sourceRepositoryPath = resource.getPath().toString();
        try {
          byte[] data = repository.exportZip(sourceRepositoryPath, true);
          repository.importZip(data, targetReposiotryPath);
        } catch (IOException e) {
          if (throwable == null) {
            throwable = e;
          }
        }
        if (CUT.equals(command)) {
          try {
            resource.delete();
          } catch (IOException e) {
            if (throwable == null) {
              throwable = e;
            }
          }
        }
      }
    }

    if (throwable != null) {
      MessageDialog.openWarning(null, PASTE_ERROR, SOME_OR_ALL_OF_THE_FILES_COULD_NOT_BE_PASTED);
    }

    RefreshHandler.refreshActivePart(event);
  }