Package ca.simplegames.micro.repositories

Examples of ca.simplegames.micro.repositories.Repository


    @SuppressWarnings("unchecked")
    public void execute(MicroContext context, Map configuration) throws ControllerException {
        SiteContext site = context.getSiteContext();
        Map<String, Object> params = (Map<String, Object>) context.get(Globals.PARAMS);
        Repository defaultRepository = site.getRepositoryManager().getDefaultRepository();
        if (configuration != null && configuration.get(Globals.REPOSITORY) != null) {
            defaultRepository = site.getRepositoryManager()
                    .getRepository((String) configuration.get(Globals.REPOSITORY));
        }

        File file = defaultRepository.pathToFile(
                String.format(FILE_FORMAT, params.get(IMAGE_FILE), params.get(TYPE)));

        String fileType = PathUtilities.extractType(file.getAbsolutePath());

        if (file.exists()) {
View Full Code Here


          final String pathBasedContentType = PathUtilities.extractType((String) context.get(Globals.PATH));

          String templateName = StringUtils.defaultString(context.getTemplateName(),
              RepositoryManager.DEFAULT_TEMPLATE_NAME);

          Repository defaultRepository = site.getRepositoryManager().getDefaultRepository();
          // verify if there is a default repository decided by 3rd party components; controllers, extensions, etc.
          if (context.getDefaultRepositoryName() != null) {
            defaultRepository = site.getRepositoryManager()
                .getRepository(context.getDefaultRepositoryName());
          }

          // calculate the Template name
          View view = (View) context.get(Globals.VIEW);
          if (view != null && StringUtils.isNotBlank(view.getTemplate())) {
            templateName = view.getTemplate();
          } else {
            view = defaultRepository.getView(path);
            if (view != null && view.getTemplate() != null) {
              templateName = view.getTemplate();
            }
          }

          // Render the Default Template. The template will pull out the View, the result being sent out as
          // the Template body merged with the View's own content. Controllers are executed *before*
          // rendering the Template *and before* rendering the View, but only if there are any View or Template
          // Controllers defined by the user.

          Repository templatesRepository = site.getRepositoryManager().getTemplatesRepository();
          if (context.getTemplatesRepositoryName() != null) {
            templatesRepository = site.getRepositoryManager()
                .getRepository(context.getTemplatesRepositoryName());
          }

          if (templatesRepository != null) {
            String out = templatesRepository.getRepositoryWrapper(context)
                .get(templateName + pathBasedContentType);

            response.withContentLength(out.getBytes(Charset.forName(Globals.UTF8)).length)
                .withBody(out);
          } else {
View Full Code Here

                String out;
                if (getView().getTemplate() != null) {
                    out = repositoryManager.getTemplatesRepository().getRepositoryWrapper(context)
                            .get(getView().getTemplate() + PathUtilities.extractType(path));
                } else {
                    Repository repository = repositoryManager.getRepository(repositoryName);
                    out = repository.getRepositoryWrapper(context).get(getView().getPath());
                }

                String contentType = Mime.mimeType(PathUtilities.extractType(path));

                if (response.getHeaders().get(Globals.HEADERS_CONTENT_TYPE) != null) {
View Full Code Here

TOP

Related Classes of ca.simplegames.micro.repositories.Repository

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.