Package org.sonatype.nexus.componentviews

Examples of org.sonatype.nexus.componentviews.ViewRequest


    handler = new TestableRawProxyHandler(store, SOURCE_NAME, registry);
  }

  @Test
  public void binariesFoundLocallyAreStreamed() throws Exception {
    ViewRequest request = mockRequest(PATH, HttpMethod.GET);

    HandlerContext context = mock(HandlerContext.class);
    when(context.getRequest()).thenReturn(request);

    final RawBinary localBinary = mock(RawBinary.class);
View Full Code Here


    assertThat(handler.getStreamed(), is(sameInstance(localBinary)));
  }

  @Test
  public void notFoundLocallyCallsSource() throws Exception {
    ViewRequest request = mockRequest(PATH, HttpMethod.GET);
    HandlerContext context = mock(HandlerContext.class);
    when(context.getRequest()).thenReturn(request);

    // There's no matching local raw binary
    when(store.getForPath(PATH)).thenReturn(Collections.<RawBinary>emptyList());
View Full Code Here

    verify(source).fetchComponents(eq(fetchRequest));
  }

  private ViewRequest mockRequest(final String path, final HttpMethod method) {
    ViewRequest request = mock(ViewRequest.class);
    when(request.getPath()).thenReturn(path);
    when(request.getMethod()).thenReturn(method);
    return request;
  }
View Full Code Here

    final View view = viewRegistry.getView(viewNameParser.getViewName());
    if (view == null) {
      throw new ErrorStatusException(HttpServletResponse.SC_NOT_FOUND, "Not Found", "View not found.");
    }

    final ViewRequest request = new HttpViewRequest(req, view.getConfig(), viewNameParser.getRemainingPath(),
        req.getQueryString());

    try {
      view.dispatch(request).send(resp);
    }
View Full Code Here

    this.sourceRegistry = checkNotNull(sourceRegistry);
  }

  @Override
  public ViewResponse handle(final HandlerContext context) throws Exception {
    final ViewRequest req = context.getRequest();

    final String requestPath = ensureLeadingSlash(
        req.getPath() + (req.getQueryString() == null ? "" : "?" + req.getQueryString()));

    switch (req.getMethod()) {
      case GET:
        // Check locally.

        final List<RawBinary> localBinaries = binaryStore.getForPath(requestPath);
View Full Code Here

    this.binaryStore = checkNotNull(binaryStore);
  }

  @Override
  public ViewResponse handle(final HandlerContext context) {
    ViewRequest req = context.getRequest();

    String binaryPath = ensureLeadingSlash(
        req.getPath() + (req.getQueryString() == null ? "" : "?" + req.getQueryString()));
    switch (req.getMethod()) {

      case PUT:
        try {
          final RawBinary created = binaryStore.create(binaryPath, req.getContentType(), req.getInputStream());

          if (created != null) {
            return Responses.created();
          }
          else {
View Full Code Here

TOP

Related Classes of org.sonatype.nexus.componentviews.ViewRequest

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.