@Override
 public void createContent() throws Exception {
   this.session = PentahoSessionHolder.getSession();
   this.repository = PentahoSystem.get(IUnifiedRepository.class, session);
   final RepositoryFile BIRTfile =
       (RepositoryFile) parameterProviders.get("path").getParameter("file");
   final String ExecBIRTFilePath = "../webapps/birt/" + BIRTfile.getId() + ".rptdocument";
   /*
    * Get BIRT report design from repository
    */
   final File ExecBIRTFile = new File(ExecBIRTFilePath);
   if (!ExecBIRTFile.exists()) {
     final FileOutputStream fos = new FileOutputStream(ExecBIRTFilePath);
     try {
       final SimpleRepositoryFileData data =
           repository.getDataForRead(BIRTfile.getId(), SimpleRepositoryFileData.class);
       final InputStream inputStream = data.getInputStream();
       final byte[] buffer = new byte[0x1000];
       int bytesRead = inputStream.read(buffer);
       while (bytesRead >= 0) {
         fos.write(buffer, 0, bytesRead);
         bytesRead = inputStream.read(buffer);
       }
     } catch (final Exception e) {
       Logger.error(getClass().getName(), e.getMessage());
     } finally {
       fos.close();
     }
   }
   /*
    * Redirect to BIRT Viewer
    */
   try {
     // Get informations about user context
     final IUserRoleListService service = PentahoSystem.get(IUserRoleListService.class);
     String roles = "";
     final ListIterator<String> li =
         service.getRolesForUser(null, session.getName()).listIterator();
     while (li.hasNext()) {
       roles = roles + li.next().toString() + ",";
     }
     // Redirect
     final HttpServletResponse response =
         (HttpServletResponse) this.parameterProviders.get("path").getParameter("httpresponse");
     response.sendRedirect(
         "/birt/frameset?__document="
             + BIRTfile.getId()
             + ".rptdocument&__showtitle=false&username="******"&userroles="
             + roles
             + "&reportname="
             + BIRTfile.getTitle());
   } catch (final Exception e) {
     Logger.error(getClass().getName(), e.getMessage());
   }
 }
  /**
   * retrieve a domain from the repo. This does lazy loading of the repo, so it calls
   * reloadDomains() if not already loaded.
   *
   * @param domainId domain to get from the repository
   * @return domain object
   */
  @Override
  public Domain getDomain(final String domainId) {
    if (logger.isDebugEnabled()) {
      logger.debug("getDomain(" + domainId + ")");
    }

    if (StringUtils.isEmpty(domainId)) {
      throw new IllegalArgumentException(
          messages.getErrorString(
              "PentahoMetadataDomainRepository.ERROR_0004_DOMAIN_ID_INVALID", domainId));
    }
    Domain domain = null;
    try {
      // Load the domain file
      final RepositoryFile file = getMetadataRepositoryFile(domainId);
      if (file != null) {
        if (hasAccessFor(file)) {
          SimpleRepositoryFileData data =
              repository.getDataForRead(file.getId(), SimpleRepositoryFileData.class);
          if (data != null) {
            domain = xmiParser.parseXmi(data.getStream());
            domain.setId(domainId);
            logger.debug("loaded domain");
            // Load any I18N bundles
            loadLocaleStrings(domainId, domain);
            logger.debug("loaded I18N bundles");
          } else {
            throw new UnifiedRepositoryException(
                messages.getErrorString(
                    "PentahoMetadataDomainRepository.ERROR_0005_ERROR_RETRIEVING_DOMAIN",
                    domainId,
                    "data not found"));
          }
        } else {
          throw new PentahoAccessControlException(
              messages.getErrorString(
                  "PentahoMetadataDomainRepository.ERROR_0005_ERROR_RETRIEVING_DOMAIN",
                  domainId,
                  "access denied"));
        }
      }
    } catch (Exception e) {
      if (!(e instanceof UnifiedRepositoryException
          || e instanceof PentahoAccessControlException)) {
        throw new UnifiedRepositoryException(
            messages.getErrorString(
                "PentahoMetadataDomainRepository.ERROR_0005_ERROR_RETRIEVING_DOMAIN",
                domainId,
                e.getLocalizedMessage()),
            e);
      }
    }

    // Return
    return domain;
  }
 public List<NodeRepositoryFileDataDto> getDataAsNodeForReadInBatch(
     final List<RepositoryFileDto> files) {
   List<NodeRepositoryFileDataDto> data = new ArrayList<NodeRepositoryFileDataDto>(files.size());
   for (RepositoryFileDto f : files) {
     if (f.getVersionId() == null) {
       data.add(
           nodeRepositoryFileDataAdapter.marshal(
               repo.getDataForRead(f.getId(), NodeRepositoryFileData.class)));
     } else {
       data.add(
           nodeRepositoryFileDataAdapter.marshal(
               repo.getDataAtVersionForRead(
                   f.getId(), f.getVersionId(), NodeRepositoryFileData.class)));
     }
   }
   return data;
 }
 protected Properties loadProperties(final RepositoryFile bundle) {
   try {
     Properties properties = null;
     final SimpleRepositoryFileData bundleData =
         repository.getDataForRead(bundle.getId(), SimpleRepositoryFileData.class);
     if (bundleData != null) {
       properties = new Properties();
       properties.load(bundleData.getStream());
     } else {
       if (logger.isWarnEnabled()) {
         logger.warn("Could not load properties from repository file: " + bundle.getName());
       }
     }
     return properties;
   } catch (IOException e) {
     throw new UnifiedRepositoryException(
         messages.getErrorString(
             "PentahoMetadataDomainRepository.ERROR_0008_ERROR_IN_REPOSITORY",
             e.getLocalizedMessage()),
         e);
   }
 }
 public NodeRepositoryFileDataDto getDataAsNodeForRead(final String fileId) {
   NodeRepositoryFileData fileData = repo.getDataForRead(fileId, NodeRepositoryFileData.class);
   return fileData != null ? nodeRepositoryFileDataAdapter.marshal(fileData) : null;
 }