Esempio n. 1
0
  protected void run(
      Site site,
      Container container,
      File file,
      String originalFilename,
      String displayName,
      Group permittedGroup,
      Person person,
      EducationalResourceType type)
      throws FenixServiceException, DomainException, IOException {

    final VirtualPath filePath = getVirtualPath(site, container);

    Collection<FileSetMetaData> metaData =
        createMetaData(person.getName(), displayName, site.getAuthorName(), type);

    final byte[] bs = FileUtils.readFileToByteArray(file);

    checkSiteQuota(site, bs.length);

    FileContent fileContent =
        new FileContent(filePath, originalFilename, displayName, metaData, bs, permittedGroup);

    container.addFile(fileContent);
  }
Esempio n. 2
0
  private VirtualPath getVirtualPath(Site site, Container container) {

    List<Content> contents = site.getPathTo(container);

    final VirtualPath filePath = new VirtualPath();

    for (Content content : contents.subList(1, contents.size())) {
      filePath.addNode(
          0,
          new VirtualPathNode(
              content.getClass().getSimpleName().substring(0, 1) + content.getExternalId(),
              content.getName().getContent()));
    }

    String authorName = site.getAuthorName();
    filePath.addNode(
        0,
        new VirtualPathNode(
            "Site" + site.getExternalId(),
            authorName == null ? "Site" + site.getExternalId() : authorName));

    ExecutionSemester executionSemester = site.getExecutionPeriod();
    if (executionSemester == null) {
      filePath.addNode(0, new VirtualPathNode("Intemporal", "Intemporal"));
    } else {
      filePath.addNode(
          0,
          new VirtualPathNode(
              "EP" + executionSemester.getExternalId(), executionSemester.getName()));

      ExecutionYear executionYear = executionSemester.getExecutionYear();
      filePath.addNode(
          0, new VirtualPathNode("EY" + executionYear.getExternalId(), executionYear.getYear()));
    }

    filePath.addNode(0, new VirtualPathNode("Courses", "Courses"));
    return filePath;
  }