CPD Results

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

Duplications

File Line
info/magnolia/dam/app/setup/DamAppVersionHandler.java 321
info/magnolia/dam/app/setup/DamAppVersionHandler.java 516
                        new BootstrapSingleModuleResource("config.server.MIMEMapping.image.xml"),
                        new NodeExistsDelegateTask("", "/server/MIMEMapping/txt",
                                new SetPropertyTask(RepositoryConstants.CONFIG, "/server/MIMEMapping/txt", "iconStyle", "icon-file-text")),
                        new NodeExistsDelegateTask("", "/server/MIMEMapping/txt",
                                new SetPropertyTask(RepositoryConstants.CONFIG, "/server/MIMEMapping/doc", "iconStyle", "icon-file-word")),
                        new NodeExistsDelegateTask("", "/server/MIMEMapping/txt",
                                new SetPropertyTask(RepositoryConstants.CONFIG, "/server/MIMEMapping/docx", "iconStyle", "icon-file-word")),
                        new NodeExistsDelegateTask("", "/server/MIMEMapping/txt",
                                new SetPropertyTask(RepositoryConstants.CONFIG, "/server/MIMEMapping/xls", "iconStyle", "icon-file-excel")),
                        new NodeExistsDelegateTask("", "/server/MIMEMapping/txt",
                                new SetPropertyTask(RepositoryConstants.CONFIG, "/server/MIMEMapping/xlsx", "iconStyle", "icon-file-excel")),
                        new NodeExistsDelegateTask("", "/server/MIMEMapping/txt",
                                new SetPropertyTask(RepositoryConstants.CONFIG, "/server/MIMEMapping/ppt", "iconStyle", "icon-file-powerpoint")),
                        new NodeExistsDelegateTask("", "/server/MIMEMapping/txt",
                                new SetPropertyTask(RepositoryConstants.CONFIG, "/server/MIMEMapping/pptx", "iconStyle", "icon-file-powerpoint")),
                        new NodeExistsDelegateTask("", "/server/MIMEMapping/txt",
                                new SetPropertyTask(RepositoryConstants.CONFIG, "/server/MIMEMapping/pdf", "iconStyle", "icon-file-pdf")),
                        new NodeExistsDelegateTask("", "/server/MIMEMapping/txt",
                                new SetPropertyTask(RepositoryConstants.CONFIG, "/server/MIMEMapping/htm", "iconStyle", "icon-file-webpage")),
                        new NodeExistsDelegateTask("", "/server/MIMEMapping/txt",
                                new SetPropertyTask(RepositoryConstants.CONFIG, "/server/MIMEMapping/html", "iconStyle", "icon-file-webpage")))));
File Line
info/magnolia/dam/app/ui/field/upload/DamUploadField.java 215
info/magnolia/dam/app/ui/field/upload/ResurfaceDamUploadField.java 221
        final NativeButton mediaEditorPlaceholder = new NativeButton(i18n.translate("dam.assets.uploadField.button.mediaEditorPlaceholder"));
        mediaEditorPlaceholder.addStyleName("btn-form btn-form-commit");

        MediaEditorPresenter mediaEditorPresenter = mediaEditorFactory.getPresenterById(presenterById);
        final InputStream inputStream = new FileInputStream(getValue().getFile());
        final OverlayCloser overlayCloser = uiContext.openOverlay(mediaEditorPresenter.start(inputStream));
        mediaEditorPresenter.addCompletionHandler(new MediaEditorCompletedEvent.Handler() {
            @Override
            public void onSubmit(MediaEditorCompletedEvent event) {
                getValue().updateContent(event.getStream());
                // Update the display to show changes to media.
                updateDisplay();
                overlayCloser.close();
                closeInputStream(inputStream);
                getPropertyDataSource().setValue(getValue());
            }

            @Override
            public void onCancel(MediaEditorCompletedEvent event) {
                overlayCloser.close();
                closeInputStream(inputStream);
            }

            private void closeInputStream(InputStream inputStream) {
                try {
                    if (inputStream != null) {
                        inputStream.close();
                    }
                } catch (Exception e) {
                    log.warn("Could not close the InputStream ", e);
                }
            }
        });
    }
File Line
info/magnolia/dam/app/assets/field/UploadAndEditActionRenderer.java 79
info/magnolia/dam/app/assets/field/UploadAssetActionRenderer.java 118
        chooseDialogEventBus.addHandler(SelectionChangedEvent.class, event -> {
            // inner availability logic here mirrors the one in UpladAssetActionRenderer (in use for DirectUploadAction)
            Set<Object> itemIds = event.getItemIds();
            if (itemIds == null || itemIds.isEmpty()) {
                return;
            }
            try {
                JcrNodeItemId nodeItemId = (JcrNodeItemId) itemIds.iterator().next();
                javax.jcr.Node node = MgnlContext.getJCRSession(nodeItemId.getWorkspace()).getNodeByIdentifier(nodeItemId.getUuid());
                boolean uploadAllowed = itemIds.size() == 1;
                if (uploadAllowed) {
                    uploadAllowed = NodeUtil.isNodeType(node, NodeTypes.Folder.NAME) || NodeUtil.getAncestors(node).isEmpty();
                    // Upload is allowed only if user has WRITE permission on child path which is intended to create (checking "untitled" as default) under the current path.
                    uploadAllowed &= PermissionUtil.isGranted(node, Permission.WRITE)
                            && PermissionUtil.isGranted(node.getSession(), PathUtil.createPath(node.getPath(), AbstractRepositoryAction.DEFAULT_NEW_ITEM_NAME), Permission.WRITE);
                }
File Line
info/magnolia/dam/app/ui/field/upload/DamUploadField.java 120
info/magnolia/dam/app/ui/field/upload/ResurfaceDamUploadField.java 111
        label.setCaption(i18n.translate(fileDetailSizeCaption));
        StringBuilder sb = new StringBuilder();
        if (getValue().isImage()) {
            sb.append(getValue().getWidth() + " x " + getValue().getHeight() + ", ");
        }
        sb.append(FileUtils.byteCountToDisplaySize(getValue().getFileSize()));
        if (getValue().getDuration() > 0) {
            sb.append("(x:x min)");
        }

        label.setValue(sb.toString());
        return label;
    }

    /**
     * Override of CompletedLayout section.<br>
     * Used the configuration in order to define the action to perform and Thumbnail component to display.
     */
    @Override
    protected Layout createCompletedActionLayout() {