class ClassFilePathAssembler {

    public String createFilePath(final InputStream classFile, final String fileName, final String exceptionMessage) {
        String filePath = null;
        File file = fileFactory.createFile(fileName);
        String folderPart = file.getParent();
        String filePart = file.getName();
        String packageName;
        try {
            JavaClass javaClass = javaClassFactory.createJavaClass(classFile, fileName);
            packageName = javaClass.getPackageName();
            String packageAsFolderName = packageName.replace('.', '/');
            String folderStructure = folderPart + FORWARDSLASH + packageAsFolderName;
            filePath = folderStructure + FORWARDSLASH + filePart;
        } catch (IOException e) {
            throw new CannotUploadExternalResourceException(exceptionMessage + fileName, e);
        } catch (ClassFormatException e) {
            throw new CannotUploadExternalResourceException(exceptionMessage + String.format(CLASS_FORMAT_EXCEPTION_MESSAGE, fileName), e);
        }
        return filePath;
    }

}