aboutsummaryrefslogtreecommitdiffstats
path: root/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/request/SessionContentRequestV2.java
blob: 8c07ccfe598f80ef9db96fc5c76fbe83d5348c87 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server.http.v2.request;

import com.yahoo.config.application.api.ApplicationFile;
import com.yahoo.config.provision.TenantName;
import com.yahoo.container.jdisc.HttpRequest;
import ai.vespa.http.HttpURL;
import com.yahoo.restapi.Path;
import com.yahoo.vespa.config.server.http.ContentRequest;

/**
 * Requests for content and content status (v2)
 * are handled by this class.
 *
 * @author hmusum
 * @since 5.3
 */
public class SessionContentRequestV2 extends ContentRequest {

    private final TenantName tenantName;
    private final long sessionId;

    public SessionContentRequestV2(HttpRequest request,
                            long sessionId,
                            TenantName tenantName,
                            HttpURL.Path path,
                            ApplicationFile applicationFile) {
        super(request, sessionId, path, applicationFile);
        this.tenantName = tenantName;
        this.sessionId = sessionId;
    }

    @Override
    public String getPathPrefix() {
        return "/application/v2/tenant/" + tenantName.value() + "/session/" + sessionId;
    }

    public static HttpURL.Path getContentPath(HttpRequest request) {
        Path path = new Path(request.getUri());
        if ( ! path.matches("/application/v2/tenant/{tenant}/session/{session}/content/{*}"))
            throw new IllegalStateException("error in request routing");
        return path.getRest();
    }

}