CPD Results

The following document contains the results of PMD's CPD 6.13.0.

Duplications

File Line
info/magnolia/rest/RestDispatcherServlet.java 261
info/magnolia/rest/RestJerseyDispatcherServlet.java 273
    }

    /**
     * Extract base path from preference id and definition path.
     * Only applicable for {@linkplain DynamicPath} annotated endpoint class.
     * Convention:
     * /module_name/restEndpoints/p1/p2/p3/def_v1.yaml -> {context}/p1/p2/p3/def/v1
     * /module_name/restEndpoints/p1/p2/p3/defv1.yaml -> {context}/p1/p2/p3/defv1
     * /module_name/restEndpoints/def_v1.yaml -> {context}/def/v1
     * /module_name/restEndpoints/defv1.yaml -> {context}/defv1
     *
     * @return base path
     */
    protected String getBasePath(String endpointReferenceId) {
        final String[] endpointPaths = StringUtils.split(endpointReferenceId, File.separator);
        endpointPaths[endpointPaths.length - 1] = endpointPaths[endpointPaths.length - 1].replace('_', '/');
        return Arrays.stream(endpointPaths).collect(Collectors.joining("/"));
    }

    private boolean supportDynamicPath(final Class<?> implementationClass) {
        return implementationClass != null && implementationClass.getAnnotation(DynamicPath.class) != null;
    }

    private String truncatePath(String configuredPath) {
        String path = StringUtils.removeEnd(configuredPath, "/");
        path = StringUtils.removeStart(path, "/");
        return path;
    }
}