Examples of MetaFile


Examples of org.apache.jackrabbit.vault.vlt.meta.MetaFile

        entry.put(base.copyAs(VltEntryInfo.Type.WORK));
    }

    private boolean equalsToRemote(VaultFile remoteFile)
            throws VltException {
        MetaFile tmpFile = getTmpFile();

        // copy file
        byte[] lineFeed = MimeTypes.isBinary(remoteFile.getContentType())
                ? null
                : LineOutputStream.LS_NATIVE;
        VaultFileCopy copy;
        File temp = null;
        try {
            temp = tmpFile.openTempFile();
            copy = VaultFileCopy.copy(remoteFile, temp, lineFeed);
        } catch (IOException e) {
            throw exception("Error while copying files.", e);
        } finally {
            if (tmpFile != null) {
                try {
                    tmpFile.closeTempFile(true);
                } catch (IOException e) {
                    // ignore
                }
            }
        }
View Full Code Here

Examples of org.apache.jackrabbit.vault.vlt.meta.MetaFile

                    dir.control(remoteFile.getPath(), remoteFile.getControllingAggregate().getPath());
                    action = FileAction.ADDED;
                }
            }
        } else {
            MetaFile baseFile = getBaseFile(true);

            // copy file
            byte[] lineFeed = MimeTypes.isBinary(remoteFile.getContentType())
                    ? null
                    : LineOutputStream.LS_NATIVE;
            VaultFileCopy copy;
            try {
                File temp = baseFile.openTempFile();
                copy = VaultFileCopy.copy(remoteFile, temp, lineFeed);
                baseFile.closeTempFile(false);
            } catch (IOException e) {
                throw exception("Error while copying files.", e);
            }
            // if md5 is equal, no update
            if (copy.getMd5().equals(base.getMd5())) {
                action = FileAction.VOID;
            }

            if (action == FileAction.VOID
                    && (base.getContentType() != null || remoteFile.getContentType() != null)
                    && (base.getContentType() == null || !base.getContentType().equals(remoteFile.getContentType()))) {
                action = FileAction.UPDATED;
            }

            // update infos
            VltEntryInfo work = entry.work();
            base.setContentType(remoteFile.getContentType());
            base.setSize(copy.getLength());
            base.setMd5(copy.getMd5());
            if (!baseOnly) {
                // only copy if not equal
                if (work == null || !work.getMd5().equals(copy.getMd5()) || !getFile().exists()) {
                    try {
                        baseFile.copyTo(getFile(), true);
                        entry.put(base.copyAs(VltEntryInfo.Type.WORK));
                    } catch (IOException e) {
                        throw exception("Error while copying files.", e);
                    }
                }
View Full Code Here

Examples of org.hive2hive.core.model.MetaFile

    // check if the file is still in the DHT
    UserProfile userProfile = UseCaseTestUtil.getUserProfile(client, userCredentials);
    Assert.assertNull(userProfile.getFileById(metaKeyPair.getPublic()));

    MetaFile metaDocument = UseCaseTestUtil.getMetaFile(client, metaKeyPair, false);
    Assert.assertNull(metaDocument);

    for (FileVersion version : metaDocumentBeforeDeletion.getVersions()) {
      for (MetaChunk metaChunks : version.getMetaChunks()) {
        FutureGet get = client.getDataManager().getUnblocked(
View Full Code Here

Examples of org.hive2hive.core.model.MetaFile

    // check if the folder is still in the DHT
    Assert.assertNotNull(userProfile.getFileById(metaKeyPairFolder.getPublic()));

    // check the meta file is still in the DHT
    MetaFile metaFile = UseCaseTestUtil.getMetaFile(client, metaKeyPairFile, false);
    Assert.assertNull(metaFile);
  }
View Full Code Here

Examples of org.hive2hive.core.model.MetaFile

    Assert.assertNotNull(node);

    // verify the meta document
    KeyPair metaFileKeys = node.getFileKeys();
    if (originalFile.isFile()) {
      MetaFile metaFile = UseCaseTestUtil.getMetaFile(client, metaFileKeys);
      Assert.assertNotNull(metaFile);
      Assert.assertTrue(metaFile instanceof MetaFileSmall);
      MetaFileSmall metaFileSmall = (MetaFileSmall) metaFile;

      // get the meta file with the keys (decrypt it)
View Full Code Here

Examples of org.hive2hive.core.model.MetaFile

    this.ownPeerAddress = ownPeerAddress;
  }

  @Override
  protected void doExecute() throws InvalidProcessStateException, ProcessExecutionException {
    MetaFile metaFile = context.consumeMetaFile();

    // support to store the file on another location than default (used for recovery)
    if (context.downloadToDefaultDestination()) {
      destination = FileUtil.getPath(session.getRoot(), context.consumeIndex()).toFile();
    } else {
      destination = context.getDestination();
    }

    if (metaFile.isSmall()) {
      downloadChunksFromDHT((MetaFileSmall) metaFile);
    } else {
      downloadChunksFromUsers((MetaFileLarge) metaFile);
    }
View Full Code Here

Examples of org.hive2hive.core.model.MetaFile

  }

  @Override
  protected void doExecute() throws InvalidProcessStateException, ProcessExecutionException {
    try {
      MetaFile metaFile = context.consumeMetaFile();
      KeyPair protectionKeys = context.consumeProtectionKeys();

      logger.trace("Encrypting meta file of file '{}' in a hybrid manner.", context.getFile().getName());
      HybridEncryptedContent encrypted = H2HEncryptionUtil.encryptHybrid(metaFile, metaFile.getId());
      encrypted.setBasedOnKey(metaFile.getVersionKey());
      encrypted.generateVersionKey();

      Parameters parameters = new Parameters()
          .setLocationKey(H2HEncryptionUtil.key2String(metaFile.getId()))
          .setContentKey(H2HConstants.META_FILE).setVersionKey(encrypted.getVersionKey())
          .setData(encrypted).setProtectionKeys(protectionKeys).setTTL(metaFile.getTimeToLive());
      // data manager has to produce the hash, which gets used for signing
      parameters.setHashFlag(true);
      // put the encrypted meta file into the network
      put(parameters);
      // store the hash
View Full Code Here

Examples of org.hive2hive.core.model.MetaFile

          | BadPaddingException | IllegalStateException | InvalidCipherTextException
          | ClassNotFoundException | IOException e) {
        throw new ProcessExecutionException("Meta file could not be decrypted.", e);
      }

      MetaFile metaFile = (MetaFile) decryptedContent;
      metaFile.setVersionKey(loadedContent.getVersionKey());
      metaFile.setBasedOnKey(loadedContent.getBasedOnKey());

      metaContext.provideMetaFile(metaFile);
      metaContext.provideEncryptedMetaFile(encryptedContent);
      logger.debug("Got and decrypted the meta file.");
    }
View Full Code Here

Examples of org.hive2hive.core.model.MetaFile

    if (context.consumeProtectionKeys() == null) {
      throw new ProcessExecutionException("No protection keys given.");
    }

    List<MetaChunk> metaChunks = new ArrayList<MetaChunk>();
    MetaFile metaFile = context.consumeMetaFile();

    if (metaFile.isSmall()) {
      MetaFileSmall metaSmall = (MetaFileSmall) metaFile;
      // TODO rather delete file by file than all chunks mixed
      for (FileVersion version : metaSmall.getVersions()) {
        metaChunks.addAll(version.getMetaChunks());
      }
View Full Code Here

Examples of org.hive2hive.core.model.MetaFile

    this.dataManager = dataManager;
  }

  @Override
  protected void doExecute() throws InvalidProcessStateException, ProcessExecutionException {
    MetaFile metaFile = context.consumeMetaFile();
    if (metaFile == null) {
      throw new ProcessExecutionException("Meta File not found");
    } else if (!(metaFile.isSmall())) {
      logger.debug("No need to update any chunks for a large meta file");
      return;
    }

    MetaFileSmall metaFileSmall = (MetaFileSmall) metaFile;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.