CPD Results

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

Duplications

File Line
fr/cnes/doi/plugin/impl/db/DefaultProjectSuffixImpl.java 104
fr/cnes/doi/plugin/impl/db/DefaultTokenImpl.java 102
    @Override
    public void setConfiguration(final Object configuration) {
        this.conf = (Map<String, String>) configuration;
        final String dbUrl = this.conf.get(DB_URL);
        final String dbUser = this.conf.get(DB_USER);
        final String dbPwd = this.conf.get(DB_PWD);
        if (this.conf.containsKey(DB_MIN_IDLE_CONNECTIONS)) {
            this.options.put(DB_MIN_IDLE_CONNECTIONS,
                    Integer.valueOf(this.conf.get(DB_MIN_IDLE_CONNECTIONS)));
        }
        if (this.conf.containsKey(DB_MAX_IDLE_CONNECTIONS)) {
            this.options.put(DB_MAX_IDLE_CONNECTIONS,
                    Integer.valueOf(this.conf.get(DB_MAX_IDLE_CONNECTIONS)));
        }
        if (this.conf.containsKey(DB_MAX_ACTIVE_CONNECTIONS)) {
            this.options.put(DB_MAX_ACTIVE_CONNECTIONS,
                    Integer.valueOf(this.conf.get(DB_MAX_ACTIVE_CONNECTIONS)));
        }
        LOG.info("[CONF] Plugin database URL : {}", dbUrl);
        LOG.info("[CONF] Plugin database user : {}", dbUser);
        LOG.info("[CONF] Plugin database password : {}", Utils.transformPasswordToStars(dbPwd));
        LOG.info("[CONF] Plugin options : {}", this.options);

        this.configured = true;
    }

    @Override
    public void initConnection() throws DoiRuntimeException {
        DatabaseSingleton.getInstance().init(
                this.conf.get(DB_URL), this.conf.get(DB_USER), this.conf.get(DB_PWD), this.options);
        this.das = DatabaseSingleton.getInstance().getDatabaseAccess();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public synchronized boolean addProjectSuffix(final int projectID, final String projectName) {
File Line
fr/cnes/doi/plugin/impl/db/DefaultTokenImpl.java 77
fr/cnes/doi/plugin/impl/db/DefaultUserRoleImpl.java 92
    private final String NAME = this.getClass().getName();

    /**
     * Database access.
     */
    private DOIDbDataAccessService das;

    /**
     * Configuration file.
     */
    private Map<String, String> conf;

    /**
     * Status of the plugin configuration.
     */
    private boolean configured = false;

    /**
     * Options for JDBC.
     */
    private final Map<String, Integer> options = new ConcurrentHashMap<>();

    /**
     * {@inheritDoc }
     */
    @Override
    public void setConfiguration(final Object configuration) {
        this.conf = (Map<String, String>) configuration;
        final String dbUrl = this.conf.get(DB_URL);
        final String dbUser = this.conf.get(DB_USER);
        final String dbPwd = this.conf.get(DB_PWD);
        if (this.conf.containsKey(DB_MIN_IDLE_CONNECTIONS)) {
            this.options.put(DB_MIN_IDLE_CONNECTIONS,
                    Integer.valueOf(this.conf.get(DB_MIN_IDLE_CONNECTIONS)));
        }
        if (this.conf.containsKey(DB_MAX_IDLE_CONNECTIONS)) {
            this.options.put(DB_MAX_IDLE_CONNECTIONS,
                    Integer.valueOf(this.conf.get(DB_MAX_IDLE_CONNECTIONS)));
        }
        if (this.conf.containsKey(DB_MAX_ACTIVE_CONNECTIONS)) {
            this.options.put(DB_MAX_ACTIVE_CONNECTIONS,
                    Integer.valueOf(this.conf.get(DB_MAX_ACTIVE_CONNECTIONS)));
        }
        LOG.info("[CONF] Plugin database URL : {}", dbUrl);
        LOG.info("[CONF] Plugin database user : {}", dbUser);
        LOG.info("[CONF] Plugin database password : {}", Utils.transformPasswordToStars(dbPwd));
        LOG.info("[CONF] Plugin options : {}", this.options);
File Line
fr/cnes/doi/plugin/impl/db/DefaultProjectSuffixImpl.java 104
fr/cnes/doi/plugin/impl/db/DefaultUserRoleImpl.java 117
    @Override
    public void setConfiguration(final Object configuration) {
        this.conf = (Map<String, String>) configuration;
        final String dbUrl = this.conf.get(DB_URL);
        final String dbUser = this.conf.get(DB_USER);
        final String dbPwd = this.conf.get(DB_PWD);
        if (this.conf.containsKey(DB_MIN_IDLE_CONNECTIONS)) {
            this.options.put(DB_MIN_IDLE_CONNECTIONS,
                    Integer.valueOf(this.conf.get(DB_MIN_IDLE_CONNECTIONS)));
        }
        if (this.conf.containsKey(DB_MAX_IDLE_CONNECTIONS)) {
            this.options.put(DB_MAX_IDLE_CONNECTIONS,
                    Integer.valueOf(this.conf.get(DB_MAX_IDLE_CONNECTIONS)));
        }
        if (this.conf.containsKey(DB_MAX_ACTIVE_CONNECTIONS)) {
            this.options.put(DB_MAX_ACTIVE_CONNECTIONS,
                    Integer.valueOf(this.conf.get(DB_MAX_ACTIVE_CONNECTIONS)));
        }
        LOG.info("[CONF] Plugin database URL : {}", dbUrl);
        LOG.info("[CONF] Plugin database user : {}", dbUser);
        LOG.info("[CONF] Plugin database password : {}", Utils.transformPasswordToStars(dbPwd));
        LOG.info("[CONF] Plugin options : {}", this.options);
File Line
fr/cnes/doi/resource/admin/SuffixProjectsDoisResource.java 100
fr/cnes/doi/resource/admin/SuffixProjectsResource.java 164
        return LOG.traceExit(response);
    }

    /**
     * projects representation
     *
     * @return Wadl representation for projects
     */
    @Requirement(reqId = Requirement.DOI_DOC_010, reqName = Requirement.DOI_DOC_010_NAME)
    private RepresentationInfo projectsRepresentation() {
        final RepresentationInfo repInfo = new RepresentationInfo();
        repInfo.setMediaType(MediaType.APPLICATION_XML);
        final DocumentationInfo docInfo = new DocumentationInfo();
        docInfo.setTitle("Projects Representation");
        docInfo.setTextContent("The representation contains informations about all projects.");
        repInfo.setDocumentation(docInfo);
        return repInfo;
    }

    //TODO describres get method
    /**
     * Describes a GET method.
     *
     * @param info method information
     */
    @Requirement(reqId = Requirement.DOI_DOC_010, reqName = Requirement.DOI_DOC_010_NAME)
    @Override
    protected void describeGet(final MethodInfo info) {
        info.setName(Method.GET);
        info.setDocumentation("Get information about the created projects");
        addResponseDocToMethod(info, createResponseDoc(
                Status.SUCCESS_OK,
                "Operation successful",
                projectsRepresentation()
        ));
    }
File Line
fr/cnes/doi/application/AdminApplication.java 358
fr/cnes/doi/application/DoiMdsApplication.java 187
        return LOG.traceExit(updateDataBaseTask);
    }

    /**
     * Creates a router for the AdminApplication. This router routes :
     * <ul>
     * <li>the web resources for the website with no authentication</li>
     * <li>the REST resources for the system administration with
     * authentication/authorization</li>
     * </ul>
     * The web resources are attached by default to the AdminApplication where
     * as the REST resources for the system administration are attached with the
     * {@link AdminApplication#ADMIN_URI}
     *
     * @see AdminApplication#createWebSiteRouter() the router that contains the
     * the web resources
     * @see AdminApplication#createAdminRouter() the router that contains the
     * REST resources
     * @see AdminApplication#createAuthenticator() the authentication mechanism
     * @see AdminApplication#createRoleAuthorizer() the authorization mechanism
     * @return Router
     */
    @Override
    public Restlet createInboundRoot() {
        LOG.traceEntry();
        
        final Filter logContext = new Filter() {
            /**
             * Get the IP client from proxy (if there is one) and set it in
             * the header.
             * 
             * @param request request
             * @param response response
             * @return 0
             */
            @Override
            protected int beforeHandle(final Request request, final Response response) {
                final ClientInfo clientInfo = request.getClientInfo();
                final String ipAddress = request.getHeaders().getFirstValue(
                        Consts.PROXIFIED_IP, clientInfo.getUpstreamAddress()
                );
                ThreadContext.put(Consts.LOG_IP_ADDRESS, ipAddress);
                return Filter.CONTINUE;
            }
        }; 
        
        // Defines the strategy of authentication (authentication is not required)
        //   - authentication with login/pwd
        final ChallengeAuthenticator challAuth = createAuthenticatorLoginBased();
        challAuth.setOptional(true);

        //   - authentication with token
        final ChallengeAuthenticator challTokenAuth = createTokenAuthenticator();
        challTokenAuth.setOptional(false);