CPD Ergebnisse

Dieses Dokument enthält die Ergebnisse von PMD's CPD 5.0.2.

Duplikationen

Datei Zeile
de/tivsource/page/user/actions/contact/SentAction.java 189
de/tivsource/page/user/actions/request/RequestAction.java 231
                        sendIt.send("Kontaktformular", (EmailTemplate)notification, argu, session);
                    } catch (UnsupportedEncodingException | MessagingException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    return; // to stop the thread
                }
            }).start();

		} catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		 
		
	}// Ende sendMail()

    private Properties getProperties() {
        LOGGER.info("getProperties() aufgerufen.");

        // Get system properties
        Properties props = System.getProperties();

        // Setup mail server
        props.put("mail.transport.protocol", 
                propertyDaoLocal.findByKey("mail.transport.protocol").getValue());
        props.put("mail.host", 
                propertyDaoLocal.findByKey("mail.host").getValue());
        props.put("mail.port", 
                propertyDaoLocal.findByKey("mail.port").getValue());
        props.put("mail.smtp.auth", 
                propertyDaoLocal.findByKey("mail.smtp.auth").getValue());
        props.put("mail.smtp.tls", 
                propertyDaoLocal.findByKey("mail.smtp.tls").getValue());
        props.put("mail.smtp.starttls.enable",
                propertyDaoLocal.findByKey("mail.smtp.starttls.enable").getValue());
        props.put("mail.smtp.localhost", 
                propertyDaoLocal.findByKey("mail.smtp.localhost").getValue());
        props.put("mail.user", 
                propertyDaoLocal.findByKey("mail.user").getValue());
        props.put("mail.password", 
                propertyDaoLocal.findByKey("mail.password").getValue());
        props.put("mail.mime.charset", 
                propertyDaoLocal.findByKey("mail.mime.charset").getValue());
        props.put("mail.use8bit", 
                propertyDaoLocal.findByKey("mail.use8bit").getValue());
        
        return props;
    } // Ende getProperties()

    private void setUpPage() {
        LOGGER.info("Action Errors: " + this.getFieldErrors().size());
        if(this.getFieldErrors().size() > 0) {
Datei Zeile
de/tivsource/page/user/actions/appointment/AppointmentAction.java 41
de/tivsource/page/user/actions/appointmentarchive/AppointmentAction.java 40
    private static final Logger LOGGER = LogManager.getLogger(AppointmentAction.class);

    @InjectEJB(name = "PageDao")
    private PageDaoLocal pageDaoLocal;

    @InjectEJB(name="PropertyDao")
    private PropertyDaoLocal propertyDaoLocal;

    @InjectEJB(name="AppointmentDao")
    private AppointmentDaoLocal appointmentDaoLocal;

    private Appointment appointment;

    private String appointmentUuid;
    
    private Page page;

    @Override
    @Actions({
        @Action(value = "*/index", results = {
            @Result(name = "success", type = "tiles", location = "appointment"),
            @Result(name = "input", type = "redirectAction", location = "index.html", params={"namespace", "/"}),
            @Result(name = "error", type = "redirectAction", location = "index.html", params={"namespace", "/"})
        })
    })
    public String execute() throws Exception {
        LOGGER.info("execute() aufgerufen.");

        // Hole Action Locale
        this.getLanguageFromActionContext();

        appointmentUuid = ServletActionContext.getRequest().getServletPath();
        LOGGER.info("Appointment Uuid: " + appointmentUuid);

        // /gallery/painting/index.html?page=1&request_locale=de
        
        
        appointmentUuid = appointmentUuid.replaceAll("/index.html", "");
        appointmentUuid = appointmentUuid.replaceAll("/appointment/", "");
Datei Zeile
de/tivsource/page/user/actions/gallery/GalleryAction.java 98
de/tivsource/page/user/actions/gallery/PictureAction.java 120
            @Result(name = "success", type = "tiles", location = "gallery"),
            @Result(name = "input", type = "redirectAction", location = "index.html", params={"namespace", "/"}),
            @Result(name = "error", type = "redirectAction", location = "index.html", params={"namespace", "/"})
        })
    })
    public String execute() throws Exception {
        LOGGER.info("execute() aufgerufen.");

        // Hole Action Locale
        this.getLanguageFromActionContext();

        /*
         * Ermittle ob die Galeriefunktion der Webseite angeschaltet wurde.
         */
        boolean galleryPageEnabled = getProperty("gallery.page.enabled").equals("true") ? true : false;
        if(!galleryPageEnabled) {
            return ERROR;
        }

        /*
         * Ermittle Wert des Attributes maxElements aus Datenbank, versuche
         * die Eigenschaft gallery.page.max.pictures zu laden.
         */
        if(getProperty("gallery.overview.list.quantity") != null) {
            maxElements = Integer.parseInt(getProperty("gallery.overview.list.quantity"));
        }


        pathUuid = ServletActionContext.getRequest().getServletPath();
        LOGGER.info("UUID from Path: " + pathUuid);

        // /gallery/index.html?page=1&request_locale=de
        pathUuid = pathUuid.replaceAll("/index.html", "");
        pathUuid = pathUuid.replaceAll("/gallery/", "");
            
        LOGGER.info("UUID from Path: " + pathUuid);
Datei Zeile
de/tivsource/page/user/actions/PageAction.java 56
de/tivsource/page/user/actions/home/IndexAction.java 42
            @Result(name = "success", type = "tiles", location = "page"),
            @Result(name = "error", type = "redirectAction", location = "index.html") })
    })
    public String execute() throws Exception {
        LOGGER.info("execute() aufgerufen.");

        // Hole Action Locale
        this.getLanguageFromActionContext();

        pageName = ServletActionContext.getRequest().getServletPath();
        LOGGER.info("PageName: " + pageName);

        // /gallery/painting/index.html?page=1&request_locale=de
        
        
        pageName = pageName.replaceAll("/index.html", "");
        pageName = pageName.replaceAll("/", "");
            
        LOGGER.info("PageName: " + pageName);

        /*
         * Wenn der Seiten-Name keine nicht erlaubten Zeichen enthält und es
         * die Seite mit dem Namen gibt dann wird der Block ausgeführt.
         */
        if (isValid(pageName) && pageDaoLocal.isPageUrl(pageName)) {
            page = pageDaoLocal.findByTechnical(pageName);
            return SUCCESS;
        }

        /*
         * Wenn es die Seite nicht gibt oder es einen Manipulationsversuch
         * gab.
         */
         return ERROR;
    }// Ende execute()

    @Override
    public Page getPage() {
        return page;
    }

    private Boolean isValid(String input) {
        if (Pattern.matches("[a-z]*", input)) {
            return true;
        } else {
            return false;
        }
    }

}// Ende class
Datei Zeile
de/tivsource/page/user/actions/appointment/IndexAction.java 90
de/tivsource/page/user/actions/appointmentarchive/IndexAction.java 90
        page = pageDaoLocal.findByTechnical("appointment");
    }

    @Override
    @Actions({
        @Action(value = "index", results = {
            @Result(name = "success", type = "tiles", location = "appointmentList"),
            @Result(name = "input", type = "redirectAction", location = "index.html", params={"namespace", "/"}),
            @Result(name = "error", type = "redirectAction", location = "index.html", params={"namespace", "/"})
        })
    })
    public String execute() throws Exception {
        LOGGER.info("execute() aufgerufen.");

        // Hole Action Locale
        this.getLanguageFromActionContext();

        // Hole die Anzahl aus der Datenbank
        this.getDBCount();

        // Wenn page nicht gesetzt wurde
        if(pagination == null) {
        	pagination = 1;
        }

        //  Wenn page größer als maxPages ist.
        if(pagination > maxPages) {
        	pagination = 1;
        }

        // Kalkuliere die Seiten
        this.calculate();
 
        // Hole sichtbare Anleitungen aus der Datenbank
        appointments = appointmentDaoLocal.findAllVisible(from, TO);
Datei Zeile
de/tivsource/page/user/actions/event/IndexAction.java 88
de/tivsource/page/user/actions/event/ReservationAction.java 121
        List<Date> times = new ArrayList<Date>();

        // Anfangs Punkt der Zeitreihe
        Calendar calendarStart = Calendar.getInstance();
        calendarStart.setTime(event.getBeginning());
        times.add(calendarStart.getTime());
                
        // Endpunkt der Zeitreihe 
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(event.getEnding());
        calendar.add(Calendar.MINUTE, -30);
        Date end = calendar.getTime();

        // Datum mit dem gerechnet wird
        Date time = event.getBeginning();
        while (time.before(end)) {
            Calendar calendarTime = Calendar.getInstance();
            calendarTime.setTime(time);
            calendarTime.add(Calendar.MINUTE, 15);
            time = calendarTime.getTime();
            times.add(time);
        }
Datei Zeile
de/tivsource/page/user/actions/contact/SentAction.java 189
de/tivsource/page/user/actions/event/ReservationAction.java 287
de/tivsource/page/user/actions/request/RequestAction.java 231
                        sendIt.send("Kontaktformular", (EmailTemplate)notification, argu, session);
                    } catch (UnsupportedEncodingException | MessagingException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    return; // to stop the thread
                }
            }).start();

		} catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		 
		
	}// Ende sendMail()

    private Properties getProperties() {
        LOGGER.info("getProperties() aufgerufen.");

        // Get system properties
        Properties props = System.getProperties();

        // Setup mail server
        props.put("mail.transport.protocol", 
                propertyDaoLocal.findByKey("mail.transport.protocol").getValue());
        props.put("mail.host", 
                propertyDaoLocal.findByKey("mail.host").getValue());
        props.put("mail.port", 
Datei Zeile
de/tivsource/page/user/actions/contact/SentAction.java 126
de/tivsource/page/user/actions/request/RequestAction.java 163
    }

	/**
     * @return the captcha
     */
    public Captcha getCaptcha() {
        return captcha;
    }

    /**
     * @param captcha the captcha to set
     */
    public void setCaptcha(Captcha captcha) {
        this.captcha = captcha;
    }

    /**
     * @param answer the answer to set
     */
    public void setAnswer(String answer) {
        this.answer = answer;
    }

    private void sendMail() {
		LOGGER.info("sendMail() aufgerufen.");
		
		javax.mail.Authenticator auth = new javax.mail.Authenticator() {
			@Override
			public PasswordAuthentication getPasswordAuthentication() {
				return new PasswordAuthentication(
				        propertyDaoLocal.findByKey("mail.user").getValue(),
				        propertyDaoLocal.findByKey("mail.password").getValue());
			}
		};
		
		InputStream template;
		try {
		    URL templatePath = new URL(propertyDaoLocal.findByKey("mail.template.path").getValue());
Datei Zeile
de/tivsource/page/user/actions/appointment/IndexAction.java 160
de/tivsource/page/user/actions/manual/IndexAction.java 170
de/tivsource/page/user/actions/news/IndexAction.java 169
        dbQuantity = appointmentDaoLocal.countAllVisible();
        LOGGER.debug("DbQuantity: " + dbQuantity);
        // Berechne die Maximal mögliche Seitenzahl
        maxPages = (dbQuantity % TO == 0) ? (dbQuantity / TO) : (dbQuantity / TO) + 1;
        LOGGER.debug("MaxPages: " + maxPages);
    }// Ende getDBCount()

    /**
     * Methode die Start und Enpunkt der Liste und die vorherige beziehungweise
     * die nächste Seitenzahl berechnet.
     */
    private void calculate() {
        if(pagination == 1) {
            previous = null;
            next = (2 <= maxPages) ? 2 : null;
            from = 0;
            current = pagination;
        } else {
            previous = pagination -1;
            next = (pagination + 1 <= maxPages) ? pagination + 1 : null;
            from = (pagination - 1) * TO;
            current = pagination;
        }
    }// Ende calculate()

    
}// Ende class
Datei Zeile
de/tivsource/page/user/actions/appointment/IndexAction.java 160
de/tivsource/page/user/actions/appointmentarchive/IndexAction.java 160
de/tivsource/page/user/actions/manual/IndexAction.java 170
de/tivsource/page/user/actions/news/IndexAction.java 169
        dbQuantity = appointmentDaoLocal.countAllVisible();
        LOGGER.debug("DbQuantity: " + dbQuantity);
        // Berechne die Maximal mögliche Seitenzahl
        maxPages = (dbQuantity % TO == 0) ? (dbQuantity / TO) : (dbQuantity / TO) + 1;
        LOGGER.debug("MaxPages: " + maxPages);
    }// Ende getDBCount()

    /**
     * Methode die Start und Enpunkt der Liste und die vorherige beziehungweise
     * die nächste Seitenzahl berechnet.
     */
    private void calculate() {
        if(pagination == 1) {
            previous = null;
            next = (2 <= maxPages) ? 2 : null;
            from = 0;
            current = pagination;
        } else {
            previous = pagination -1;
            next = (pagination + 1 <= maxPages) ? pagination + 1 : null;
            from = (pagination - 1) * TO;
            current = pagination;
        }
    }// Ende calculate()

    
}// Ende class
Datei Zeile
de/tivsource/page/user/actions/appointment/IndexAction.java 160
de/tivsource/page/user/actions/appointmentarchive/IndexAction.java 160
de/tivsource/page/user/actions/manual/IndexAction.java 170
de/tivsource/page/user/actions/news/IndexAction.java 169
de/tivsource/page/user/actions/reservation/LocationAction.java 227
        dbQuantity = appointmentDaoLocal.countAllVisible();
        LOGGER.debug("DbQuantity: " + dbQuantity);
        // Berechne die Maximal mögliche Seitenzahl
        maxPages = (dbQuantity % TO == 0) ? (dbQuantity / TO) : (dbQuantity / TO) + 1;
        LOGGER.debug("MaxPages: " + maxPages);
    }// Ende getDBCount()

    /**
     * Methode die Start und Enpunkt der Liste und die vorherige beziehungweise
     * die nächste Seitenzahl berechnet.
     */
    private void calculate() {
        if(pagination == 1) {
            previous = null;
            next = (2 <= maxPages) ? 2 : null;
            from = 0;
            current = pagination;
        } else {
            previous = pagination -1;
            next = (pagination + 1 <= maxPages) ? pagination + 1 : null;
            from = (pagination - 1) * TO;
            current = pagination;
        }
    }// Ende calculate()

    
}// Ende class
Datei Zeile
de/tivsource/page/user/actions/appointment/AppointmentAction.java 101
de/tivsource/page/user/actions/appointmentarchive/AppointmentAction.java 95
        }

        /*
         * Wenn es die Seite nicht gibt oder es einen Manipulationsversuch
         * gab.
         */
         return ERROR;
    }// Ende execute()

    @Override
    public Page getPage() {
        return page;
    }

    public Appointment getAppointment() {
        return appointment;
    }

    private Boolean isValid(String input) {
        if (Pattern.matches("[abcdef0-9-]*", input)) {
            return true;
        } else {
            return false;
        }
    }

    private void setUpPage() {
        page = new Page();
        page.setDescriptionMap(appointment.getDescriptionMap());
        page.setPicture(appointment.getPicture());
        page.setPictureOnPage(appointment.getPictureOnPage());
        page.setCssGroup(appointment.getCssGroup());
    }

}// Ende class
Datei Zeile
de/tivsource/page/user/actions/location/LocationAction.java 144
de/tivsource/page/user/actions/reservation/LocationAction.java 205
	}

	private Boolean isValid(String input) {
        if (Pattern.matches("[abcdef0-9-]*", input)) {
            return true;
        } else {
            return false;
        }
    }

    private void setUpPage() {
        location = locationDaoLocal.findByUuid(locationUuid);
        page = new Page();
        page.setTechnical(location.getTechnical());
        page.setDescriptionMap(location.getDescriptionMap());
        page.setPicture(location.getPicture());
        page.setPictureOnPage(location.getPictureOnPage());
        page.setCssGroup(location.getCssGroup());
    }