<commit_before>package com.heikkiv.shorthand.repositories.mongodb;

import javax.annotation.PostConstruct;

import org.springframework.stereotype.Repository;

import com.heikkiv.shorthand.repositories.UrlRepository;
import com.mongodb.BasicDBObject;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.DBObject;
import com.mongodb.Mongo;

@Repository
public class UrlRepositoryMongoDb implements UrlRepository {

	private Mongo mongo;
	private DB db;
	private DBCollection collection;
	
	@PostConstruct
	public void init() {
		try {
			mongo = new Mongo( "flame.mongohq.com" , 27075 );
			db = mongo.getDB( "urls" );
			db.authenticate("heikki", "helppo".toCharArray());
			collection = db.getCollection("urls");
		} catch (Exception e) {
			throw new RuntimeException("Problem initializing MongoDb", e);
		}
	}
	
	@Override
	public int nextKey() {
		DBObject sequenceDoc = collection.findOne();
		int nextKey = (Integer) sequenceDoc.get("nextkey");
		nextKey += 1;
		sequenceDoc.put("nextkey", nextKey);
		collection.save(sequenceDoc);
		return nextKey;
	}

	@Override
	public void saveUrl(int key, String url, String hash) {
		BasicDBObject urlDoc = new BasicDBObject();
		urlDoc.put("_id", hash);
		urlDoc.put("key", key);
		urlDoc.put("url", url);
		collection.insert(urlDoc);
	}

	@Override
	public String findUrlByHash(String hash) {
		DBObject urlDoc = new BasicDBObject();
		urlDoc.put("_id", hash);
		urlDoc = collection.findOne(urlDoc);
		return (String) (urlDoc != null ? urlDoc.get("url") : "");
	}

	@Override
	public String findHashByLongUrl(String longUrl) {
		DBObject urlDoc = new BasicDBObject();
		urlDoc.put("url", longUrl);
		urlDoc = collection.findOne(urlDoc);
		return (String) (urlDoc != null ? urlDoc.get("_id") : "");
	}

}
<commit_msg>Removed username and password :)<commit_after>package com.heikkiv.shorthand.repositories.mongodb;

import javax.annotation.PostConstruct;

import org.springframework.stereotype.Repository;

import com.heikkiv.shorthand.repositories.UrlRepository;
import com.mongodb.BasicDBObject;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.DBObject;
import com.mongodb.Mongo;

@Repository
public class UrlRepositoryMongoDb implements UrlRepository {

	private Mongo mongo;
	private DB db;
	private DBCollection collection;
	
	@PostConstruct
	public void init() {
		try {
			mongo = new Mongo( "flame.mongohq.com" , 27075 );
			db = mongo.getDB( "urls" );
			db.authenticate("YOUR_USERNAME", "YOUR_PASSWORD".toCharArray());
			collection = db.getCollection("urls");
		} catch (Exception e) {
			throw new RuntimeException("Problem initializing MongoDb", e);
		}
	}
	
	@Override
	public int nextKey() {
		DBObject sequenceDoc = collection.findOne();
		int nextKey = (Integer) sequenceDoc.get("nextkey");
		nextKey += 1;
		sequenceDoc.put("nextkey", nextKey);
		collection.save(sequenceDoc);
		return nextKey;
	}

	@Override
	public void saveUrl(int key, String url, String hash) {
		BasicDBObject urlDoc = new BasicDBObject();
		urlDoc.put("_id", hash);
		urlDoc.put("key", key);
		urlDoc.put("url", url);
		collection.insert(urlDoc);
	}

	@Override
	public String findUrlByHash(String hash) {
		DBObject urlDoc = new BasicDBObject();
		urlDoc.put("_id", hash);
		urlDoc = collection.findOne(urlDoc);
		return (String) (urlDoc != null ? urlDoc.get("url") : "");
	}

	@Override
	public String findHashByLongUrl(String longUrl) {
		DBObject urlDoc = new BasicDBObject();
		urlDoc.put("url", longUrl);
		urlDoc = collection.findOne(urlDoc);
		return (String) (urlDoc != null ? urlDoc.get("_id") : "");
	}

}

{'fraction_non_alphanumeric': 0.13203883495145632, 'fraction_numerical': 0.00332871012482663, 'mean_word_length': 4.882544861337683, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6081685', 'n_tokens_mistral': 1307, 'n_tokens_neox': 1196, 'n_words': 270}