Bug 99512 - check if cut-and-pasted code needs to be refactored
check if cut-and-pasted code needs to be refactored
Status: CLOSED WONTFIX
Product: Red Hat Web Application Framework
Classification: Retired
Component: other (Show other bugs)
nightly
All Linux
medium Severity low
: ---
: ---
Assigned To: ccm-bugs-list
Jon Orris
:
Depends On:
Blocks: 99159
  Show dependency treegraph
 
Reported: 2003-07-21 09:55 EDT by Vadim Nasardinov
Modified: 2007-04-18 12:55 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2005-08-03 14:26:45 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Vadim Nasardinov 2003-07-21 09:55:05 EDT
=====================================================================
Found a 107 line (295 tokens) duplication in the following files: 
Starting at line 44 of
/var/vadim/scratch/waf/com/arsdigita/ui/permissions/PermissionsConstants.java
Starting at line 44 of
/var/vadim/scratch/waf/com/arsdigita/cms/ui/permissions/CMSPermissionsConstants.java
    GlobalizedMessage SEARCH_LABEL =  new GlobalizedMessage
        ("permissions.userSearchForm.label", BUNDLE_NAME);

    GlobalizedMessage SEARCH_BUTTON = new GlobalizedMessage
        ("permissions.button.search", BUNDLE_NAME);

    GlobalizedMessage SAVE_BUTTON = new GlobalizedMessage
        ("permissions.button.save", BUNDLE_NAME);

    GlobalizedMessage NO_RESULTS = new GlobalizedMessage
        ("permissions.userSearchForm.noResults", BUNDLE_NAME);


    // Direct / Indirect permissions

    GlobalizedMessage PERM_TABLE_DIRECT_HEADING = new GlobalizedMessage
        ("permissions.directPermissions.heading", BUNDLE_NAME);

    GlobalizedMessage PERM_TABLE_DIRECT_EXPLANATION = new GlobalizedMessage
        ("permissions.directPermissions.explanation", BUNDLE_NAME);

    GlobalizedMessage PERM_TABLE_INDIRECT_HEADING = new GlobalizedMessage
        ("permissions.indirectPermissions.heading", BUNDLE_NAME);

    GlobalizedMessage PERM_TABLE_INDIRECT_EXPLANATION = new GlobalizedMessage
        ("permissions.indirectPermissions.explanation", BUNDLE_NAME);

    GlobalizedMessage PERM_TABLE_INDIRECT_CONTEXT = new GlobalizedMessage
        ("permissions.indirectPermissions.context", BUNDLE_NAME);

    GlobalizedMessage PERM_TABLE_GRANTEE =  new GlobalizedMessage
        ("permissions.table.grantee", BUNDLE_NAME);

    GlobalizedMessage PERM_TABLE_ACTIONS = new GlobalizedMessage
        ("permissions.table.actions",  BUNDLE_NAME);

    GlobalizedMessage REMOVE_ALL_CONFIRM = new GlobalizedMessage
        ("permissions.table.actions.removeAll",  BUNDLE_NAME);

    GlobalizedMessage PERM_TABLE_INHERITED = new GlobalizedMessage
        ("permissions.table.inherited",  BUNDLE_NAME);

    GlobalizedMessage PERM_TABLE_NO_PARENT_CONTEXT = new GlobalizedMessage
        ("permissions.table.parent.context.null",  BUNDLE_NAME);


    // Permissions header

    GlobalizedMessage PAGE_TITLE = new GlobalizedMessage
        ("permissions.one.title", BUNDLE_NAME);

    GlobalizedMessage MAIN_SITE = new GlobalizedMessage
        ("permissions.main.site", BUNDLE_NAME);

    GlobalizedMessage PERSONAL_SITE = new GlobalizedMessage
        ("permissions.personal.site", BUNDLE_NAME);

    GlobalizedMessage PERMISSIONS_INDEX = new GlobalizedMessage
        ("permissions.index.title", BUNDLE_NAME);

    GlobalizedMessage PERMISSIONS_INDEX_NAVBAR = new GlobalizedMessage
        ("permissions.index.navbarItem", BUNDLE_NAME);

    // Permissions grant form

    GlobalizedMessage PAGE_GRANT_TITLE = new GlobalizedMessage
        ("permissions.one.grant.title",BUNDLE_NAME);

    GlobalizedMessage PAGE_GRANT_LEFT = new GlobalizedMessage
        ("permissions.one.grant.explanation.left", BUNDLE_NAME);

    GlobalizedMessage PAGE_GRANT_RIGHT = new GlobalizedMessage
        ("permissions.one.grant.explanation.right", BUNDLE_NAME);

    // Access denied page

    GlobalizedMessage PAGE_DENIED_TITLE =  new GlobalizedMessage
        ("permissions.denied.title", BUNDLE_NAME);

    // Index page

    GlobalizedMessage PAGE_OBJECT_INDEX =  new GlobalizedMessage
        ("permissions.index.adminObjects", BUNDLE_NAME);

    GlobalizedMessage PAGE_OBJECT_PANEL_TITLE = new GlobalizedMessage
        ("permissions.index.panelTitle", BUNDLE_NAME);

    GlobalizedMessage PAGE_OBJECT_NONE =  new GlobalizedMessage
        ("permissions.index.noAdminObjects", BUNDLE_NAME);

    // Flats for permission types

    int DIRECT    = 0;
    int INHERITED = 1;

    // Form constants

    String OBJECT_ID = "po_id";
    String DIRECT_PERMISSIONS = "direct";
    String INDIRECT_PERMISSIONS = "indirect";
    String SEARCH_QUERY = "query";
    String PRIV_SET = "privs_set";


    // shared query
    String RETRIEVE_USERS = "com.arsdigita.kernel.RetrieveUsers";
=====================================================================
Found a 50 line (204 tokens) duplication in the following files: 
Starting at line 169 of /var/vadim/scratch/waf/com/arsdigita/cms/ImageAsset.java
Starting at line 158 of
/var/vadim/scratch/waf/com/arsdigita/cms/ReusableImageAsset.java
        if(i > 0) {
            fileName = fileName.substring(i+1);
        }
        i = fileName.lastIndexOf("\\");  // DOS-style
        if(i > 0) {
            fileName = fileName.substring(i+1);
        }

        setName(fileName);

        FileInputStream in = new FileInputStream(file);
        readBytes(in);
    }

    /**
     * Write the image asset content to a file.
     *
     * @param file      The file on the server to write to.
     */
    public void writeToFile(File file)
        throws IOException {
        FileOutputStream fs = new FileOutputStream(file);
        try {
            fs.write(getContent());

        } finally {
            if (null != fs) {
                fs.close();
            }
        }
    }


    /**
     * Guess image size by loading it from file. Set the WIDTH and HEIGHT
     * attributes, if possible
     */
    protected void guessSize(File file, ImageMimeType mime) {
        BigDecimal width = null, height = null;
        ImageSizer sizer = ImageSizerFactory.getImageSizer(mime.getMimeType());

        try {
            if(sizer != null) {
                Dimension d = sizer.computeImageSize(file);
                if(d != null) {
                    width = new BigDecimal((int)d.getWidth());
                    height = new BigDecimal((int)d.getHeight());
                }
            }
        } catch (IOException ex) {
=====================================================================
Found a 50 line (186 tokens) duplication in the following files: 
Starting at line 473 of
/var/vadim/scratch/waf/com/arsdigita/cms/ui/folder/FolderItemPane.java
Starting at line 478 of
/var/vadim/scratch/waf/com/arsdigita/cms/ui/FlatItemList.java
                        PermissionDescriptor desc2 = new
PermissionDescriptor(livePerms.getPrivilege(), liveVersion.getOID(),
                                                                             
livePerms.getGranteeOID());
                        PermissionService.revokePermission(desc2);
                    }
                }
            }

        }
        m_permPane.reset(state);
    }

    public void reset(PageState s) {
        browseMode(s);
        m_folderSel.clearSelection(s);
        m_folderManip.reset(s);
    }

    public final FolderManipulator getManipulator() {
        return m_folderManip;
    }

    public final CMSPermissionsPane getPermissionsPane() {
        return m_permPane;
    }

    public void setPermissionLinkVis(PageState state) {
        if (!Utilities.getSecurityManager(state).
            canAccess(state.getRequest(), SecurityManager.STAFF_ADMIN)) {
            m_togglePrivateAction.setVisible(state, false);
        }
    }

    private static class SectionNewItemForm extends NewItemForm {

        public SectionNewItemForm(String name) {
            super(name);
        }

        public ContentSection getContentSection(PageState s) {
            return CMS.getContext().getContentSection();
        }
    }

    /**
     * Getting the GlobalizedMessage using a CMS Class targetBundle.
     *
     * @param key The resource key
     * @pre ( key != null )
     */
    private static GlobalizedMessage globalize(String key) {
=====================================================================
Found a 25 line (141 tokens) duplication in the following files: 
Starting at line 510 of
/var/vadim/scratch/waf/com/arsdigita/cms/ui/authoring/PageEditDynamic.java
Starting at line 475 of
/var/vadim/scratch/waf/com/arsdigita/cms/ui/authoring/PageCreateDynamic.java
                                                  AddFileElement.ACTION);
                            String fileName =
                                (String)data.get(currentPropertyName + "." +
                                                 FileUploadSection.FILE_UPLOAD);
                            String mimeType =
                                (String)data.get(currentPropertyName + "." +
                                                 FileUploadSection.MIME_TYPE);
                            if (fileAction.equals(AddFileElement.ACTION_UPLOAD)) {
                                File file = null;
                                if(fileName != null && fileName.length() > 0) {
                                    file = ((MultipartHttpServletRequest)
                                            state.getRequest())
                                        .getFile(currentPropertyName + "." +
                                                 FileUploadSection.FILE_UPLOAD);
                                    FileAsset a = new FileAsset();

                                    // Load the asset from file
                                    try {
                                        a.loadFromFile
                                            (fileName,
                                             file,
                                             FileUploadSection.GUESS_MIME
                                             .equals(mimeType) ?
                                             (String) null : mimeType);
                                    } catch (IOException ex) {
=====================================================================
Found a 16 line (139 tokens) duplication in the following files: 
Starting at line 52 of
/var/vadim/scratch/waf/com/arsdigita/persistence/pdl/TestPDLGenerator.java
Starting at line 105 of
/var/vadim/scratch/waf/com/arsdigita/persistence/pdl/SQLRegressionGenerator.java
            Logger.getRootLogger().setLevel(Level.DEBUG);
        } else if (Boolean.TRUE.equals(options.get("-verbose"))) {
            Logger.getRootLogger().setLevel(Level.INFO);
        } else if (Boolean.TRUE.equals(options.get("-quiet"))) {
            Logger.getRootLogger().setLevel(Level.ERROR);
        } else {
            Logger.getRootLogger().setLevel(Level.FATAL);
        }

        String database = (String) options.get("-database");
        if ("postgres".equalsIgnoreCase(database)) {
            DbHelper.setDatabase(DbHelper.DB_POSTGRES);
        } else {
            DbHelper.setDatabase(DbHelper.DB_ORACLE);
        }

=====================================================================
Found a 20 line (130 tokens) duplication in the following files: 
Starting at line 40 of
/var/vadim/scratch/waf/com/redhat/persistence/DynamicQuerySource.java
Starting at line 117 of
/var/vadim/scratch/waf/com/redhat/persistence/engine/rdbms/StaticQuerySource.java
            Property keyProp = (Property) it.next();
            Object key = keys.get(keyProp);
            Parameter keyParam = new Parameter
                (keyProp.getType(), Path.add("key__", keyProp.getName()));
            sig.addParameter(keyParam);
            query.set(keyParam, key);
            Expression propFilt = Condition.equals
                (Path.get(keyProp.getName()), keyParam.getPath());

            if (f == null) {
                f = propFilt;
            } else {
                f = Condition.and(f, propFilt);
            }
        }

        return new Query(query, f);
    }

    public Query getQuery(Object obj) {
=====================================================================
Found a 26 line (128 tokens) duplication in the following files: 
Starting at line 325 of
/var/vadim/scratch/waf/com/arsdigita/ui/permissions/PermissionsPane.java
Starting at line 349 of
/var/vadim/scratch/waf/com/arsdigita/cms/ui/permissions/CMSPermissionsPane.java
        getInheritedPermissionsPanel().setVisible(s, false);
        getContextPanel().setVisible(s, false);
        getUserSearchForm().setVisible(s, false);
        getPermissionGrantPanel().setVisible(s,false);
        getNoSearchResultPanel().setVisible(s, true);
    }

    /**
     * Show the Grant privileges panel
     */

    public void showGrant(PageState s) {
        getDirectPermissionsPanel().setVisible(s, false);
        getInheritedPermissionsPanel().setVisible(s, false);
        getContextPanel().setVisible(s, false);
        getUserSearchForm().setVisible(s, false);
        getNoSearchResultPanel().setVisible(s, false);
        getPermissionGrantPanel().setVisible(s,true);
    }

    /**
     * Shows the administration page of permissions to
     * one object.
     */

    public void showAdmin(PageState s) {
=====================================================================
Found a 44 line (126 tokens) duplication in the following files: 
Starting at line 210 of
/var/vadim/scratch/waf/com/arsdigita/kernel/ResourceType.java
Starting at line 429 of
/var/vadim/scratch/waf/com/arsdigita/web/ApplicationType.java
            result.add(priv);
        }

        return result;
    }

    /**
     * <p>Add an entry to the list of relevant privileges for this
     * ApplicationType.</p>
     */
    public void addRelevantPrivilege(PrivilegeDescriptor privilege) {
        addRelevantPrivilege(privilege.getName());
    }

    /**
     * <p>Add an entry to the list of relevant privileges for this
     * ApplicationType.</p>
     */
    public void addRelevantPrivilege(String privilegeName) {
        OID privOID = new OID("com.arsdigita.kernel.permissions.Privilege",
                              privilegeName);
        DataObject privDO = SessionManager.getSession().retrieve(privOID);
        add("relevantPrivileges", privDO);
    }

    /**
     * <p>Remove an entry from the list of relevant privileges for
     * this ApplicationType.</p>
     */
    public void removeRelevantPrivilege(PrivilegeDescriptor privilege) {
        removeRelevantPrivilege(privilege.getName());
    }

    /**
     * <p>Remove an entry from the list of relevant privileges for
     * this ApplicationType.</p>
     */
    public void removeRelevantPrivilege(String privilegeName) {
        OID privOID = new OID("com.arsdigita.kernel.permissions.Privilege",
                              privilegeName);
        DataObject privDO = SessionManager.getSession().retrieve(privOID);
        remove("relevantPrivileges", privDO);
    }

=====================================================================
Found a 23 line (123 tokens) duplication in the following files: 
Starting at line 226 of
/var/vadim/scratch/waf/com/arsdigita/cms/formbuilder/FormItem.java
Starting at line 177 of
/var/vadim/scratch/waf/com/arsdigita/cms/formbuilder/FormSectionItem.java
        element.addAttribute("title", getTitle());
        element.addAttribute("name", getName());
        element.addAttribute("description", form.getDescription());
        element.addAttribute("javaClass", getClass().getName());
        element.addAttribute("id",getID().toString());
        c.generateXML(fake, element);
    }


    private class VisibleTraverse extends Traversal {

        PageState m_state;
        VisibleTraverse(PageState state) {
            m_state = state;
        }
        public void act(Component c) {
            try {
                m_state.setVisible(c, true);
            } catch (ClassCastException ex) {
                // Nada
            }
        }
    }
=====================================================================
Found a 21 line (121 tokens) duplication in the following files: 
Starting at line 466 of /var/vadim/scratch/waf/com/arsdigita/dmi/ProductVersion.java
Starting at line 391 of /var/vadim/scratch/waf/com/arsdigita/dmi/Product.java
            Object dbSpecificValue = queries.get(queryName);
            if ( dbSpecificValue != null ) {
                s_log.warn ("Query specific lookup - key: " + queryName + "
value: " + dbSpecificValue.toString());
                return dbSpecificValue.toString();
            }
        }

        // Otherwise, fetch the default value
        queries = (HashMap)s_queries.get(new Integer(DbHelper.DB_DEFAULT));
        if (queries != null) {
            Object dbDefaultValue = queries.get(queryName);
            if ( dbDefaultValue != null ) {
                s_log.warn ("Query default lookup - key: " + queryName + "
value: " + dbDefaultValue.toString());
                return dbDefaultValue.toString();
            }
        }

        s_log.warn ("Query lookup failed for key: " + queryName);
        return null;
    }

=====================================================================
Found a 25 line (120 tokens) duplication in the following files: 
Starting at line 227 of
/var/vadim/scratch/waf/com/arsdigita/cms/ui/templates/CategoryTemplates.java
Starting at line 157 of
/var/vadim/scratch/waf/com/arsdigita/cms/ui/templates/ItemTemplates.java
                                    TemplateCollection.TEMPLATE, false,
                                    new AssignCellRenderer());

            addTableActionListener(new TableActionAdapter() {
                    public void cellSelected(TableActionEvent e) {
                        PageState s = e.getPageState();
                        TemplatesListing l = (TemplatesListing)e.getSource();
                        int i = e.getColumn().intValue();
                        TableColumn c = l.getColumnModel().get(i);

                        // Safe to check pointer equality since the column is
                        // created statically
                        if(c == m_assignCol) {
                            SectionTemplateMapping m =
                               
(SectionTemplateMapping)getMappingModel().getSelectedObject(s);
                            assignTemplate(s, m.getTemplate());
                        }
                    }
                });
        }

        /**
         * Get all the templates for the given context in the current section
         */
        protected TemplateCollection getTemplateCollection(PageState s) {
=====================================================================
Found a 17 line (116 tokens) duplication in the following files: 
Starting at line 51 of
/var/vadim/scratch/waf/com/arsdigita/cms/ui/formbuilder/FormSingleSelectionModel.java
Starting at line 51 of
/var/vadim/scratch/waf/com/arsdigita/cms/ui/formbuilder/FormSectionSingleSelectionModel.java
    }

    public void clearSelection(PageState state) {
        throw new RuntimeException( (String)
GlobalizationUtil.globalize("cms.ui.formbuilder.oh_no_you_dont").localize());
    }

    public void addChangeListener(ChangeListener l) {
        throw new RuntimeException( (String)
GlobalizationUtil.globalize("cms.ui.formbuilder.oh_no_you_dont").localize());
    }

    public void removeChangeListener(ChangeListener l) {
        throw new RuntimeException( (String)
GlobalizationUtil.globalize("cms.ui.formbuilder.oh_no_you_dont").localize());
    }

    public ParameterModel getStateParameter() {
        throw new RuntimeException( (String)
GlobalizationUtil.globalize("cms.ui.formbuilder.oh_no_you_dont").localize());
    }
=====================================================================
Found a 25 line (116 tokens) duplication in the following files: 
Starting at line 80 of /var/vadim/scratch/waf/com/arsdigita/bebop/form/Time.java
Starting at line 157 of
/var/vadim/scratch/waf/com/arsdigita/bebop/form/DateTime.java
        }

        protected ParameterData getParameterData(PageState ps) {
            Object value = getValue(ps);
            if (value == null) {
                return null;
            }
            return new ParameterData(getParameterModel(), value);
        }

        public Object getValue(PageState ps) {
            Integer min = (Integer) parent.getFragmentValue(ps, Calendar.MINUTE);
            if (min == null) {
                return null;
            }
            if ( min.intValue() < 10 ) {
                return ZERO + min.toString();
            } else {
                return min.toString();
            }
        }
    }

    private class SecondFragment extends TextField {

=====================================================================
Found a 15 line (115 tokens) duplication in the following files: 
Starting at line 304 of
/var/vadim/scratch/waf/com/arsdigita/cms/ui/ItemSearchWidget.java
Starting at line 356 of
/var/vadim/scratch/waf/com/arsdigita/cms/ui/ItemSearchWidget.java
		m_searchComponent.getSelectItem().
		    setVisible(s, (m_searchComponent.getSearchForm().getTerms(s) != null));
		m_topHR.setVisible(s, true);
		m_bottomHR.setVisible(s, true);
		m_search.setVisible(s, false);
	    } catch (IllegalStateException ex) {
		// component is in metaform. nothing to do here. Custom generateXML must hide for us
	    }

	    if (m_contentType != null) {
		s.setValue(new BigDecimalParameter(ItemSearch.SINGLE_TYPE_PARAM),
m_contentType.getID());
	    } else {
		s.setValue(new BigDecimalParameter(ItemSearch.SINGLE_TYPE_PARAM), null);
	    }
	    throw new FormProcessException("item search FormSection submit");
=====================================================================
Found a 37 line (114 tokens) duplication in the following files: 
Starting at line 147 of
/var/vadim/scratch/waf/com/arsdigita/formbuilder/PersistentPassword.java
Starting at line 151 of
/var/vadim/scratch/waf/com/arsdigita/formbuilder/PersistentTextField.java
        if (maxLength == null) {
            return 50;
        }

        return Integer.parseInt(maxLength);
    }

    public void setSize(int size) {

        setComponentAttribute("size", Integer.toString(size));
    }

    /**
     * Defaults to 12 if no value is set.
     */
    public int getSize() {

        String size = getComponentAttribute("size");

        if (size == null) {
            return 12;
        }

        return Integer.parseInt(size);
    }

    //*** Attribute metadata
    public AttributeMetaDataList getAttributeMetaData() {

        AttributeMetaDataList list = super.getAttributeMetaData();

        list.add(new AttributeMetaData("size", "The size of the Text field as
shown on the form"));
        list.add(new AttributeMetaData("maxLength", "Maximum number of
characters that user can input"));

        return list;
    }
=====================================================================
Found a 20 line (113 tokens) duplication in the following files: 
Starting at line 64 of
/var/vadim/scratch/waf/com/arsdigita/cms/ui/permissions/CMSUserSearchForm.java
Starting at line 68 of
/var/vadim/scratch/waf/com/arsdigita/ui/permissions/UserSearchForm.java
        StringParameter searchParam = new StringParameter(SEARCH_QUERY);
        m_search = new TextField(searchParam);
        m_search.addValidationListener(new NotEmptyValidationListener());
        m_search.setSize(20);
        add(m_search, ColumnPanel.RIGHT);

        Submit submit = new Submit("submit");
        submit.setButtonLabel(SEARCH_BUTTON);
        add(submit, ColumnPanel.LEFT);
    }


    public void process (FormSectionEvent e)
        throws FormProcessException {
        PageState state = e.getPageState();
        FormData data = e.getFormData();

        String search = (String)data.get(SEARCH_QUERY);
        search = StringUtils.stripWhiteSpace(search);
=====================================================================
Found a 23 line (113 tokens) duplication in the following files: 
Starting at line 118 of
/var/vadim/scratch/waf/com/arsdigita/ui/permissions/PermissionsGrant.java
Starting at line 120 of
/var/vadim/scratch/waf/com/arsdigita/cms/ui/permissions/CMSPermissionsGrant.java
        m_form.add(m_save);
    }

    /**
     * Returns the SegmentedPanel with the permissions grant Form
     *
     * @return the SegmentedPanel with the permissions grant form
     */

    public SegmentedPanel getPanel() {
        return m_grantPanel;
    }

    private class GrantFormSubmissionListener
        implements FormSubmissionListener {
        public void submitted(FormSectionEvent e) throws FormProcessException {
            PageState state = e.getPageState();
            FormData data = e.getFormData();
            String[] gids = (String[])data.get(PARTIES_CBG);
            String[] privs = (String[])data.get(PRIVILEGES_CBG);
            if (privs != null && gids != null) {
                BigDecimal oID = m_parent.getObject(state).getID();
                BigDecimal gID = null;
=====================================================================
Found a 49 line (113 tokens) duplication in the following files: 
Starting at line 83 of
/var/vadim/scratch/waf/com/arsdigita/bebop/table/DefaultTableCellRenderer.java
Starting at line 82 of
/var/vadim/scratch/waf/com/arsdigita/cms/ui/util/DefaultTableCellRenderer.java
                }
            };
        m_controlLink = new ThreadLocal() {
                protected Object initialValue() {
                    return new ControlLink((Label) m_label.get());
                }
            };
    }

    /**
     * Return <code>true</code> if the renderer is in active mode. A
     * rendererin active mode will enclose the objects it renders in links
     * that, when clicked, will cause the containing table to fire a
     * <code>TableActionEvent</code>.
     *
     * @return <code>true</code> if the renderer is in active mode.
     */
    public final boolean isActive() {
        return m_active;
    }

    /**
     * Set the renderer to active or inactive mode.
     *
     * @param v <code>true</code> if the renderer should operate in active
     * mode.
     * @pre ! isLocked()
     */
    public void setActive(boolean v) {
        Assert.assertNotLocked(this);
        m_active = v;
    }

    /**
     * Return the component that should be used to render the given
     * <code>value</code>. Returns a {@link com.arsdigita.bebop.Label} if the
     * renderer is active, and a {@link com.arsdigita.bebop.ControlLink} if
     * the renderer is inactive.
     *
     * @pre table == null || table != null
     */
    public Component getComponent(Table table, PageState state, Object value,
                                  boolean isSelected, Object key,
                                  int row, int column)
    {
        if ( ! isLocked() && table != null && table.isLocked() ) {
            lock();
        }

=====================================================================
Found a 34 line (113 tokens) duplication in the following files: 
Starting at line 86 of
/var/vadim/scratch/waf/com/arsdigita/formbuilder/actions/XMLEmailListener.java
Starting at line 86 of
/var/vadim/scratch/waf/com/arsdigita/formbuilder/actions/SimpleEmailListener.java
                         String description,
                         String to,
                         String subject) {
        super.setup(name, description);
        set(TO, to);
        set(SUBJECT, subject);
    }

    // XXX hack to get around some wierd issues
    // with mdsql associations where the object
    // type in question is a subtype of the
    // one named in the association definition
    public boolean isContainerModified() {
        return false;
    }

    public String getTo() {
        return (String)get(TO);
    }

    public void setTo(String to) {
        set(TO, to);
    }

    public String getSubject() {
        return (String)get(SUBJECT);
    }

    public void setSubject(String subject) {
        set(SUBJECT, subject);
    }


    public FormProcessListener createProcessListener() {
=====================================================================
Found a 19 line (110 tokens) duplication in the following files: 
Starting at line 83 of
/var/vadim/scratch/waf/com/arsdigita/cms/contenttypes/ui/ImageDisplay.java
Starting at line 84 of /var/vadim/scratch/waf/com/arsdigita/cms/ui/ImageDisplay.java
        BigDecimal width = image.getWidth();
        if ( width != null ) {
            element.addAttribute("width", width.toString());
        }

        BigDecimal height = image.getHeight();
        if ( height != null ) {
            element.addAttribute("height", height.toString());
        }

        MimeType mimeType = image.getMimeType();
        if ( mimeType != null ) {
            element.addAttribute("mime_type", mimeType.getLabel());
        }
    }

    protected ImageAsset getImageAsset(PageState state) {
        ImageAsset image = (ImageAsset) m_item.getSelectedObject(state);
=====================================================================
Found a 17 line (109 tokens) duplication in the following files: 
Starting at line 213 of
/var/vadim/scratch/waf/com/arsdigita/cms/ui/role/BaseRoleItemPane.java
Starting at line 250 of
/var/vadim/scratch/waf/com/arsdigita/cms/ui/role/BaseRoleItemPane.java
            getColumn(2).setCellRenderer
                (new DefaultTableCellRenderer(true));

            addTableActionListener(new Listener());
        }

        private class Listener extends TableActionAdapter {
            public final void cellSelected(final TableActionEvent e) {
                final PageState state = e.getPageState();

                if (e.getColumn().intValue() == 2 && hasAdmin(state)) {
                    final Role role = m_role.getRole(state);
                    final Party party = (Party) DomainObjectFactory.newInstance
                        (new OID(Party.BASE_DATA_OBJECT_TYPE,
                                 new BigDecimal(e.getRowKey().toString())));

=====================================================================
Found a 15 line (108 tokens) duplication in the following files: 
Starting at line 90 of /var/vadim/scratch/waf/com/arsdigita/cms/ui/type/AddType.java
Starting at line 98 of
/var/vadim/scratch/waf/com/arsdigita/cms/ui/type/EditType.java
        m_label = new TextField(new StringParameter("label"));
        m_label.addValidationListener(new NotNullValidationListener());
        m_label.setSize(40);
        m_label.setMaxLength(1000);
        add(m_label);

        add(new Label(GlobalizationUtil.globalize("cms.ui.description")));
        m_description = new TextArea(new StringParameter("description"));
        m_description.addValidationListener(
                                            new
StringLengthValidationListener(4000));
        m_description.setCols(40);
        m_description.setRows(5);
        m_description.setWrap(TextArea.SOFT);
        add(m_description);

=====================================================================
Found a 40 line (108 tokens) duplication in the following files: 
Starting at line 621 of /var/vadim/scratch/waf/com/arsdigita/bebop/List.java
Starting at line 324 of /var/vadim/scratch/waf/com/arsdigita/bebop/Tree.java
        ChangeEvent e = null;

        while (i.hasNext()) {
            if ( e == null ) {
                e = new ChangeEvent(this, state);
            }
            ((ChangeListener) i.next()).stateChanged(e);
        }
    }

    /**
     * Adds a listener that is notified whenever a user clicks on any part
     * of the tree, either to expand or collapse a node, or to select a
     * node. The listener is run whenever {@link #respond respond} is
     * called.
     *
     * @pre l != null
     * @pre ! isLocked()
     */
    public void addActionListener(ActionListener l) {
        Assert.assertNotLocked(this);
        m_listeners.add(ActionListener.class, l);
    }

    /**
     * Removes a previously added <code>ActionListener</code>.
     * @see #addActionListener addActionListener
     */
    public void removeActionListener(ActionListener l) {
        Assert.assertNotLocked(this);
        m_listeners.remove(ActionListener.class, l);
    }

    /**
     * Notifies listeners that some part of the tree was clicked by the
     * user. The source of the event is the tree.
     *
     * @pre data != null
     * @see #respond respond
     */
=====================================================================
Found a 13 line (107 tokens) duplication in the following files: 
Starting at line 63 of
/var/vadim/scratch/waf/com/arsdigita/formbuilder/ui/editors/SimpleEmailForm.java
Starting at line 65 of
/var/vadim/scratch/waf/com/arsdigita/formbuilder/ui/editors/TemplateEmailForm.java
        m_to.setSize(50);
        m_to.addValidationListener(new NotNullValidationListener());
        //m_to.addValidationListener(new StringInRangeValidationListener(1, 120));
        section.add(new
Label(GlobalizationUtil.globalize("formbuilder.ui.editors.to")), ColumnPanel.RIGHT);
        section.add(m_to);

        m_subject = new TextField(new StringParameter("subject"));
        m_subject.setSize(50);
        m_subject.addValidationListener(new NotNullValidationListener());
        m_subject.addValidationListener(new StringInRangeValidationListener(1,
120));
        section.add(new
Label(GlobalizationUtil.globalize("formbuilder.ui.editors.subject")),
ColumnPanel.RIGHT);
        section.add(m_subject);

=====================================================================
Found a 27 line (107 tokens) duplication in the following files: 
Starting at line 68 of
/var/vadim/scratch/waf/com/arsdigita/cms/ui/role/MemberTableModelBuilder.java
Starting at line 82 of
/var/vadim/scratch/waf/com/arsdigita/cms/ui/role/AdminTableModelBuilder.java
                m_party = m_parties.getParty();

                return true;
            } else {
                m_parties.close();
                
                return false;
            }
        }

        public final Object getKeyAt(final int column) {
            return m_party.getID();
        }

        public final Object getElementAt(final int column) {
            switch (column) {
            case 0:
                return m_party.getDisplayName();
            case 1:
                final EmailAddress email = m_party.getPrimaryEmail();

                if (email == null) {
                    return lz("cms.ui.none");
                } else {
                    return email.toString();
                }
            case 2:
=====================================================================
Found a 22 line (107 tokens) duplication in the following files: 
Starting at line 29 of
/var/vadim/scratch/waf/com/arsdigita/formbuilder/ui/YesNoSection.java
Starting at line 25 of /var/vadim/scratch/waf/com/arsdigita/bebop/YesNoSection.java
        super(new BoxPanel(BoxPanel.HORIZONTAL, false));

        BoxPanel panel = (BoxPanel)getPanel();
        panel.setWidth("2%");

        // Submit widgets
        m_yes = new Submit("yes");
        m_yes.setButtonLabel("Yes");
        add(m_yes, BoxPanel.RIGHT);

        m_no = new Submit("no");
        m_no.setButtonLabel("No");
        add(m_no, BoxPanel.RIGHT);
    }

    public boolean yesPressed(PageState state) {
        return m_yes.isSelected(state);
    }

    public boolean noPressed(PageState state) {
        return m_no.isSelected(state);
    }
=====================================================================
Found a 33 line (106 tokens) duplication in the following files: 
Starting at line 125 of
/var/vadim/scratch/waf/com/arsdigita/categorization/dispatch/EditCategory.java
Starting at line 132 of
/var/vadim/scratch/waf/com/arsdigita/categorization/dispatch/LinkCategory.java
        s.add(m_cancel);
        add(s, ColumnPanel.FULL_WIDTH | ColumnPanel.CENTER);

        addInitListener(this);
        addProcessListener(this);
    }

    /**
     * Determines whether the form is cancelled.
     *
     * @param s the page state
     * @return <code>true</code> if the form is cancelled;
     * <code>false</code> otherwise.
     */
    public boolean isCancelled(PageState s) {
        return m_cancel.isSelected(s);
    }

    /**
     * Generates a checkbox list of parent categories.
     * There is only one default parent.
     *
     * @param event the print event
     */
    public void prepare(PrintEvent event) {

        CheckboxGroup r = (CheckboxGroup) event.getTarget();
        FormData data = getFormData(event.getPageState());
        PageState state = event.getPageState();
        String key = (String) m_categories.getSelectedKey(state);
        BigDecimal catId = new BigDecimal(key);

        Category catToEdit;
=====================================================================
Found a 15 line (106 tokens) duplication in the following files: 
Starting at line 377 of
/var/vadim/scratch/waf/com/arsdigita/cms/dispatcher/CategoryItemResolverImpl.java
Starting at line 371 of
/var/vadim/scratch/waf/com/arsdigita/cms/dispatcher/MultilingualItemResolver.java
        Assert.assertNotNull(context, "String context");

        if (section == null) {
            section = item.getContentSection();
        }

        if (ContentItem.DRAFT.equals(context)) {
            if (Assert.isAssertEnabled()) {
                Assert.assertTrue(ContentItem.DRAFT.equals(item.getVersion()),
                                  "Generating " + ContentItem.DRAFT +
                                  " url: item must be draft version");
            }

            return generateDraftURL(section, item.getID());
        } else if (CMSDispatcher.PREVIEW.equals(context)) {
=====================================================================
Found a 40 line (106 tokens) duplication in the following files: 
Starting at line 116 of
/var/vadim/scratch/waf/com/arsdigita/cms/ui/ItemPropertySheet.java
Starting at line 109 of
/var/vadim/scratch/waf/com/arsdigita/toolbox/ui/DomainObjectPropertySheet.java
        getColumn(0).setAlign("left");
        getColumn(1).setVAlign("top");
        getColumn(1).setAlign("left");
    }

    /**
     * Add a new property to the sheet. The sheet will automatically
     * retrieve an attribute of the object and call toString() on it
     *
     * @param label The label for the attribute
     * @param attribute The name for the attribute. Could be a simple name
     *   or a compound path, such as "foo.bar.baz"
     */
    public void add(String label, String attribute) {

        // Determine if we are dealing with a simple string or a complex
        // path
        if(attribute.indexOf('.') == -1) {
            add(label, attribute, m_toStringFormatter);
        } else {
            add(label, attribute, m_recursiveFormatter);
        }
    }

    /**
     * Add a new property to the sheet. The sheet will use an
     * AttributeFormatter to convert the value of the attribute
     * to a String.
     *
     * @param label The label for the attribute
     * @param attribute The name for the attribute
     * @param formatter An instance of AttributeFormatter
     */
    public void add(String label, String attribute, AttributeFormatter f) {
        m_props.add(new Property(label, attribute, f));
    }

    /**
     * @return The object selection model
     */
=====================================================================
Found a 10 line (106 tokens) duplication in the following files: 
Starting at line 93 of
/var/vadim/scratch/waf/com/arsdigita/cms/ui/formbuilder/FormSectionProperties.java
Starting at line 94 of
/var/vadim/scratch/waf/com/arsdigita/cms/ui/formbuilder/FormProperties.java
            form.setDescription((String)data.get("description"));
            form.save();
        }
    }

    private Component buildDisplayComponent(ItemSelectionModel itemModel) {
        ItemPropertySheet sheet = new ItemPropertySheet(itemModel);

        sheet.add((String)
GlobalizationUtil.globalize("cms.ui.formbuilder.name").localize(), 
ContentPage.NAME);
        sheet.add((String)
GlobalizationUtil.globalize("cms.ui.formbuilder.title").localize(), 
ContentPage.TITLE);
=====================================================================
Found a 36 line (106 tokens) duplication in the following files: 
Starting at line 163 of
/var/vadim/scratch/waf/com/arsdigita/cms/ui/category/PurposeForm.java
Starting at line 169 of
/var/vadim/scratch/waf/com/arsdigita/cms/ui/CategoryForm.java
        addAssignButton(c);
        addRemoveButton(c);
    }

    protected void addAssignButton(Container c) {
        m_assign = new Submit(ASSIGN, ">>");
        m_assign.setSize(10);
        c.add(m_assign);
    }
    protected void addRemoveButton(Container c) {
        m_remove = new Submit(REMOVE, "<<");
        m_remove.setSize(10);
        c.add(m_remove);
    }
    /**
     * Set the caption of the unassigned categories label
     *
     * @param caption the new caption
     */
    public void setUnassignedCaption(String caption) {
        m_freeLabel.setLabel(caption);
    }

    /**
     * Set the caption of the assigned categories label
     *
     * @param caption the new caption
     */
    public void setAssignedCaption(String caption) {
        m_assignedLabel.setLabel(caption);
    }

    /**
     * @param s the page state
     * @return a {@link CategoryMap} of all assigned categories
     */
=====================================================================
Found a 56 line (106 tokens) duplication in the following files: 
Starting at line 286 of /var/vadim/scratch/waf/com/arsdigita/bebop/Label.java
Starting at line 110 of /var/vadim/scratch/waf/com/arsdigita/bebop/Image.java
        throws IllegalStateException, IllegalArgumentException
    {
        if ( listener == null ) {
            throw new IllegalArgumentException
                ("Argument listener can not be null");
        }
        if ( m_printListener != null ) {
            throw new IllegalStateException
                ("Too many listeners. Can only have one");
        }
        m_printListener = listener;
    }

    /**
     * Removes a previously added print listener. If <code>listener</code> is
     * not the listener that was added with {@link #addPrintListener
     * addPrintListener}, an IllegalArgumentException will be thrown.
     * @param listener the listener that was previously added with
     *      <code>addPrintListener</code>
     * @throws IllegalArgumentException if <code>listener</code> is not the
     *      currently registered print listener or is <code>null</code>.
     * @pre listener != null
     */
    public void removePrintListener(PrintListener listener)
        throws IllegalArgumentException
    {
        if ( listener == null ) {
            throw new IllegalArgumentException("listener can not be null");
        }
        if ( listener != m_printListener ) {
            throw new IllegalArgumentException
                ("listener is not registered with this widget");
        }
        m_printListener = null;
    }

    /**
     * Writes the output to a DOM to be used with the XSLT template
     * to produce the appropriate output.
     *
     * <p>Generates DOM fragment:
     * <p><code><pre>
     * &lt;bebop:image [src=...] [alt=...] [height=...]
     *       [width=...] [border=...]/>
     * </pre></code>
     *
     * @param pageState the pageState used to determine values of form
     * widgets and page state attributes
     * @param parent the XML element to which the form adds its XML representation
     * */
    public void generateXML(PageState state, Element parent) {

        if ( ! isVisible(state) ) {
            return;
        }

=====================================================================
Found a 21 line (104 tokens) duplication in the following files: 
Starting at line 630 of
/var/vadim/scratch/waf/com/arsdigita/ui/permissions/PermissionsTables.java
Starting at line 651 of
/var/vadim/scratch/waf/com/arsdigita/cms/ui/permissions/CMSPermissionsTables.java
            m_objectID  + "." +
            m_granteeID + "." +
            m_granted;
    }

    /**
     * Decodes the information in a key into the helper class
     * @see PermissionStatus
     */

    static PermissionStatus undescribe(String key) {

        int i = key.indexOf(".");
        int j = key.indexOf(".", i+1);
        int k = key.lastIndexOf(".");

        String privilege = key.substring(0,i);
        BigDecimal oID = new BigDecimal(key.substring(i+1, j));
        BigDecimal gID = new BigDecimal(key.substring(j+1, k));

        byte granted = (byte)0;
=====================================================================
Found a 30 line (104 tokens) duplication in the following files: 
Starting at line 201 of
/var/vadim/scratch/waf/com/arsdigita/cms/dispatcher/ServiceDispatcher.java
Starting at line 213 of
/var/vadim/scratch/waf/com/arsdigita/cms/dispatcher/ContentCenterDispatcher.java
                    throw new ServletException(e);
                }

                // Try and instantiate the page.
                try {
                    page = (ResourceHandler) pageClass.newInstance();
                } catch (InstantiationException e) {
                    s_log.error("error instantiating a ResourceHandler", e);
                    throw new ServletException(e);
                } catch (IllegalAccessException e) {
                    s_log.error("error instantiating a ResourceHandler", e);
                    throw new ServletException(e);
                }

                page.init();
                s_pages.put(url, page);
            }
        }
        return page;
    }

    /**
     * Map a page to a URL.
     *
     * @param url The URL
     * @param className The name of the ResourceHandler class
     * @pre (url != null && className != null)
     */
    protected void addResource(String url, String className) {
        s_pageClasses.put(url, className);
=====================================================================
Found a 21 line (103 tokens) duplication in the following files: 
Starting at line 70 of
/var/vadim/scratch/waf/com/arsdigita/ui/permissions/PermissionsHeader.java
Starting at line 70 of
/var/vadim/scratch/waf/com/arsdigita/cms/ui/permissions/CMSPermissionsHeader.java
        navbar.add(new Link(PERMISSIONS_INDEX.localize()+"", "/permissions/"));
        navbar.add(objectName);
        navbar.setClassAttr("permNavBar");
        add(navbar);
    }

    private String getObjectName(PrintEvent e) {
        PageState s = e.getPageState();
        ACSObject obj = m_parent.getObject(s);
        String objName = obj.getDisplayName() +
            " (ID " + obj.getID()+")";
        return objName;
    }

    /**
     * Returns the object used to render the title of the panel.
     */

    Label getTitle() {
        return m_title;
    }
=====================================================================
Found a 27 line (103 tokens) duplication in the following files: 
Starting at line 324 of
/var/vadim/scratch/waf/com/arsdigita/cms/ui/lifecycle/EditPhaseForm.java
Starting at line 326 of
/var/vadim/scratch/waf/com/arsdigita/cms/ui/lifecycle/AddPhaseForm.java
        // Phase duration is infinite, so the duration is valid.
        if (durDays == null && durHours == null && durMinutes == null) {
            return;
        }

        int days, hours, minutes;
        if (durDays != null) {
            days = durDays.intValue();
        } else {
            days = 0;
        }

        if (durHours != null) {
            hours = durHours.intValue();
        } else {
            hours = 0;
        }

        if (durMinutes != null) {
            minutes = durMinutes.intValue();
        } else {
            minutes = 0;
        }

        if ((days + hours + minutes) == 0) {
            throw new FormProcessException
=====================================================================
Found a 29 line (102 tokens) duplication in the following files: 
Starting at line 618 of
/var/vadim/scratch/waf/com/arsdigita/bebop/demo/DemoDispatcher.java
Starting at line 751 of
/var/vadim/scratch/waf/com/arsdigita/bebop/demo/DemoDispatcher.java
                                            System.out.print("Sauce:");
                                            for (i=0; i < sauce.length; i++) {
                                                System.out.print(" " + sauce[i]);
                                            }
                                            System.out.println();
                                        }

                                        System.out.println("Payment: " + payment);

                                        System.out.println("Thank you for
shopping at McStas's.");

                                    }
                                }
                                );

        form.add(new Submit("Purchase"),
                 ColumnPanel.RIGHT | ColumnPanel.FULL_WIDTH);

        page.add(form);

        // Finish the page
        page.lock();
        return page;
    }

    /**
     * Define a form section which can be reused in multiple forms
     * From tutorial demo/form-sections.xml
     */
=====================================================================
Found a 56 line (102 tokens) duplication in the following files: 
Starting at line 164 of /var/vadim/scratch/waf/com/arsdigita/cms/ui/UserAddForm.java
Starting at line 175 of
/var/vadim/scratch/waf/com/arsdigita/cms/ui/PartyAddForm.java
        form.addSubmissionListener(new FormSubmissionListener() {
                public void submitted(FormSectionEvent event)
                    throws FormProcessException {
                    PageState state = event.getPageState();
                    if ( isCancelled(state) ) {
                        throw new FormProcessException( (String)
GlobalizationUtil.globalize("cms.ui.cancel_hit").localize());
                    }
                }
            });

        form.addProcessListener(this);




        return form;
    }

    /**
     * Fetches the form for adding parties.
     *
     * @return The "add party" form
     */
    public Form getForm() {
        return m_form;
    }

    /**
     * Fetches the widget that contains the search string.
     *
     * @return The widget that contains the search string
     */
    protected Widget getSearchWidget() {
        return m_searchQuery;
    }

    /**
     * Return true if the form is cancelled, false otherwise.
     *
     * @param state The page state
     * @return true if the form is cancelled, false otherwise.
     * @pre ( state != null )
     */
    public boolean isCancelled(PageState state) {
        return m_cancel.isSelected(state);
    }


    /**
     * Adds parties to the option group.
     *
     * @param state The page state
     * @param target The option group
     * @pre ( state != null && target != null )
     */
=====================================================================
Found a 15 line (101 tokens) duplication in the following files: 
Starting at line 81 of
/var/vadim/scratch/waf/com/arsdigita/bebop/parameters/TimeParameter.java
Starting at line 94 of
/var/vadim/scratch/waf/com/arsdigita/bebop/parameters/DateTimeParameter.java
        if ( minute != null ) {
            c.set(Calendar.MINUTE, Integer.parseInt(minute));
        }
        if ( second != null ) {
            c.set(Calendar.SECOND, Integer.parseInt(second));
        }
        if ( amOrPm != null ) {
            c.set(Calendar.AM_PM, Integer.parseInt(amOrPm));
        }
        return c.getTime();
    }

    public Object unmarshal(String encoded) {
        try {
            return new Date(Long.parseLong(encoded));
=====================================================================
Found a 33 line (101 tokens) duplication in the following files: 
Starting at line 224 of
/var/vadim/scratch/waf/com/arsdigita/cms/ui/folder/FolderBrowser.java
Starting at line 194 of
/var/vadim/scratch/waf/com/arsdigita/cms/ui/ItemSearchFolderBrowser.java
            m_fb = fb;
        }

        /**
         * Indicates whether the paginator should be visible,
         * based on the visibility of the folder browser itself.
         *
         * @return true if folder browser is visible, or if the
         *         associated folder browser is unknown.
         */
        public boolean isVisible(PageState state) {
            return (m_fb != null)?m_fb.isVisible(state):true;
        }
    }

    /**
     * Produce links to view an item or control links for folders
     * to change into the folder.
     */
    private class NameCellRenderer extends DefaultTableCellRenderer
    {
      public NameCellRenderer()
      {
	super(true);
      }

      public Component getComponent (Table table, PageState state,
				     Object value, boolean isSelected,
				     Object key, int row, int column)
      {
	Folder.ItemCollection coll = (Folder.ItemCollection) value;
	String name = coll.getName();
	if ( coll.isFolder() )
=====================================================================
Found a 39 line (101 tokens) duplication in the following files: 
Starting at line 41 of
/var/vadim/scratch/waf/com/arsdigita/cms/ui/HorizontalLine.java
Starting at line 36 of
/var/vadim/scratch/waf/com/arsdigita/bebop/HorizontalLine.java
    public HorizontalLine() {
        super();
    }

    public String getWidth() {
        return m_width;
    }

    // TODO: should be renamed to setHeight() to make the correspondance
    // with XML more obvious
    public String getThickness() {
        return m_height;
    }

    public String getColor() {
        return m_bgcolor;
    }

    public void setWidth(String w) {
        m_width = w;
    }

    public void setThickness(String t) {
        m_height = t;
    }

    public void setColor(String c) {
        m_bgcolor = c;
    }

    // TODO: document the XML generated by this component
    public void generateXML(PageState state, Element parent) {
        if ( !isVisible(state) ) {
            return;
        }

=====================================================================
Found a 28 line (101 tokens) duplication in the following files: 
Starting at line 118 of
/var/vadim/scratch/waf/com/arsdigita/cms/ui/category/OrderedCategorizedObjectsList.java
Starting at line 115 of
/var/vadim/scratch/waf/com/arsdigita/cms/ui/SortableList.java
            hasNext = m.next();

            // Add attributes containing URLs that fire control events
            // for various portlet actions
            try {
                // Maybe add attribute containing URL for "move up" link
                if (i > 0) {
                    state.setControlEvent(this, PREV_EVENT, key);
                    item.addAttribute("prevURL", state.stateAsURL());
                }

                // Maybe add attribute containing URL for "move down" link
                if (hasNext) {
                    state.setControlEvent(this, NEXT_EVENT, key);
                    item.addAttribute("nextURL", state.stateAsURL());
                }

            } catch (IOException ex) {
                throw new IllegalStateException("Caught IOException: " +
                                                ex.getMessage());
            }
            i++;
        }  while (hasNext);

        state.clearControlEvent();
    }

=====================================================================
Found a 16 line (101 tokens) duplication in the following files: 
Starting at line 538 of
/var/vadim/scratch/waf/com/arsdigita/kernel/security/UserContext.java
Starting at line 403 of
/var/vadim/scratch/waf/com/arsdigita/kernel/security/UserContext.java
        }

        public void handle(Callback[] callbacks)
            throws IOException, UnsupportedCallbackException {

            for (int i = 0; i < callbacks.length; i++) {
                Callback cb = callbacks[i];
                if (cb instanceof HTTPRequestCallback) {
                    ((HTTPRequestCallback)cb).setRequest
                        (UserContext.this.m_req);

                } else if (cb instanceof HTTPResponseCallback) {
                    ((HTTPResponseCallback)cb).setResponse
                        (UserContext.this.m_res);

                } else if (cb instanceof LifetimeCallback) {
Comment 1 Vadim Nasardinov 2003-07-21 10:03:24 EDT
BTW, the above only includes duplications of more than 100 tokens.  If you
lower the bar and search for duplication of 50 tokens or more, there is a
lot more of those.  Here's what I did:


$ java -cp /tmp/pmd-1.1.jar -Xmx512M \
  net.sourceforge.pmd.cpd.CPD 100

See
http://pmd.sourceforge.net/cpd.html

Comment 2 Vadim Nasardinov 2004-03-22 09:30:45 EST
Xref: bug 118872.
Comment 3 Vadim Nasardinov 2005-08-03 14:26:45 EDT
stale

Note You need to log in before you can comment on or make changes to this bug.