<commit_before>package org.hive2hive.core.processes.implementations.context;

import java.io.File;
import java.security.KeyPair;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import org.hive2hive.core.H2HConstants;
import org.hive2hive.core.model.Index;
import org.hive2hive.core.model.MetaChunk;
import org.hive2hive.core.model.MetaFile;
import org.hive2hive.core.processes.implementations.context.interfaces.IConsumeNotificationFactory;
import org.hive2hive.core.processes.implementations.context.interfaces.IProvideHash;
import org.hive2hive.core.processes.implementations.context.interfaces.IProvideMetaFile;
import org.hive2hive.core.processes.implementations.context.interfaces.IProvideProtectionKeys;
import org.hive2hive.core.processes.implementations.notify.BaseNotificationMessageFactory;
import org.hive2hive.core.security.EncryptionUtil;
import org.hive2hive.core.security.HybridEncryptedContent;

/**
 * The context for the process of putting a file.
 * 
 * @author <NAME>
 */
public class AddFileProcessContext implements IProvideHash, IConsumeNotificationFactory,
		IProvideProtectionKeys, IProvideMetaFile {

	private final File file;

	private KeyPair metaKeys;
	private List<MetaChunk> metaChunks = new ArrayList<MetaChunk>();

	private KeyPair chunkEncryptionKeys;
	private MetaFile metaFile;
	private byte[] hash;
	private KeyPair protectionKeys;

	private Index index;
	private BaseNotificationMessageFactory messageFactory;
	private Set<String> users;

	private boolean largeFile;

	public AddFileProcessContext(File file) {
		this.file = file;
	}

	public File getFile() {
		return file;
	}

	public void setLargeFile(boolean largeFile) {
		this.largeFile = largeFile;
	}

	public boolean isLargeFile() {
		return largeFile;
	}

	public KeyPair getMetaKeys() {
		if (metaKeys == null)
			// generate them when not existing
			metaKeys = EncryptionUtil.generateRSAKeyPair(H2HConstants.KEYLENGTH_META_FILE);
		return metaKeys;
	}

	public List<MetaChunk> getMetaChunks() {
		return metaChunks;
	}

	public void provideChunkKeys(KeyPair chunkEncryptionKeys) {
		this.chunkEncryptionKeys = chunkEncryptionKeys;
	}

	public KeyPair consumeChunkKeys() {
		return chunkEncryptionKeys;
	}

	public MetaFile consumeMetaFile() {
		return metaFile;
	}

	@Override<commit_msg>Generation of meta file keys happens now earlier.<commit_after>package org.hive2hive.core.processes.implementations.context;

import java.io.File;
import java.security.KeyPair;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import org.hive2hive.core.H2HConstants;
import org.hive2hive.core.model.Index;
import org.hive2hive.core.model.MetaChunk;
import org.hive2hive.core.model.MetaFile;
import org.hive2hive.core.processes.implementations.context.interfaces.IConsumeNotificationFactory;
import org.hive2hive.core.processes.implementations.context.interfaces.IProvideHash;
import org.hive2hive.core.processes.implementations.context.interfaces.IProvideMetaFile;
import org.hive2hive.core.processes.implementations.context.interfaces.IProvideProtectionKeys;
import org.hive2hive.core.processes.implementations.notify.BaseNotificationMessageFactory;
import org.hive2hive.core.security.EncryptionUtil;
import org.hive2hive.core.security.HybridEncryptedContent;

/**
 * The context for the process of putting a file.
 * 
 * @author Nico, Seppi
 */
public class AddFileProcessContext implements IProvideHash, IConsumeNotificationFactory,
		IProvideProtectionKeys, IProvideMetaFile {

	private final File file;

	private KeyPair metaKeys = EncryptionUtil.generateRSAKeyPair(H2HConstants.KEYLENGTH_META_FILE);
	private List<MetaChunk> metaChunks = new ArrayList<MetaChunk>();

	private KeyPair chunkEncryptionKeys;
	private MetaFile metaFile;
	private byte[] hash;
	private KeyPair protectionKeys;

	private Index index;
	private BaseNotificationMessageFactory messageFactory;
	private Set<String> users;

	private boolean largeFile;

	public AddFileProcessContext(File file) {
		this.file = file;
	}

	public File getFile() {
		return file;
	}

	public void setLargeFile(boolean largeFile) {
		this.largeFile = largeFile;
	}

	public boolean isLargeFile() {
		return largeFile;
	}

	public KeyPair getMetaKeys() {
		return metaKeys;
	}

	public List<MetaChunk> getMetaChunks() {
		return metaChunks;
	}

	public void provideChunkKeys(KeyPair chunkEncryptionKeys) {
		this.chunkEncryptionKeys = chunkEncryptionKeys;
	}

	public KeyPair consumeChunkKeys() {
		return chunkEncryptionKeys;
	}

	public MetaFile consumeMetaFile() {
		return metaFile;
	}

	@Override
{'fraction_non_alphanumeric': 0.08376849434290688, 'fraction_numerical': 0.006092254134029591, 'mean_word_length': 5.871449925261585, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3234670', 'n_tokens_mistral': 1490, 'n_tokens_neox': 1442, 'n_words': 292}