@Override
  public void create(
      final Package pkg, final String baseFileName, final NewResourcePresenter presenter) {
    busyIndicatorView.showBusyIndicator(DecisionTableXLSEditorConstants.INSTANCE.Uploading());

    final Path path = pkg.getPackageMainResourcesPath();
    final String fileName = buildFileName(baseFileName, fileExtensionSelector.getResourceType());
    // Package Path is already encoded, fileName needs to be encoded
    final Path newPath =
        PathFactory.newPathBasedOn(fileName, path.toURI() + "/" + encode(fileName), path);

    uploadWidget.submit(
        path,
        fileName,
        URLHelper.getServletUrl(),
        new Command() {

          @Override
          public void execute() {
            busyIndicatorView.hideBusyIndicator();
            presenter.complete();
            notifySuccess();
            placeManager.goTo(newPath);
          }
        },
        new Command() {

          @Override
          public void execute() {
            busyIndicatorView.hideBusyIndicator();
          }
        });
  }
  @Before
  public void setup() {
    service =
        new GuidedDecisionTableGraphEditorServiceImpl(
            ioService,
            copyService,
            deleteService,
            renameService,
            projectService,
            versionRecordService,
            dtableService,
            dtableLinkManager,
            resourceOpenedEvent,
            commentedOptionFactory,
            dtResourceType,
            sessionInfo) {
          {
            this.metadataService = mockMetaDataService;
          }
        };

    when(projectService.resolvePackage(any(Path.class))).thenReturn(pkg);
    when(pkg.getPackageMainResourcesPath())
        .thenReturn(PathFactory.newPath("project", "default://project/src/main/resources"));

    resolvedPaths.clear();
    when(ioService.newDirectoryStream(any(org.uberfire.java.nio.file.Path.class)))
        .thenReturn(new MockDirectoryStream(resolvedPaths));
  }
  @Override
  public void create(
      final Package pkg, final String baseFileName, final NewResourcePresenter presenter) {
    busyIndicatorView.showBusyIndicator(ScoreCardXLSEditorConstants.INSTANCE.Uploading());

    final Path path = pkg.getPackageMainResourcesPath();
    final String fileName = buildFileName(resourceType, baseFileName);
    final Path newPath =
        PathFactory.newPath(
            path.getFileSystem(), fileName, URL.encode(path.toURI() + "/" + fileName));

    uploadWidget.submit(
        path,
        fileName,
        URLHelper.getServletUrl(),
        new Command() {

          @Override
          public void execute() {
            busyIndicatorView.hideBusyIndicator();
            presenter.complete();
            notifySuccess();
            final PlaceRequest place = new PathPlaceRequest(newPath);
            placeManager.goTo(place);
          }
        },
        new Command() {

          @Override
          public void execute() {
            busyIndicatorView.hideBusyIndicator();
          }
        });
  }
Exemplo n.º 4
0
  /**
   * Returns a path of a lock for the provided file.
   *
   * <p>Examples:
   *
   * <pre>
   * default://master@repo/some/path/to/file.txt =>
   * default://locks@system/repo/master/some/path/to/file.txt.ulock
   *
   * file:\\master@repo\some\path\to\file.txt =>
   * file:\\locks@system\repo\master\some\path\to\file.txt.ulock
   * </pre>
   *
   * @param path the path of a file for which a lock should be created, must not be null.
   * @return the lock path
   */
  public static Path newLockPath(final Path path) {
    checkNotNull("path", path);

    final String systemUri =
        path.toURI().replaceFirst("(/|\\\\)([^/&^\\\\]*)@([^/&^\\\\]*)", "$1locks@system$1$3$1$2");

    return PathFactory.newPath("/", systemUri);
  }
 @Override
 public org.uberfire.backend.vfs.Path getProcessAssetPath(String processId) {
   String reporoot = fs.getRepositoryRoot();
   if (reporoot.endsWith("/")) {
     reporoot = reporoot.substring(0, (reporoot.length() - 1));
   }
   String uri = reporoot + domainService.getProcessAssetPath(processId);
   String name = uri.substring(uri.lastIndexOf("/") + 1);
   return PathFactory.newPath(fileSystems.getBootstrapFileSystem(), name, uri);
 }
Exemplo n.º 6
0
  /**
   * Returns the path of the locked file for the provided lock.
   *
   * <p>Examples:
   *
   * <pre>
   * default://locks@system/repo/master/some/path/to/file.txt.ulock =>
   * default://master@repo/some/path/to/file.txt
   *
   * file:\\locks@system\repo\master\some\path\to\file.txt.ulock =>
   * file:\\master@repo\some\path\to\file.txt
   * </pre>
   *
   * @param lockPath the path of a lock, must not be null.
   * @return the locked path.
   */
  public static Path fromLock(final Path lockPath) {
    checkNotNull("path", lockPath);

    final String uri =
        lockPath
            .toURI()
            .replaceFirst("locks@system(/|\\\\)([^/&^\\\\]*)(/|\\\\)([^/&^\\\\]*)", "$4@$2");

    return PathFactory.newPath(
        lockPath.getFileName().replace(LOCK_FILE_EXTENSION, ""),
        uri.replace(LOCK_FILE_EXTENSION, ""));
  }
Exemplo n.º 7
0
 @Override
 public Path copy(final Path path, final String newName, final String comment) {
   System.out.println(
       "USER:"******" COPYING asset ["
           + path.getFileName()
           + "] to ["
           + newName
           + "]");
   String targetName =
       path.getFileName().substring(0, path.getFileName().lastIndexOf("/") + 1) + newName;
   String targetURI = path.toURI().substring(0, path.toURI().lastIndexOf("/") + 1) + newName;
   Path targetPath = PathFactory.newPath(path.getFileSystem(), targetName, targetURI);
   ioService.copy(
       paths.convert(path),
       paths.convert(targetPath),
       new CommentedOption(identity.getName(), comment));
   return targetPath;
 }
Exemplo n.º 8
0
 public static Path newLock(final Path path) {
   Path lockPath = newLockPath(path);
   return PathFactory.newPath(
       path.getFileName() + LOCK_FILE_EXTENSION, lockPath.toURI() + LOCK_FILE_EXTENSION);
 }