Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * #%L
   * *********************************************************************************************************************
   *
   * NorthernWind - lightweight CMS
   * http://northernwind.tidalwave.it - hg clone https://bitbucket.org/tidalwave/northernwind-src
   * %%
   * Copyright (C) 2011 - 2013 Tidalwave s.a.s. (http://tidalwave.it)
   * %%
  * *********************************************************************************************************************
  *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
  * the License. You may obtain a copy of the License at
  *
  *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
  * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations under the License.
  *
  * *********************************************************************************************************************
  *
  * $Id: DefaultLibraryRequestProcessor.java,v 0f8d7eb32e63 2013/06/15 09:00:07 fabrizio $
  *
  * *********************************************************************************************************************
  * #L%
  */
 package it.tidalwave.northernwind.core.model.spi;
 
 import  javax.annotation.Nonnull;
 import  it.tidalwave.util.NotFoundException;
 import lombok.Getter;
 import lombok.Setter;
 import static org.springframework.core.Ordered.*;
 import static it.tidalwave.northernwind.core.model.RequestProcessor.Status.*;

Author(s):
Fabrizio Giudici
Version:
$Id: DefaultLibraryRequestProcessor.java,v 0f8d7eb32e63 2013/06/15 09:00:07 fabrizio $ /
 
   {
     @Inject @Nonnull
     private Provider<SiteProvidersiteProvider;
 
     @Inject @Nonnull
 
     @Inject @Nonnull
     private ResponseHolder<?> responseHolder;
 
     @Getter @Setter
     private Duration duration = Duration.standardDays(7);

    
/
 
     @Override @Nonnull
     public Status process (final @Nonnull Request request)
       {
         final String relativePath = request.getRelativeUri();
 
         try
           {
             final Resource resource = .get().getSite().find(Resource.class).withRelativePath(relativePath).result();
             final ResourceFile file = resource.getFile();
             final String mimeType = file.getMimeType();
             final Object content = mimeType.startsWith("text/") ? .get().filter(file.asText("UTF-8"), mimeType)
                                                                 : file.asBytes();
             .response().withContentType(mimeType)
                                      .withLatestModifiedTime(file.getLatestModificationTime())
                                      .withExpirationTime()
                                      .withBody(content)
                                      .put();
             return ;
           }
         catch (IOException | NotFoundException e)
           {
             log.info("Requested URI {} doesn't map to a library resource, continuing..."relativePath);
           }
 
        return ;
      }
  }
New to GrepCode? Check out our FAQ X