Package ch.entwine.weblounge.common.repository

Examples of ch.entwine.weblounge.common.repository.ContentRepository


   */
  private void index(Site site) {
    // boolean restart = site.isOnline();

    // Make sure we are in good shape before we index
    ContentRepository repository = site.getContentRepository();
    if (repository == null) {
      System.out.println("Site " + site + " has no content repository");
      return;
    } else if (repository.isReadOnly()) {
      System.out.println("Site " + site + " is read only");
      return;
      // } else if (site.isOnline()) {
      // while (true) {
      // String answer =
View Full Code Here


   */
  public int doStartTag() throws JspException {
    Site site = request.getSite();
    Language language = request.getLanguage();

    ContentRepository repository = site.getContentRepository();
    if (repository == null) {
      logger.debug("Unable to load content repository for site '{}'", site);
      response.invalidate();
      return SKIP_BODY;
    }

    SearchQuery query = new SearchQueryImpl(site);
    query.withVersion(Resource.LIVE);
    query.withTypes(ImageResource.TYPE);
    for (int i = 0; i < imageSubjects.size(); i++)
      query.withSubject(imageSubjects.get(i));
    SearchResult result;
    try {
      result = repository.find(query);
    } catch (ContentRepositoryException e) {
      logger.warn("Error searching for image with given subjects.");
      return SKIP_BODY;
    }

    ResourceURI uri = null;
    ImageResource image = null;
    ImageContent imageContent = null;
    String linkToImage = null;
    PrintWriter writer = null;

    try {
      writer = response.getWriter();

      for (int i = 0; i < result.getItems().length; i++) {
        uri = new ImageResourceURIImpl(site, null, result.getItems()[i].getId());
        if (repository.exists(uri)) {
          image = (ImageResource) repository.get(uri);
          language = LanguageUtils.getPreferredLanguage(image, request, site);
          image.switchTo(language);
          imageContent = image.getContent(language);

          linkToImage = UrlUtils.concat("/weblounge-images", image.getIdentifier(), imageContent.getFilename());
View Full Code Here

   * {@inheritDoc}
   *
   * @see ch.entwine.weblounge.common.site.Site#setContentRepository(ch.entwine.weblounge.common.repository.ContentRepository)
   */
  public void setContentRepository(ContentRepository repository) {
    ContentRepository oldRepository = contentRepository;
    this.contentRepository = repository;
    if (repository != null) {
      logger.debug("Content repository {} connected to site '{}'", repository, this);
      fireRepositoryConnected(repository);
    } else {
View Full Code Here

    if (RequestUtils.isPrecompileRequest(request))
      return SKIP_BODY;

    Site site = request.getSite();

    ContentRepository repository = site.getContentRepository();
    if (repository == null) {
      logger.debug("Unable to load content repository for site '{}'", site);
      response.invalidate();
      return SKIP_BODY;
    }

    // Create the file uri, either from the id or the path. If none is
    // specified, issue a warning
    ResourceURI uri = null;
    if (StringUtils.isNotBlank(fileId)) {
      uri = new FileResourceURIImpl(site, null, fileId);
    } else if (StringUtils.isNotBlank(filePath)) {
      uri = new FileResourceURIImpl(site, filePath, null);
    } else {
      throw new JspException("Neither resource id nor resource path were specified");
    }

    // Try to load the file from the content repository
    try {
      if (!repository.exists(uri)) {
        logger.warn("Non existing file {} requested on {}", uri, request.getUrl());
        return SKIP_BODY;
      }
    } catch (ContentRepositoryException e) {
      logger.error("Error trying to look up file {} from {}", fileId, repository);
      return SKIP_BODY;
    }

    FileResource file = null;
    FileContent fileContent = null;

    // Determine the languages
    Language language = request.getLanguage();

    // Store the result in the jsp page context
    try {
      file = (FileResource) repository.get(uri);
      file.switchTo(language);

      Language contentLanguage = null;
      contentLanguage = LanguageUtils.getPreferredContentLanguage(file, request, site);
      if (contentLanguage == null) {
View Full Code Here

    }

    logger.debug("Site '{}' registered", site);

    // Look for content repositories
    ContentRepository repository = repositoriesBySite.get(site.getIdentifier());
    if (repository != null && site.getContentRepository() == null) {
      try {
        repository.connect(site);
        site.setContentRepository(repository);
        logger.info("Site '{}' connected to content repository at {}", site, repository);
      } catch (ContentRepositoryException e) {
        logger.warn("Error connecting content repository " + repository + " to site '" + site + "'", e);
      }
View Full Code Here

        logger.warn("Found content repository without site property");
        return super.addingService(reference);
      }

      // Register the content repository
      ContentRepository repository = (ContentRepository) super.addingService(reference);
      try {
        siteManager.addContentRepository(siteIdentifier, repository);
      } catch (ContentRepositoryException e) {
        return null;
      }
View Full Code Here

     * @see org.osgi.util.tracker.ServiceTrackerCustomizer#removedService(org.osgi.framework.ServiceReference,
     *      java.lang.Object)
     */
    @Override
    public void removedService(ServiceReference reference, Object service) {
      ContentRepository repository = (ContentRepository) service;
      siteManager.removeContentRepository(repository);
    }
View Full Code Here

      String className = (String) properties.get(OPT_TYPE);
      if (StringUtils.isBlank(className)) {
        className = repositoryType;
      }
      Class<ContentRepository> repositoryImplementation;
      ContentRepository repository = null;
      try {
        repositoryImplementation = (Class<ContentRepository>) Class.forName(className);
        repository = repositoryImplementation.newInstance();
        repository.setEnvironment(environment);
        repository.setSerializer(serializer);
        repository.setSearchIndex(searchIndex);

        // If this is a managed service, make sure it's configured properly
        // before the site is connected

        if (repository instanceof ManagedService) {
          Dictionary<Object, Object> finalProperties = new Hashtable<Object, Object>();

          // Add the default configuration according to the repository type
          Dictionary<Object, Object> configuration = loadConfiguration(repository.getType());
          if (configuration != null) {
            for (Enumeration<Object> keys = configuration.keys(); keys.hasMoreElements();) {
              Object key = keys.nextElement();
              Object value = configuration.get(key);
              if (value instanceof String)
View Full Code Here

   *
   * @see org.osgi.service.cm.ManagedServiceFactory#deleted(java.lang.String)
   */
  public void deleted(String pid) {
    ServiceRegistration registration = services.remove(pid);
    ContentRepository repository = (ContentRepository) bundleCtx.getService(registration.getReference());
    try {
      repository.disconnect();
    } catch (ContentRepositoryException e) {
      logger.warn("Error disconnecting repository {}: {}", repository, e.getMessage());
    }
    try {
      registration.unregister();
View Full Code Here

    SearchQuery q = new SearchQueryImpl(site);
    q.withVersion(Resource.LIVE);
    q.withTypes(Page.TYPE);
    q.withPathPrefix(page.getURI().getPath());

    ContentRepository repository = getContentRepository(site, false);
    SearchResult result = null;
    try {
      result = repository.find(q);
    } catch (ContentRepositoryException e) {
      return Response.status(Status.INTERNAL_SERVER_ERROR).build();
    }

    StringBuffer buf = new StringBuffer("<pages>");
View Full Code Here

TOP

Related Classes of ch.entwine.weblounge.common.repository.ContentRepository

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.