CPD Results

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

Duplications

File Line
info/magnolia/module/blossom/web/BlossomHandlerMethodArgumentResolver.java 98
info/magnolia/module/blossom/web/BlossomWebArgumentResolver.java 68
    public Object resolveArgument(MethodParameter methodParameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {

        if (methodParameter.getParameterType().isAssignableFrom(Node.class)) {
            RenderingContext renderingContext = Components.getComponent(RenderingContext.class);
            if (hasSubsequentParametersOfType(methodParameter, Node.class)) {
                return renderingContext.getMainContent();
            }
            Node currentContent = renderingContext.getCurrentContent();
            return currentContent != null ? currentContent : renderingContext.getMainContent();
        }
        if (methodParameter.getParameterType().isAssignableFrom(Content.class)) {
            AggregationState aggregationState = MgnlContext.getAggregationState();
            if (hasSubsequentParametersOfType(methodParameter, Content.class)) {
                return aggregationState.getMainContent();
            }
            Content currentContent = aggregationState.getCurrentContent();
            return currentContent != null ? currentContent : aggregationState.getMainContent();
        }
        if (methodParameter.getParameterType().isAssignableFrom(TemplateDefinition.class)) {
            return Components.getComponent(RenderingContext.class).getRenderableDefinition();
        }
        if (methodParameter.getParameterType().isAssignableFrom(BlossomTemplateDefinition.class)) {
            return Components.getComponent(RenderingContext.class).getRenderableDefinition();
        }
        if (methodParameter.getParameterType().isAssignableFrom(AreaDefinition.class)) {
            return Components.getComponent(RenderingContext.class).getRenderableDefinition();
        }
        if (methodParameter.getParameterType().isAssignableFrom(BlossomAreaDefinition.class)) {
            return Components.getComponent(RenderingContext.class).getRenderableDefinition();
        }
        if (methodParameter.getParameterType().isAssignableFrom(AggregationState.class)) {
            return MgnlContext.getAggregationState();
        }
        if (methodParameter.getParameterType().isAssignableFrom(WebContext.class)) {
            return MgnlContext.getWebContext();
        }
        if (methodParameter.getParameterType().isAssignableFrom(Context.class)) {
            return MgnlContext.getInstance();
        }
        if (methodParameter.getParameterType().isAssignableFrom(User.class)) {
            return MgnlContext.getUser();
        }
        if (methodParameter.getParameterType().isAssignableFrom(MgnlUser.class)) {
            return MgnlContext.getUser();
        }

        return null;
File Line
info/magnolia/module/blossom/dialog/DialogExporter.java 107
info/magnolia/module/blossom/template/TemplateExporter.java 454
    protected BlossomDialogDescription postProcessDialogFactoryDialog(final BlossomDialogDescription dialogDescription) {

        Object factoryObject = dialogDescription.getFactoryMetaData().getFactoryObject();

        final Class<?> factoryClass = AopUtils.getTargetClass(factoryObject);

        final List<Method> matchingMethods = new ArrayList<Method>();

        ReflectionUtils.doWithMethods(factoryClass, new ReflectionUtils.MethodCallback() {

            @Override
            public void doWith(Method method) {
                if (method.isAnnotationPresent(PreRegister.class) && method.equals(ClassUtils.getMostSpecificMethod(method, factoryClass))) {
                    if (Modifier.isStatic(method.getModifiers())) {
                        throw new IllegalStateException("PreRegister annotation is not supported on static methods");
                    }
                    if (method.getParameterTypes().length == 1 && method.getParameterTypes()[0].isAssignableFrom(BlossomDialogDescription.class)) {
                        matchingMethods.add(method);
                    }
                }
            }
        });
        Collections.reverse(matchingMethods);

        final AtomicReference<BlossomDialogDescription> reference = new AtomicReference<BlossomDialogDescription>(dialogDescription);
        for (Method matchingMethod : matchingMethods) {
            Object returnValue = MethodInvocationUtils.invoke(matchingMethod, factoryObject, new ParameterResolver() {
                @Override
                public Object resolveParameter(Class<?> parameterType) {
                    if (parameterType.isAssignableFrom(BlossomDialogDescription.class)) {
                        return reference.get();
                    }
File Line
info/magnolia/module/blossom/template/TemplateExporter.java 328
info/magnolia/module/blossom/template/TemplateExporter.java 395
        Object handler = templateDefinition.getHandler();

        final Class<?> factoryClass = AopUtils.getTargetClass(handler);

        final List<Method> matchingMethods = new ArrayList<Method>();

        ReflectionUtils.doWithMethods(factoryClass, new ReflectionUtils.MethodCallback() {

            @Override
            public void doWith(Method method) {
                if (method.isAnnotationPresent(PreRegister.class) && method.equals(ClassUtils.getMostSpecificMethod(method, factoryClass))) {
                    if (Modifier.isStatic(method.getModifiers())) {
                        throw new IllegalStateException("PreRegister annotation is not supported on static methods");
                    }
                    if (method.getParameterTypes().length == 1 && method.getParameterTypes()[0].isAssignableFrom(BlossomTemplateDefinition.class)) {
File Line
info/magnolia/module/blossom/template/TemplateExporter.java 454
info/magnolia/module/blossom/template/TemplateExporter.java 506
    protected BlossomDialogDescription postProcessTemplateDialog(final BlossomTemplateDefinition templateDefinition, final BlossomDialogDescription dialogDescription) {
        Object factoryObject = dialogDescription.getFactoryMetaData().getFactoryObject();

        final Class<?> factoryClass = AopUtils.getTargetClass(factoryObject);

        final List<Method> matchingMethods = new ArrayList<Method>();

        ReflectionUtils.doWithMethods(factoryClass, new ReflectionUtils.MethodCallback() {

            @Override
            public void doWith(Method method) {
                if (method.isAnnotationPresent(PreRegister.class) && method.equals(ClassUtils.getMostSpecificMethod(method, factoryClass))) {
                    if (Modifier.isStatic(method.getModifiers())) {
                        throw new IllegalStateException("PreRegister annotation is not supported on static methods");
                    }
                    if (method.getParameterTypes().length == 1 && method.getParameterTypes()[0].isAssignableFrom(BlossomDialogDescription.class)) {
File Line
info/magnolia/module/blossom/dialog/DialogExporter.java 107
info/magnolia/module/blossom/template/TemplateExporter.java 506
    protected BlossomDialogDescription postProcessDialogFactoryDialog(final BlossomDialogDescription dialogDescription) {

        Object factoryObject = dialogDescription.getFactoryMetaData().getFactoryObject();

        final Class<?> factoryClass = AopUtils.getTargetClass(factoryObject);

        final List<Method> matchingMethods = new ArrayList<Method>();

        ReflectionUtils.doWithMethods(factoryClass, new ReflectionUtils.MethodCallback() {

            @Override
            public void doWith(Method method) {
                if (method.isAnnotationPresent(PreRegister.class) && method.equals(ClassUtils.getMostSpecificMethod(method, factoryClass))) {
                    if (Modifier.isStatic(method.getModifiers())) {
                        throw new IllegalStateException("PreRegister annotation is not supported on static methods");
                    }
                    if (method.getParameterTypes().length == 1 && method.getParameterTypes()[0].isAssignableFrom(BlossomDialogDescription.class)) {
File Line
info/magnolia/module/blossom/template/TemplateExporter.java 469
info/magnolia/module/blossom/template/TemplateExporter.java 522
                    if (method.getParameterTypes().length == 1 && method.getParameterTypes()[0].isAssignableFrom(BlossomDialogDescription.class)) {
                        matchingMethods.add(method);
                    }
                }
            }
        });
        Collections.reverse(matchingMethods);

        final AtomicReference<BlossomDialogDescription> reference = new AtomicReference<BlossomDialogDescription>(dialogDescription);
        for (Method matchingMethod : matchingMethods) {
            Object returnValue = MethodInvocationUtils.invoke(matchingMethod, factoryObject, new ParameterResolver() {
                @Override
                public Object resolveParameter(Class<?> parameterType) {
                    if (parameterType.isAssignableFrom(BlossomDialogDescription.class)) {
                        return reference.get();
                    }
                    if (parameterType.isAssignableFrom(BlossomTemplateDefinition.class)) {
File Line
info/magnolia/module/blossom/support/CustomFilterConfig.java 78
info/magnolia/module/blossom/support/CustomServletConfig.java 78
    }

    @Override
    public ServletContext getServletContext() {
        return servletContext;
    }

    @Override
    public String getInitParameter(String name) {
        return initParameters.get(name);
    }

    @Override
    public Enumeration getInitParameterNames() {
        return Collections.enumeration(initParameters.keySet());
    }

    public void addInitParameters(Map<String, String> map) {
        this.initParameters.putAll(map);
    }

    public void addInitParameter(String name, String value) {
        this.initParameters.put(name, value);
    }

    public String removeInitParameter(String name) {
        return initParameters.remove(name);
    }
}
File Line
info/magnolia/module/blossom/dialog/DialogExporter.java 111
info/magnolia/module/blossom/template/TemplateExporter.java 330
info/magnolia/module/blossom/template/TemplateExporter.java 397
info/magnolia/module/blossom/template/TemplateExporter.java 457
        final Class<?> factoryClass = AopUtils.getTargetClass(factoryObject);

        final List<Method> matchingMethods = new ArrayList<Method>();

        ReflectionUtils.doWithMethods(factoryClass, new ReflectionUtils.MethodCallback() {

            @Override
            public void doWith(Method method) {
                if (method.isAnnotationPresent(PreRegister.class) && method.equals(ClassUtils.getMostSpecificMethod(method, factoryClass))) {
                    if (Modifier.isStatic(method.getModifiers())) {
                        throw new IllegalStateException("PreRegister annotation is not supported on static methods");
                    }
                    if (method.getParameterTypes().length == 1 && method.getParameterTypes()[0].isAssignableFrom(BlossomDialogDescription.class)) {
File Line
info/magnolia/module/blossom/dialog/DialogExporter.java 123
info/magnolia/module/blossom/template/TemplateExporter.java 522
                    if (method.getParameterTypes().length == 1 && method.getParameterTypes()[0].isAssignableFrom(BlossomDialogDescription.class)) {
                        matchingMethods.add(method);
                    }
                }
            }
        });
        Collections.reverse(matchingMethods);

        final AtomicReference<BlossomDialogDescription> reference = new AtomicReference<BlossomDialogDescription>(dialogDescription);
        for (Method matchingMethod : matchingMethods) {
            Object returnValue = MethodInvocationUtils.invoke(matchingMethod, factoryObject, new ParameterResolver() {
                @Override
                public Object resolveParameter(Class<?> parameterType) {
                    if (parameterType.isAssignableFrom(BlossomDialogDescription.class)) {
                        return reference.get();
                    }
File Line
info/magnolia/module/blossom/content2bean/SpringContent2BeanTransformer.java 72
info/magnolia/module/blossom/node2bean/SpringNode2BeanTransformer.java 70
    public SpringContent2BeanTransformer(AutowireCapableBeanFactory autowireCapableBeanFactory) {
        this.autowireCapableBeanFactory = autowireCapableBeanFactory;
    }

    public void setDefaultClass(Class<?> defaultClass) {
        this.defaultClass = defaultClass;
    }

    public void setTopLevelBeanName(String topLevelBeanName) {
        this.topLevelBeanName = topLevelBeanName;
    }

    @Override
    protected TypeDescriptor onResolveType(TypeMapping typeMapping, TransformationState state, TypeDescriptor resolvedType, ComponentProvider componentProvider) {
        if (resolvedType == null && defaultType == null && defaultClass != null) {
            defaultType = typeMapping.getTypeDescriptor(defaultClass);
        }
        return resolvedType == null ? defaultType : resolvedType;
    }

    @Override
    public Object newBeanInstance(TransformationState state, Map properties, ComponentProvider componentProvider) throws Content2BeanException {