CPD Results

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

Duplications

FileLine
info/magnolia/security/app/container/RoleContainer.java55
info/magnolia/security/app/container/UserContainer.java55
    public UserContainer(WorkbenchDefinition workbenchDefinition) {
        super(workbenchDefinition);
    }

    @Override
    public boolean moveItem(Item source, Item target) {
        try {
            String pathBefore = source.getPath();
            if (super.moveItem(source, target)) {
                if (source.isNode()) {
                    UsersWorkspaceUtil.updateAcls((Node) source, pathBefore);
                    source.getSession().save();
                }
                return true;
            }
        } catch (RepositoryException e) {
            log.error("Error while moving node", e);
        }
        return false;
    }

    @Override
    public boolean moveItemBefore(Item source, Item target) {
        try {
            String pathBefore = source.getPath();
            if (super.moveItemBefore(source, target)) {
                if (source.isNode()) {
                    UsersWorkspaceUtil.updateAcls((Node) source, pathBefore);
                    source.getSession().save();
                }
                return true;
            }
        } catch (RepositoryException e) {
            log.error("Error while moving node", e);
        }
        return false;
    }

    @Override
    public boolean moveItemAfter(Item source, Item target) {
        try {
            String pathBefore = source.getPath();
            if (super.moveItemAfter(source, target)) {
                if (source.isNode()) {
                    UsersWorkspaceUtil.updateAcls((Node) source, pathBefore);
                    source.getSession().save();
                }
                return true;
            }
        } catch (RepositoryException e) {
            log.error("Error while moving node", e);
        }
        return false;
    }
}
FileLine
info/magnolia/security/app/dialog/field/validator/UniqueGroupNameValidator.java62
info/magnolia/security/app/dialog/field/validator/UniqueUserNameValidator.java61
    public UniqueUserNameValidator(Item item, String errorMessage, SecuritySupport securitySupport) {
        super(errorMessage);
        this.item = item;
        this.securitySupport = securitySupport;
    }

    @Override
    protected boolean isValidValue(String value) {

        if (item instanceof JcrNodeAdapter) {
            // If we're editing an existing node then its allowed to use the current username of course
            if (!(item instanceof JcrNewNodeAdapter)) {
                try {
                    String currentName = ((JcrNodeAdapter)item).getJcrItem().getName();
                    if (StringUtils.equals(value, currentName)) {
                        return true;
                    }
                } catch (RepositoryException e) {
                    log.error("Exception occurred getting node name of node [{}]", ((JcrNodeAdapter) item).getItemId(), e);
                    return false;
                }
            }
FileLine
info/magnolia/security/app/dialog/field/WebAccessFieldFactory.java128
info/magnolia/security/app/dialog/field/WorkspaceAccessFieldFactory.java185
                        Component ruleRow = createRuleRow(aclLayout, entryItem, emptyLabel);
                        aclLayout.removeComponent(emptyLabel);
                        aclLayout.addComponent(ruleRow, aclLayout.getComponentCount() - 1);
                    } catch (RepositoryException e) {
                        throw new RuntimeRepositoryException(e);
                    }
                }
            });
            buttons.addComponent(addButton);
            aclLayout.addComponent(buttons);

            layout.addComponent(aclLayout);

        } catch (RepositoryException e) {
            throw new RuntimeRepositoryException(e);
        }

        return new CustomField<Object>() {

            @Override
            protected Component initContent() {
                return layout;
            }

            @Override
            public Class<?> getType() {
                return Object.class;
            }
        };
    }