Package org.pentaho.platform.api.repository

Examples of org.pentaho.platform.api.repository.ISolutionRepository


      String action = pathParts[pathParts.length - 1];
     
      System.out.println("file: " + file + " solution:"+solution+" path:"+path + " action:" + action);

      String fullPath = ActionInfo.buildSolutionPath(solution, path, action);
      ISolutionRepository repository = PentahoSystem.get(ISolutionRepository.class, PentahoSessionHolder.getSession());
     
      if( repository == null ) {
        log.error("Access to Repository has failed");
        throw new NullPointerException("Access to Repository has failed");
      }

      if (repository.resourceExists(fullPath)) {
        String doc = repository.getResourceAsString(fullPath, ISolutionRepository.ACTION_EXECUTE);
        if (doc == null) {
          log.error("Error retrieving document from solution repository");
          throw new NullPointerException("Error retrieving saiku document from solution repository");
        }
        return Response.ok(doc.getBytes("UTF-8"), MediaType.TEXT_PLAIN).header(
View Full Code Here


     
      System.out.println("file: " + file + " solution:"+solution+" path:"+path + " action:" + action);

      String fullPath = ActionInfo.buildSolutionPath(solution, path, action);
      IPentahoSession userSession = PentahoSessionHolder.getSession();
      ISolutionRepository repository = PentahoSystem.get(ISolutionRepository.class, userSession);

      if( repository == null ) {
        log.error("Access to Repository has failed");
        throw new NullPointerException("Access to Repository has failed");
      }
      String base = PentahoSystem.getApplicationContext().getSolutionRootPath();
      String parentPath = ActionInfo.buildSolutionPath(solution, path, "");
      ISolutionFile parentFile = repository.getSolutionFile(parentPath, ISolutionRepository.ACTION_CREATE);
      String filePath = parentPath + ISolutionRepository.SEPARATOR + action;
      ISolutionFile fileToSave = repository.getSolutionFile(fullPath, ISolutionRepository.ACTION_UPDATE);



      if (fileToSave != null || (!repository.resourceExists(filePath) && parentFile != null)) {
        repository.publish(base, '/' + parentPath, action, content.getBytes() , true);
        log.debug(PluginConfig.PLUGIN_NAME + " : Published " + solution + " / " + path + " / " + action );
      } else {
        throw new Exception("Error ocurred while saving query to solution repository");
      }
      return Response.ok().build();
View Full Code Here

    try {
      if (StringUtils.isBlank(directory))
        return Response.ok().build();

      IPentahoSession userSession = PentahoSessionHolder.getSession();
      ISolutionRepository repository = PentahoSystem.get(ISolutionRepository.class, userSession);
      ByteArrayOutputStream bos = new ByteArrayOutputStream();
      ZipOutputStream zos = new ZipOutputStream(bos);

      String[] fileArray = null;
      if (StringUtils.isBlank(files)) {
        ISolutionFile dir = repository.getSolutionFile(directory);
        for (ISolutionFile fo : dir.listFiles()) {
          if (!fo.isDirectory()) {
            String entry = fo.getFileName();
            if (".saiku".equals(fo.getExtension())) {
              byte[] doc = fo.getData();
View Full Code Here

      InputStream is = null;
      try {
       
      SolutionReposHelper.setSolutionRepositoryThreadVariable(PentahoSystem.get(ISolutionRepository.class, PentahoSessionHolder.getSession()));
       
        ISolutionRepository repository = PentahoSystem.get(ISolutionRepository.class, PentahoSessionHolder.getSession());
        if (repository.resourceExists(mondrianPropsFilename, ISolutionRepository.ACTION_EXECUTE)) {
          is = repository.getResourceInputStream(mondrianPropsFilename, false, ISolutionRepository.ACTION_EXECUTE);
          MondrianProperties.instance().load(is);
          log.debug("Loaded mondrian properties file: " + mondrianPropsFilename);
        } else {
          log.debug("Cannot find mondrian properties file: "+  mondrianPropsFilename);
        }
View Full Code Here

            return;
        }
        String resourcePath = null;
        resourcePath = resource;
       
        ISolutionRepository repository = PentahoSystem.get(ISolutionRepository.class,session);// PentahoSystem.getSolutionRepository(session);
        InputStream in = repository.getResourceInputStream(resourcePath, true, ISolutionRepository.ACTION_EXECUTE);
        if (in == null) {
            error(Messages.getErrorString("GetResource.ERROR_0003_RESOURCE_MISSING", resourcePath)); //$NON-NLS-1$
            response.setStatus(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
            return;
        }
View Full Code Here

        final String fullPath = ActionInfo.buildSolutionPath(solution, path, action);

        // Check for access permissions

        final ISolutionRepository repository = PentahoSystem.get(ISolutionRepository.class, userSession);
        if (repository.getSolutionFile(fullPath, ISolutionRepository.ACTION_EXECUTE) == null) {
            out.write("Access Denied".getBytes(ENCODING));
            return;
        }

        String templateName = null;
        String messagesBaseFilename = null;

        if (repository.resourceExists(fullPath)) {
            final ActionResource resource = new ActionResource("", IActionSequenceResource.SOLUTION_FILE_RESOURCE, "text/xml", fullPath);
            final String dashboardMetadata = repository.getResourceAsString(resource, ISolutionRepository.ACTION_EXECUTE);
            final Document doc = DocumentHelper.parseText(dashboardMetadata);
            templateName = XmlDom4JHelper.getNodeText("/cdf/template", doc, "");

            // Get message file base name if any
            if (doc.selectSingleNode("/cdf/messages") != null) {
View Full Code Here

            template = "";
        } else {
            template = "-" + template;
        }

        final ISolutionRepository repository = PentahoSystem.get(ISolutionRepository.class, userSession);
        final ActionResource resource;

        String fullTemplatePath = null;

        if (templateName != null) {
            if (templateName.startsWith("/") || templateName.startsWith("\\")) { //$NON-NLS-1$ //$NON-NLS-2$
                fullTemplatePath = templateName;
            } else {
                fullTemplatePath = ActionInfo.buildSolutionPath(solution, path, templateName);
            }
        }

        if (fullTemplatePath != null && repository.resourceExists(fullTemplatePath)) {
            resource = new ActionResource("", IActionSequenceResource.SOLUTION_FILE_RESOURCE, "text/xml", //$NON-NLS-1$ //$NON-NLS-2$
                    fullTemplatePath);
        } else {
            resource = new ActionResource("", IActionSequenceResource.SOLUTION_FILE_RESOURCE, "text/xml", //$NON-NLS-1$ //$NON-NLS-2$
                    "system/" + PLUGIN_NAME + "/default-dashboard-template.html"); //$NON-NLS-1$ //$NON-NLS-2$
        }

        // Check for access permissions
        if (repository.getSolutionFile(resource, ISolutionRepository.ACTION_EXECUTE) == null) {
            out.write("Access Denied".getBytes(ENCODING));
            return;
        }

        String intro = ""; //$NON-NLS-1$
        String footer = ""; //$NON-NLS-1$

        final String dashboardTemplate = "template-dashboard" + template + ".html"; //$NON-NLS-1$

        final IUITemplater templater = PentahoSystem.get(IUITemplater.class, userSession);
        ArrayList<String> i18nTagsList = new ArrayList<String>();
        if (templater != null) {
           
          String solutionPath = "system/" + PLUGIN_NAME + "/" + dashboardTemplate;
            if(!repository.resourceExists(solutionPath))
            {//then try in solution
              solutionPath = SOLUTION_DIR + "/templates/" + dashboardTemplate;
            }
             
            final ActionResource templateResource = new ActionResource("", IActionSequenceResource.SOLUTION_FILE_RESOURCE, "text/xml", solutionPath); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            String templateContent = repository.getResourceAsString(templateResource, ISolutionRepository.ACTION_EXECUTE);
            // Process i18n on dashboard outer template
            templateContent = updateUserLanguageKey(templateContent);
            templateContent = processi18nTags(templateContent, i18nTagsList);
            // Process i18n on dashboard outer template - end
            final String[] sections = templater.breakTemplateString(templateContent, "", userSession); //$NON-NLS-1$
            if (sections != null && sections.length > 0) {
                intro = sections[0];
            }
            if (sections != null && sections.length > 1) {
                footer = sections[1];
            }
        } else {
            intro = Messages.getErrorString("CdfContentGenerator.ERROR_0005_BAD_TEMPLATE_OBJECT");
        }

        final String dashboardContent;

        // TESTING to localize the template
        //dashboardContent = repository.getResourceAsString(resource);
        InputStream is = repository.getResourceInputStream(resource, true, ISolutionRepository.ACTION_EXECUTE);

        // Fixed ISSUE #CDF-113
        //BufferedReader reader = new BufferedReader(new InputStreamReader(is));
        BufferedReader reader = new BufferedReader(new InputStreamReader(is, Charset.forName(LocaleHelper.getSystemEncoding())));
View Full Code Here

        String extension = resourcePath.replaceAll(".*\\.(.*)", "$1");
        if (allowedFormats.indexOf(extension) < 0) {
            // We can't provide this type of file
            throw new SecurityException("Not allowed");
        }
        final ISolutionRepository repository = PentahoSystem.get(ISolutionRepository.class, userSession);
        final InputStream in = repository.getResourceInputStream(resourcePath, true, ISolutionRepository.ACTION_EXECUTE);
        try{
          IOUtils.copy(in, out);
        }
        finally {
          IOUtils.closeQuietly(in);
View Full Code Here

TOP

Related Classes of org.pentaho.platform.api.repository.ISolutionRepository

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.