Functionality: Zip Files
Clone type: Type-3 (WT3/4)
Is clone: FALSE

Function 1:
@Override
public void execute () {
    File currentModelDirectory = new File (this.globalData.getData (String.class, GlobalData.MODEL_INSTALL_DIRECTORY));
    File mobileDirectory = new File (currentModelDirectory, "mobile");
    mobileDirectory.mkdir ();
    File mobileModelFile = new File (mobileDirectory, "mobile_model.zip");
    FileOutputStream outputStream = null;
    ZipOutputStream zipStream = null;
    BusinessModel businessModel = BusinessUnit.getInstance ().getBusinessModel ();
    try {
        mobileModelFile.createNewFile ();
        outputStream = new FileOutputStream (mobileModelFile);
        zipStream = new ZipOutputStream (outputStream);
        Dictionary dictionary = businessModel.getDictionary ();
        for (Definition definition : dictionary.getAllDefinitions ()) {
            ZipEntry entry = new ZipEntry (definition.getRelativeFileName ());
            zipStream.putNextEntry (entry);
            writeBinary (definition.getAbsoluteFileName (), zipStream);
        }
        final String modelFilename = "model.xml";
        ZipEntry entry = new ZipEntry (modelFilename);
        zipStream.putNextEntry (entry);
        writeBinary (businessModel.getAbsoluteFilename (modelFilename), zipStream);
        final String logoFilename = dictionary.getModel ().getImageSource (LogoType.mobile);
        entry = new ZipEntry (logoFilename);
        zipStream.putNextEntry (entry);
        writeBinary (businessModel.getAbsoluteFilename (logoFilename), zipStream);
    } catch (IOException e) {
        agentLogger.error (e);
    } finally {
        StreamHelper.close (zipStream);
        StreamHelper.close (outputStream);
    }
}

Function 2:
public int addDirectory (ZipOutputStream zosFile, File dirSource, String preSource) throws Exception {
    String ldirSource = dirSource.getName ();
    String lpreSource = preSource;
    int lcntEntries = 0;
    if (! (isRelativeDirectory ())) {
        ldirSource = dirSource.getAbsolutePath ();
        lpreSource = "";
    } else {
        ldirSource = dirSource.getName ();
        lpreSource = preSource;
    }
    File [] files = dirSource.listFiles ();
    for (int i = 0;
    i < files.length; i ++) {
        if (files [i].isDirectory () && isTraverseDirectory ()) {
            if (isRelativeDirectory ()) {
                lpreSource = lpreSource + File.separator + ldirSource;
                getLog ().debug ("Adding directory " + lpreSource + File.separator + files [i].getName ());
                addDirectory (zosFile, files [i], lpreSource);
                lpreSource = preSource;
            } else {
                getLog ().debug ("Adding directory " + ldirSource);
                addDirectory (zosFile, files [i], "");
            }
        } else if (! (files [i].isDirectory ())) {
            try {
                byte [] buffer = new byte [1024];
                FileInputStream fin = new FileInputStream (files [i]);
                if (isRelativeDirectory ()) {
                    getLog ().debug ("Adding file [" + lpreSource + File.separator + ldirSource + File.separator + files [i].getName () + "]");
                    zosFile.putNextEntry (new ZipEntry (lpreSource + File.separator + ldirSource + File.separator + files [i].getName ()));
                } else {
                    getLog ().debug ("Adding file [" + ldirSource + File.separator + files [i].getName () + "]");
                    zosFile.putNextEntry (new ZipEntry (ldirSource + File.separator + files [i].getName ()));
                }
                int length;
                while ((length = fin.read (buffer)) > 0) {
                    zosFile.write (buffer, 0, length);
                }
                zosFile.closeEntry ();
                fin.close ();
            } catch (IOException ioe) {
                getLog ().fatal (ioe);
                throw ioe;
            } catch (Exception ltheXcp) {
                getLog ().fatal (ltheXcp);
                throw ltheXcp;
            }
        }

        lcntEntries ++;
    }
    return lcntEntries;
}