CPD Results

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

Duplications

FileLine
it/imolinfo/jbi4ejb/processor/Jbi4EjbNormalizer.java157
it/imolinfo/jbi4ejb/processor/Jbi4EjbNormalizer.java280
            Part part = (Part)wsdlFault.getParts().values().iterator().next();        

            // String[] partNames = wsdlMessage.getParts().values().iterator().next(); 
            String partName = part.getName();

            Node node = null;
            if (xmlSource instanceof DOMSource) {
                // saves a transformation
                node = ((DOMSource) xmlSource).getNode();
            } else {
                DOMResult domResult = new DOMResult();
                mTrans.transform(xmlSource, domResult);
                node = domResult.getNode();
            }

            DOMSource domSource = null;
            
            if (!toWrap) {
                // If do not need wrapping, return the document
                domSource =  new DOMSource(node);
            } else {
                // needs wrapping
                if (node instanceof Document) {
                    wrapperBuilder.addPart(partName, ((Document) node).getDocumentElement());
                } else if (node instanceof Element) {
                    wrapperBuilder.addPart(partName, (Element) node);
                } else {
                	String msg=MESSAGES.getString("EJB000605_Invalid_result_from_XML_transformation", new Object[]{node.getClass()});
                    LOG.error(msg);
                    throw new Jbi4EjbException(msg);
                }

                Document doc = wrapperBuilder.getResult();
                domSource = new DOMSource(doc);
            }

FileLine
it/imolinfo/jbi4ejb/processor/Jbi4EjbNormalizer.java191
it/imolinfo/jbi4ejb/processor/Jbi4EjbNormalizer.java316
            fault.setContent(domSource);
        } catch (WrapperProcessingException ex) {
        	String msg=MESSAGES.getString("EJB000602_Jbi4Ejb_processor", new Object[]{ex.getMessage()});
            LOG.error(msg,ex);
            throw new Jbi4EjbException(msg,ex);
        } catch (TransformerException ex) {
        	String msg=MESSAGES.getString("EJB000602_Jbi4Ejb_processor", new Object[]{ex.getMessage()});
            LOG.error(msg,ex);
            throw new Jbi4EjbException(msg,ex);          
        } catch (MessagingException ex) {
        	String msg=MESSAGES.getString("EJB000602_Jbi4Ejb_processor", new Object[]{ex.getMessage()});
            LOG.error(msg,ex);
            throw new Jbi4EjbException(msg,ex);                        
        }
    }

FileLine
it/imolinfo/jbi4ejb/processor/Jbi4EjbDenormalizer.java76
it/imolinfo/jbi4ejb/processor/Jbi4EjbNormalizer.java78
        	String msg=MESSAGES.getString("EJB000602_Jbi4Ejb_processor", new Object[]{ex.getMessage()});
            LOG.error(msg,ex);
            throw new Jbi4EjbException(msg,ex);
        }
        
        try {
            TransformerFactory factory = TransformerFactory.newInstance();
            mTrans = factory.newTransformer();
        } catch (TransformerFactoryConfigurationError ex) {
        	String msg=MESSAGES.getString("EJB000602_Jbi4Ejb_processor", new Object[]{ex.getMessage()});
            LOG.error(msg,ex);
            throw new Jbi4EjbException(msg,ex);
        } catch (TransformerConfigurationException e) {
        	String msg=MESSAGES.getString("EJB000602_Jbi4Ejb_processor", new Object[]{e.getMessage()});
            LOG.error(msg,e);
            throw new Jbi4EjbException(msg,e);
        }               
    }
        
    /**
     * Normalize the message.
     * 
     * @param xmlSource
     *            the xmlSource to normalize
     * @param normalizedMsg
     *            the normlized message
     * @param endpoint
     *            the invoked endpoint
     * @param operation
     *            the invoked operation
     * @param toWrap
     *              if the message must be wrapped
     * @throws Jbi4EjbException
     *             if some problem occurs in normalization
     */
    public void normalize(Source xmlSource,

FileLine
it/imolinfo/jbi4ejb/webservice/generator/JarUtil.java54
it/imolinfo/jbi4ejb/webservice/generator/JarUtil.java106
    public static void unjar(File jarFile, String resource, File targetDir)
    throws IOException {
        // clear target directory:
        if (targetDir.exists()) {
            targetDir.delete();
        }
        // create new target directory:
        targetDir.mkdirs(); 
        // read jar-file:
        String targetPath = targetDir.getAbsolutePath() + File.separatorChar;
        byte[] buffer = new byte[ BUFFER_LENGTH * BUFFER_LENGTH ];
        JarFile input = new JarFile( jarFile, false, ZipFile.OPEN_READ );
        Enumeration<JarEntry> enumeration = input.entries();
        for (; enumeration.hasMoreElements();) {
            JarEntry entry = (JarEntry) enumeration.nextElement();
            if (!entry.isDirectory()) {
                // do not copy anything from the package cache:
                if (entry.getName().equals(resource)) {

FileLine
it/imolinfo/jbi4ejb/webservice/generator/JarUtil.java72
it/imolinfo/jbi4ejb/webservice/generator/JarUtil.java123
                if (entry.getName().equals(resource)) {
                    String path = targetPath + entry.getName();
                    File file = new File( path );
                    if (!file.getParentFile().exists()) {
                        file.getParentFile().mkdirs();
                    }
                    FileOutputStream out = new FileOutputStream( file);
                    InputStream in = input.getInputStream(entry);
                    int read;
                    while ( (read = in.read( buffer )) != -1) {
                        out.write( buffer, 0, read );
                    }
                    in.close();
                    out.close();
                }
            }
        }
    }

FileLine
org/slf4j/impl/JDK14LoggerAdapter.java120
org/slf4j/impl/Log4jLoggerAdapter.java111
    }

    /**
     * Formats the specified message, applying I18N if it is available for this
     * logger.
     *
     * @param   format  the format string.
     * @param   args    the optional arguments.
     * @return  the formatted message, eventually internationalized.
     */
    private String formatMessage(final String format, final Object ... args) {
        String msg;

        if (isI18N()) {
            if (args.length == 0) {
                msg = messages.getString(format);
            } else {
                msg = messages.getString(format, args);
            }
        } else {
            if (args.length == 0) {
                msg = format;
            } else {
                try {
                    msg = MessageFormat.format(format, args);
                } catch (IllegalArgumentException e) {
                    msg = format;
                }
            }
        }
        return msg;
    }

    /**
     * Gets the name of this <code>Logger</code>.
     *
     * @return the name of this <code>Logger</code> instance.
     */
    public String getName() {

FileLine
it/imolinfo/jbi4ejb/jbi/component/Jbi4EjbSUManager.java579
it/imolinfo/jbi4ejb/webservice/generator/WSDLGenerator.java464
    private static Definition readWsdl(final File f) throws WSDLException {
        final WSDLFactory wsdlFactory = WSDLFactory.newInstance();
        ExtensionRegistry registry = wsdlFactory
        .newPopulatedExtensionRegistry();        
        final WSDLReader reader = ((WSDLFactoryImpl) wsdlFactory)
        .newWSDLReader();
        reader.setFeature(Constants.FEATURE_VERBOSE, false);
        reader.setFeature(Constants.FEATURE_IMPORT_DOCUMENTS, true);
        Jbi4EjbExtension.register(registry);
        LOG.debug("Extension QName: " + Jbi4EjbExtension.NS_URI_JBI4EJB);
        reader.setExtensionRegistry(registry);
        final Definition def = reader.readWSDL(f.getAbsolutePath());
        return def;
    }  

FileLine
it/imolinfo/jbi4ejb/configuration/InterfaceExtractorUtil.java83
it/imolinfo/jbi4ejb/configuration/InterfaceExtractorUtil.java391
    public static String extractEarClassesInTempDirectory(String earPath)  throws EJBWSDLGenerationException {
                    
            // Creates the temp dir
            File tempDir;
            try {
                tempDir = File.createTempFile(EAR_TEMP_DIR, null);
            } catch (IOException e) {
            	String msg=MESSAGES.getString("EJB000001_Could_not_create_directory", new Object[]{EAR_TEMP_DIR});
                LOG.error(msg,e);
                throw new EJBWSDLGenerationException(msg,e);
            } 
            tempDir.delete();
            tempDir.mkdir();
            
            try {
                JarUtil.unjar(new File(earPath), tempDir);
            } catch (IOException e) {
            	String msg=MESSAGES.getString("EJB000001_Could_not_create_directory", new Object[]{EAR_TEMP_DIR});