예제 #1
0
  public boolean checkEncrStream(
      XStorage xParentStorage, String sName, String sMediaType, byte[] pBytes, byte[] pPass) {
    // Important: a common password for any of parent storage should not be set or
    //            should be different from pPass

    if (pPass.length == 0) {
      Error("Wrong password is used in the test!");
      return false;
    }

    try {
      xParentStorage.openStreamElement(sName, ElementModes.READ);
      Error("Encrypted stream '" + sName + "' was opened without password!");
      return false;
    } catch (WrongPasswordException wpe) {
    } catch (Exception e) {
      Error(
          "Unexpected exception in case of opening of encrypted stream '"
              + sName
              + "' without password: "******"!");
      return false;
    }

    byte pWrongPass[] = {1, 1};
    pWrongPass[0] += pPass[0];
    try {
      xParentStorage.openEncryptedStreamElement(sName, ElementModes.READ, new String(pWrongPass));
      Error("Encrypted stream '" + sName + "' was opened with wrong password!");
      return false;
    } catch (WrongPasswordException wpe) {
    } catch (Exception e) {
      Error(
          "Unexpected exception in case of opening of encrypted stream '"
              + sName
              + "' with wrong password: "******"!");
      return false;
    }

    XStream xSubStream = null;
    try {
      Object oSubStream =
          xParentStorage.openEncryptedStreamElement(sName, ElementModes.READ, new String(pPass));
      xSubStream = UnoRuntime.queryInterface(XStream.class, oSubStream);
      if (xSubStream == null) {
        Error("Can't open encrypted substream '" + sName + "'!");
        return false;
      }
    } catch (Exception e) {
      Error("Can't open encrypted substream '" + sName + "', exception : " + e + "!");
      return false;
    }

    return InternalCheckStream(xSubStream, sName, sMediaType, pBytes);
  }
예제 #2
0
  public boolean WriteBytesToEncrSubstream(
      XStorage xStorage,
      String sStreamName,
      String sMediaType,
      boolean bCompressed,
      byte[] pBytes,
      String sPass) {
    // open substream element
    XStream xSubStream = null;
    try {
      Object oSubStream =
          xStorage.openEncryptedStreamElement(sStreamName, ElementModes.WRITE, sPass);
      xSubStream = (XStream) UnoRuntime.queryInterface(XStream.class, oSubStream);
      if (xSubStream == null) {
        Error("Can't create substream '" + sStreamName + "'!");
        return false;
      }
    } catch (Exception e) {
      Error("Can't create substream '" + sStreamName + "', exception : " + e + "!");
      return false;
    }

    if (!WriteBytesToStream(xSubStream, sStreamName, sMediaType, bCompressed, pBytes)) return false;

    // free the stream resources, garbage collector may remove the object too late
    if (!disposeStream(xSubStream, sStreamName)) return false;

    return true;
  }
예제 #3
0
  public boolean checkStream(
      XStorage xParentStorage,
      String sName,
      String sMediaType,
      boolean bCompressed,
      byte[] pBytes) {
    // open substream element first
    XStream xSubStream = null;
    try {
      Object oSubStream = xParentStorage.openStreamElement(sName, ElementModes.READ);
      xSubStream = (XStream) UnoRuntime.queryInterface(XStream.class, oSubStream);
      if (xSubStream == null) {
        Error("Can't open substream '" + sName + "'!");
        return false;
      }
    } catch (Exception e) {
      Error("Can't open substream '" + sName + "', exception : " + e + "!");
      return false;
    }

    boolean bResult = InternalCheckStream(xSubStream, sName, sMediaType, bCompressed, pBytes, true);

    // free the stream resources, garbage collector may remove the object too late
    if (!disposeStream(xSubStream, sName)) return false;

    return bResult;
  }
  // com.sun.star.embed.XEmbedObjectFactory:
  public Object createInstanceUserInit(
      byte[] aClassID,
      String sClassName,
      com.sun.star.embed.XStorage xStorage,
      String sEntName,
      int nEntryConnectionMode,
      com.sun.star.beans.PropertyValue[] aArgs,
      com.sun.star.beans.PropertyValue[] aObjectArgs)
      throws com.sun.star.lang.IllegalArgumentException, com.sun.star.io.IOException,
          com.sun.star.uno.Exception {
    if (xStorage == null || sEntName == null || sEntName.length() == 0)
      throw new com.sun.star.lang.IllegalArgumentException();

    if (nEntryConnectionMode == com.sun.star.embed.EntryInitModes.DEFAULT_INIT) {
      if (aClassID != null && aClassID.length != 0) {
        if (aClassID.length != m_classID.length)
          throw new com.sun.star.lang.IllegalArgumentException();

        for (int i = 0; i < aClassID.length; i++)
          if (aClassID[i] != m_classID[i]) throw new com.sun.star.lang.IllegalArgumentException();
      } else if (!xStorage.hasByName(sEntName))
        throw new com.sun.star.lang.IllegalArgumentException();
    } else if (nEntryConnectionMode == com.sun.star.embed.EntryInitModes.TRUNCATE_INIT) {
      if (aClassID.length != m_classID.length)
        throw new com.sun.star.lang.IllegalArgumentException();

      for (int i = 0; i < m_classID.length; i++)
        if (aClassID[i] != m_classID[i]) throw new com.sun.star.lang.IllegalArgumentException();
    }

    OwnEmbeddedObject aObject = new OwnEmbeddedObject(m_xContext, m_classID);
    aObject.setPersistentEntry(xStorage, sEntName, nEntryConnectionMode, aArgs, aObjectArgs);

    return aObject;
  }
예제 #5
0
  public boolean copyStorage(XStorage xSourceStorage, XStorage xDestStorage) {
    // copy xSourceStorage to xDestStorage
    try {
      xSourceStorage.copyToStorage(xDestStorage);
    } catch (Exception e) {
      Error("Storage copying failed, exception: " + e);
      return false;
    }

    return true;
  }
예제 #6
0
  public boolean cantOpenStream(XStorage xStorage, String sName, int nMode) {
    // try to open the substream with specified mode must fail
    try {
      Object oDummyStream = xStorage.openStreamElement(sName, nMode);
      Error("The trying to open substream '" + sName + "' must fail!");
    } catch (Exception e) {
      return true;
    }

    return false;
  }
예제 #7
0
  public boolean removeElement(XStorage xStorage, String sName) {
    // remove element with name sName
    try {
      xStorage.removeElement(sName);
    } catch (Exception e) {
      Error("Element removing failed, exception: " + e);
      return false;
    }

    return true;
  }
예제 #8
0
  public XStream cloneEncrSubStream(XStorage xStorage, String sName, String sPass) {
    // clone existing substream
    try {
      XStream xStream = xStorage.cloneEncryptedStreamElement(sName, sPass);
      return xStream;
    } catch (Exception e) {
      Error("Can't clone encrypted substream '" + sName + "', exception: " + e);
    }

    return null;
  }
예제 #9
0
  public boolean renameElement(XStorage xStorage, String sOldName, String sNewName) {
    // rename element with name sOldName to sNewName
    try {
      xStorage.renameElement(sOldName, sNewName);
    } catch (Exception e) {
      Error("Element renaming failed, exception: " + e);
      return false;
    }

    return true;
  }
예제 #10
0
  public boolean cantOpenStorage(XStorage xStorage, String sName) {
    // try to open an opened substorage, open call must fail
    try {
      Object oDummyStorage = xStorage.openStorageElement(sName, ElementModes.READ);
      Error("The trying to reopen opened substorage '" + sName + "' must fail!");
    } catch (Exception e) {
      return true;
    }

    return false;
  }
예제 #11
0
  public boolean moveElementTo(XStorage xSource, String sName, XStorage xDest) {
    // move element with name sName from xSource to xDest
    try {
      xSource.moveElementTo(sName, xDest, sName);
    } catch (Exception e) {
      Error("Element moving failed, exception: " + e);
      return false;
    }

    return true;
  }
예제 #12
0
  public boolean copyElementTo(XStorage xSource, String sName, XStorage xDest, String sTargetName) {
    // copy element with name sName from xSource to xDest
    try {
      xSource.copyElementTo(sName, xDest, sTargetName);
    } catch (Exception e) {
      Error("Element copying failed, exception: " + e);
      return false;
    }

    return true;
  }
예제 #13
0
  public XStorage openSubStorage(XStorage xStorage, String sName, int nMode) {
    // open existing substorage
    try {
      Object oSubStorage = xStorage.openStorageElement(sName, nMode);
      XStorage xSubStorage = (XStorage) UnoRuntime.queryInterface(XStorage.class, oSubStorage);
      return xSubStorage;
    } catch (Exception e) {
      Error("Can't open substorage '" + sName + "', exception: " + e);
    }

    return null;
  }
예제 #14
0
  public XStream OpenStream(XStorage xStorage, String sStreamName, int nMode) {
    // open substream element
    XStream xSubStream = null;
    try {
      Object oSubStream = xStorage.openStreamElement(sStreamName, nMode);
      xSubStream = (XStream) UnoRuntime.queryInterface(XStream.class, oSubStream);
      if (xSubStream == null) Error("Can't create substream '" + sStreamName + "'!");
    } catch (Exception e) {
      Error("Can't create substream '" + sStreamName + "', exception : " + e + "!");
    }

    return xSubStream;
  }
예제 #15
0
  public XStorage cloneSubStorage(XSingleServiceFactory xFactory, XStorage xStorage, String sName) {
    // create a copy of a last committed version of specified substorage
    XStorage xResult = null;
    try {
      Object oTempStorage = xFactory.createInstance();
      xResult = (XStorage) UnoRuntime.queryInterface(XStorage.class, oTempStorage);
      if (xResult != null) xStorage.copyStorageElementLastCommitTo(sName, xResult);
    } catch (Exception e) {
      Error("Can't clone substorage '" + sName + "', exception: " + e);
      return null;
    }

    return xResult;
  }
예제 #16
0
  public boolean WBToSubstrOfEncr(
      XStorage xStorage,
      String sStreamName,
      String sMediaType,
      boolean bCompressed,
      byte[] pBytes,
      boolean bEncrypted) {
    // open substream element
    XStream xSubStream = null;
    try {
      Object oSubStream = xStorage.openStreamElement(sStreamName, ElementModes.WRITE);
      xSubStream = (XStream) UnoRuntime.queryInterface(XStream.class, oSubStream);
      if (xSubStream == null) {
        Error("Can't create substream '" + sStreamName + "'!");
        return false;
      }
    } catch (Exception e) {
      Error("Can't create substream '" + sStreamName + "', exception : " + e + "!");
      return false;
    }

    // get access to the XPropertySet interface
    XPropertySet xPropSet =
        (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xSubStream);
    if (xPropSet == null) {
      Error("Can't get XPropertySet implementation from substream '" + sStreamName + "'!");
      return false;
    }

    // set properties to the stream
    try {
      xPropSet.setPropertyValue("UseCommonStoragePasswordEncryption", new Boolean(bEncrypted));
    } catch (Exception e) {
      Error(
          "Can't set 'UseCommonStoragePasswordEncryption' property to substream '"
              + sStreamName
              + "', exception: "
              + e);
      return false;
    }

    if (!WriteBytesToStream(xSubStream, sStreamName, sMediaType, bCompressed, pBytes)) return false;

    // free the stream resources, garbage collector may remove the object too late
    if (!disposeStream(xSubStream, sStreamName)) return false;

    return true;
  }
예제 #17
0
  public int ChangeStreamPass(
      XStorage xStorage, String sStreamName, byte[] pOldPass, byte[] pNewPass) {
    // open substream element
    XStream xSubStream = null;
    try {
      Object oSubStream =
          xStorage.openEncryptedStreamElement(
              sStreamName, ElementModes.WRITE, new String(pOldPass));
      xSubStream = UnoRuntime.queryInterface(XStream.class, oSubStream);
      if (xSubStream == null) {
        Error("Can't open substream '" + sStreamName + "'!");
        return 0;
      }
    } catch (Exception e) {
      Error("Can't open substream '" + sStreamName + "', exception : " + e + "!");
      return 0;
    }

    // change the password for the stream
    XEncryptionProtectedSource xStreamEncryption =
        UnoRuntime.queryInterface(XEncryptionProtectedSource.class, xSubStream);

    if (xStreamEncryption == null) {
      Message(
          "Optional interface XEncryptionProtectedSource is not implemented, feature can not be tested!");
      return -1;
    }

    try {
      xStreamEncryption.setEncryptionPassword(new String(pNewPass));
    } catch (Exception e) {
      Error("Can't change encryption key of the substream '" + sStreamName + "', exception:" + e);
      return 0;
    }

    // free the stream resources, garbage collector may remove the object too late
    XComponent xComponent = UnoRuntime.queryInterface(XComponent.class, xSubStream);
    if (xComponent == null) {
      Error("Can't get XComponent implementation from substream '" + sStreamName + "'!");
      return 0;
    }
    xComponent.dispose();

    return 1;
  }
예제 #18
0
  public boolean checkStream(
      XStorage xParentStorage, String sName, String sMediaType, byte[] pBytes) {
    // open substream element first
    XStream xSubStream = null;
    try {
      Object oSubStream = xParentStorage.openStreamElement(sName, ElementModes.READ);
      xSubStream = UnoRuntime.queryInterface(XStream.class, oSubStream);
      if (xSubStream == null) {
        Error("Can't open substream '" + sName + "'!");
        return false;
      }
    } catch (Exception e) {
      Error("Can't open substream '" + sName + "', exception : " + e + "!");
      return false;
    }

    return InternalCheckStream(xSubStream, sName, sMediaType, pBytes);
  }
예제 #19
0
  public boolean WriteBytesToSubstream(
      XStorage xStorage,
      String sStreamName,
      String sMediaType,
      boolean bCompressed,
      byte[] pBytes) {
    // open substream element
    XStream xSubStream = null;
    try {
      Object oSubStream = xStorage.openStreamElement(sStreamName, ElementModes.WRITE);
      xSubStream = UnoRuntime.queryInterface(XStream.class, oSubStream);
      if (xSubStream == null) {
        Error("Can't create substream '" + sStreamName + "'!");
        return false;
      }
    } catch (Exception e) {
      Error("Can't create substream '" + sStreamName + "', exception : " + e + "!");
      return false;
    }

    return WriteBytesToStream(xSubStream, sStreamName, sMediaType, bCompressed, pBytes);
  }
예제 #20
0
  public boolean WBToSubstrOfEncr(
      XStorage xStorage,
      String sStreamName,
      String sMediaType,
      boolean bCompressed,
      byte[] pBytes,
      boolean bEncrypted) {
    // open substream element
    XStream xSubStream = null;
    try {
      Object oSubStream = xStorage.openStreamElement(sStreamName, ElementModes.WRITE);
      xSubStream = UnoRuntime.queryInterface(XStream.class, oSubStream);
      if (xSubStream == null) {
        Error("Can't create substream '" + sStreamName + "'!");
        return false;
      }
    } catch (Exception e) {
      Error("Can't create substream '" + sStreamName + "', exception : " + e + "!");
      return false;
    }

    // get access to the XPropertySet interface
    XPropertySet xPropSet = UnoRuntime.queryInterface(XPropertySet.class, xSubStream);
    if (xPropSet == null) {
      Error("Can't get XPropertySet implementation from substream '" + sStreamName + "'!");
      return false;
    }

    // set properties to the stream
    try {
      xPropSet.setPropertyValue("Encrypted", Boolean.valueOf(bEncrypted));
    } catch (Exception e) {
      Error("Can't set 'Encrypted' property to substream '" + sStreamName + "', exception: " + e);
      return false;
    }

    return WriteBytesToStream(xSubStream, sStreamName, sMediaType, bCompressed, pBytes);
  }
예제 #21
0
  public boolean WriteBytesToSubstreamDefaultCompressed(
      XStorage xStorage, String sStreamName, String sMediaType, byte[] pBytes) {
    // open substream element
    XStream xSubStream = null;
    try {
      Object oSubStream = xStorage.openStreamElement(sStreamName, ElementModes.WRITE);
      xSubStream = (XStream) UnoRuntime.queryInterface(XStream.class, oSubStream);
      if (xSubStream == null) {
        Error("Can't create substream '" + sStreamName + "'!");
        return false;
      }
    } catch (Exception e) {
      Error("Can't create substream '" + sStreamName + "', exception : " + e + "!");
      return false;
    }

    // get output stream of substream
    XOutputStream xOutput = xSubStream.getOutputStream();
    if (xOutput == null) {
      Error("Can't get XOutputStream implementation from substream '" + sStreamName + "'!");
      return false;
    }

    // get XTrucate implementation from output stream
    XTruncate xTruncate = (XTruncate) UnoRuntime.queryInterface(XTruncate.class, xOutput);
    if (xTruncate == null) {
      Error("Can't get XTruncate implementation from substream '" + sStreamName + "'!");
      return false;
    }

    // write requested byte sequence
    try {
      xTruncate.truncate();
      xOutput.writeBytes(pBytes);
    } catch (Exception e) {
      Error("Can't write to stream '" + sStreamName + "', exception: " + e);
      return false;
    }

    // get access to the XPropertySet interface
    XPropertySet xPropSet =
        (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xSubStream);
    if (xPropSet == null) {
      Error("Can't get XPropertySet implementation from substream '" + sStreamName + "'!");
      return false;
    }

    // set properties to the stream
    // do not set the compressed property
    try {
      xPropSet.setPropertyValue("MediaType", sMediaType);
    } catch (Exception e) {
      Error("Can't set properties to substream '" + sStreamName + "', exception: " + e);
      return false;
    }

    // check size property of the stream
    try {
      long nSize = AnyConverter.toLong(xPropSet.getPropertyValue("Size"));
      if (nSize != pBytes.length) {
        Error("The 'Size' property of substream '" + sStreamName + "' contains wrong value!");
        return false;
      }
    } catch (Exception e) {
      Error("Can't get 'Size' property from substream '" + sStreamName + "', exception: " + e);
      return false;
    }

    // free the stream resources, garbage collector may remove the object too late
    if (!disposeStream(xSubStream, sStreamName)) return false;

    return true;
  }
예제 #22
0
  public boolean checkEncrStream(
      XStorage xParentStorage, String sName, String sMediaType, byte[] pBytes, String sPass) {
    // Important: a common password for any of parent storage should not be set or
    //            should be different from sPass

    try {
      Object oSubStream = xParentStorage.openStreamElement(sName, ElementModes.READ);
      Error("Encrypted stream '" + sName + "' was opened without password!");
      return false;
    } catch (WrongPasswordException wpe) {
    } catch (Exception e) {
      Error(
          "Unexpected exception in case of opening of encrypted stream '"
              + sName
              + "' without password: "******"!");
      return false;
    }

    String sWrongPass = "******";
    sWrongPass += sPass;
    try {
      Object oSubStream =
          xParentStorage.openEncryptedStreamElement(sName, ElementModes.READ, sWrongPass);
      Error("Encrypted stream '" + sName + "' was opened with wrong password!");
      return false;
    } catch (WrongPasswordException wpe) {
    } catch (Exception e) {
      Error(
          "Unexpected exception in case of opening of encrypted stream '"
              + sName
              + "' with wrong password: "******"!");
      return false;
    }

    XStream xSubStream = null;
    try {
      Object oSubStream =
          xParentStorage.openEncryptedStreamElement(sName, ElementModes.READ, sPass);
      xSubStream = (XStream) UnoRuntime.queryInterface(XStream.class, oSubStream);
      if (xSubStream == null) {
        Error("Can't open encrypted substream '" + sName + "'!");
        return false;
      }
    } catch (Exception e) {
      Error("Can't open encrypted substream '" + sName + "', exception : " + e + "!");
      return false;
    }

    // encrypted streams will be compressed always, so after the storing this property is always
    // true,
    // although before the storing it can be set to false ( it is not always clear whether a stream
    // is encrypted
    // before the storing )
    boolean bResult = InternalCheckStream(xSubStream, sName, sMediaType, true, pBytes, false);

    // free the stream resources, garbage collector may remove the object too late
    if (!disposeStream(xSubStream, sName)) return false;

    return bResult;
  }
예제 #23
0
  public boolean test() {
    try {
      String sTempFileURL = m_aTestHelper.CreateTempFile(m_xMSF);
      if (sTempFileURL == null || sTempFileURL == "") {
        m_aTestHelper.Error("No valid temporary file was created!");
        return false;
      }

      // create temporary storage based on arbitrary medium
      // after such a storage is closed it is lost
      Object oTempStorage = m_xStorageFactory.createInstance();
      XStorage xTempStorage = (XStorage) UnoRuntime.queryInterface(XStorage.class, oTempStorage);
      if (xTempStorage == null) {
        m_aTestHelper.Error("Can't create temporary storage representation!");
        return false;
      }

      // open substorages and create streams there

      // first substorage of the root storage
      XStorage xTempSubStorage1 =
          m_aTestHelper.openSubStorage(xTempStorage, "SubStorage1", ElementModes.WRITE);
      if (xTempSubStorage1 == null) {
        m_aTestHelper.Error("Can't create substorage!");
        return false;
      }

      byte pBigBytes[] = new byte[33000];
      for (int nInd = 0; nInd < 33000; nInd++) pBigBytes[nInd] = (byte) (nInd % 128);

      // open a new substream, set "MediaType" and "Compressed" properties to it and write some
      // bytes
      if (!m_aTestHelper.WriteBytesToSubstream(
          xTempSubStorage1, "BigSubStream1", "MediaType1", true, pBigBytes)) return false;

      byte pBytes1[] = {1, 1, 1, 1, 1};

      // open a new substream, set "MediaType" and "Compressed" properties to it and write some
      // bytes
      if (!m_aTestHelper.WriteBytesToSubstream(
          xTempSubStorage1, "SubStream1", "MediaType1", true, pBytes1)) return false;

      // second substorage of the root storage
      XStorage xTempSubStorage2 =
          m_aTestHelper.openSubStorage(xTempStorage, "SubStorage2", ElementModes.WRITE);
      if (xTempSubStorage2 == null) {
        m_aTestHelper.Error("Can't create substorage!");
        return false;
      }

      // open a new substream, set "MediaType" and "Compressed" properties to it and write some
      // bytes
      if (!m_aTestHelper.WriteBytesToSubstream(
          xTempSubStorage2, "BigSubStream2", "MediaType2", false, pBigBytes)) return false;

      byte pBytes2[] = {2, 2, 2, 2, 2};

      // open a new substream, set "MediaType" and "Compressed" properties to it and write some
      // bytes
      if (!m_aTestHelper.WriteBytesToSubstream(
          xTempSubStorage2, "SubStream2", "MediaType2", false, pBytes2)) return false;

      // set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are
      // set correctly
      if (!m_aTestHelper.setStorageTypeAndCheckProps(
          xTempStorage, "MediaType3", true, ElementModes.WRITE)) return false;

      // set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are
      // set correctly
      if (!m_aTestHelper.setStorageTypeAndCheckProps(
          xTempSubStorage1, "MediaType4", false, ElementModes.WRITE)) return false;

      // set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are
      // set correctly
      if (!m_aTestHelper.setStorageTypeAndCheckProps(
          xTempSubStorage2, "MediaType5", false, ElementModes.WRITE)) return false;

      // create temporary storage based on a previously created temporary file
      Object pArgs[] = new Object[2];
      pArgs[0] = (Object) sTempFileURL;
      pArgs[1] = new Integer(ElementModes.WRITE);

      Object oTempFileStorage = m_xStorageFactory.createInstanceWithArguments(pArgs);
      XStorage xTempFileStorage =
          (XStorage) UnoRuntime.queryInterface(XStorage.class, oTempFileStorage);
      if (xTempFileStorage == null) {
        m_aTestHelper.Error("Can't create storage based on temporary file!");
        return false;
      }

      if (!m_aTestHelper.copyElementTo(xTempStorage, "SubStorage1", xTempFileStorage)) return false;

      // if storage is not commited before disposing all the changes will be lost
      if (!m_aTestHelper.commitStorage(xTempSubStorage2)) return false;

      // a storage must be disposed before moving/removing otherwise the access will be denied
      if (!m_aTestHelper.disposeStorage(xTempSubStorage2)) return false;

      if (!m_aTestHelper.moveElementTo(xTempStorage, "SubStorage2", xTempFileStorage)) return false;

      // SubStorage2 must be removed and disposed now
      try {
        xTempSubStorage2.isStreamElement("SubStream2");
        m_aTestHelper.Error("SubStorage2 must be disposed already!");
        return false;
      } catch (com.sun.star.lang.DisposedException de) {
      } catch (Exception e) {
        m_aTestHelper.Error("Wrong exception in case of disposed storage, exception: " + e);
        return false;
      }

      if (!m_aTestHelper.copyElementTo(xTempSubStorage1, "SubStream1", xTempFileStorage))
        return false;

      if (!m_aTestHelper.renameElement(xTempFileStorage, "SubStream1", "SubStream1_copy"))
        return false;

      if (!m_aTestHelper.moveElementTo(xTempSubStorage1, "SubStream1", xTempFileStorage))
        return false;

      if (!m_aTestHelper.copyElementTo(xTempSubStorage1, "BigSubStream1", xTempFileStorage))
        return false;

      if (!m_aTestHelper.renameElement(xTempFileStorage, "BigSubStream1", "BigSubStream1_copy"))
        return false;

      if (!m_aTestHelper.moveElementTo(xTempSubStorage1, "BigSubStream1", xTempFileStorage))
        return false;

      if (!m_aTestHelper.commitStorage(xTempFileStorage)) return false;

      // dispose used storages to free resources
      if (!m_aTestHelper.disposeStorage(xTempStorage)
          || !m_aTestHelper.disposeStorage(xTempFileStorage)) return false;

      // ================================================
      // now check all the written and copied information
      // ================================================

      // the temporary file must not be locked any more after storage disposing
      pArgs[1] = new Integer(ElementModes.WRITE);
      Object oResStorage = m_xStorageFactory.createInstanceWithArguments(pArgs);
      XStorage xResStorage = (XStorage) UnoRuntime.queryInterface(XStorage.class, oResStorage);
      if (xResStorage == null) {
        m_aTestHelper.Error("Can't reopen storage based on temporary file!");
        return false;
      }

      // open and check SubStorage1
      XStorage xResSubStorage1 =
          m_aTestHelper.openSubStorage(xResStorage, "SubStorage1", ElementModes.READ);
      if (xResSubStorage1 == null) {
        m_aTestHelper.Error("Can't open existing substorage!");
        return false;
      }

      if (!m_aTestHelper.checkStorageProperties(
          xResSubStorage1, "MediaType4", false, ElementModes.READ)) return false;

      // open and check SubStorage2
      XStorage xResSubStorage2 =
          m_aTestHelper.openSubStorage(xResStorage, "SubStorage2", ElementModes.READ);
      if (xResSubStorage2 == null) {
        m_aTestHelper.Error("Can't open existing substorage!");
        return false;
      }

      if (!m_aTestHelper.checkStorageProperties(
          xResSubStorage2, "MediaType5", false, ElementModes.READ)) return false;

      // check all the result streams

      if (!m_aTestHelper.checkStream(xResStorage, "SubStream1", "MediaType1", true, pBytes1))
        return false;

      if (!m_aTestHelper.checkStream(xResStorage, "BigSubStream1", "MediaType1", true, pBigBytes))
        return false;

      if (!m_aTestHelper.checkStream(xResStorage, "SubStream1_copy", "MediaType1", true, pBytes1))
        return false;

      if (!m_aTestHelper.checkStream(
          xResStorage, "BigSubStream1_copy", "MediaType1", true, pBigBytes)) return false;

      if (!m_aTestHelper.checkStream(xResSubStorage1, "SubStream1", "MediaType1", true, pBytes1))
        return false;

      if (!m_aTestHelper.checkStream(
          xResSubStorage1, "BigSubStream1", "MediaType1", true, pBigBytes)) return false;

      if (!m_aTestHelper.checkStream(xResSubStorage2, "SubStream2", "MediaType2", false, pBytes2))
        return false;

      if (!m_aTestHelper.checkStream(
          xResSubStorage2, "BigSubStream2", "MediaType2", false, pBigBytes)) return false;

      // the storage must be disposed before removing
      if (!m_aTestHelper.disposeStorage(xResSubStorage2)) return false;

      // remove element and check that it was removed completelly
      if (!m_aTestHelper.removeElement(xResStorage, "SubStorage2")) return false;

      try {
        XNameAccess xResAccess =
            (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, xResStorage);
        if (xResAccess.hasByName("SubStorage2"))
          m_aTestHelper.Error("SubStorage2 must be removed already!");
      } catch (Exception e) {
        m_aTestHelper.Error("Can't get access to root storage, exception: " + e);
        return false;
      }

      try {
        xResSubStorage2.isStreamElement("SubStream2");

        m_aTestHelper.Error("SubStorage2 must be disposed already!");
        return false;
      } catch (com.sun.star.lang.DisposedException de) {
      } catch (Exception e) {
        m_aTestHelper.Error("Wrong exception in case of disposed storage, exception: " + e);
        return false;
      }

      // dispose used storages to free resources
      if (!m_aTestHelper.disposeStorage(xResStorage)) return false;

      return true;
    } catch (Exception e) {
      m_aTestHelper.Error("Exception: " + e);
      return false;
    }
  }