Skip to content
BaseNodeController.java 912 B
Newer Older
Sonia Zorba's avatar
Sonia Zorba committed
/*
 * This file is part of vospace-rest
 * Copyright (C) 2021 Istituto Nazionale di Astrofisica
 * SPDX-License-Identifier: GPL-3.0-or-later
 */
import it.inaf.oats.vospace.datamodel.NodeUtils;
import it.inaf.oats.vospace.exception.InvalidURIException;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;

public abstract class BaseNodeController {

    @Autowired
    private HttpServletRequest servletRequest;

    protected String getPath() {       
        String requestURL = servletRequest.getRequestURL().toString();
        try {
            return NodeUtils.getPathFromRequestURLString(requestURL);
        } catch (IllegalArgumentException ex) {
            throw new InvalidURIException(ex);
        }
    }

    protected String getParentPath(String path) {
        return NodeUtils.getParentPath(path);