docs: private void importZipResource(ZipInputStream zipStreamIn, String importPath, boolean noSubFolder)
      throws Exception {
  
          // HACK: this method looks very crude, it should be re-written sometime...
  
          boolean isFolder = false;
          int j, r, stop, size;
          int entries = 0;
          byte[] buffer = null;
          boolean resourceExists;
  
          while (true) {
              // handle the single entries ...
              j = 0;
              stop = 0;
              // open the entry ...
              ZipEntry entry = zipStreamIn.getNextEntry();
              if (entry == null) {
                  break;
              }
              entries++; // count number of entries in zip
              String actImportPath = importPath;
              String title = CmsResource.getName(entry.getName());
              String filename = m_cms.getRequestContext().getFileTranslator().translateResource(entry.getName());
              // separate path in directories an file name ...
              StringTokenizer st = new StringTokenizer(filename, "/\\");
              int count = st.countTokens();
              String[] path = new String[count];
  
              if (filename.endsWith("\\") || filename.endsWith("/")) {
                  isFolder = true; // last entry is a folder
              } else {
                  isFolder = false; // last entry is a file
              }
              while (st.hasMoreTokens()) {
                  // store the files and folder names in array ...
                  path[j] = st.nextToken();
                  j++;
              }
              stop = isFolder ? path.length : (path.length - 1);
  
              if (noSubFolder) {
                  stop = 0;
              }
              // now write the folders ...
              for (r = 0; r < stop; r++) {
                  try {
                      CmsResource createdFolder = m_cms.createResource(
                          actImportPath + path[r],
                          CmsResourceTypeFolder.RESOURCE_TYPE_ID);
                      m_importedResources.add(createdFolder);
                  } catch (CmsException e) {
                      // of course some folders did already exist!
                  }
                  actImportPath += path[r];
                  actImportPath += "/";
              }
              if (!isFolder) {
                  // import file into cms
                  int type = OpenCms.getResourceManager().getDefaultTypeForName(path[path.length - 1]).getTypeId();
                  size = new Long(entry.getSize()).intValue();
                  if (size == -1) {
                      buffer = CmsFileUtil.readFully(zipStreamIn, false);
                  } else {
                      buffer = CmsFileUtil.readFully(zipStreamIn, size, false);
                  }
                  filename = actImportPath + path[path.length - 1];
  
                  try {
                      m_cms.lockResource(filename);
                      m_cms.readResource(filename);
                      resourceExists = true;
                  } catch (CmsException e) {
                      resourceExists = false;
                  }
  
                  int plainId = OpenCms.getResourceManager().getResourceType(
                      CmsResourceTypePlain.getStaticTypeName()).getTypeId();
                  if (resourceExists) {
                      CmsResource res = m_cms.readResource(filename, CmsResourceFilter.ALL);
                      CmsFile file = m_cms.readFile(res);
                      byte[] contents = file.getContents();
                      try {
                          m_cms.replaceResource(filename, res.getTypeId(), buffer, new ArrayList<CmsProperty>(0));
                          m_importedResources.add(res);
                      } catch (CmsSecurityException e) {
                          // in case of not enough permissions, try to create a plain text file
                          m_cms.replaceResource(filename, plainId, buffer, new ArrayList<CmsProperty>(0));
                          m_importedResources.add(res);
                      } catch (CmsDbSqlException sqlExc) {
                          // SQL error, probably the file is too large for the database settings, restore content
                          file.setContents(contents);
                          m_cms.writeFile(file);
                          throw sqlExc;
                      }
                  } else {
                      String newResName = actImportPath + path[path.length - 1];
                      if (title.lastIndexOf('.') != -1) {
                          title = title.substring(0, title.lastIndexOf('.'));
                      }
                      List<CmsProperty> properties = new ArrayList<CmsProperty>(1);
                      CmsProperty titleProp = new CmsProperty();
                      titleProp.setName(CmsPropertyDefinition.PROPERTY_TITLE);
                      if (OpenCms.getWorkplaceManager().isDefaultPropertiesOnStructure()) {
                          titleProp.setStructureValue(title);
                      } else {
                          titleProp.setResourceValue(title);
                      }
                      properties.add(titleProp);
                      try {
                          m_importedResources.add(m_cms.createResource(newResName, type, buffer, properties));
                      } catch (CmsSecurityException e) {
                          // in case of not enough permissions, try to create a plain text file
                          m_importedResources.add(m_cms.createResource(newResName, plainId, buffer, properties));
                      } catch (CmsDbSqlException sqlExc) {
                          // SQL error, probably the file is too large for the database settings, delete file
                          m_cms.lockResource(newResName);
                          m_cms.deleteResource(newResName, CmsResource.DELETE_PRESERVE_SIBLINGS);
                          throw sqlExc;
                      }
                  }
              }
  
              // close the entry ...
              zipStreamIn.closeEntry();
          }
          zipStreamIn.close();
          if (entries > 0) {
              // at least one entry, got a valid zip file ...
              m_validZipFile = true;
          }
      }