repo_name
stringlengths
7
104
file_path
stringlengths
13
198
context
stringlengths
67
7.15k
import_statement
stringlengths
16
4.43k
code
stringlengths
40
6.98k
prompt
stringlengths
227
8.27k
next_line
stringlengths
8
795
kwon37xi/hibernate4-memcached
hibernate4-memcached-spymemcached-adapter/src/main/java/kr/pe/kwonnam/hibernate4memcached/spymemcached/KryoTranscoder.java
// Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/util/IntToBytesUtils.java // public class IntToBytesUtils { // // /** // * int value to 4 bytes array. // */ // public static byte[] intToBytes(int value) { // return new byte[]{(byte) (value >>> 24), (byte) (value >>> 16), (byte) (value >>> 8), (byte) (value) // // }; // } // // /** // * 4 bytes array to int // */ // public static int bytesToInt(byte[] bytes) { // int value = ((int) bytes[0] & 0xFF) << 24; // value += ((int) bytes[1] & 0xFF) << 16; // value += ((int) bytes[2] & 0xFF) << 8; // value += (int) bytes[3] & 0xFF; // return value; // } // // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/util/Lz4CompressUtils.java // public class Lz4CompressUtils { // private static final LZ4Factory factory = LZ4Factory.fastestInstance(); // // public static byte[] compress(final byte[] src) { // if (src == null) { // throw new IllegalArgumentException("src must not be null."); // } // // LZ4Compressor compressor = factory.fastCompressor(); // // return compressor.compress(src); // } // // /** // * When the exact decompressed size is unknown. // * Decompress data size cannot be larger then maxDecompressedSize // */ // public static byte[] decompressSafe(final byte[] src, int maxDecompressedSize) { // if (src == null) { // throw new IllegalArgumentException("src must not be null."); // } // // if (maxDecompressedSize <= 0) { // throw new IllegalArgumentException("maxDecompressedSize must be larger than 0 but " + maxDecompressedSize); // } // // LZ4SafeDecompressor decompressor = factory.safeDecompressor(); // // return decompressor.decompress(src, maxDecompressedSize); // } // // /** // * When the exact decompressed size is known, use this method to decompress. It's faster. // * // * @see net.jpountz.lz4.LZ4FastDecompressor // */ // public static byte[] decompressFast(byte[] src, int srcOffset, int exactDecompressedSize) { // if (src == null) { // throw new IllegalArgumentException("src must not be null."); // } // // if (srcOffset < 0) { // throw new IllegalArgumentException("srcOffset must equal to or larger than 0 but " + srcOffset); // } // // if (exactDecompressedSize < 0) { // throw new IllegalArgumentException("exactDecompressedSize must equal to or larger than 0 but " + exactDecompressedSize); // } // // LZ4FastDecompressor decompressor = factory.fastDecompressor(); // // return decompressor.decompress(src, srcOffset, exactDecompressedSize); // } // // /** // * @see #decompressFast(byte[], int, int) // */ // public static byte[] decompressFast(final byte[] src, int exactDecompressedSize) { // return decompressFast(src, 0, exactDecompressedSize); // } // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/util/OverridableReadOnlyProperties.java // public interface OverridableReadOnlyProperties { // String getProperty(String key); // // String getProperty(String key, String defaultValue); // // String getRequiredProperty(String key); // }
import com.esotericsoftware.kryo.Kryo; import com.esotericsoftware.kryo.io.Input; import com.esotericsoftware.kryo.io.Output; import com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer; import de.javakaffee.kryoserializers.KryoReflectionFactorySupport; import kr.pe.kwonnam.hibernate4memcached.util.IntToBytesUtils; import kr.pe.kwonnam.hibernate4memcached.util.Lz4CompressUtils; import kr.pe.kwonnam.hibernate4memcached.util.OverridableReadOnlyProperties; import net.spy.memcached.CachedData; import org.apache.commons.lang3.ArrayUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.ByteArrayOutputStream; import java.io.IOException;
@Override public CachedData encode(Object object) { int flags = BASE_FLAG; byte[] encodedBytes = kryoEncode(object); boolean compressionRequired = encodedBytes.length > compressionThreasholdBytes; if (compressionRequired) { int beforeSize = encodedBytes.length; encodedBytes = compress(encodedBytes); log.debug("kryotranscoder compress required : {}, original {} bytes -> compressed {} bytes", compressionRequired, beforeSize, encodedBytes.length); flags = flags | COMPRESS_FLAG; } return new CachedData(flags, encodedBytes, getMaxSize()); } private byte[] kryoEncode(Object o) { Kryo kryo = createKryo(); Output output = new Output(bufferSize, getMaxSize()); kryo.writeClassAndObject(output, o); return output.toBytes(); } byte[] compress(byte[] encodedBytes) { ByteArrayOutputStream baos = new ByteArrayOutputStream(encodedBytes.length); try {
// Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/util/IntToBytesUtils.java // public class IntToBytesUtils { // // /** // * int value to 4 bytes array. // */ // public static byte[] intToBytes(int value) { // return new byte[]{(byte) (value >>> 24), (byte) (value >>> 16), (byte) (value >>> 8), (byte) (value) // // }; // } // // /** // * 4 bytes array to int // */ // public static int bytesToInt(byte[] bytes) { // int value = ((int) bytes[0] & 0xFF) << 24; // value += ((int) bytes[1] & 0xFF) << 16; // value += ((int) bytes[2] & 0xFF) << 8; // value += (int) bytes[3] & 0xFF; // return value; // } // // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/util/Lz4CompressUtils.java // public class Lz4CompressUtils { // private static final LZ4Factory factory = LZ4Factory.fastestInstance(); // // public static byte[] compress(final byte[] src) { // if (src == null) { // throw new IllegalArgumentException("src must not be null."); // } // // LZ4Compressor compressor = factory.fastCompressor(); // // return compressor.compress(src); // } // // /** // * When the exact decompressed size is unknown. // * Decompress data size cannot be larger then maxDecompressedSize // */ // public static byte[] decompressSafe(final byte[] src, int maxDecompressedSize) { // if (src == null) { // throw new IllegalArgumentException("src must not be null."); // } // // if (maxDecompressedSize <= 0) { // throw new IllegalArgumentException("maxDecompressedSize must be larger than 0 but " + maxDecompressedSize); // } // // LZ4SafeDecompressor decompressor = factory.safeDecompressor(); // // return decompressor.decompress(src, maxDecompressedSize); // } // // /** // * When the exact decompressed size is known, use this method to decompress. It's faster. // * // * @see net.jpountz.lz4.LZ4FastDecompressor // */ // public static byte[] decompressFast(byte[] src, int srcOffset, int exactDecompressedSize) { // if (src == null) { // throw new IllegalArgumentException("src must not be null."); // } // // if (srcOffset < 0) { // throw new IllegalArgumentException("srcOffset must equal to or larger than 0 but " + srcOffset); // } // // if (exactDecompressedSize < 0) { // throw new IllegalArgumentException("exactDecompressedSize must equal to or larger than 0 but " + exactDecompressedSize); // } // // LZ4FastDecompressor decompressor = factory.fastDecompressor(); // // return decompressor.decompress(src, srcOffset, exactDecompressedSize); // } // // /** // * @see #decompressFast(byte[], int, int) // */ // public static byte[] decompressFast(final byte[] src, int exactDecompressedSize) { // return decompressFast(src, 0, exactDecompressedSize); // } // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/util/OverridableReadOnlyProperties.java // public interface OverridableReadOnlyProperties { // String getProperty(String key); // // String getProperty(String key, String defaultValue); // // String getRequiredProperty(String key); // } // Path: hibernate4-memcached-spymemcached-adapter/src/main/java/kr/pe/kwonnam/hibernate4memcached/spymemcached/KryoTranscoder.java import com.esotericsoftware.kryo.Kryo; import com.esotericsoftware.kryo.io.Input; import com.esotericsoftware.kryo.io.Output; import com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer; import de.javakaffee.kryoserializers.KryoReflectionFactorySupport; import kr.pe.kwonnam.hibernate4memcached.util.IntToBytesUtils; import kr.pe.kwonnam.hibernate4memcached.util.Lz4CompressUtils; import kr.pe.kwonnam.hibernate4memcached.util.OverridableReadOnlyProperties; import net.spy.memcached.CachedData; import org.apache.commons.lang3.ArrayUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.ByteArrayOutputStream; import java.io.IOException; @Override public CachedData encode(Object object) { int flags = BASE_FLAG; byte[] encodedBytes = kryoEncode(object); boolean compressionRequired = encodedBytes.length > compressionThreasholdBytes; if (compressionRequired) { int beforeSize = encodedBytes.length; encodedBytes = compress(encodedBytes); log.debug("kryotranscoder compress required : {}, original {} bytes -> compressed {} bytes", compressionRequired, beforeSize, encodedBytes.length); flags = flags | COMPRESS_FLAG; } return new CachedData(flags, encodedBytes, getMaxSize()); } private byte[] kryoEncode(Object o) { Kryo kryo = createKryo(); Output output = new Output(bufferSize, getMaxSize()); kryo.writeClassAndObject(output, o); return output.toBytes(); } byte[] compress(byte[] encodedBytes) { ByteArrayOutputStream baos = new ByteArrayOutputStream(encodedBytes.length); try {
baos.write(IntToBytesUtils.intToBytes(encodedBytes.length));
kwon37xi/hibernate4-memcached
hibernate4-memcached-spymemcached-adapter/src/main/java/kr/pe/kwonnam/hibernate4memcached/spymemcached/KryoTranscoder.java
// Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/util/IntToBytesUtils.java // public class IntToBytesUtils { // // /** // * int value to 4 bytes array. // */ // public static byte[] intToBytes(int value) { // return new byte[]{(byte) (value >>> 24), (byte) (value >>> 16), (byte) (value >>> 8), (byte) (value) // // }; // } // // /** // * 4 bytes array to int // */ // public static int bytesToInt(byte[] bytes) { // int value = ((int) bytes[0] & 0xFF) << 24; // value += ((int) bytes[1] & 0xFF) << 16; // value += ((int) bytes[2] & 0xFF) << 8; // value += (int) bytes[3] & 0xFF; // return value; // } // // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/util/Lz4CompressUtils.java // public class Lz4CompressUtils { // private static final LZ4Factory factory = LZ4Factory.fastestInstance(); // // public static byte[] compress(final byte[] src) { // if (src == null) { // throw new IllegalArgumentException("src must not be null."); // } // // LZ4Compressor compressor = factory.fastCompressor(); // // return compressor.compress(src); // } // // /** // * When the exact decompressed size is unknown. // * Decompress data size cannot be larger then maxDecompressedSize // */ // public static byte[] decompressSafe(final byte[] src, int maxDecompressedSize) { // if (src == null) { // throw new IllegalArgumentException("src must not be null."); // } // // if (maxDecompressedSize <= 0) { // throw new IllegalArgumentException("maxDecompressedSize must be larger than 0 but " + maxDecompressedSize); // } // // LZ4SafeDecompressor decompressor = factory.safeDecompressor(); // // return decompressor.decompress(src, maxDecompressedSize); // } // // /** // * When the exact decompressed size is known, use this method to decompress. It's faster. // * // * @see net.jpountz.lz4.LZ4FastDecompressor // */ // public static byte[] decompressFast(byte[] src, int srcOffset, int exactDecompressedSize) { // if (src == null) { // throw new IllegalArgumentException("src must not be null."); // } // // if (srcOffset < 0) { // throw new IllegalArgumentException("srcOffset must equal to or larger than 0 but " + srcOffset); // } // // if (exactDecompressedSize < 0) { // throw new IllegalArgumentException("exactDecompressedSize must equal to or larger than 0 but " + exactDecompressedSize); // } // // LZ4FastDecompressor decompressor = factory.fastDecompressor(); // // return decompressor.decompress(src, srcOffset, exactDecompressedSize); // } // // /** // * @see #decompressFast(byte[], int, int) // */ // public static byte[] decompressFast(final byte[] src, int exactDecompressedSize) { // return decompressFast(src, 0, exactDecompressedSize); // } // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/util/OverridableReadOnlyProperties.java // public interface OverridableReadOnlyProperties { // String getProperty(String key); // // String getProperty(String key, String defaultValue); // // String getRequiredProperty(String key); // }
import com.esotericsoftware.kryo.Kryo; import com.esotericsoftware.kryo.io.Input; import com.esotericsoftware.kryo.io.Output; import com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer; import de.javakaffee.kryoserializers.KryoReflectionFactorySupport; import kr.pe.kwonnam.hibernate4memcached.util.IntToBytesUtils; import kr.pe.kwonnam.hibernate4memcached.util.Lz4CompressUtils; import kr.pe.kwonnam.hibernate4memcached.util.OverridableReadOnlyProperties; import net.spy.memcached.CachedData; import org.apache.commons.lang3.ArrayUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.ByteArrayOutputStream; import java.io.IOException;
public CachedData encode(Object object) { int flags = BASE_FLAG; byte[] encodedBytes = kryoEncode(object); boolean compressionRequired = encodedBytes.length > compressionThreasholdBytes; if (compressionRequired) { int beforeSize = encodedBytes.length; encodedBytes = compress(encodedBytes); log.debug("kryotranscoder compress required : {}, original {} bytes -> compressed {} bytes", compressionRequired, beforeSize, encodedBytes.length); flags = flags | COMPRESS_FLAG; } return new CachedData(flags, encodedBytes, getMaxSize()); } private byte[] kryoEncode(Object o) { Kryo kryo = createKryo(); Output output = new Output(bufferSize, getMaxSize()); kryo.writeClassAndObject(output, o); return output.toBytes(); } byte[] compress(byte[] encodedBytes) { ByteArrayOutputStream baos = new ByteArrayOutputStream(encodedBytes.length); try { baos.write(IntToBytesUtils.intToBytes(encodedBytes.length));
// Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/util/IntToBytesUtils.java // public class IntToBytesUtils { // // /** // * int value to 4 bytes array. // */ // public static byte[] intToBytes(int value) { // return new byte[]{(byte) (value >>> 24), (byte) (value >>> 16), (byte) (value >>> 8), (byte) (value) // // }; // } // // /** // * 4 bytes array to int // */ // public static int bytesToInt(byte[] bytes) { // int value = ((int) bytes[0] & 0xFF) << 24; // value += ((int) bytes[1] & 0xFF) << 16; // value += ((int) bytes[2] & 0xFF) << 8; // value += (int) bytes[3] & 0xFF; // return value; // } // // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/util/Lz4CompressUtils.java // public class Lz4CompressUtils { // private static final LZ4Factory factory = LZ4Factory.fastestInstance(); // // public static byte[] compress(final byte[] src) { // if (src == null) { // throw new IllegalArgumentException("src must not be null."); // } // // LZ4Compressor compressor = factory.fastCompressor(); // // return compressor.compress(src); // } // // /** // * When the exact decompressed size is unknown. // * Decompress data size cannot be larger then maxDecompressedSize // */ // public static byte[] decompressSafe(final byte[] src, int maxDecompressedSize) { // if (src == null) { // throw new IllegalArgumentException("src must not be null."); // } // // if (maxDecompressedSize <= 0) { // throw new IllegalArgumentException("maxDecompressedSize must be larger than 0 but " + maxDecompressedSize); // } // // LZ4SafeDecompressor decompressor = factory.safeDecompressor(); // // return decompressor.decompress(src, maxDecompressedSize); // } // // /** // * When the exact decompressed size is known, use this method to decompress. It's faster. // * // * @see net.jpountz.lz4.LZ4FastDecompressor // */ // public static byte[] decompressFast(byte[] src, int srcOffset, int exactDecompressedSize) { // if (src == null) { // throw new IllegalArgumentException("src must not be null."); // } // // if (srcOffset < 0) { // throw new IllegalArgumentException("srcOffset must equal to or larger than 0 but " + srcOffset); // } // // if (exactDecompressedSize < 0) { // throw new IllegalArgumentException("exactDecompressedSize must equal to or larger than 0 but " + exactDecompressedSize); // } // // LZ4FastDecompressor decompressor = factory.fastDecompressor(); // // return decompressor.decompress(src, srcOffset, exactDecompressedSize); // } // // /** // * @see #decompressFast(byte[], int, int) // */ // public static byte[] decompressFast(final byte[] src, int exactDecompressedSize) { // return decompressFast(src, 0, exactDecompressedSize); // } // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/util/OverridableReadOnlyProperties.java // public interface OverridableReadOnlyProperties { // String getProperty(String key); // // String getProperty(String key, String defaultValue); // // String getRequiredProperty(String key); // } // Path: hibernate4-memcached-spymemcached-adapter/src/main/java/kr/pe/kwonnam/hibernate4memcached/spymemcached/KryoTranscoder.java import com.esotericsoftware.kryo.Kryo; import com.esotericsoftware.kryo.io.Input; import com.esotericsoftware.kryo.io.Output; import com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer; import de.javakaffee.kryoserializers.KryoReflectionFactorySupport; import kr.pe.kwonnam.hibernate4memcached.util.IntToBytesUtils; import kr.pe.kwonnam.hibernate4memcached.util.Lz4CompressUtils; import kr.pe.kwonnam.hibernate4memcached.util.OverridableReadOnlyProperties; import net.spy.memcached.CachedData; import org.apache.commons.lang3.ArrayUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.ByteArrayOutputStream; import java.io.IOException; public CachedData encode(Object object) { int flags = BASE_FLAG; byte[] encodedBytes = kryoEncode(object); boolean compressionRequired = encodedBytes.length > compressionThreasholdBytes; if (compressionRequired) { int beforeSize = encodedBytes.length; encodedBytes = compress(encodedBytes); log.debug("kryotranscoder compress required : {}, original {} bytes -> compressed {} bytes", compressionRequired, beforeSize, encodedBytes.length); flags = flags | COMPRESS_FLAG; } return new CachedData(flags, encodedBytes, getMaxSize()); } private byte[] kryoEncode(Object o) { Kryo kryo = createKryo(); Output output = new Output(bufferSize, getMaxSize()); kryo.writeClassAndObject(output, o); return output.toBytes(); } byte[] compress(byte[] encodedBytes) { ByteArrayOutputStream baos = new ByteArrayOutputStream(encodedBytes.length); try { baos.write(IntToBytesUtils.intToBytes(encodedBytes.length));
byte[] compressedBytes = Lz4CompressUtils.compress(encodedBytes);
kwon37xi/hibernate4-memcached
hibernate4-memcached-core/src/test/java/kr/pe/kwonnam/hibernate4memcached/timestamper/FakeHibernateCacheTimestamper.java
// Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/memcached/MemcachedAdapter.java // public interface MemcachedAdapter { // /** // * Lifecycle callback to perform initialization. // * // * @param properties the defined cfg properties // */ // void init(OverridableReadOnlyProperties properties); // // /** // * Lifecycle callback to perform cleanup. // */ // void destroy(); // // /** // * get value from memcached // */ // Object get(CacheNamespace cacheNamespace, String key); // // /** // * set value to memcache with expirySeconds // */ // void set(CacheNamespace cacheNamespace, String key, Object value, int expirySeconds); // // /** // * delete key from memcached // */ // void delete(CacheNamespace cacheNamespace, String key); // // /** // * increase given increment couter and return new value. // * // * @param cacheNamespace cache namespace // * @param key counter key // * @param by the amount of increment // * @param defaultValue default value when the key missing // * @return increased value // */ // long increaseCounter(CacheNamespace cacheNamespace, String key, long by, long defaultValue, int expirySeconds); // // /** // * get current value from increment counter // * // * @param cacheNamespace cache namespace // * @param key counter key // * @param defaultValue default value when the key missing // * @return current value of counter without increment // */ // long getCounter(CacheNamespace cacheNamespace, String key, long defaultValue, int expirySeconds); // // /** // * Evict namespace // * // * @param cacheNamespace cache namespace // */ // void evictAll(CacheNamespace cacheNamespace); // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/util/OverridableReadOnlyProperties.java // public interface OverridableReadOnlyProperties { // String getProperty(String key); // // String getProperty(String key, String defaultValue); // // String getRequiredProperty(String key); // }
import kr.pe.kwonnam.hibernate4memcached.memcached.MemcachedAdapter; import kr.pe.kwonnam.hibernate4memcached.util.OverridableReadOnlyProperties; import org.hibernate.cfg.Settings;
package kr.pe.kwonnam.hibernate4memcached.timestamper; /** * @author KwonNam Son ([email protected]) */ public class FakeHibernateCacheTimestamper implements HibernateCacheTimestamper { private boolean initCalled = false; public boolean isInitCalled() { return initCalled; } @Override public void setSettings(Settings settings) { } @Override
// Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/memcached/MemcachedAdapter.java // public interface MemcachedAdapter { // /** // * Lifecycle callback to perform initialization. // * // * @param properties the defined cfg properties // */ // void init(OverridableReadOnlyProperties properties); // // /** // * Lifecycle callback to perform cleanup. // */ // void destroy(); // // /** // * get value from memcached // */ // Object get(CacheNamespace cacheNamespace, String key); // // /** // * set value to memcache with expirySeconds // */ // void set(CacheNamespace cacheNamespace, String key, Object value, int expirySeconds); // // /** // * delete key from memcached // */ // void delete(CacheNamespace cacheNamespace, String key); // // /** // * increase given increment couter and return new value. // * // * @param cacheNamespace cache namespace // * @param key counter key // * @param by the amount of increment // * @param defaultValue default value when the key missing // * @return increased value // */ // long increaseCounter(CacheNamespace cacheNamespace, String key, long by, long defaultValue, int expirySeconds); // // /** // * get current value from increment counter // * // * @param cacheNamespace cache namespace // * @param key counter key // * @param defaultValue default value when the key missing // * @return current value of counter without increment // */ // long getCounter(CacheNamespace cacheNamespace, String key, long defaultValue, int expirySeconds); // // /** // * Evict namespace // * // * @param cacheNamespace cache namespace // */ // void evictAll(CacheNamespace cacheNamespace); // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/util/OverridableReadOnlyProperties.java // public interface OverridableReadOnlyProperties { // String getProperty(String key); // // String getProperty(String key, String defaultValue); // // String getRequiredProperty(String key); // } // Path: hibernate4-memcached-core/src/test/java/kr/pe/kwonnam/hibernate4memcached/timestamper/FakeHibernateCacheTimestamper.java import kr.pe.kwonnam.hibernate4memcached.memcached.MemcachedAdapter; import kr.pe.kwonnam.hibernate4memcached.util.OverridableReadOnlyProperties; import org.hibernate.cfg.Settings; package kr.pe.kwonnam.hibernate4memcached.timestamper; /** * @author KwonNam Son ([email protected]) */ public class FakeHibernateCacheTimestamper implements HibernateCacheTimestamper { private boolean initCalled = false; public boolean isInitCalled() { return initCalled; } @Override public void setSettings(Settings settings) { } @Override
public void setProperties(OverridableReadOnlyProperties properties) {
kwon37xi/hibernate4-memcached
hibernate4-memcached-core/src/test/java/kr/pe/kwonnam/hibernate4memcached/timestamper/FakeHibernateCacheTimestamper.java
// Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/memcached/MemcachedAdapter.java // public interface MemcachedAdapter { // /** // * Lifecycle callback to perform initialization. // * // * @param properties the defined cfg properties // */ // void init(OverridableReadOnlyProperties properties); // // /** // * Lifecycle callback to perform cleanup. // */ // void destroy(); // // /** // * get value from memcached // */ // Object get(CacheNamespace cacheNamespace, String key); // // /** // * set value to memcache with expirySeconds // */ // void set(CacheNamespace cacheNamespace, String key, Object value, int expirySeconds); // // /** // * delete key from memcached // */ // void delete(CacheNamespace cacheNamespace, String key); // // /** // * increase given increment couter and return new value. // * // * @param cacheNamespace cache namespace // * @param key counter key // * @param by the amount of increment // * @param defaultValue default value when the key missing // * @return increased value // */ // long increaseCounter(CacheNamespace cacheNamespace, String key, long by, long defaultValue, int expirySeconds); // // /** // * get current value from increment counter // * // * @param cacheNamespace cache namespace // * @param key counter key // * @param defaultValue default value when the key missing // * @return current value of counter without increment // */ // long getCounter(CacheNamespace cacheNamespace, String key, long defaultValue, int expirySeconds); // // /** // * Evict namespace // * // * @param cacheNamespace cache namespace // */ // void evictAll(CacheNamespace cacheNamespace); // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/util/OverridableReadOnlyProperties.java // public interface OverridableReadOnlyProperties { // String getProperty(String key); // // String getProperty(String key, String defaultValue); // // String getRequiredProperty(String key); // }
import kr.pe.kwonnam.hibernate4memcached.memcached.MemcachedAdapter; import kr.pe.kwonnam.hibernate4memcached.util.OverridableReadOnlyProperties; import org.hibernate.cfg.Settings;
package kr.pe.kwonnam.hibernate4memcached.timestamper; /** * @author KwonNam Son ([email protected]) */ public class FakeHibernateCacheTimestamper implements HibernateCacheTimestamper { private boolean initCalled = false; public boolean isInitCalled() { return initCalled; } @Override public void setSettings(Settings settings) { } @Override public void setProperties(OverridableReadOnlyProperties properties) { } @Override
// Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/memcached/MemcachedAdapter.java // public interface MemcachedAdapter { // /** // * Lifecycle callback to perform initialization. // * // * @param properties the defined cfg properties // */ // void init(OverridableReadOnlyProperties properties); // // /** // * Lifecycle callback to perform cleanup. // */ // void destroy(); // // /** // * get value from memcached // */ // Object get(CacheNamespace cacheNamespace, String key); // // /** // * set value to memcache with expirySeconds // */ // void set(CacheNamespace cacheNamespace, String key, Object value, int expirySeconds); // // /** // * delete key from memcached // */ // void delete(CacheNamespace cacheNamespace, String key); // // /** // * increase given increment couter and return new value. // * // * @param cacheNamespace cache namespace // * @param key counter key // * @param by the amount of increment // * @param defaultValue default value when the key missing // * @return increased value // */ // long increaseCounter(CacheNamespace cacheNamespace, String key, long by, long defaultValue, int expirySeconds); // // /** // * get current value from increment counter // * // * @param cacheNamespace cache namespace // * @param key counter key // * @param defaultValue default value when the key missing // * @return current value of counter without increment // */ // long getCounter(CacheNamespace cacheNamespace, String key, long defaultValue, int expirySeconds); // // /** // * Evict namespace // * // * @param cacheNamespace cache namespace // */ // void evictAll(CacheNamespace cacheNamespace); // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/util/OverridableReadOnlyProperties.java // public interface OverridableReadOnlyProperties { // String getProperty(String key); // // String getProperty(String key, String defaultValue); // // String getRequiredProperty(String key); // } // Path: hibernate4-memcached-core/src/test/java/kr/pe/kwonnam/hibernate4memcached/timestamper/FakeHibernateCacheTimestamper.java import kr.pe.kwonnam.hibernate4memcached.memcached.MemcachedAdapter; import kr.pe.kwonnam.hibernate4memcached.util.OverridableReadOnlyProperties; import org.hibernate.cfg.Settings; package kr.pe.kwonnam.hibernate4memcached.timestamper; /** * @author KwonNam Son ([email protected]) */ public class FakeHibernateCacheTimestamper implements HibernateCacheTimestamper { private boolean initCalled = false; public boolean isInitCalled() { return initCalled; } @Override public void setSettings(Settings settings) { } @Override public void setProperties(OverridableReadOnlyProperties properties) { } @Override
public void setMemcachedAdapter(MemcachedAdapter memcachedAdapter) {
kwon37xi/hibernate4-memcached
hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/strategies/NonstrictReadWriteNaturalIdRegionAccessStrategy.java
// Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/regions/NaturalIdMemcachedRegion.java // public class NaturalIdMemcachedRegion extends TransactionalDataMemcachedRegion implements NaturalIdRegion { // public NaturalIdMemcachedRegion(String regionName, OverridableReadOnlyProperties properties, // CacheDataDescription metadata, Settings settings, // MemcachedAdapter memcachedAdapter, // HibernateCacheTimestamper hibernateCacheTimestamper) { // super(new CacheNamespace(regionName, true), properties, metadata, settings, memcachedAdapter, // hibernateCacheTimestamper); // } // // @Override // public NaturalIdRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException { // switch (accessType) { // case READ_ONLY: // return new ReadOnlyNaturalIdRegionAccessStrategy(this); // case NONSTRICT_READ_WRITE: // return new NonstrictReadWriteNaturalIdRegionAccessStrategy(this); // default: // throw new CacheException("Unsupported access strategy : " + accessType + "."); // } // } // }
import kr.pe.kwonnam.hibernate4memcached.regions.NaturalIdMemcachedRegion; import org.hibernate.cache.CacheException; import org.hibernate.cache.spi.access.SoftLock; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
package kr.pe.kwonnam.hibernate4memcached.strategies; /** * @author KwonNam Son ([email protected]) */ public class NonstrictReadWriteNaturalIdRegionAccessStrategy extends BaseNaturalIdMemcachedRegionAccessStrategy { private Logger log = LoggerFactory.getLogger(NonstrictReadWriteNaturalIdRegionAccessStrategy.class);
// Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/regions/NaturalIdMemcachedRegion.java // public class NaturalIdMemcachedRegion extends TransactionalDataMemcachedRegion implements NaturalIdRegion { // public NaturalIdMemcachedRegion(String regionName, OverridableReadOnlyProperties properties, // CacheDataDescription metadata, Settings settings, // MemcachedAdapter memcachedAdapter, // HibernateCacheTimestamper hibernateCacheTimestamper) { // super(new CacheNamespace(regionName, true), properties, metadata, settings, memcachedAdapter, // hibernateCacheTimestamper); // } // // @Override // public NaturalIdRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException { // switch (accessType) { // case READ_ONLY: // return new ReadOnlyNaturalIdRegionAccessStrategy(this); // case NONSTRICT_READ_WRITE: // return new NonstrictReadWriteNaturalIdRegionAccessStrategy(this); // default: // throw new CacheException("Unsupported access strategy : " + accessType + "."); // } // } // } // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/strategies/NonstrictReadWriteNaturalIdRegionAccessStrategy.java import kr.pe.kwonnam.hibernate4memcached.regions.NaturalIdMemcachedRegion; import org.hibernate.cache.CacheException; import org.hibernate.cache.spi.access.SoftLock; import org.slf4j.Logger; import org.slf4j.LoggerFactory; package kr.pe.kwonnam.hibernate4memcached.strategies; /** * @author KwonNam Son ([email protected]) */ public class NonstrictReadWriteNaturalIdRegionAccessStrategy extends BaseNaturalIdMemcachedRegionAccessStrategy { private Logger log = LoggerFactory.getLogger(NonstrictReadWriteNaturalIdRegionAccessStrategy.class);
public NonstrictReadWriteNaturalIdRegionAccessStrategy(NaturalIdMemcachedRegion naturalIdMemcachedRegion) {
kwon37xi/hibernate4-memcached
hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/regions/GeneralDataMemcachedRegion.java
// Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/memcached/CacheNamespace.java // public class CacheNamespace implements Serializable { // /** // * name of region // */ // private String name; // // /** // * if this value is true, the memcached adapter should implement namespace pattern // * or ignore namespace pattern. // * <p/> // * see <a href="https://code.google.com/p/memcached/wiki/NewProgrammingTricks#Namespacing">Memcached Namespacing</a> // */ // private boolean namespaceExpirationRequired; // // public CacheNamespace(String name, boolean namespaceExpirationRequired) { // this.name = name; // this.namespaceExpirationRequired = namespaceExpirationRequired; // } // // public String getName() { // return name; // } // // public boolean isNamespaceExpirationRequired() { // return namespaceExpirationRequired; // } // // @Override // public boolean equals(Object o) { // if (o == null) { // return false; // } // if (this == o) { // return true; // } // if (getClass() != o.getClass()) { // return false; // } // // CacheNamespace otherCacheNamespace = (CacheNamespace) o; // // return new EqualsBuilder().append(name, otherCacheNamespace.name) // .append(namespaceExpirationRequired, otherCacheNamespace.namespaceExpirationRequired).isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder().append(name).append(namespaceExpirationRequired).toHashCode(); // } // // @Override // public String toString() { // return new ToStringBuilder(this).append("name", name).append("namespaceExpirationRequired", namespaceExpirationRequired).toString(); // } // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/memcached/MemcachedAdapter.java // public interface MemcachedAdapter { // /** // * Lifecycle callback to perform initialization. // * // * @param properties the defined cfg properties // */ // void init(OverridableReadOnlyProperties properties); // // /** // * Lifecycle callback to perform cleanup. // */ // void destroy(); // // /** // * get value from memcached // */ // Object get(CacheNamespace cacheNamespace, String key); // // /** // * set value to memcache with expirySeconds // */ // void set(CacheNamespace cacheNamespace, String key, Object value, int expirySeconds); // // /** // * delete key from memcached // */ // void delete(CacheNamespace cacheNamespace, String key); // // /** // * increase given increment couter and return new value. // * // * @param cacheNamespace cache namespace // * @param key counter key // * @param by the amount of increment // * @param defaultValue default value when the key missing // * @return increased value // */ // long increaseCounter(CacheNamespace cacheNamespace, String key, long by, long defaultValue, int expirySeconds); // // /** // * get current value from increment counter // * // * @param cacheNamespace cache namespace // * @param key counter key // * @param defaultValue default value when the key missing // * @return current value of counter without increment // */ // long getCounter(CacheNamespace cacheNamespace, String key, long defaultValue, int expirySeconds); // // /** // * Evict namespace // * // * @param cacheNamespace cache namespace // */ // void evictAll(CacheNamespace cacheNamespace); // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/timestamper/HibernateCacheTimestamper.java // public interface HibernateCacheTimestamper { // // void setSettings(Settings settings); // // void setProperties(OverridableReadOnlyProperties properties); // // void setMemcachedAdapter(MemcachedAdapter memcachedAdapter); // // /** initialize timestamp object */ // void init(); // // /** get next timestamp */ // long next(); // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/util/OverridableReadOnlyProperties.java // public interface OverridableReadOnlyProperties { // String getProperty(String key); // // String getProperty(String key, String defaultValue); // // String getRequiredProperty(String key); // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/Hibernate4MemcachedRegionFactory.java // public static final String REGION_EXPIRY_SECONDS_PROPERTY_KEY_PREFIX = "h4m.expiry.seconds";
import kr.pe.kwonnam.hibernate4memcached.memcached.CacheNamespace; import kr.pe.kwonnam.hibernate4memcached.memcached.MemcachedAdapter; import kr.pe.kwonnam.hibernate4memcached.timestamper.HibernateCacheTimestamper; import kr.pe.kwonnam.hibernate4memcached.util.OverridableReadOnlyProperties; import org.hibernate.cache.CacheException; import org.hibernate.cache.spi.CacheDataDescription; import org.hibernate.cache.spi.GeneralDataRegion; import org.hibernate.cfg.Settings; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import static kr.pe.kwonnam.hibernate4memcached.Hibernate4MemcachedRegionFactory.REGION_EXPIRY_SECONDS_PROPERTY_KEY_PREFIX;
package kr.pe.kwonnam.hibernate4memcached.regions; /** * @author KwonNam Son ([email protected]) */ public class GeneralDataMemcachedRegion extends MemcachedRegion implements GeneralDataRegion { private Logger log = LoggerFactory.getLogger(GeneralDataMemcachedRegion.class); private int expirySeconds;
// Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/memcached/CacheNamespace.java // public class CacheNamespace implements Serializable { // /** // * name of region // */ // private String name; // // /** // * if this value is true, the memcached adapter should implement namespace pattern // * or ignore namespace pattern. // * <p/> // * see <a href="https://code.google.com/p/memcached/wiki/NewProgrammingTricks#Namespacing">Memcached Namespacing</a> // */ // private boolean namespaceExpirationRequired; // // public CacheNamespace(String name, boolean namespaceExpirationRequired) { // this.name = name; // this.namespaceExpirationRequired = namespaceExpirationRequired; // } // // public String getName() { // return name; // } // // public boolean isNamespaceExpirationRequired() { // return namespaceExpirationRequired; // } // // @Override // public boolean equals(Object o) { // if (o == null) { // return false; // } // if (this == o) { // return true; // } // if (getClass() != o.getClass()) { // return false; // } // // CacheNamespace otherCacheNamespace = (CacheNamespace) o; // // return new EqualsBuilder().append(name, otherCacheNamespace.name) // .append(namespaceExpirationRequired, otherCacheNamespace.namespaceExpirationRequired).isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder().append(name).append(namespaceExpirationRequired).toHashCode(); // } // // @Override // public String toString() { // return new ToStringBuilder(this).append("name", name).append("namespaceExpirationRequired", namespaceExpirationRequired).toString(); // } // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/memcached/MemcachedAdapter.java // public interface MemcachedAdapter { // /** // * Lifecycle callback to perform initialization. // * // * @param properties the defined cfg properties // */ // void init(OverridableReadOnlyProperties properties); // // /** // * Lifecycle callback to perform cleanup. // */ // void destroy(); // // /** // * get value from memcached // */ // Object get(CacheNamespace cacheNamespace, String key); // // /** // * set value to memcache with expirySeconds // */ // void set(CacheNamespace cacheNamespace, String key, Object value, int expirySeconds); // // /** // * delete key from memcached // */ // void delete(CacheNamespace cacheNamespace, String key); // // /** // * increase given increment couter and return new value. // * // * @param cacheNamespace cache namespace // * @param key counter key // * @param by the amount of increment // * @param defaultValue default value when the key missing // * @return increased value // */ // long increaseCounter(CacheNamespace cacheNamespace, String key, long by, long defaultValue, int expirySeconds); // // /** // * get current value from increment counter // * // * @param cacheNamespace cache namespace // * @param key counter key // * @param defaultValue default value when the key missing // * @return current value of counter without increment // */ // long getCounter(CacheNamespace cacheNamespace, String key, long defaultValue, int expirySeconds); // // /** // * Evict namespace // * // * @param cacheNamespace cache namespace // */ // void evictAll(CacheNamespace cacheNamespace); // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/timestamper/HibernateCacheTimestamper.java // public interface HibernateCacheTimestamper { // // void setSettings(Settings settings); // // void setProperties(OverridableReadOnlyProperties properties); // // void setMemcachedAdapter(MemcachedAdapter memcachedAdapter); // // /** initialize timestamp object */ // void init(); // // /** get next timestamp */ // long next(); // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/util/OverridableReadOnlyProperties.java // public interface OverridableReadOnlyProperties { // String getProperty(String key); // // String getProperty(String key, String defaultValue); // // String getRequiredProperty(String key); // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/Hibernate4MemcachedRegionFactory.java // public static final String REGION_EXPIRY_SECONDS_PROPERTY_KEY_PREFIX = "h4m.expiry.seconds"; // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/regions/GeneralDataMemcachedRegion.java import kr.pe.kwonnam.hibernate4memcached.memcached.CacheNamespace; import kr.pe.kwonnam.hibernate4memcached.memcached.MemcachedAdapter; import kr.pe.kwonnam.hibernate4memcached.timestamper.HibernateCacheTimestamper; import kr.pe.kwonnam.hibernate4memcached.util.OverridableReadOnlyProperties; import org.hibernate.cache.CacheException; import org.hibernate.cache.spi.CacheDataDescription; import org.hibernate.cache.spi.GeneralDataRegion; import org.hibernate.cfg.Settings; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import static kr.pe.kwonnam.hibernate4memcached.Hibernate4MemcachedRegionFactory.REGION_EXPIRY_SECONDS_PROPERTY_KEY_PREFIX; package kr.pe.kwonnam.hibernate4memcached.regions; /** * @author KwonNam Son ([email protected]) */ public class GeneralDataMemcachedRegion extends MemcachedRegion implements GeneralDataRegion { private Logger log = LoggerFactory.getLogger(GeneralDataMemcachedRegion.class); private int expirySeconds;
public GeneralDataMemcachedRegion(CacheNamespace cacheNamespace, OverridableReadOnlyProperties properties, CacheDataDescription metadata,
kwon37xi/hibernate4-memcached
hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/regions/GeneralDataMemcachedRegion.java
// Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/memcached/CacheNamespace.java // public class CacheNamespace implements Serializable { // /** // * name of region // */ // private String name; // // /** // * if this value is true, the memcached adapter should implement namespace pattern // * or ignore namespace pattern. // * <p/> // * see <a href="https://code.google.com/p/memcached/wiki/NewProgrammingTricks#Namespacing">Memcached Namespacing</a> // */ // private boolean namespaceExpirationRequired; // // public CacheNamespace(String name, boolean namespaceExpirationRequired) { // this.name = name; // this.namespaceExpirationRequired = namespaceExpirationRequired; // } // // public String getName() { // return name; // } // // public boolean isNamespaceExpirationRequired() { // return namespaceExpirationRequired; // } // // @Override // public boolean equals(Object o) { // if (o == null) { // return false; // } // if (this == o) { // return true; // } // if (getClass() != o.getClass()) { // return false; // } // // CacheNamespace otherCacheNamespace = (CacheNamespace) o; // // return new EqualsBuilder().append(name, otherCacheNamespace.name) // .append(namespaceExpirationRequired, otherCacheNamespace.namespaceExpirationRequired).isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder().append(name).append(namespaceExpirationRequired).toHashCode(); // } // // @Override // public String toString() { // return new ToStringBuilder(this).append("name", name).append("namespaceExpirationRequired", namespaceExpirationRequired).toString(); // } // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/memcached/MemcachedAdapter.java // public interface MemcachedAdapter { // /** // * Lifecycle callback to perform initialization. // * // * @param properties the defined cfg properties // */ // void init(OverridableReadOnlyProperties properties); // // /** // * Lifecycle callback to perform cleanup. // */ // void destroy(); // // /** // * get value from memcached // */ // Object get(CacheNamespace cacheNamespace, String key); // // /** // * set value to memcache with expirySeconds // */ // void set(CacheNamespace cacheNamespace, String key, Object value, int expirySeconds); // // /** // * delete key from memcached // */ // void delete(CacheNamespace cacheNamespace, String key); // // /** // * increase given increment couter and return new value. // * // * @param cacheNamespace cache namespace // * @param key counter key // * @param by the amount of increment // * @param defaultValue default value when the key missing // * @return increased value // */ // long increaseCounter(CacheNamespace cacheNamespace, String key, long by, long defaultValue, int expirySeconds); // // /** // * get current value from increment counter // * // * @param cacheNamespace cache namespace // * @param key counter key // * @param defaultValue default value when the key missing // * @return current value of counter without increment // */ // long getCounter(CacheNamespace cacheNamespace, String key, long defaultValue, int expirySeconds); // // /** // * Evict namespace // * // * @param cacheNamespace cache namespace // */ // void evictAll(CacheNamespace cacheNamespace); // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/timestamper/HibernateCacheTimestamper.java // public interface HibernateCacheTimestamper { // // void setSettings(Settings settings); // // void setProperties(OverridableReadOnlyProperties properties); // // void setMemcachedAdapter(MemcachedAdapter memcachedAdapter); // // /** initialize timestamp object */ // void init(); // // /** get next timestamp */ // long next(); // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/util/OverridableReadOnlyProperties.java // public interface OverridableReadOnlyProperties { // String getProperty(String key); // // String getProperty(String key, String defaultValue); // // String getRequiredProperty(String key); // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/Hibernate4MemcachedRegionFactory.java // public static final String REGION_EXPIRY_SECONDS_PROPERTY_KEY_PREFIX = "h4m.expiry.seconds";
import kr.pe.kwonnam.hibernate4memcached.memcached.CacheNamespace; import kr.pe.kwonnam.hibernate4memcached.memcached.MemcachedAdapter; import kr.pe.kwonnam.hibernate4memcached.timestamper.HibernateCacheTimestamper; import kr.pe.kwonnam.hibernate4memcached.util.OverridableReadOnlyProperties; import org.hibernate.cache.CacheException; import org.hibernate.cache.spi.CacheDataDescription; import org.hibernate.cache.spi.GeneralDataRegion; import org.hibernate.cfg.Settings; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import static kr.pe.kwonnam.hibernate4memcached.Hibernate4MemcachedRegionFactory.REGION_EXPIRY_SECONDS_PROPERTY_KEY_PREFIX;
package kr.pe.kwonnam.hibernate4memcached.regions; /** * @author KwonNam Son ([email protected]) */ public class GeneralDataMemcachedRegion extends MemcachedRegion implements GeneralDataRegion { private Logger log = LoggerFactory.getLogger(GeneralDataMemcachedRegion.class); private int expirySeconds;
// Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/memcached/CacheNamespace.java // public class CacheNamespace implements Serializable { // /** // * name of region // */ // private String name; // // /** // * if this value is true, the memcached adapter should implement namespace pattern // * or ignore namespace pattern. // * <p/> // * see <a href="https://code.google.com/p/memcached/wiki/NewProgrammingTricks#Namespacing">Memcached Namespacing</a> // */ // private boolean namespaceExpirationRequired; // // public CacheNamespace(String name, boolean namespaceExpirationRequired) { // this.name = name; // this.namespaceExpirationRequired = namespaceExpirationRequired; // } // // public String getName() { // return name; // } // // public boolean isNamespaceExpirationRequired() { // return namespaceExpirationRequired; // } // // @Override // public boolean equals(Object o) { // if (o == null) { // return false; // } // if (this == o) { // return true; // } // if (getClass() != o.getClass()) { // return false; // } // // CacheNamespace otherCacheNamespace = (CacheNamespace) o; // // return new EqualsBuilder().append(name, otherCacheNamespace.name) // .append(namespaceExpirationRequired, otherCacheNamespace.namespaceExpirationRequired).isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder().append(name).append(namespaceExpirationRequired).toHashCode(); // } // // @Override // public String toString() { // return new ToStringBuilder(this).append("name", name).append("namespaceExpirationRequired", namespaceExpirationRequired).toString(); // } // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/memcached/MemcachedAdapter.java // public interface MemcachedAdapter { // /** // * Lifecycle callback to perform initialization. // * // * @param properties the defined cfg properties // */ // void init(OverridableReadOnlyProperties properties); // // /** // * Lifecycle callback to perform cleanup. // */ // void destroy(); // // /** // * get value from memcached // */ // Object get(CacheNamespace cacheNamespace, String key); // // /** // * set value to memcache with expirySeconds // */ // void set(CacheNamespace cacheNamespace, String key, Object value, int expirySeconds); // // /** // * delete key from memcached // */ // void delete(CacheNamespace cacheNamespace, String key); // // /** // * increase given increment couter and return new value. // * // * @param cacheNamespace cache namespace // * @param key counter key // * @param by the amount of increment // * @param defaultValue default value when the key missing // * @return increased value // */ // long increaseCounter(CacheNamespace cacheNamespace, String key, long by, long defaultValue, int expirySeconds); // // /** // * get current value from increment counter // * // * @param cacheNamespace cache namespace // * @param key counter key // * @param defaultValue default value when the key missing // * @return current value of counter without increment // */ // long getCounter(CacheNamespace cacheNamespace, String key, long defaultValue, int expirySeconds); // // /** // * Evict namespace // * // * @param cacheNamespace cache namespace // */ // void evictAll(CacheNamespace cacheNamespace); // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/timestamper/HibernateCacheTimestamper.java // public interface HibernateCacheTimestamper { // // void setSettings(Settings settings); // // void setProperties(OverridableReadOnlyProperties properties); // // void setMemcachedAdapter(MemcachedAdapter memcachedAdapter); // // /** initialize timestamp object */ // void init(); // // /** get next timestamp */ // long next(); // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/util/OverridableReadOnlyProperties.java // public interface OverridableReadOnlyProperties { // String getProperty(String key); // // String getProperty(String key, String defaultValue); // // String getRequiredProperty(String key); // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/Hibernate4MemcachedRegionFactory.java // public static final String REGION_EXPIRY_SECONDS_PROPERTY_KEY_PREFIX = "h4m.expiry.seconds"; // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/regions/GeneralDataMemcachedRegion.java import kr.pe.kwonnam.hibernate4memcached.memcached.CacheNamespace; import kr.pe.kwonnam.hibernate4memcached.memcached.MemcachedAdapter; import kr.pe.kwonnam.hibernate4memcached.timestamper.HibernateCacheTimestamper; import kr.pe.kwonnam.hibernate4memcached.util.OverridableReadOnlyProperties; import org.hibernate.cache.CacheException; import org.hibernate.cache.spi.CacheDataDescription; import org.hibernate.cache.spi.GeneralDataRegion; import org.hibernate.cfg.Settings; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import static kr.pe.kwonnam.hibernate4memcached.Hibernate4MemcachedRegionFactory.REGION_EXPIRY_SECONDS_PROPERTY_KEY_PREFIX; package kr.pe.kwonnam.hibernate4memcached.regions; /** * @author KwonNam Son ([email protected]) */ public class GeneralDataMemcachedRegion extends MemcachedRegion implements GeneralDataRegion { private Logger log = LoggerFactory.getLogger(GeneralDataMemcachedRegion.class); private int expirySeconds;
public GeneralDataMemcachedRegion(CacheNamespace cacheNamespace, OverridableReadOnlyProperties properties, CacheDataDescription metadata,
kwon37xi/hibernate4-memcached
hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/regions/GeneralDataMemcachedRegion.java
// Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/memcached/CacheNamespace.java // public class CacheNamespace implements Serializable { // /** // * name of region // */ // private String name; // // /** // * if this value is true, the memcached adapter should implement namespace pattern // * or ignore namespace pattern. // * <p/> // * see <a href="https://code.google.com/p/memcached/wiki/NewProgrammingTricks#Namespacing">Memcached Namespacing</a> // */ // private boolean namespaceExpirationRequired; // // public CacheNamespace(String name, boolean namespaceExpirationRequired) { // this.name = name; // this.namespaceExpirationRequired = namespaceExpirationRequired; // } // // public String getName() { // return name; // } // // public boolean isNamespaceExpirationRequired() { // return namespaceExpirationRequired; // } // // @Override // public boolean equals(Object o) { // if (o == null) { // return false; // } // if (this == o) { // return true; // } // if (getClass() != o.getClass()) { // return false; // } // // CacheNamespace otherCacheNamespace = (CacheNamespace) o; // // return new EqualsBuilder().append(name, otherCacheNamespace.name) // .append(namespaceExpirationRequired, otherCacheNamespace.namespaceExpirationRequired).isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder().append(name).append(namespaceExpirationRequired).toHashCode(); // } // // @Override // public String toString() { // return new ToStringBuilder(this).append("name", name).append("namespaceExpirationRequired", namespaceExpirationRequired).toString(); // } // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/memcached/MemcachedAdapter.java // public interface MemcachedAdapter { // /** // * Lifecycle callback to perform initialization. // * // * @param properties the defined cfg properties // */ // void init(OverridableReadOnlyProperties properties); // // /** // * Lifecycle callback to perform cleanup. // */ // void destroy(); // // /** // * get value from memcached // */ // Object get(CacheNamespace cacheNamespace, String key); // // /** // * set value to memcache with expirySeconds // */ // void set(CacheNamespace cacheNamespace, String key, Object value, int expirySeconds); // // /** // * delete key from memcached // */ // void delete(CacheNamespace cacheNamespace, String key); // // /** // * increase given increment couter and return new value. // * // * @param cacheNamespace cache namespace // * @param key counter key // * @param by the amount of increment // * @param defaultValue default value when the key missing // * @return increased value // */ // long increaseCounter(CacheNamespace cacheNamespace, String key, long by, long defaultValue, int expirySeconds); // // /** // * get current value from increment counter // * // * @param cacheNamespace cache namespace // * @param key counter key // * @param defaultValue default value when the key missing // * @return current value of counter without increment // */ // long getCounter(CacheNamespace cacheNamespace, String key, long defaultValue, int expirySeconds); // // /** // * Evict namespace // * // * @param cacheNamespace cache namespace // */ // void evictAll(CacheNamespace cacheNamespace); // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/timestamper/HibernateCacheTimestamper.java // public interface HibernateCacheTimestamper { // // void setSettings(Settings settings); // // void setProperties(OverridableReadOnlyProperties properties); // // void setMemcachedAdapter(MemcachedAdapter memcachedAdapter); // // /** initialize timestamp object */ // void init(); // // /** get next timestamp */ // long next(); // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/util/OverridableReadOnlyProperties.java // public interface OverridableReadOnlyProperties { // String getProperty(String key); // // String getProperty(String key, String defaultValue); // // String getRequiredProperty(String key); // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/Hibernate4MemcachedRegionFactory.java // public static final String REGION_EXPIRY_SECONDS_PROPERTY_KEY_PREFIX = "h4m.expiry.seconds";
import kr.pe.kwonnam.hibernate4memcached.memcached.CacheNamespace; import kr.pe.kwonnam.hibernate4memcached.memcached.MemcachedAdapter; import kr.pe.kwonnam.hibernate4memcached.timestamper.HibernateCacheTimestamper; import kr.pe.kwonnam.hibernate4memcached.util.OverridableReadOnlyProperties; import org.hibernate.cache.CacheException; import org.hibernate.cache.spi.CacheDataDescription; import org.hibernate.cache.spi.GeneralDataRegion; import org.hibernate.cfg.Settings; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import static kr.pe.kwonnam.hibernate4memcached.Hibernate4MemcachedRegionFactory.REGION_EXPIRY_SECONDS_PROPERTY_KEY_PREFIX;
package kr.pe.kwonnam.hibernate4memcached.regions; /** * @author KwonNam Son ([email protected]) */ public class GeneralDataMemcachedRegion extends MemcachedRegion implements GeneralDataRegion { private Logger log = LoggerFactory.getLogger(GeneralDataMemcachedRegion.class); private int expirySeconds; public GeneralDataMemcachedRegion(CacheNamespace cacheNamespace, OverridableReadOnlyProperties properties, CacheDataDescription metadata,
// Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/memcached/CacheNamespace.java // public class CacheNamespace implements Serializable { // /** // * name of region // */ // private String name; // // /** // * if this value is true, the memcached adapter should implement namespace pattern // * or ignore namespace pattern. // * <p/> // * see <a href="https://code.google.com/p/memcached/wiki/NewProgrammingTricks#Namespacing">Memcached Namespacing</a> // */ // private boolean namespaceExpirationRequired; // // public CacheNamespace(String name, boolean namespaceExpirationRequired) { // this.name = name; // this.namespaceExpirationRequired = namespaceExpirationRequired; // } // // public String getName() { // return name; // } // // public boolean isNamespaceExpirationRequired() { // return namespaceExpirationRequired; // } // // @Override // public boolean equals(Object o) { // if (o == null) { // return false; // } // if (this == o) { // return true; // } // if (getClass() != o.getClass()) { // return false; // } // // CacheNamespace otherCacheNamespace = (CacheNamespace) o; // // return new EqualsBuilder().append(name, otherCacheNamespace.name) // .append(namespaceExpirationRequired, otherCacheNamespace.namespaceExpirationRequired).isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder().append(name).append(namespaceExpirationRequired).toHashCode(); // } // // @Override // public String toString() { // return new ToStringBuilder(this).append("name", name).append("namespaceExpirationRequired", namespaceExpirationRequired).toString(); // } // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/memcached/MemcachedAdapter.java // public interface MemcachedAdapter { // /** // * Lifecycle callback to perform initialization. // * // * @param properties the defined cfg properties // */ // void init(OverridableReadOnlyProperties properties); // // /** // * Lifecycle callback to perform cleanup. // */ // void destroy(); // // /** // * get value from memcached // */ // Object get(CacheNamespace cacheNamespace, String key); // // /** // * set value to memcache with expirySeconds // */ // void set(CacheNamespace cacheNamespace, String key, Object value, int expirySeconds); // // /** // * delete key from memcached // */ // void delete(CacheNamespace cacheNamespace, String key); // // /** // * increase given increment couter and return new value. // * // * @param cacheNamespace cache namespace // * @param key counter key // * @param by the amount of increment // * @param defaultValue default value when the key missing // * @return increased value // */ // long increaseCounter(CacheNamespace cacheNamespace, String key, long by, long defaultValue, int expirySeconds); // // /** // * get current value from increment counter // * // * @param cacheNamespace cache namespace // * @param key counter key // * @param defaultValue default value when the key missing // * @return current value of counter without increment // */ // long getCounter(CacheNamespace cacheNamespace, String key, long defaultValue, int expirySeconds); // // /** // * Evict namespace // * // * @param cacheNamespace cache namespace // */ // void evictAll(CacheNamespace cacheNamespace); // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/timestamper/HibernateCacheTimestamper.java // public interface HibernateCacheTimestamper { // // void setSettings(Settings settings); // // void setProperties(OverridableReadOnlyProperties properties); // // void setMemcachedAdapter(MemcachedAdapter memcachedAdapter); // // /** initialize timestamp object */ // void init(); // // /** get next timestamp */ // long next(); // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/util/OverridableReadOnlyProperties.java // public interface OverridableReadOnlyProperties { // String getProperty(String key); // // String getProperty(String key, String defaultValue); // // String getRequiredProperty(String key); // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/Hibernate4MemcachedRegionFactory.java // public static final String REGION_EXPIRY_SECONDS_PROPERTY_KEY_PREFIX = "h4m.expiry.seconds"; // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/regions/GeneralDataMemcachedRegion.java import kr.pe.kwonnam.hibernate4memcached.memcached.CacheNamespace; import kr.pe.kwonnam.hibernate4memcached.memcached.MemcachedAdapter; import kr.pe.kwonnam.hibernate4memcached.timestamper.HibernateCacheTimestamper; import kr.pe.kwonnam.hibernate4memcached.util.OverridableReadOnlyProperties; import org.hibernate.cache.CacheException; import org.hibernate.cache.spi.CacheDataDescription; import org.hibernate.cache.spi.GeneralDataRegion; import org.hibernate.cfg.Settings; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import static kr.pe.kwonnam.hibernate4memcached.Hibernate4MemcachedRegionFactory.REGION_EXPIRY_SECONDS_PROPERTY_KEY_PREFIX; package kr.pe.kwonnam.hibernate4memcached.regions; /** * @author KwonNam Son ([email protected]) */ public class GeneralDataMemcachedRegion extends MemcachedRegion implements GeneralDataRegion { private Logger log = LoggerFactory.getLogger(GeneralDataMemcachedRegion.class); private int expirySeconds; public GeneralDataMemcachedRegion(CacheNamespace cacheNamespace, OverridableReadOnlyProperties properties, CacheDataDescription metadata,
Settings settings, MemcachedAdapter memcachedAdapter, HibernateCacheTimestamper hibernateCacheTimestamper) {
kwon37xi/hibernate4-memcached
hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/regions/GeneralDataMemcachedRegion.java
// Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/memcached/CacheNamespace.java // public class CacheNamespace implements Serializable { // /** // * name of region // */ // private String name; // // /** // * if this value is true, the memcached adapter should implement namespace pattern // * or ignore namespace pattern. // * <p/> // * see <a href="https://code.google.com/p/memcached/wiki/NewProgrammingTricks#Namespacing">Memcached Namespacing</a> // */ // private boolean namespaceExpirationRequired; // // public CacheNamespace(String name, boolean namespaceExpirationRequired) { // this.name = name; // this.namespaceExpirationRequired = namespaceExpirationRequired; // } // // public String getName() { // return name; // } // // public boolean isNamespaceExpirationRequired() { // return namespaceExpirationRequired; // } // // @Override // public boolean equals(Object o) { // if (o == null) { // return false; // } // if (this == o) { // return true; // } // if (getClass() != o.getClass()) { // return false; // } // // CacheNamespace otherCacheNamespace = (CacheNamespace) o; // // return new EqualsBuilder().append(name, otherCacheNamespace.name) // .append(namespaceExpirationRequired, otherCacheNamespace.namespaceExpirationRequired).isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder().append(name).append(namespaceExpirationRequired).toHashCode(); // } // // @Override // public String toString() { // return new ToStringBuilder(this).append("name", name).append("namespaceExpirationRequired", namespaceExpirationRequired).toString(); // } // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/memcached/MemcachedAdapter.java // public interface MemcachedAdapter { // /** // * Lifecycle callback to perform initialization. // * // * @param properties the defined cfg properties // */ // void init(OverridableReadOnlyProperties properties); // // /** // * Lifecycle callback to perform cleanup. // */ // void destroy(); // // /** // * get value from memcached // */ // Object get(CacheNamespace cacheNamespace, String key); // // /** // * set value to memcache with expirySeconds // */ // void set(CacheNamespace cacheNamespace, String key, Object value, int expirySeconds); // // /** // * delete key from memcached // */ // void delete(CacheNamespace cacheNamespace, String key); // // /** // * increase given increment couter and return new value. // * // * @param cacheNamespace cache namespace // * @param key counter key // * @param by the amount of increment // * @param defaultValue default value when the key missing // * @return increased value // */ // long increaseCounter(CacheNamespace cacheNamespace, String key, long by, long defaultValue, int expirySeconds); // // /** // * get current value from increment counter // * // * @param cacheNamespace cache namespace // * @param key counter key // * @param defaultValue default value when the key missing // * @return current value of counter without increment // */ // long getCounter(CacheNamespace cacheNamespace, String key, long defaultValue, int expirySeconds); // // /** // * Evict namespace // * // * @param cacheNamespace cache namespace // */ // void evictAll(CacheNamespace cacheNamespace); // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/timestamper/HibernateCacheTimestamper.java // public interface HibernateCacheTimestamper { // // void setSettings(Settings settings); // // void setProperties(OverridableReadOnlyProperties properties); // // void setMemcachedAdapter(MemcachedAdapter memcachedAdapter); // // /** initialize timestamp object */ // void init(); // // /** get next timestamp */ // long next(); // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/util/OverridableReadOnlyProperties.java // public interface OverridableReadOnlyProperties { // String getProperty(String key); // // String getProperty(String key, String defaultValue); // // String getRequiredProperty(String key); // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/Hibernate4MemcachedRegionFactory.java // public static final String REGION_EXPIRY_SECONDS_PROPERTY_KEY_PREFIX = "h4m.expiry.seconds";
import kr.pe.kwonnam.hibernate4memcached.memcached.CacheNamespace; import kr.pe.kwonnam.hibernate4memcached.memcached.MemcachedAdapter; import kr.pe.kwonnam.hibernate4memcached.timestamper.HibernateCacheTimestamper; import kr.pe.kwonnam.hibernate4memcached.util.OverridableReadOnlyProperties; import org.hibernate.cache.CacheException; import org.hibernate.cache.spi.CacheDataDescription; import org.hibernate.cache.spi.GeneralDataRegion; import org.hibernate.cfg.Settings; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import static kr.pe.kwonnam.hibernate4memcached.Hibernate4MemcachedRegionFactory.REGION_EXPIRY_SECONDS_PROPERTY_KEY_PREFIX;
package kr.pe.kwonnam.hibernate4memcached.regions; /** * @author KwonNam Son ([email protected]) */ public class GeneralDataMemcachedRegion extends MemcachedRegion implements GeneralDataRegion { private Logger log = LoggerFactory.getLogger(GeneralDataMemcachedRegion.class); private int expirySeconds; public GeneralDataMemcachedRegion(CacheNamespace cacheNamespace, OverridableReadOnlyProperties properties, CacheDataDescription metadata,
// Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/memcached/CacheNamespace.java // public class CacheNamespace implements Serializable { // /** // * name of region // */ // private String name; // // /** // * if this value is true, the memcached adapter should implement namespace pattern // * or ignore namespace pattern. // * <p/> // * see <a href="https://code.google.com/p/memcached/wiki/NewProgrammingTricks#Namespacing">Memcached Namespacing</a> // */ // private boolean namespaceExpirationRequired; // // public CacheNamespace(String name, boolean namespaceExpirationRequired) { // this.name = name; // this.namespaceExpirationRequired = namespaceExpirationRequired; // } // // public String getName() { // return name; // } // // public boolean isNamespaceExpirationRequired() { // return namespaceExpirationRequired; // } // // @Override // public boolean equals(Object o) { // if (o == null) { // return false; // } // if (this == o) { // return true; // } // if (getClass() != o.getClass()) { // return false; // } // // CacheNamespace otherCacheNamespace = (CacheNamespace) o; // // return new EqualsBuilder().append(name, otherCacheNamespace.name) // .append(namespaceExpirationRequired, otherCacheNamespace.namespaceExpirationRequired).isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder().append(name).append(namespaceExpirationRequired).toHashCode(); // } // // @Override // public String toString() { // return new ToStringBuilder(this).append("name", name).append("namespaceExpirationRequired", namespaceExpirationRequired).toString(); // } // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/memcached/MemcachedAdapter.java // public interface MemcachedAdapter { // /** // * Lifecycle callback to perform initialization. // * // * @param properties the defined cfg properties // */ // void init(OverridableReadOnlyProperties properties); // // /** // * Lifecycle callback to perform cleanup. // */ // void destroy(); // // /** // * get value from memcached // */ // Object get(CacheNamespace cacheNamespace, String key); // // /** // * set value to memcache with expirySeconds // */ // void set(CacheNamespace cacheNamespace, String key, Object value, int expirySeconds); // // /** // * delete key from memcached // */ // void delete(CacheNamespace cacheNamespace, String key); // // /** // * increase given increment couter and return new value. // * // * @param cacheNamespace cache namespace // * @param key counter key // * @param by the amount of increment // * @param defaultValue default value when the key missing // * @return increased value // */ // long increaseCounter(CacheNamespace cacheNamespace, String key, long by, long defaultValue, int expirySeconds); // // /** // * get current value from increment counter // * // * @param cacheNamespace cache namespace // * @param key counter key // * @param defaultValue default value when the key missing // * @return current value of counter without increment // */ // long getCounter(CacheNamespace cacheNamespace, String key, long defaultValue, int expirySeconds); // // /** // * Evict namespace // * // * @param cacheNamespace cache namespace // */ // void evictAll(CacheNamespace cacheNamespace); // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/timestamper/HibernateCacheTimestamper.java // public interface HibernateCacheTimestamper { // // void setSettings(Settings settings); // // void setProperties(OverridableReadOnlyProperties properties); // // void setMemcachedAdapter(MemcachedAdapter memcachedAdapter); // // /** initialize timestamp object */ // void init(); // // /** get next timestamp */ // long next(); // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/util/OverridableReadOnlyProperties.java // public interface OverridableReadOnlyProperties { // String getProperty(String key); // // String getProperty(String key, String defaultValue); // // String getRequiredProperty(String key); // } // // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/Hibernate4MemcachedRegionFactory.java // public static final String REGION_EXPIRY_SECONDS_PROPERTY_KEY_PREFIX = "h4m.expiry.seconds"; // Path: hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/regions/GeneralDataMemcachedRegion.java import kr.pe.kwonnam.hibernate4memcached.memcached.CacheNamespace; import kr.pe.kwonnam.hibernate4memcached.memcached.MemcachedAdapter; import kr.pe.kwonnam.hibernate4memcached.timestamper.HibernateCacheTimestamper; import kr.pe.kwonnam.hibernate4memcached.util.OverridableReadOnlyProperties; import org.hibernate.cache.CacheException; import org.hibernate.cache.spi.CacheDataDescription; import org.hibernate.cache.spi.GeneralDataRegion; import org.hibernate.cfg.Settings; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import static kr.pe.kwonnam.hibernate4memcached.Hibernate4MemcachedRegionFactory.REGION_EXPIRY_SECONDS_PROPERTY_KEY_PREFIX; package kr.pe.kwonnam.hibernate4memcached.regions; /** * @author KwonNam Son ([email protected]) */ public class GeneralDataMemcachedRegion extends MemcachedRegion implements GeneralDataRegion { private Logger log = LoggerFactory.getLogger(GeneralDataMemcachedRegion.class); private int expirySeconds; public GeneralDataMemcachedRegion(CacheNamespace cacheNamespace, OverridableReadOnlyProperties properties, CacheDataDescription metadata,
Settings settings, MemcachedAdapter memcachedAdapter, HibernateCacheTimestamper hibernateCacheTimestamper) {
headwirecom/aem-solr-search
aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/solr/index/DefaultSolrIndexListenerService.java
// Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaContentType.java // public interface GeometrixxMediaContentType { // // JSONObject getJson(); // // SolrInputDocument getSolrDoc(); // // } // // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaPage.java // @Model(adaptables = Resource.class, adapters = {GeometrixxMediaContentType.class, GeometrixxMediaPage.class}) // public class GeometrixxMediaPage implements GeometrixxMediaContentType{ // // private static final Logger LOG = LoggerFactory.getLogger(GeometrixxMediaPage.class); // // private GeometrixxMediaPageContent pageContent; // // @Inject @Named("jcr:content") // private Resource jcrResource; // // @PostConstruct // public void init() throws SlingModelsException { // // pageContent = jcrResource.adaptTo(GeometrixxMediaPageContent.class); // // } // // public GeometrixxMediaPage(Resource resource) throws SlingModelsException { // // if (null == resource) { // LOG.debug("resource is null"); // throw new SlingModelsException("Resource is null"); // } // // if (ResourceUtil.isNonExistingResource(resource)) { // LOG.warn("Can't adapt non existent resource: '{}'", resource.getPath()); // throw new SlingModelsException( // "Can't adapt non existent resource." + resource.getPath()); // } // // } // // @Override // public String toString() { // // final StringBuilder sb = new StringBuilder("GeometrixxMediaPage{"); // if(null != pageContent){ // sb.append(pageContent.toString()); // } // sb.append('}'); // return sb.toString(); // } // // @Override // public JSONObject getJson() { // // return pageContent != null ? pageContent.getJson() : new JSONObject(); // } // // @Override // public SolrInputDocument getSolrDoc() { // // return pageContent != null ? pageContent.getSolrDoc() : null; // } // }
import com.day.cq.replication.ReplicationAction; import com.day.cq.wcm.api.PageEvent; import com.day.cq.wcm.api.PageModification; import com.headwire.aemsolrsearch.geometrixxmedia.model.GeometrixxMediaContentType; import com.headwire.aemsolrsearch.geometrixxmedia.model.GeometrixxMediaPage; import org.apache.felix.scr.annotations.*; import org.apache.sling.api.resource.*; import org.osgi.service.event.Event; import org.osgi.service.event.EventHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Iterator; import java.util.Map;
LOG.info("Page '{}' is in observed path '{}'", pagePath, observedPath); return true; } } return false; } protected boolean pageIsNotInObservedPath(String pagePath) { return !pageIsInObservedPath(pagePath); } protected void addOrUpdatePage(PageModification modification) { // We need to add the correct page for the add/update. On page moves, we need to use the destination. final String modificationPath = (modification.getType() == PageModification.ModificationType.MOVED) ? modification.getDestination() : modification.getPath(); if (null == resourceResolver) { LOG.warn("Can't perform indexing operation for '{}'", modificationPath); return; } final Resource resource = resourceResolver.getResource(modificationPath); if (ResourceUtil.isNonExistingResource(resource)) { LOG.warn("Can't perform indexing operation for '{}'. Resource does not exist.", modificationPath); return; }
// Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaContentType.java // public interface GeometrixxMediaContentType { // // JSONObject getJson(); // // SolrInputDocument getSolrDoc(); // // } // // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaPage.java // @Model(adaptables = Resource.class, adapters = {GeometrixxMediaContentType.class, GeometrixxMediaPage.class}) // public class GeometrixxMediaPage implements GeometrixxMediaContentType{ // // private static final Logger LOG = LoggerFactory.getLogger(GeometrixxMediaPage.class); // // private GeometrixxMediaPageContent pageContent; // // @Inject @Named("jcr:content") // private Resource jcrResource; // // @PostConstruct // public void init() throws SlingModelsException { // // pageContent = jcrResource.adaptTo(GeometrixxMediaPageContent.class); // // } // // public GeometrixxMediaPage(Resource resource) throws SlingModelsException { // // if (null == resource) { // LOG.debug("resource is null"); // throw new SlingModelsException("Resource is null"); // } // // if (ResourceUtil.isNonExistingResource(resource)) { // LOG.warn("Can't adapt non existent resource: '{}'", resource.getPath()); // throw new SlingModelsException( // "Can't adapt non existent resource." + resource.getPath()); // } // // } // // @Override // public String toString() { // // final StringBuilder sb = new StringBuilder("GeometrixxMediaPage{"); // if(null != pageContent){ // sb.append(pageContent.toString()); // } // sb.append('}'); // return sb.toString(); // } // // @Override // public JSONObject getJson() { // // return pageContent != null ? pageContent.getJson() : new JSONObject(); // } // // @Override // public SolrInputDocument getSolrDoc() { // // return pageContent != null ? pageContent.getSolrDoc() : null; // } // } // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/solr/index/DefaultSolrIndexListenerService.java import com.day.cq.replication.ReplicationAction; import com.day.cq.wcm.api.PageEvent; import com.day.cq.wcm.api.PageModification; import com.headwire.aemsolrsearch.geometrixxmedia.model.GeometrixxMediaContentType; import com.headwire.aemsolrsearch.geometrixxmedia.model.GeometrixxMediaPage; import org.apache.felix.scr.annotations.*; import org.apache.sling.api.resource.*; import org.osgi.service.event.Event; import org.osgi.service.event.EventHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Iterator; import java.util.Map; LOG.info("Page '{}' is in observed path '{}'", pagePath, observedPath); return true; } } return false; } protected boolean pageIsNotInObservedPath(String pagePath) { return !pageIsInObservedPath(pagePath); } protected void addOrUpdatePage(PageModification modification) { // We need to add the correct page for the add/update. On page moves, we need to use the destination. final String modificationPath = (modification.getType() == PageModification.ModificationType.MOVED) ? modification.getDestination() : modification.getPath(); if (null == resourceResolver) { LOG.warn("Can't perform indexing operation for '{}'", modificationPath); return; } final Resource resource = resourceResolver.getResource(modificationPath); if (ResourceUtil.isNonExistingResource(resource)) { LOG.warn("Can't perform indexing operation for '{}'. Resource does not exist.", modificationPath); return; }
GeometrixxMediaContentType contentPage = resource.adaptTo(GeometrixxMediaPage.class);
headwirecom/aem-solr-search
aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/solr/index/DefaultSolrIndexListenerService.java
// Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaContentType.java // public interface GeometrixxMediaContentType { // // JSONObject getJson(); // // SolrInputDocument getSolrDoc(); // // } // // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaPage.java // @Model(adaptables = Resource.class, adapters = {GeometrixxMediaContentType.class, GeometrixxMediaPage.class}) // public class GeometrixxMediaPage implements GeometrixxMediaContentType{ // // private static final Logger LOG = LoggerFactory.getLogger(GeometrixxMediaPage.class); // // private GeometrixxMediaPageContent pageContent; // // @Inject @Named("jcr:content") // private Resource jcrResource; // // @PostConstruct // public void init() throws SlingModelsException { // // pageContent = jcrResource.adaptTo(GeometrixxMediaPageContent.class); // // } // // public GeometrixxMediaPage(Resource resource) throws SlingModelsException { // // if (null == resource) { // LOG.debug("resource is null"); // throw new SlingModelsException("Resource is null"); // } // // if (ResourceUtil.isNonExistingResource(resource)) { // LOG.warn("Can't adapt non existent resource: '{}'", resource.getPath()); // throw new SlingModelsException( // "Can't adapt non existent resource." + resource.getPath()); // } // // } // // @Override // public String toString() { // // final StringBuilder sb = new StringBuilder("GeometrixxMediaPage{"); // if(null != pageContent){ // sb.append(pageContent.toString()); // } // sb.append('}'); // return sb.toString(); // } // // @Override // public JSONObject getJson() { // // return pageContent != null ? pageContent.getJson() : new JSONObject(); // } // // @Override // public SolrInputDocument getSolrDoc() { // // return pageContent != null ? pageContent.getSolrDoc() : null; // } // }
import com.day.cq.replication.ReplicationAction; import com.day.cq.wcm.api.PageEvent; import com.day.cq.wcm.api.PageModification; import com.headwire.aemsolrsearch.geometrixxmedia.model.GeometrixxMediaContentType; import com.headwire.aemsolrsearch.geometrixxmedia.model.GeometrixxMediaPage; import org.apache.felix.scr.annotations.*; import org.apache.sling.api.resource.*; import org.osgi.service.event.Event; import org.osgi.service.event.EventHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Iterator; import java.util.Map;
LOG.info("Page '{}' is in observed path '{}'", pagePath, observedPath); return true; } } return false; } protected boolean pageIsNotInObservedPath(String pagePath) { return !pageIsInObservedPath(pagePath); } protected void addOrUpdatePage(PageModification modification) { // We need to add the correct page for the add/update. On page moves, we need to use the destination. final String modificationPath = (modification.getType() == PageModification.ModificationType.MOVED) ? modification.getDestination() : modification.getPath(); if (null == resourceResolver) { LOG.warn("Can't perform indexing operation for '{}'", modificationPath); return; } final Resource resource = resourceResolver.getResource(modificationPath); if (ResourceUtil.isNonExistingResource(resource)) { LOG.warn("Can't perform indexing operation for '{}'. Resource does not exist.", modificationPath); return; }
// Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaContentType.java // public interface GeometrixxMediaContentType { // // JSONObject getJson(); // // SolrInputDocument getSolrDoc(); // // } // // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaPage.java // @Model(adaptables = Resource.class, adapters = {GeometrixxMediaContentType.class, GeometrixxMediaPage.class}) // public class GeometrixxMediaPage implements GeometrixxMediaContentType{ // // private static final Logger LOG = LoggerFactory.getLogger(GeometrixxMediaPage.class); // // private GeometrixxMediaPageContent pageContent; // // @Inject @Named("jcr:content") // private Resource jcrResource; // // @PostConstruct // public void init() throws SlingModelsException { // // pageContent = jcrResource.adaptTo(GeometrixxMediaPageContent.class); // // } // // public GeometrixxMediaPage(Resource resource) throws SlingModelsException { // // if (null == resource) { // LOG.debug("resource is null"); // throw new SlingModelsException("Resource is null"); // } // // if (ResourceUtil.isNonExistingResource(resource)) { // LOG.warn("Can't adapt non existent resource: '{}'", resource.getPath()); // throw new SlingModelsException( // "Can't adapt non existent resource." + resource.getPath()); // } // // } // // @Override // public String toString() { // // final StringBuilder sb = new StringBuilder("GeometrixxMediaPage{"); // if(null != pageContent){ // sb.append(pageContent.toString()); // } // sb.append('}'); // return sb.toString(); // } // // @Override // public JSONObject getJson() { // // return pageContent != null ? pageContent.getJson() : new JSONObject(); // } // // @Override // public SolrInputDocument getSolrDoc() { // // return pageContent != null ? pageContent.getSolrDoc() : null; // } // } // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/solr/index/DefaultSolrIndexListenerService.java import com.day.cq.replication.ReplicationAction; import com.day.cq.wcm.api.PageEvent; import com.day.cq.wcm.api.PageModification; import com.headwire.aemsolrsearch.geometrixxmedia.model.GeometrixxMediaContentType; import com.headwire.aemsolrsearch.geometrixxmedia.model.GeometrixxMediaPage; import org.apache.felix.scr.annotations.*; import org.apache.sling.api.resource.*; import org.osgi.service.event.Event; import org.osgi.service.event.EventHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Iterator; import java.util.Map; LOG.info("Page '{}' is in observed path '{}'", pagePath, observedPath); return true; } } return false; } protected boolean pageIsNotInObservedPath(String pagePath) { return !pageIsInObservedPath(pagePath); } protected void addOrUpdatePage(PageModification modification) { // We need to add the correct page for the add/update. On page moves, we need to use the destination. final String modificationPath = (modification.getType() == PageModification.ModificationType.MOVED) ? modification.getDestination() : modification.getPath(); if (null == resourceResolver) { LOG.warn("Can't perform indexing operation for '{}'", modificationPath); return; } final Resource resource = resourceResolver.getResource(modificationPath); if (ResourceUtil.isNonExistingResource(resource)) { LOG.warn("Can't perform indexing operation for '{}'. Resource does not exist.", modificationPath); return; }
GeometrixxMediaContentType contentPage = resource.adaptTo(GeometrixxMediaPage.class);
headwirecom/aem-solr-search
aemsolrsearch-services/src/main/java/com/headwire/aemsolrsearch/services/servlets/ProxyServlet.java
// Path: aemsolrsearch-services/src/main/java/com/headwire/aemsolrsearch/services/ProxyConfigurationService.java // @Component( // name = "com.headwire.aemsolrsearch.services.ProxyConfigurationService", // label = "AEM Solr Search - Solr Proxy Service", // description = "A service for configuring the search proxy", // immediate = true, // metatype = true) // @Service(ProxyConfigurationService.class) // @Properties({ // @Property( // name = Constants.SERVICE_VENDOR, // value = "headwire.com, Inc."), // @Property( // name = Constants.SERVICE_DESCRIPTION, // value = "CQ Search proxy configuration service"), // @Property( // name = ProxyConfigurationServiceAdminConstants.HTTP_CONN_TIMEOUT, // intValue = 10000, // label = "Connection Timeout", // description = "Connection timeout in ms"), // @Property( // name = ProxyConfigurationServiceAdminConstants.HTTP_SO_TIMEOUT, // intValue = 30000, // label = "Socket Timeout", // description = "Socket timeout in ms") // }) // /** // * ProxyConfigurationService provides services for setting and getting proxy configuration information. // */ // public class ProxyConfigurationService { // // private static final Logger LOG = LoggerFactory.getLogger(ProxyConfigurationService.class); // private Integer httpConnTimeout; // private Integer httpSoTimeout; // // public static final Integer DEFAULT_HTTP_CONN_TIMEOUT = 10000; // public static final Integer DEFAULT_HTTP_SO_TIMEOUT= 30000; // // public Integer getHttpConnTimeout() { // return httpConnTimeout; // } // // public Integer getHttpSoTimeout() { // return httpSoTimeout; // } // // @Activate // protected void activate(final Map<String, Object> config) { // resetService(config); // } // // @Modified // protected void modified(final Map<String, Object> config) { // resetService(config); // } // // private synchronized void resetService(final Map<String, Object> config) { // LOG.info("Resetting CQ Search proxy configuration service using configuration: " + config); // // httpConnTimeout = config.containsKey(ProxyConfigurationServiceAdminConstants.HTTP_CONN_TIMEOUT) ? // (Integer)config.get(ProxyConfigurationServiceAdminConstants.HTTP_CONN_TIMEOUT) : DEFAULT_HTTP_CONN_TIMEOUT; // // httpSoTimeout = config.containsKey(ProxyConfigurationServiceAdminConstants.HTTP_SO_TIMEOUT) ? // (Integer)config.get(ProxyConfigurationServiceAdminConstants.HTTP_SO_TIMEOUT) : DEFAULT_HTTP_SO_TIMEOUT; // } // }
import com.headwire.aemsolrsearch.services.ProxyConfigurationService; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Reference; import org.apache.http.*; import org.apache.http.client.HttpClient; import org.apache.http.client.utils.URIUtils; import org.apache.http.entity.InputStreamEntity; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.conn.PoolingClientConnectionManager; import org.apache.http.message.BasicHeader; import org.apache.http.message.BasicHttpEntityEnclosingRequest; import org.apache.http.message.BasicHttpRequest; import org.apache.http.message.HeaderGroup; import org.apache.http.params.BasicHttpParams; import org.apache.http.params.CoreConnectionPNames; import org.apache.http.params.HttpParams; import org.apache.http.util.EntityUtils; import org.apache.sling.api.SlingHttpServletRequest; import org.apache.sling.api.SlingHttpServletResponse; import org.apache.sling.api.servlets.SlingSafeMethodsServlet; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.Closeable; import java.io.IOException; import java.io.OutputStream; import java.io.PrintWriter; import java.net.URI; import java.util.BitSet; import java.util.Enumeration; import java.util.Formatter;
/* * Author : Gaston Gonzalez * Date : 8/12/13 * Version : $Id$ */ package com.headwire.aemsolrsearch.services.servlets; @Component(componentAbstract = true) /** * ProxyServlet provides a basic proxy. It is based on David Smiley's HTTP-Proxy-Servlet * (https://github.com/dsmiley/HTTP-Proxy-Servlet). */ public abstract class ProxyServlet extends SlingSafeMethodsServlet { private static final Logger LOG = LoggerFactory.getLogger(ProxyServlet.class); protected HttpClient proxyClient; protected URI targetUri; @Reference
// Path: aemsolrsearch-services/src/main/java/com/headwire/aemsolrsearch/services/ProxyConfigurationService.java // @Component( // name = "com.headwire.aemsolrsearch.services.ProxyConfigurationService", // label = "AEM Solr Search - Solr Proxy Service", // description = "A service for configuring the search proxy", // immediate = true, // metatype = true) // @Service(ProxyConfigurationService.class) // @Properties({ // @Property( // name = Constants.SERVICE_VENDOR, // value = "headwire.com, Inc."), // @Property( // name = Constants.SERVICE_DESCRIPTION, // value = "CQ Search proxy configuration service"), // @Property( // name = ProxyConfigurationServiceAdminConstants.HTTP_CONN_TIMEOUT, // intValue = 10000, // label = "Connection Timeout", // description = "Connection timeout in ms"), // @Property( // name = ProxyConfigurationServiceAdminConstants.HTTP_SO_TIMEOUT, // intValue = 30000, // label = "Socket Timeout", // description = "Socket timeout in ms") // }) // /** // * ProxyConfigurationService provides services for setting and getting proxy configuration information. // */ // public class ProxyConfigurationService { // // private static final Logger LOG = LoggerFactory.getLogger(ProxyConfigurationService.class); // private Integer httpConnTimeout; // private Integer httpSoTimeout; // // public static final Integer DEFAULT_HTTP_CONN_TIMEOUT = 10000; // public static final Integer DEFAULT_HTTP_SO_TIMEOUT= 30000; // // public Integer getHttpConnTimeout() { // return httpConnTimeout; // } // // public Integer getHttpSoTimeout() { // return httpSoTimeout; // } // // @Activate // protected void activate(final Map<String, Object> config) { // resetService(config); // } // // @Modified // protected void modified(final Map<String, Object> config) { // resetService(config); // } // // private synchronized void resetService(final Map<String, Object> config) { // LOG.info("Resetting CQ Search proxy configuration service using configuration: " + config); // // httpConnTimeout = config.containsKey(ProxyConfigurationServiceAdminConstants.HTTP_CONN_TIMEOUT) ? // (Integer)config.get(ProxyConfigurationServiceAdminConstants.HTTP_CONN_TIMEOUT) : DEFAULT_HTTP_CONN_TIMEOUT; // // httpSoTimeout = config.containsKey(ProxyConfigurationServiceAdminConstants.HTTP_SO_TIMEOUT) ? // (Integer)config.get(ProxyConfigurationServiceAdminConstants.HTTP_SO_TIMEOUT) : DEFAULT_HTTP_SO_TIMEOUT; // } // } // Path: aemsolrsearch-services/src/main/java/com/headwire/aemsolrsearch/services/servlets/ProxyServlet.java import com.headwire.aemsolrsearch.services.ProxyConfigurationService; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Reference; import org.apache.http.*; import org.apache.http.client.HttpClient; import org.apache.http.client.utils.URIUtils; import org.apache.http.entity.InputStreamEntity; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.conn.PoolingClientConnectionManager; import org.apache.http.message.BasicHeader; import org.apache.http.message.BasicHttpEntityEnclosingRequest; import org.apache.http.message.BasicHttpRequest; import org.apache.http.message.HeaderGroup; import org.apache.http.params.BasicHttpParams; import org.apache.http.params.CoreConnectionPNames; import org.apache.http.params.HttpParams; import org.apache.http.util.EntityUtils; import org.apache.sling.api.SlingHttpServletRequest; import org.apache.sling.api.SlingHttpServletResponse; import org.apache.sling.api.servlets.SlingSafeMethodsServlet; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.Closeable; import java.io.IOException; import java.io.OutputStream; import java.io.PrintWriter; import java.net.URI; import java.util.BitSet; import java.util.Enumeration; import java.util.Formatter; /* * Author : Gaston Gonzalez * Date : 8/12/13 * Version : $Id$ */ package com.headwire.aemsolrsearch.services.servlets; @Component(componentAbstract = true) /** * ProxyServlet provides a basic proxy. It is based on David Smiley's HTTP-Proxy-Servlet * (https://github.com/dsmiley/HTTP-Proxy-Servlet). */ public abstract class ProxyServlet extends SlingSafeMethodsServlet { private static final Logger LOG = LoggerFactory.getLogger(ProxyServlet.class); protected HttpClient proxyClient; protected URI targetUri; @Reference
protected ProxyConfigurationService proxyConfigurationService;
headwirecom/aem-solr-search
aemsolrsearch-taglib/src/main/java/com/headwire/aemsolrsearch/taglib/SolrSearchTag.java
// Path: aemsolrsearch-search-service/src/main/java/com/headwire/aemsolrsearch/search/services/AbstractSolrSearchService.java // public abstract class AbstractSolrSearchService extends AbstractSolrService { // // private static final Logger LOG = LoggerFactory.getLogger(AbstractSolrSearchService.class); // // /** // * Query a particular instance of SolrServer identified by the core name // * with a given query. // */ // public QueryResponse query(String solrCore, SolrQuery solrQuery) throws SolrServerException { // SolrClient server = getSolrQueryClient(); // LOG.info("Quering {} with '{}'", getSolrServerURI(solrCore), solrQuery); // QueryResponse solrResponse; // try { // solrResponse = server.query(solrCore, solrQuery); // return solrResponse; // } catch (IOException e) { // e.printStackTrace(); // } // return new QueryResponse(); // } // // } // // Path: aemsolrsearch-search-service/src/main/java/com/headwire/aemsolrsearch/search/services/DefaultSolrSearchService.java // @Component( // name = "com.headwire.aemsolrsearch.search.services.DefaultSolrSearchService", // label = "AEM Solr Search - Solr Search Service", // description = "A service for performing searches against Solr", // immediate = true, // metatype = true) // @Service(DefaultSolrSearchService.class) // @Properties({ // @Property( // name = Constants.SERVICE_VENDOR, // value = "headwire.com, Inc."), // @Property( // name = Constants.SERVICE_DESCRIPTION, // value = "A default implementation of the Solr.search.service") // }) // /** // * DefaultSolrSearchService is responsible for obtaining the uri for a particular solr instance identified by a core. // */ // public class DefaultSolrSearchService extends AbstractSolrSearchService { // // private static final Logger LOG = LoggerFactory.getLogger(DefaultSolrSearchService.class); // // @Reference // SolrConfigurationService solrConfigService; // // @Activate // protected void activate(final Map<String, String> config) { // resetService(config); // } // // @Modified // protected void modified(final Map<String, String> config) { // resetService(config); // } // // @Override // protected String getSolrServerURI() { // assertSolrConfigService(); // return solrConfigService.getSolrEndPoint(); // } // // @Override // protected String getSolrServerURI(String solrCore) { // assertSolrConfigService(); // return formatSolrEndPointAndCore(solrConfigService.getSolrEndPoint(), solrCore); // } // // @Override // protected SolrClient getSolrIndexClient() { // return solrConfigService.getIndexingSolrClient(); // } // // @Override // protected SolrClient getSolrQueryClient() { // return solrConfigService.getQueryingSolrClient(); // } // // private void resetService(final Map<String, String> config) { // LOG.info("Resetting Solr search service using configuration: " + config); // } // // private void assertSolrConfigService() throws IllegalStateException { // if (null == solrConfigService) { // LOG.error("Can't get SolrConfigurationService. Check that all OSGi bundles are active"); // throw new IllegalStateException("No solr configuration service."); // } // } // }
import java.io.IOException; import java.util.Arrays; import java.util.HashSet; import java.util.Set; import javax.servlet.jsp.JspException; import org.apache.commons.lang.StringUtils; import org.apache.solr.client.solrj.SolrQuery; import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.response.QueryResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.cqblueprints.taglib.CqSimpleTagSupport; import com.headwire.aemsolrsearch.search.services.AbstractSolrSearchService; import com.headwire.aemsolrsearch.search.services.DefaultSolrSearchService; import com.squeakysand.jsp.tagext.annotations.JspTag; import com.squeakysand.jsp.tagext.annotations.JspTagAttribute;
package com.headwire.aemsolrsearch.taglib; /** * Tag used to build SolrQuery, call the SolrSearchService, and store results. */ @JspTag public class SolrSearchTag extends CqSimpleTagSupport { private static final Logger LOG = LoggerFactory .getLogger(SolrSearchTag.class); private SolrQuery solrQuery; /** Name to retrieve this object in JSP/Servlet in page scope. */ private String var; /** Name to retrieve the SolrSearchResult object in JSP/Servlet in page scope. */ private String varResults; // Set by user private String query; private int start = 0; private String[] filterQueries; // Set by author private String solrCoreName; private int rows = 0; private String[] fieldNames; private String[] advancedFilterQueries; private boolean facetEnabled; private String facetSort; private int facetLimit; private int facetMinCount; private String[] facetFieldNames; private boolean highlightEnabled; private boolean highlightRequireFieldMatchEnabled; private String highlightSimplePre; private String highlightSimplePost; private int highlightNumberSnippets; private int highlightFragsize; private String[] highlightingFields; private String searchHandler; private String sort; private String sortDir; @Override public void doTag() throws JspException, IOException { // Make this tag object available to the JSP/Servlet scope. if (StringUtils.isNotBlank(getVar())) { getPageContext().setAttribute(getVar(), this); // getRequest().setAttribute(getVar(), this); } // Get Solr Service
// Path: aemsolrsearch-search-service/src/main/java/com/headwire/aemsolrsearch/search/services/AbstractSolrSearchService.java // public abstract class AbstractSolrSearchService extends AbstractSolrService { // // private static final Logger LOG = LoggerFactory.getLogger(AbstractSolrSearchService.class); // // /** // * Query a particular instance of SolrServer identified by the core name // * with a given query. // */ // public QueryResponse query(String solrCore, SolrQuery solrQuery) throws SolrServerException { // SolrClient server = getSolrQueryClient(); // LOG.info("Quering {} with '{}'", getSolrServerURI(solrCore), solrQuery); // QueryResponse solrResponse; // try { // solrResponse = server.query(solrCore, solrQuery); // return solrResponse; // } catch (IOException e) { // e.printStackTrace(); // } // return new QueryResponse(); // } // // } // // Path: aemsolrsearch-search-service/src/main/java/com/headwire/aemsolrsearch/search/services/DefaultSolrSearchService.java // @Component( // name = "com.headwire.aemsolrsearch.search.services.DefaultSolrSearchService", // label = "AEM Solr Search - Solr Search Service", // description = "A service for performing searches against Solr", // immediate = true, // metatype = true) // @Service(DefaultSolrSearchService.class) // @Properties({ // @Property( // name = Constants.SERVICE_VENDOR, // value = "headwire.com, Inc."), // @Property( // name = Constants.SERVICE_DESCRIPTION, // value = "A default implementation of the Solr.search.service") // }) // /** // * DefaultSolrSearchService is responsible for obtaining the uri for a particular solr instance identified by a core. // */ // public class DefaultSolrSearchService extends AbstractSolrSearchService { // // private static final Logger LOG = LoggerFactory.getLogger(DefaultSolrSearchService.class); // // @Reference // SolrConfigurationService solrConfigService; // // @Activate // protected void activate(final Map<String, String> config) { // resetService(config); // } // // @Modified // protected void modified(final Map<String, String> config) { // resetService(config); // } // // @Override // protected String getSolrServerURI() { // assertSolrConfigService(); // return solrConfigService.getSolrEndPoint(); // } // // @Override // protected String getSolrServerURI(String solrCore) { // assertSolrConfigService(); // return formatSolrEndPointAndCore(solrConfigService.getSolrEndPoint(), solrCore); // } // // @Override // protected SolrClient getSolrIndexClient() { // return solrConfigService.getIndexingSolrClient(); // } // // @Override // protected SolrClient getSolrQueryClient() { // return solrConfigService.getQueryingSolrClient(); // } // // private void resetService(final Map<String, String> config) { // LOG.info("Resetting Solr search service using configuration: " + config); // } // // private void assertSolrConfigService() throws IllegalStateException { // if (null == solrConfigService) { // LOG.error("Can't get SolrConfigurationService. Check that all OSGi bundles are active"); // throw new IllegalStateException("No solr configuration service."); // } // } // } // Path: aemsolrsearch-taglib/src/main/java/com/headwire/aemsolrsearch/taglib/SolrSearchTag.java import java.io.IOException; import java.util.Arrays; import java.util.HashSet; import java.util.Set; import javax.servlet.jsp.JspException; import org.apache.commons.lang.StringUtils; import org.apache.solr.client.solrj.SolrQuery; import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.response.QueryResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.cqblueprints.taglib.CqSimpleTagSupport; import com.headwire.aemsolrsearch.search.services.AbstractSolrSearchService; import com.headwire.aemsolrsearch.search.services.DefaultSolrSearchService; import com.squeakysand.jsp.tagext.annotations.JspTag; import com.squeakysand.jsp.tagext.annotations.JspTagAttribute; package com.headwire.aemsolrsearch.taglib; /** * Tag used to build SolrQuery, call the SolrSearchService, and store results. */ @JspTag public class SolrSearchTag extends CqSimpleTagSupport { private static final Logger LOG = LoggerFactory .getLogger(SolrSearchTag.class); private SolrQuery solrQuery; /** Name to retrieve this object in JSP/Servlet in page scope. */ private String var; /** Name to retrieve the SolrSearchResult object in JSP/Servlet in page scope. */ private String varResults; // Set by user private String query; private int start = 0; private String[] filterQueries; // Set by author private String solrCoreName; private int rows = 0; private String[] fieldNames; private String[] advancedFilterQueries; private boolean facetEnabled; private String facetSort; private int facetLimit; private int facetMinCount; private String[] facetFieldNames; private boolean highlightEnabled; private boolean highlightRequireFieldMatchEnabled; private String highlightSimplePre; private String highlightSimplePost; private int highlightNumberSnippets; private int highlightFragsize; private String[] highlightingFields; private String searchHandler; private String sort; private String sortDir; @Override public void doTag() throws JspException, IOException { // Make this tag object available to the JSP/Servlet scope. if (StringUtils.isNotBlank(getVar())) { getPageContext().setAttribute(getVar(), this); // getRequest().setAttribute(getVar(), this); } // Get Solr Service
AbstractSolrSearchService searchService = null;
headwirecom/aem-solr-search
aemsolrsearch-taglib/src/main/java/com/headwire/aemsolrsearch/taglib/SolrSearchTag.java
// Path: aemsolrsearch-search-service/src/main/java/com/headwire/aemsolrsearch/search/services/AbstractSolrSearchService.java // public abstract class AbstractSolrSearchService extends AbstractSolrService { // // private static final Logger LOG = LoggerFactory.getLogger(AbstractSolrSearchService.class); // // /** // * Query a particular instance of SolrServer identified by the core name // * with a given query. // */ // public QueryResponse query(String solrCore, SolrQuery solrQuery) throws SolrServerException { // SolrClient server = getSolrQueryClient(); // LOG.info("Quering {} with '{}'", getSolrServerURI(solrCore), solrQuery); // QueryResponse solrResponse; // try { // solrResponse = server.query(solrCore, solrQuery); // return solrResponse; // } catch (IOException e) { // e.printStackTrace(); // } // return new QueryResponse(); // } // // } // // Path: aemsolrsearch-search-service/src/main/java/com/headwire/aemsolrsearch/search/services/DefaultSolrSearchService.java // @Component( // name = "com.headwire.aemsolrsearch.search.services.DefaultSolrSearchService", // label = "AEM Solr Search - Solr Search Service", // description = "A service for performing searches against Solr", // immediate = true, // metatype = true) // @Service(DefaultSolrSearchService.class) // @Properties({ // @Property( // name = Constants.SERVICE_VENDOR, // value = "headwire.com, Inc."), // @Property( // name = Constants.SERVICE_DESCRIPTION, // value = "A default implementation of the Solr.search.service") // }) // /** // * DefaultSolrSearchService is responsible for obtaining the uri for a particular solr instance identified by a core. // */ // public class DefaultSolrSearchService extends AbstractSolrSearchService { // // private static final Logger LOG = LoggerFactory.getLogger(DefaultSolrSearchService.class); // // @Reference // SolrConfigurationService solrConfigService; // // @Activate // protected void activate(final Map<String, String> config) { // resetService(config); // } // // @Modified // protected void modified(final Map<String, String> config) { // resetService(config); // } // // @Override // protected String getSolrServerURI() { // assertSolrConfigService(); // return solrConfigService.getSolrEndPoint(); // } // // @Override // protected String getSolrServerURI(String solrCore) { // assertSolrConfigService(); // return formatSolrEndPointAndCore(solrConfigService.getSolrEndPoint(), solrCore); // } // // @Override // protected SolrClient getSolrIndexClient() { // return solrConfigService.getIndexingSolrClient(); // } // // @Override // protected SolrClient getSolrQueryClient() { // return solrConfigService.getQueryingSolrClient(); // } // // private void resetService(final Map<String, String> config) { // LOG.info("Resetting Solr search service using configuration: " + config); // } // // private void assertSolrConfigService() throws IllegalStateException { // if (null == solrConfigService) { // LOG.error("Can't get SolrConfigurationService. Check that all OSGi bundles are active"); // throw new IllegalStateException("No solr configuration service."); // } // } // }
import java.io.IOException; import java.util.Arrays; import java.util.HashSet; import java.util.Set; import javax.servlet.jsp.JspException; import org.apache.commons.lang.StringUtils; import org.apache.solr.client.solrj.SolrQuery; import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.response.QueryResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.cqblueprints.taglib.CqSimpleTagSupport; import com.headwire.aemsolrsearch.search.services.AbstractSolrSearchService; import com.headwire.aemsolrsearch.search.services.DefaultSolrSearchService; import com.squeakysand.jsp.tagext.annotations.JspTag; import com.squeakysand.jsp.tagext.annotations.JspTagAttribute;
package com.headwire.aemsolrsearch.taglib; /** * Tag used to build SolrQuery, call the SolrSearchService, and store results. */ @JspTag public class SolrSearchTag extends CqSimpleTagSupport { private static final Logger LOG = LoggerFactory .getLogger(SolrSearchTag.class); private SolrQuery solrQuery; /** Name to retrieve this object in JSP/Servlet in page scope. */ private String var; /** Name to retrieve the SolrSearchResult object in JSP/Servlet in page scope. */ private String varResults; // Set by user private String query; private int start = 0; private String[] filterQueries; // Set by author private String solrCoreName; private int rows = 0; private String[] fieldNames; private String[] advancedFilterQueries; private boolean facetEnabled; private String facetSort; private int facetLimit; private int facetMinCount; private String[] facetFieldNames; private boolean highlightEnabled; private boolean highlightRequireFieldMatchEnabled; private String highlightSimplePre; private String highlightSimplePost; private int highlightNumberSnippets; private int highlightFragsize; private String[] highlightingFields; private String searchHandler; private String sort; private String sortDir; @Override public void doTag() throws JspException, IOException { // Make this tag object available to the JSP/Servlet scope. if (StringUtils.isNotBlank(getVar())) { getPageContext().setAttribute(getVar(), this); // getRequest().setAttribute(getVar(), this); } // Get Solr Service AbstractSolrSearchService searchService = null; try {
// Path: aemsolrsearch-search-service/src/main/java/com/headwire/aemsolrsearch/search/services/AbstractSolrSearchService.java // public abstract class AbstractSolrSearchService extends AbstractSolrService { // // private static final Logger LOG = LoggerFactory.getLogger(AbstractSolrSearchService.class); // // /** // * Query a particular instance of SolrServer identified by the core name // * with a given query. // */ // public QueryResponse query(String solrCore, SolrQuery solrQuery) throws SolrServerException { // SolrClient server = getSolrQueryClient(); // LOG.info("Quering {} with '{}'", getSolrServerURI(solrCore), solrQuery); // QueryResponse solrResponse; // try { // solrResponse = server.query(solrCore, solrQuery); // return solrResponse; // } catch (IOException e) { // e.printStackTrace(); // } // return new QueryResponse(); // } // // } // // Path: aemsolrsearch-search-service/src/main/java/com/headwire/aemsolrsearch/search/services/DefaultSolrSearchService.java // @Component( // name = "com.headwire.aemsolrsearch.search.services.DefaultSolrSearchService", // label = "AEM Solr Search - Solr Search Service", // description = "A service for performing searches against Solr", // immediate = true, // metatype = true) // @Service(DefaultSolrSearchService.class) // @Properties({ // @Property( // name = Constants.SERVICE_VENDOR, // value = "headwire.com, Inc."), // @Property( // name = Constants.SERVICE_DESCRIPTION, // value = "A default implementation of the Solr.search.service") // }) // /** // * DefaultSolrSearchService is responsible for obtaining the uri for a particular solr instance identified by a core. // */ // public class DefaultSolrSearchService extends AbstractSolrSearchService { // // private static final Logger LOG = LoggerFactory.getLogger(DefaultSolrSearchService.class); // // @Reference // SolrConfigurationService solrConfigService; // // @Activate // protected void activate(final Map<String, String> config) { // resetService(config); // } // // @Modified // protected void modified(final Map<String, String> config) { // resetService(config); // } // // @Override // protected String getSolrServerURI() { // assertSolrConfigService(); // return solrConfigService.getSolrEndPoint(); // } // // @Override // protected String getSolrServerURI(String solrCore) { // assertSolrConfigService(); // return formatSolrEndPointAndCore(solrConfigService.getSolrEndPoint(), solrCore); // } // // @Override // protected SolrClient getSolrIndexClient() { // return solrConfigService.getIndexingSolrClient(); // } // // @Override // protected SolrClient getSolrQueryClient() { // return solrConfigService.getQueryingSolrClient(); // } // // private void resetService(final Map<String, String> config) { // LOG.info("Resetting Solr search service using configuration: " + config); // } // // private void assertSolrConfigService() throws IllegalStateException { // if (null == solrConfigService) { // LOG.error("Can't get SolrConfigurationService. Check that all OSGi bundles are active"); // throw new IllegalStateException("No solr configuration service."); // } // } // } // Path: aemsolrsearch-taglib/src/main/java/com/headwire/aemsolrsearch/taglib/SolrSearchTag.java import java.io.IOException; import java.util.Arrays; import java.util.HashSet; import java.util.Set; import javax.servlet.jsp.JspException; import org.apache.commons.lang.StringUtils; import org.apache.solr.client.solrj.SolrQuery; import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.response.QueryResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.cqblueprints.taglib.CqSimpleTagSupport; import com.headwire.aemsolrsearch.search.services.AbstractSolrSearchService; import com.headwire.aemsolrsearch.search.services.DefaultSolrSearchService; import com.squeakysand.jsp.tagext.annotations.JspTag; import com.squeakysand.jsp.tagext.annotations.JspTagAttribute; package com.headwire.aemsolrsearch.taglib; /** * Tag used to build SolrQuery, call the SolrSearchService, and store results. */ @JspTag public class SolrSearchTag extends CqSimpleTagSupport { private static final Logger LOG = LoggerFactory .getLogger(SolrSearchTag.class); private SolrQuery solrQuery; /** Name to retrieve this object in JSP/Servlet in page scope. */ private String var; /** Name to retrieve the SolrSearchResult object in JSP/Servlet in page scope. */ private String varResults; // Set by user private String query; private int start = 0; private String[] filterQueries; // Set by author private String solrCoreName; private int rows = 0; private String[] fieldNames; private String[] advancedFilterQueries; private boolean facetEnabled; private String facetSort; private int facetLimit; private int facetMinCount; private String[] facetFieldNames; private boolean highlightEnabled; private boolean highlightRequireFieldMatchEnabled; private String highlightSimplePre; private String highlightSimplePost; private int highlightNumberSnippets; private int highlightFragsize; private String[] highlightingFields; private String searchHandler; private String sort; private String sortDir; @Override public void doTag() throws JspException, IOException { // Make this tag object available to the JSP/Servlet scope. if (StringUtils.isNotBlank(getVar())) { getPageContext().setAttribute(getVar(), this); // getRequest().setAttribute(getVar(), this); } // Get Solr Service AbstractSolrSearchService searchService = null; try {
searchService = (AbstractSolrSearchService) getService(DefaultSolrSearchService.class);
headwirecom/aem-solr-search
aemsolrsearch-services/src/main/java/com/headwire/aemsolrsearch/services/SolrConfigurationService.java
// Path: aemsolrsearch-services/src/main/java/com/headwire/aemsolrsearch/exception/AEMSolrSearchException.java // public class AEMSolrSearchException extends Throwable { // public AEMSolrSearchException(String message) { // super(message); // } // }
import com.headwire.aemsolrsearch.exception.AEMSolrSearchException; import org.apache.commons.lang.StringUtils; import org.apache.felix.scr.annotations.*; import org.apache.solr.client.solrj.SolrClient; import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.impl.CloudSolrClient; import org.apache.solr.client.solrj.impl.HttpSolrClient; import org.apache.solr.client.solrj.impl.LBHttpSolrClient; import org.apache.solr.client.solrj.impl.XMLResponseParser; import org.apache.solr.client.solrj.request.CollectionAdminRequest; import org.apache.solr.client.solrj.request.CoreAdminRequest; import org.apache.solr.client.solrj.request.LukeRequest; import org.apache.solr.client.solrj.request.schema.SchemaRequest; import org.apache.solr.client.solrj.response.CollectionAdminResponse; import org.apache.solr.client.solrj.response.CoreAdminResponse; import org.apache.solr.client.solrj.response.LukeResponse; import org.apache.solr.client.solrj.response.schema.SchemaResponse; import org.apache.solr.common.luke.FieldFlag; import org.apache.solr.common.params.CoreAdminParams; import org.osgi.framework.Constants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; import java.net.MalformedURLException; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap;
CloudSolrClient client = new CloudSolrClient(solrZKHost); client.setParser(new XMLResponseParser()); return client; } private SolrClient getStandaloneQuerySolrClient() { LBHttpSolrClient lbHttpSolrClient = null; try { if (StringUtils.isEmpty(solrSlaves) && StringUtils.isNotEmpty(solrMaster)) { LOG.debug("Creating LBHttpSolrClient using solrMaster {}", solrMaster); lbHttpSolrClient = new LBHttpSolrClient(solrMaster); } else if (StringUtils.isNotEmpty(solrSlaves)) { LOG.debug("Creating LBHttpSolrClient using solrSlaves {}", solrSlaves); lbHttpSolrClient = new LBHttpSolrClient(solrSlaves); if (solrAllowMasterQueriesEnabled && StringUtils.isNotEmpty(solrMaster)) { LOG.debug("Adding solrMaster {} to the LBHttpSolrClient", solrSlaves); lbHttpSolrClient.addSolrServer(solrMaster); } } else if (StringUtils.isEmpty(solrSlaves) && StringUtils.isEmpty(solrMaster)) { // unexpected
// Path: aemsolrsearch-services/src/main/java/com/headwire/aemsolrsearch/exception/AEMSolrSearchException.java // public class AEMSolrSearchException extends Throwable { // public AEMSolrSearchException(String message) { // super(message); // } // } // Path: aemsolrsearch-services/src/main/java/com/headwire/aemsolrsearch/services/SolrConfigurationService.java import com.headwire.aemsolrsearch.exception.AEMSolrSearchException; import org.apache.commons.lang.StringUtils; import org.apache.felix.scr.annotations.*; import org.apache.solr.client.solrj.SolrClient; import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.impl.CloudSolrClient; import org.apache.solr.client.solrj.impl.HttpSolrClient; import org.apache.solr.client.solrj.impl.LBHttpSolrClient; import org.apache.solr.client.solrj.impl.XMLResponseParser; import org.apache.solr.client.solrj.request.CollectionAdminRequest; import org.apache.solr.client.solrj.request.CoreAdminRequest; import org.apache.solr.client.solrj.request.LukeRequest; import org.apache.solr.client.solrj.request.schema.SchemaRequest; import org.apache.solr.client.solrj.response.CollectionAdminResponse; import org.apache.solr.client.solrj.response.CoreAdminResponse; import org.apache.solr.client.solrj.response.LukeResponse; import org.apache.solr.client.solrj.response.schema.SchemaResponse; import org.apache.solr.common.luke.FieldFlag; import org.apache.solr.common.params.CoreAdminParams; import org.osgi.framework.Constants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; import java.net.MalformedURLException; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; CloudSolrClient client = new CloudSolrClient(solrZKHost); client.setParser(new XMLResponseParser()); return client; } private SolrClient getStandaloneQuerySolrClient() { LBHttpSolrClient lbHttpSolrClient = null; try { if (StringUtils.isEmpty(solrSlaves) && StringUtils.isNotEmpty(solrMaster)) { LOG.debug("Creating LBHttpSolrClient using solrMaster {}", solrMaster); lbHttpSolrClient = new LBHttpSolrClient(solrMaster); } else if (StringUtils.isNotEmpty(solrSlaves)) { LOG.debug("Creating LBHttpSolrClient using solrSlaves {}", solrSlaves); lbHttpSolrClient = new LBHttpSolrClient(solrSlaves); if (solrAllowMasterQueriesEnabled && StringUtils.isNotEmpty(solrMaster)) { LOG.debug("Adding solrMaster {} to the LBHttpSolrClient", solrSlaves); lbHttpSolrClient.addSolrServer(solrMaster); } } else if (StringUtils.isEmpty(solrSlaves) && StringUtils.isEmpty(solrMaster)) { // unexpected
throw new AEMSolrSearchException("Initialization failed. "
headwirecom/aem-solr-search
aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/servlets/SolrUpdateHandler.java
// Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaContentType.java // public interface GeometrixxMediaContentType { // // JSONObject getJson(); // // SolrInputDocument getSolrDoc(); // // } // // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaPage.java // @Model(adaptables = Resource.class, adapters = {GeometrixxMediaContentType.class, GeometrixxMediaPage.class}) // public class GeometrixxMediaPage implements GeometrixxMediaContentType{ // // private static final Logger LOG = LoggerFactory.getLogger(GeometrixxMediaPage.class); // // private GeometrixxMediaPageContent pageContent; // // @Inject @Named("jcr:content") // private Resource jcrResource; // // @PostConstruct // public void init() throws SlingModelsException { // // pageContent = jcrResource.adaptTo(GeometrixxMediaPageContent.class); // // } // // public GeometrixxMediaPage(Resource resource) throws SlingModelsException { // // if (null == resource) { // LOG.debug("resource is null"); // throw new SlingModelsException("Resource is null"); // } // // if (ResourceUtil.isNonExistingResource(resource)) { // LOG.warn("Can't adapt non existent resource: '{}'", resource.getPath()); // throw new SlingModelsException( // "Can't adapt non existent resource." + resource.getPath()); // } // // } // // @Override // public String toString() { // // final StringBuilder sb = new StringBuilder("GeometrixxMediaPage{"); // if(null != pageContent){ // sb.append(pageContent.toString()); // } // sb.append('}'); // return sb.toString(); // } // // @Override // public JSONObject getJson() { // // return pageContent != null ? pageContent.getJson() : new JSONObject(); // } // // @Override // public SolrInputDocument getSolrDoc() { // // return pageContent != null ? pageContent.getSolrDoc() : null; // } // }
import com.day.cq.dam.api.DamConstants; import com.day.cq.wcm.api.NameConstants; import com.headwire.aemsolrsearch.geometrixxmedia.model.GeometrixxMediaContentType; import com.headwire.aemsolrsearch.geometrixxmedia.model.GeometrixxMediaPage; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Properties; import org.apache.felix.scr.annotations.Property; import org.apache.felix.scr.annotations.Service; import org.apache.sling.api.SlingHttpServletRequest; import org.apache.sling.api.SlingHttpServletResponse; import org.apache.sling.api.resource.Resource; import org.apache.sling.api.servlets.SlingSafeMethodsServlet; import org.osgi.framework.Constants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.servlet.Servlet; import javax.servlet.ServletException; import java.io.IOException;
package com.headwire.aemsolrsearch.geometrixxmedia.servlets; /** * Renders supported Sling resource types using Solr's JSON update handler format. The following Sling resource * types are supported: * * <ul> * <li><code>geometrixx-media/components/page/article</code></li> * </ul> * * <em>Note: *.solr.json should be blocked at dispatcher</em> * * @author <a href="mailto:[email protected]">Gaston Gonzalez</a> */ @Component(immediate = true, metatype = true) @Service(Servlet.class) @Properties({ @Property(name = Constants.SERVICE_VENDOR, value = "headwire.com, Inc."), @Property(name = Constants.SERVICE_DESCRIPTION, value = "Renders content using the Solr JSON update handler format "), @Property(name = "sling.servlet.methods", value = "GET"), @Property(name = "sling.servlet.resourceTypes", value = {NameConstants.NT_PAGE, DamConstants.NT_DAM_ASSET}), @Property(name = "sling.servlet.selectors", value = "solr"), @Property(name = "sling.servlet.extensions", value = "json") }) public class SolrUpdateHandler extends SlingSafeMethodsServlet { private static final Logger LOG = LoggerFactory.getLogger(SolrUpdateHandler.class); @Override protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException { response.setContentType("application/json"); response.setCharacterEncoding("utf-8"); Resource page = request.getResource();
// Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaContentType.java // public interface GeometrixxMediaContentType { // // JSONObject getJson(); // // SolrInputDocument getSolrDoc(); // // } // // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaPage.java // @Model(adaptables = Resource.class, adapters = {GeometrixxMediaContentType.class, GeometrixxMediaPage.class}) // public class GeometrixxMediaPage implements GeometrixxMediaContentType{ // // private static final Logger LOG = LoggerFactory.getLogger(GeometrixxMediaPage.class); // // private GeometrixxMediaPageContent pageContent; // // @Inject @Named("jcr:content") // private Resource jcrResource; // // @PostConstruct // public void init() throws SlingModelsException { // // pageContent = jcrResource.adaptTo(GeometrixxMediaPageContent.class); // // } // // public GeometrixxMediaPage(Resource resource) throws SlingModelsException { // // if (null == resource) { // LOG.debug("resource is null"); // throw new SlingModelsException("Resource is null"); // } // // if (ResourceUtil.isNonExistingResource(resource)) { // LOG.warn("Can't adapt non existent resource: '{}'", resource.getPath()); // throw new SlingModelsException( // "Can't adapt non existent resource." + resource.getPath()); // } // // } // // @Override // public String toString() { // // final StringBuilder sb = new StringBuilder("GeometrixxMediaPage{"); // if(null != pageContent){ // sb.append(pageContent.toString()); // } // sb.append('}'); // return sb.toString(); // } // // @Override // public JSONObject getJson() { // // return pageContent != null ? pageContent.getJson() : new JSONObject(); // } // // @Override // public SolrInputDocument getSolrDoc() { // // return pageContent != null ? pageContent.getSolrDoc() : null; // } // } // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/servlets/SolrUpdateHandler.java import com.day.cq.dam.api.DamConstants; import com.day.cq.wcm.api.NameConstants; import com.headwire.aemsolrsearch.geometrixxmedia.model.GeometrixxMediaContentType; import com.headwire.aemsolrsearch.geometrixxmedia.model.GeometrixxMediaPage; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Properties; import org.apache.felix.scr.annotations.Property; import org.apache.felix.scr.annotations.Service; import org.apache.sling.api.SlingHttpServletRequest; import org.apache.sling.api.SlingHttpServletResponse; import org.apache.sling.api.resource.Resource; import org.apache.sling.api.servlets.SlingSafeMethodsServlet; import org.osgi.framework.Constants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.servlet.Servlet; import javax.servlet.ServletException; import java.io.IOException; package com.headwire.aemsolrsearch.geometrixxmedia.servlets; /** * Renders supported Sling resource types using Solr's JSON update handler format. The following Sling resource * types are supported: * * <ul> * <li><code>geometrixx-media/components/page/article</code></li> * </ul> * * <em>Note: *.solr.json should be blocked at dispatcher</em> * * @author <a href="mailto:[email protected]">Gaston Gonzalez</a> */ @Component(immediate = true, metatype = true) @Service(Servlet.class) @Properties({ @Property(name = Constants.SERVICE_VENDOR, value = "headwire.com, Inc."), @Property(name = Constants.SERVICE_DESCRIPTION, value = "Renders content using the Solr JSON update handler format "), @Property(name = "sling.servlet.methods", value = "GET"), @Property(name = "sling.servlet.resourceTypes", value = {NameConstants.NT_PAGE, DamConstants.NT_DAM_ASSET}), @Property(name = "sling.servlet.selectors", value = "solr"), @Property(name = "sling.servlet.extensions", value = "json") }) public class SolrUpdateHandler extends SlingSafeMethodsServlet { private static final Logger LOG = LoggerFactory.getLogger(SolrUpdateHandler.class); @Override protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException { response.setContentType("application/json"); response.setCharacterEncoding("utf-8"); Resource page = request.getResource();
GeometrixxMediaContentType contentType = page.adaptTo(GeometrixxMediaPage.class);
headwirecom/aem-solr-search
aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/servlets/SolrUpdateHandler.java
// Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaContentType.java // public interface GeometrixxMediaContentType { // // JSONObject getJson(); // // SolrInputDocument getSolrDoc(); // // } // // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaPage.java // @Model(adaptables = Resource.class, adapters = {GeometrixxMediaContentType.class, GeometrixxMediaPage.class}) // public class GeometrixxMediaPage implements GeometrixxMediaContentType{ // // private static final Logger LOG = LoggerFactory.getLogger(GeometrixxMediaPage.class); // // private GeometrixxMediaPageContent pageContent; // // @Inject @Named("jcr:content") // private Resource jcrResource; // // @PostConstruct // public void init() throws SlingModelsException { // // pageContent = jcrResource.adaptTo(GeometrixxMediaPageContent.class); // // } // // public GeometrixxMediaPage(Resource resource) throws SlingModelsException { // // if (null == resource) { // LOG.debug("resource is null"); // throw new SlingModelsException("Resource is null"); // } // // if (ResourceUtil.isNonExistingResource(resource)) { // LOG.warn("Can't adapt non existent resource: '{}'", resource.getPath()); // throw new SlingModelsException( // "Can't adapt non existent resource." + resource.getPath()); // } // // } // // @Override // public String toString() { // // final StringBuilder sb = new StringBuilder("GeometrixxMediaPage{"); // if(null != pageContent){ // sb.append(pageContent.toString()); // } // sb.append('}'); // return sb.toString(); // } // // @Override // public JSONObject getJson() { // // return pageContent != null ? pageContent.getJson() : new JSONObject(); // } // // @Override // public SolrInputDocument getSolrDoc() { // // return pageContent != null ? pageContent.getSolrDoc() : null; // } // }
import com.day.cq.dam.api.DamConstants; import com.day.cq.wcm.api.NameConstants; import com.headwire.aemsolrsearch.geometrixxmedia.model.GeometrixxMediaContentType; import com.headwire.aemsolrsearch.geometrixxmedia.model.GeometrixxMediaPage; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Properties; import org.apache.felix.scr.annotations.Property; import org.apache.felix.scr.annotations.Service; import org.apache.sling.api.SlingHttpServletRequest; import org.apache.sling.api.SlingHttpServletResponse; import org.apache.sling.api.resource.Resource; import org.apache.sling.api.servlets.SlingSafeMethodsServlet; import org.osgi.framework.Constants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.servlet.Servlet; import javax.servlet.ServletException; import java.io.IOException;
package com.headwire.aemsolrsearch.geometrixxmedia.servlets; /** * Renders supported Sling resource types using Solr's JSON update handler format. The following Sling resource * types are supported: * * <ul> * <li><code>geometrixx-media/components/page/article</code></li> * </ul> * * <em>Note: *.solr.json should be blocked at dispatcher</em> * * @author <a href="mailto:[email protected]">Gaston Gonzalez</a> */ @Component(immediate = true, metatype = true) @Service(Servlet.class) @Properties({ @Property(name = Constants.SERVICE_VENDOR, value = "headwire.com, Inc."), @Property(name = Constants.SERVICE_DESCRIPTION, value = "Renders content using the Solr JSON update handler format "), @Property(name = "sling.servlet.methods", value = "GET"), @Property(name = "sling.servlet.resourceTypes", value = {NameConstants.NT_PAGE, DamConstants.NT_DAM_ASSET}), @Property(name = "sling.servlet.selectors", value = "solr"), @Property(name = "sling.servlet.extensions", value = "json") }) public class SolrUpdateHandler extends SlingSafeMethodsServlet { private static final Logger LOG = LoggerFactory.getLogger(SolrUpdateHandler.class); @Override protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException { response.setContentType("application/json"); response.setCharacterEncoding("utf-8"); Resource page = request.getResource();
// Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaContentType.java // public interface GeometrixxMediaContentType { // // JSONObject getJson(); // // SolrInputDocument getSolrDoc(); // // } // // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaPage.java // @Model(adaptables = Resource.class, adapters = {GeometrixxMediaContentType.class, GeometrixxMediaPage.class}) // public class GeometrixxMediaPage implements GeometrixxMediaContentType{ // // private static final Logger LOG = LoggerFactory.getLogger(GeometrixxMediaPage.class); // // private GeometrixxMediaPageContent pageContent; // // @Inject @Named("jcr:content") // private Resource jcrResource; // // @PostConstruct // public void init() throws SlingModelsException { // // pageContent = jcrResource.adaptTo(GeometrixxMediaPageContent.class); // // } // // public GeometrixxMediaPage(Resource resource) throws SlingModelsException { // // if (null == resource) { // LOG.debug("resource is null"); // throw new SlingModelsException("Resource is null"); // } // // if (ResourceUtil.isNonExistingResource(resource)) { // LOG.warn("Can't adapt non existent resource: '{}'", resource.getPath()); // throw new SlingModelsException( // "Can't adapt non existent resource." + resource.getPath()); // } // // } // // @Override // public String toString() { // // final StringBuilder sb = new StringBuilder("GeometrixxMediaPage{"); // if(null != pageContent){ // sb.append(pageContent.toString()); // } // sb.append('}'); // return sb.toString(); // } // // @Override // public JSONObject getJson() { // // return pageContent != null ? pageContent.getJson() : new JSONObject(); // } // // @Override // public SolrInputDocument getSolrDoc() { // // return pageContent != null ? pageContent.getSolrDoc() : null; // } // } // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/servlets/SolrUpdateHandler.java import com.day.cq.dam.api.DamConstants; import com.day.cq.wcm.api.NameConstants; import com.headwire.aemsolrsearch.geometrixxmedia.model.GeometrixxMediaContentType; import com.headwire.aemsolrsearch.geometrixxmedia.model.GeometrixxMediaPage; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Properties; import org.apache.felix.scr.annotations.Property; import org.apache.felix.scr.annotations.Service; import org.apache.sling.api.SlingHttpServletRequest; import org.apache.sling.api.SlingHttpServletResponse; import org.apache.sling.api.resource.Resource; import org.apache.sling.api.servlets.SlingSafeMethodsServlet; import org.osgi.framework.Constants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.servlet.Servlet; import javax.servlet.ServletException; import java.io.IOException; package com.headwire.aemsolrsearch.geometrixxmedia.servlets; /** * Renders supported Sling resource types using Solr's JSON update handler format. The following Sling resource * types are supported: * * <ul> * <li><code>geometrixx-media/components/page/article</code></li> * </ul> * * <em>Note: *.solr.json should be blocked at dispatcher</em> * * @author <a href="mailto:[email protected]">Gaston Gonzalez</a> */ @Component(immediate = true, metatype = true) @Service(Servlet.class) @Properties({ @Property(name = Constants.SERVICE_VENDOR, value = "headwire.com, Inc."), @Property(name = Constants.SERVICE_DESCRIPTION, value = "Renders content using the Solr JSON update handler format "), @Property(name = "sling.servlet.methods", value = "GET"), @Property(name = "sling.servlet.resourceTypes", value = {NameConstants.NT_PAGE, DamConstants.NT_DAM_ASSET}), @Property(name = "sling.servlet.selectors", value = "solr"), @Property(name = "sling.servlet.extensions", value = "json") }) public class SolrUpdateHandler extends SlingSafeMethodsServlet { private static final Logger LOG = LoggerFactory.getLogger(SolrUpdateHandler.class); @Override protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException { response.setContentType("application/json"); response.setCharacterEncoding("utf-8"); Resource page = request.getResource();
GeometrixxMediaContentType contentType = page.adaptTo(GeometrixxMediaPage.class);
headwirecom/aem-solr-search
aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/servlets/SolrBulkUpdateHandler.java
// Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaContentType.java // public interface GeometrixxMediaContentType { // // JSONObject getJson(); // // SolrInputDocument getSolrDoc(); // // } // // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaPage.java // @Model(adaptables = Resource.class, adapters = {GeometrixxMediaContentType.class, GeometrixxMediaPage.class}) // public class GeometrixxMediaPage implements GeometrixxMediaContentType{ // // private static final Logger LOG = LoggerFactory.getLogger(GeometrixxMediaPage.class); // // private GeometrixxMediaPageContent pageContent; // // @Inject @Named("jcr:content") // private Resource jcrResource; // // @PostConstruct // public void init() throws SlingModelsException { // // pageContent = jcrResource.adaptTo(GeometrixxMediaPageContent.class); // // } // // public GeometrixxMediaPage(Resource resource) throws SlingModelsException { // // if (null == resource) { // LOG.debug("resource is null"); // throw new SlingModelsException("Resource is null"); // } // // if (ResourceUtil.isNonExistingResource(resource)) { // LOG.warn("Can't adapt non existent resource: '{}'", resource.getPath()); // throw new SlingModelsException( // "Can't adapt non existent resource." + resource.getPath()); // } // // } // // @Override // public String toString() { // // final StringBuilder sb = new StringBuilder("GeometrixxMediaPage{"); // if(null != pageContent){ // sb.append(pageContent.toString()); // } // sb.append('}'); // return sb.toString(); // } // // @Override // public JSONObject getJson() { // // return pageContent != null ? pageContent.getJson() : new JSONObject(); // } // // @Override // public SolrInputDocument getSolrDoc() { // // return pageContent != null ? pageContent.getSolrDoc() : null; // } // }
import com.day.cq.search.PredicateGroup; import com.day.cq.search.Query; import com.day.cq.search.QueryBuilder; import com.day.cq.search.result.Hit; import com.day.cq.search.result.SearchResult; import com.headwire.aemsolrsearch.geometrixxmedia.model.GeometrixxMediaContentType; import com.headwire.aemsolrsearch.geometrixxmedia.model.GeometrixxMediaPage; import org.apache.commons.lang.StringUtils; import org.apache.felix.scr.annotations.*; import org.apache.sling.api.SlingHttpServletRequest; import org.apache.sling.api.SlingHttpServletResponse; import org.apache.sling.api.resource.Resource; import org.apache.sling.api.servlets.SlingSafeMethodsServlet; import org.apache.sling.jcr.api.SlingRepository; import org.json.simple.JSONArray; import org.osgi.framework.Constants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.jcr.RepositoryException; import javax.jcr.Session; import javax.servlet.Servlet; import javax.servlet.ServletException; import java.io.IOException; import java.util.HashMap; import java.util.Map;
JSONArray solrDocs = new JSONArray(); final String slingResourceType = getSlingResourceType(request); if (StringUtils.isEmpty(slingResourceType)) { response.getWriter().write(solrDocs.toJSONString()); return; } Map<String, String> params = new HashMap<String, String>(); params.put("path", "/content/geometrixx-media"); params.put("type", "cq:PageContent"); params.put("property", "sling:resourceType"); params.put("property.value", slingResourceType); params.put("p.offset", "0"); params.put("p.limit", "50"); Session session = null; try { session = repository.loginAdministrative(null); Query query = queryBuilder.createQuery(PredicateGroup.create(params), session); SearchResult results = query.getResult(); LOG.info("Found '{}' matches for query", results.getTotalMatches()); for (Hit hit: results.getHits()) { // The query returns the jcr:content node, so we need its parent. Resource page = hit.getResource().getParent();
// Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaContentType.java // public interface GeometrixxMediaContentType { // // JSONObject getJson(); // // SolrInputDocument getSolrDoc(); // // } // // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaPage.java // @Model(adaptables = Resource.class, adapters = {GeometrixxMediaContentType.class, GeometrixxMediaPage.class}) // public class GeometrixxMediaPage implements GeometrixxMediaContentType{ // // private static final Logger LOG = LoggerFactory.getLogger(GeometrixxMediaPage.class); // // private GeometrixxMediaPageContent pageContent; // // @Inject @Named("jcr:content") // private Resource jcrResource; // // @PostConstruct // public void init() throws SlingModelsException { // // pageContent = jcrResource.adaptTo(GeometrixxMediaPageContent.class); // // } // // public GeometrixxMediaPage(Resource resource) throws SlingModelsException { // // if (null == resource) { // LOG.debug("resource is null"); // throw new SlingModelsException("Resource is null"); // } // // if (ResourceUtil.isNonExistingResource(resource)) { // LOG.warn("Can't adapt non existent resource: '{}'", resource.getPath()); // throw new SlingModelsException( // "Can't adapt non existent resource." + resource.getPath()); // } // // } // // @Override // public String toString() { // // final StringBuilder sb = new StringBuilder("GeometrixxMediaPage{"); // if(null != pageContent){ // sb.append(pageContent.toString()); // } // sb.append('}'); // return sb.toString(); // } // // @Override // public JSONObject getJson() { // // return pageContent != null ? pageContent.getJson() : new JSONObject(); // } // // @Override // public SolrInputDocument getSolrDoc() { // // return pageContent != null ? pageContent.getSolrDoc() : null; // } // } // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/servlets/SolrBulkUpdateHandler.java import com.day.cq.search.PredicateGroup; import com.day.cq.search.Query; import com.day.cq.search.QueryBuilder; import com.day.cq.search.result.Hit; import com.day.cq.search.result.SearchResult; import com.headwire.aemsolrsearch.geometrixxmedia.model.GeometrixxMediaContentType; import com.headwire.aemsolrsearch.geometrixxmedia.model.GeometrixxMediaPage; import org.apache.commons.lang.StringUtils; import org.apache.felix.scr.annotations.*; import org.apache.sling.api.SlingHttpServletRequest; import org.apache.sling.api.SlingHttpServletResponse; import org.apache.sling.api.resource.Resource; import org.apache.sling.api.servlets.SlingSafeMethodsServlet; import org.apache.sling.jcr.api.SlingRepository; import org.json.simple.JSONArray; import org.osgi.framework.Constants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.jcr.RepositoryException; import javax.jcr.Session; import javax.servlet.Servlet; import javax.servlet.ServletException; import java.io.IOException; import java.util.HashMap; import java.util.Map; JSONArray solrDocs = new JSONArray(); final String slingResourceType = getSlingResourceType(request); if (StringUtils.isEmpty(slingResourceType)) { response.getWriter().write(solrDocs.toJSONString()); return; } Map<String, String> params = new HashMap<String, String>(); params.put("path", "/content/geometrixx-media"); params.put("type", "cq:PageContent"); params.put("property", "sling:resourceType"); params.put("property.value", slingResourceType); params.put("p.offset", "0"); params.put("p.limit", "50"); Session session = null; try { session = repository.loginAdministrative(null); Query query = queryBuilder.createQuery(PredicateGroup.create(params), session); SearchResult results = query.getResult(); LOG.info("Found '{}' matches for query", results.getTotalMatches()); for (Hit hit: results.getHits()) { // The query returns the jcr:content node, so we need its parent. Resource page = hit.getResource().getParent();
GeometrixxMediaContentType contentType = page.adaptTo(GeometrixxMediaPage.class);
headwirecom/aem-solr-search
aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/servlets/SolrBulkUpdateHandler.java
// Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaContentType.java // public interface GeometrixxMediaContentType { // // JSONObject getJson(); // // SolrInputDocument getSolrDoc(); // // } // // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaPage.java // @Model(adaptables = Resource.class, adapters = {GeometrixxMediaContentType.class, GeometrixxMediaPage.class}) // public class GeometrixxMediaPage implements GeometrixxMediaContentType{ // // private static final Logger LOG = LoggerFactory.getLogger(GeometrixxMediaPage.class); // // private GeometrixxMediaPageContent pageContent; // // @Inject @Named("jcr:content") // private Resource jcrResource; // // @PostConstruct // public void init() throws SlingModelsException { // // pageContent = jcrResource.adaptTo(GeometrixxMediaPageContent.class); // // } // // public GeometrixxMediaPage(Resource resource) throws SlingModelsException { // // if (null == resource) { // LOG.debug("resource is null"); // throw new SlingModelsException("Resource is null"); // } // // if (ResourceUtil.isNonExistingResource(resource)) { // LOG.warn("Can't adapt non existent resource: '{}'", resource.getPath()); // throw new SlingModelsException( // "Can't adapt non existent resource." + resource.getPath()); // } // // } // // @Override // public String toString() { // // final StringBuilder sb = new StringBuilder("GeometrixxMediaPage{"); // if(null != pageContent){ // sb.append(pageContent.toString()); // } // sb.append('}'); // return sb.toString(); // } // // @Override // public JSONObject getJson() { // // return pageContent != null ? pageContent.getJson() : new JSONObject(); // } // // @Override // public SolrInputDocument getSolrDoc() { // // return pageContent != null ? pageContent.getSolrDoc() : null; // } // }
import com.day.cq.search.PredicateGroup; import com.day.cq.search.Query; import com.day.cq.search.QueryBuilder; import com.day.cq.search.result.Hit; import com.day.cq.search.result.SearchResult; import com.headwire.aemsolrsearch.geometrixxmedia.model.GeometrixxMediaContentType; import com.headwire.aemsolrsearch.geometrixxmedia.model.GeometrixxMediaPage; import org.apache.commons.lang.StringUtils; import org.apache.felix.scr.annotations.*; import org.apache.sling.api.SlingHttpServletRequest; import org.apache.sling.api.SlingHttpServletResponse; import org.apache.sling.api.resource.Resource; import org.apache.sling.api.servlets.SlingSafeMethodsServlet; import org.apache.sling.jcr.api.SlingRepository; import org.json.simple.JSONArray; import org.osgi.framework.Constants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.jcr.RepositoryException; import javax.jcr.Session; import javax.servlet.Servlet; import javax.servlet.ServletException; import java.io.IOException; import java.util.HashMap; import java.util.Map;
JSONArray solrDocs = new JSONArray(); final String slingResourceType = getSlingResourceType(request); if (StringUtils.isEmpty(slingResourceType)) { response.getWriter().write(solrDocs.toJSONString()); return; } Map<String, String> params = new HashMap<String, String>(); params.put("path", "/content/geometrixx-media"); params.put("type", "cq:PageContent"); params.put("property", "sling:resourceType"); params.put("property.value", slingResourceType); params.put("p.offset", "0"); params.put("p.limit", "50"); Session session = null; try { session = repository.loginAdministrative(null); Query query = queryBuilder.createQuery(PredicateGroup.create(params), session); SearchResult results = query.getResult(); LOG.info("Found '{}' matches for query", results.getTotalMatches()); for (Hit hit: results.getHits()) { // The query returns the jcr:content node, so we need its parent. Resource page = hit.getResource().getParent();
// Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaContentType.java // public interface GeometrixxMediaContentType { // // JSONObject getJson(); // // SolrInputDocument getSolrDoc(); // // } // // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaPage.java // @Model(adaptables = Resource.class, adapters = {GeometrixxMediaContentType.class, GeometrixxMediaPage.class}) // public class GeometrixxMediaPage implements GeometrixxMediaContentType{ // // private static final Logger LOG = LoggerFactory.getLogger(GeometrixxMediaPage.class); // // private GeometrixxMediaPageContent pageContent; // // @Inject @Named("jcr:content") // private Resource jcrResource; // // @PostConstruct // public void init() throws SlingModelsException { // // pageContent = jcrResource.adaptTo(GeometrixxMediaPageContent.class); // // } // // public GeometrixxMediaPage(Resource resource) throws SlingModelsException { // // if (null == resource) { // LOG.debug("resource is null"); // throw new SlingModelsException("Resource is null"); // } // // if (ResourceUtil.isNonExistingResource(resource)) { // LOG.warn("Can't adapt non existent resource: '{}'", resource.getPath()); // throw new SlingModelsException( // "Can't adapt non existent resource." + resource.getPath()); // } // // } // // @Override // public String toString() { // // final StringBuilder sb = new StringBuilder("GeometrixxMediaPage{"); // if(null != pageContent){ // sb.append(pageContent.toString()); // } // sb.append('}'); // return sb.toString(); // } // // @Override // public JSONObject getJson() { // // return pageContent != null ? pageContent.getJson() : new JSONObject(); // } // // @Override // public SolrInputDocument getSolrDoc() { // // return pageContent != null ? pageContent.getSolrDoc() : null; // } // } // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/servlets/SolrBulkUpdateHandler.java import com.day.cq.search.PredicateGroup; import com.day.cq.search.Query; import com.day.cq.search.QueryBuilder; import com.day.cq.search.result.Hit; import com.day.cq.search.result.SearchResult; import com.headwire.aemsolrsearch.geometrixxmedia.model.GeometrixxMediaContentType; import com.headwire.aemsolrsearch.geometrixxmedia.model.GeometrixxMediaPage; import org.apache.commons.lang.StringUtils; import org.apache.felix.scr.annotations.*; import org.apache.sling.api.SlingHttpServletRequest; import org.apache.sling.api.SlingHttpServletResponse; import org.apache.sling.api.resource.Resource; import org.apache.sling.api.servlets.SlingSafeMethodsServlet; import org.apache.sling.jcr.api.SlingRepository; import org.json.simple.JSONArray; import org.osgi.framework.Constants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.jcr.RepositoryException; import javax.jcr.Session; import javax.servlet.Servlet; import javax.servlet.ServletException; import java.io.IOException; import java.util.HashMap; import java.util.Map; JSONArray solrDocs = new JSONArray(); final String slingResourceType = getSlingResourceType(request); if (StringUtils.isEmpty(slingResourceType)) { response.getWriter().write(solrDocs.toJSONString()); return; } Map<String, String> params = new HashMap<String, String>(); params.put("path", "/content/geometrixx-media"); params.put("type", "cq:PageContent"); params.put("property", "sling:resourceType"); params.put("property.value", slingResourceType); params.put("p.offset", "0"); params.put("p.limit", "50"); Session session = null; try { session = repository.loginAdministrative(null); Query query = queryBuilder.createQuery(PredicateGroup.create(params), session); SearchResult results = query.getResult(); LOG.info("Found '{}' matches for query", results.getTotalMatches()); for (Hit hit: results.getHits()) { // The query returns the jcr:content node, so we need its parent. Resource page = hit.getResource().getParent();
GeometrixxMediaContentType contentType = page.adaptTo(GeometrixxMediaPage.class);
headwirecom/aem-solr-search
aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaArticleBody.java
// Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/exceptions/SlingModelsException.java // public class SlingModelsException extends Exception { // // public SlingModelsException(String message) { // super(message); // } // // } // // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/util/HtmlUtils.java // public class HtmlUtils { // // /** // * Converts HTML to plain text. // * // * @param html // * @return Plain text on success and an empty string otherwise. // */ // public static String htmlToText(String html) { // // if (StringUtils.isBlank(html)) { // return ""; // } // // return Jsoup.parse(html).text(); // } // } // // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/util/MarkdownUtils.java // public class MarkdownUtils { // // /** // * Converts Markdown to HTML. // * // * @param markdown // * @return Markdown on success and an empty string otherwise. // */ // public static String markdownToHtml(String markdown) { // // if (StringUtils.isBlank(markdown)) { // return ""; // } // // MarkdownProcessor proc = new MarkdownProcessor(); // return proc.markdown(markdown); // } // }
import com.day.cq.dam.api.Asset; import com.day.cq.dam.api.Rendition; import com.headwire.aemsolrsearch.geometrixxmedia.model.exceptions.SlingModelsException; import com.headwire.aemsolrsearch.geometrixxmedia.util.HtmlUtils; import com.headwire.aemsolrsearch.geometrixxmedia.util.MarkdownUtils; import org.apache.commons.io.IOUtils; import org.apache.sling.api.resource.Resource; import org.apache.sling.api.resource.ResourceUtil; import org.apache.sling.models.annotations.Default; import org.apache.sling.models.annotations.Model; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.annotation.PostConstruct; import java.io.IOException; import java.io.StringWriter;
package com.headwire.aemsolrsearch.geometrixxmedia.model; /** * Represents a Geometrixx Media article body. * * @author <a href="mailto:[email protected]">Gaston Gonzalez</a> */ @Model(adaptables = Resource.class) public class GeometrixxMediaArticleBody { private static final Logger LOG = LoggerFactory.getLogger(GeometrixxMediaArticleBody.class); @Default(values = "") private String body; private Resource resource;
// Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/exceptions/SlingModelsException.java // public class SlingModelsException extends Exception { // // public SlingModelsException(String message) { // super(message); // } // // } // // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/util/HtmlUtils.java // public class HtmlUtils { // // /** // * Converts HTML to plain text. // * // * @param html // * @return Plain text on success and an empty string otherwise. // */ // public static String htmlToText(String html) { // // if (StringUtils.isBlank(html)) { // return ""; // } // // return Jsoup.parse(html).text(); // } // } // // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/util/MarkdownUtils.java // public class MarkdownUtils { // // /** // * Converts Markdown to HTML. // * // * @param markdown // * @return Markdown on success and an empty string otherwise. // */ // public static String markdownToHtml(String markdown) { // // if (StringUtils.isBlank(markdown)) { // return ""; // } // // MarkdownProcessor proc = new MarkdownProcessor(); // return proc.markdown(markdown); // } // } // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaArticleBody.java import com.day.cq.dam.api.Asset; import com.day.cq.dam.api.Rendition; import com.headwire.aemsolrsearch.geometrixxmedia.model.exceptions.SlingModelsException; import com.headwire.aemsolrsearch.geometrixxmedia.util.HtmlUtils; import com.headwire.aemsolrsearch.geometrixxmedia.util.MarkdownUtils; import org.apache.commons.io.IOUtils; import org.apache.sling.api.resource.Resource; import org.apache.sling.api.resource.ResourceUtil; import org.apache.sling.models.annotations.Default; import org.apache.sling.models.annotations.Model; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.annotation.PostConstruct; import java.io.IOException; import java.io.StringWriter; package com.headwire.aemsolrsearch.geometrixxmedia.model; /** * Represents a Geometrixx Media article body. * * @author <a href="mailto:[email protected]">Gaston Gonzalez</a> */ @Model(adaptables = Resource.class) public class GeometrixxMediaArticleBody { private static final Logger LOG = LoggerFactory.getLogger(GeometrixxMediaArticleBody.class); @Default(values = "") private String body; private Resource resource;
@PostConstruct public void init() throws SlingModelsException {
headwirecom/aem-solr-search
aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaArticleBody.java
// Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/exceptions/SlingModelsException.java // public class SlingModelsException extends Exception { // // public SlingModelsException(String message) { // super(message); // } // // } // // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/util/HtmlUtils.java // public class HtmlUtils { // // /** // * Converts HTML to plain text. // * // * @param html // * @return Plain text on success and an empty string otherwise. // */ // public static String htmlToText(String html) { // // if (StringUtils.isBlank(html)) { // return ""; // } // // return Jsoup.parse(html).text(); // } // } // // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/util/MarkdownUtils.java // public class MarkdownUtils { // // /** // * Converts Markdown to HTML. // * // * @param markdown // * @return Markdown on success and an empty string otherwise. // */ // public static String markdownToHtml(String markdown) { // // if (StringUtils.isBlank(markdown)) { // return ""; // } // // MarkdownProcessor proc = new MarkdownProcessor(); // return proc.markdown(markdown); // } // }
import com.day.cq.dam.api.Asset; import com.day.cq.dam.api.Rendition; import com.headwire.aemsolrsearch.geometrixxmedia.model.exceptions.SlingModelsException; import com.headwire.aemsolrsearch.geometrixxmedia.util.HtmlUtils; import com.headwire.aemsolrsearch.geometrixxmedia.util.MarkdownUtils; import org.apache.commons.io.IOUtils; import org.apache.sling.api.resource.Resource; import org.apache.sling.api.resource.ResourceUtil; import org.apache.sling.models.annotations.Default; import org.apache.sling.models.annotations.Model; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.annotation.PostConstruct; import java.io.IOException; import java.io.StringWriter;
} } public GeometrixxMediaArticleBody(Resource resource) throws SlingModelsException { if (null == resource) { LOG.info("Resource is null"); throw new SlingModelsException("Resource is null"); } if (ResourceUtil.isNonExistingResource(resource)) { LOG.warn("Can't adapt non existent resource: '{}'", resource.getPath()); throw new SlingModelsException( "Can't adapt non existent resource." + resource.getPath()); } this.resource = resource; } public GeometrixxMediaArticleBody(String body){ this.body = body; } public String getBody() { return body; } public String getBodyAsHtml() {
// Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/exceptions/SlingModelsException.java // public class SlingModelsException extends Exception { // // public SlingModelsException(String message) { // super(message); // } // // } // // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/util/HtmlUtils.java // public class HtmlUtils { // // /** // * Converts HTML to plain text. // * // * @param html // * @return Plain text on success and an empty string otherwise. // */ // public static String htmlToText(String html) { // // if (StringUtils.isBlank(html)) { // return ""; // } // // return Jsoup.parse(html).text(); // } // } // // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/util/MarkdownUtils.java // public class MarkdownUtils { // // /** // * Converts Markdown to HTML. // * // * @param markdown // * @return Markdown on success and an empty string otherwise. // */ // public static String markdownToHtml(String markdown) { // // if (StringUtils.isBlank(markdown)) { // return ""; // } // // MarkdownProcessor proc = new MarkdownProcessor(); // return proc.markdown(markdown); // } // } // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaArticleBody.java import com.day.cq.dam.api.Asset; import com.day.cq.dam.api.Rendition; import com.headwire.aemsolrsearch.geometrixxmedia.model.exceptions.SlingModelsException; import com.headwire.aemsolrsearch.geometrixxmedia.util.HtmlUtils; import com.headwire.aemsolrsearch.geometrixxmedia.util.MarkdownUtils; import org.apache.commons.io.IOUtils; import org.apache.sling.api.resource.Resource; import org.apache.sling.api.resource.ResourceUtil; import org.apache.sling.models.annotations.Default; import org.apache.sling.models.annotations.Model; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.annotation.PostConstruct; import java.io.IOException; import java.io.StringWriter; } } public GeometrixxMediaArticleBody(Resource resource) throws SlingModelsException { if (null == resource) { LOG.info("Resource is null"); throw new SlingModelsException("Resource is null"); } if (ResourceUtil.isNonExistingResource(resource)) { LOG.warn("Can't adapt non existent resource: '{}'", resource.getPath()); throw new SlingModelsException( "Can't adapt non existent resource." + resource.getPath()); } this.resource = resource; } public GeometrixxMediaArticleBody(String body){ this.body = body; } public String getBody() { return body; } public String getBodyAsHtml() {
return MarkdownUtils.markdownToHtml(body);
headwirecom/aem-solr-search
aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaArticleBody.java
// Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/exceptions/SlingModelsException.java // public class SlingModelsException extends Exception { // // public SlingModelsException(String message) { // super(message); // } // // } // // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/util/HtmlUtils.java // public class HtmlUtils { // // /** // * Converts HTML to plain text. // * // * @param html // * @return Plain text on success and an empty string otherwise. // */ // public static String htmlToText(String html) { // // if (StringUtils.isBlank(html)) { // return ""; // } // // return Jsoup.parse(html).text(); // } // } // // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/util/MarkdownUtils.java // public class MarkdownUtils { // // /** // * Converts Markdown to HTML. // * // * @param markdown // * @return Markdown on success and an empty string otherwise. // */ // public static String markdownToHtml(String markdown) { // // if (StringUtils.isBlank(markdown)) { // return ""; // } // // MarkdownProcessor proc = new MarkdownProcessor(); // return proc.markdown(markdown); // } // }
import com.day.cq.dam.api.Asset; import com.day.cq.dam.api.Rendition; import com.headwire.aemsolrsearch.geometrixxmedia.model.exceptions.SlingModelsException; import com.headwire.aemsolrsearch.geometrixxmedia.util.HtmlUtils; import com.headwire.aemsolrsearch.geometrixxmedia.util.MarkdownUtils; import org.apache.commons.io.IOUtils; import org.apache.sling.api.resource.Resource; import org.apache.sling.api.resource.ResourceUtil; import org.apache.sling.models.annotations.Default; import org.apache.sling.models.annotations.Model; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.annotation.PostConstruct; import java.io.IOException; import java.io.StringWriter;
if (null == resource) { LOG.info("Resource is null"); throw new SlingModelsException("Resource is null"); } if (ResourceUtil.isNonExistingResource(resource)) { LOG.warn("Can't adapt non existent resource: '{}'", resource.getPath()); throw new SlingModelsException( "Can't adapt non existent resource." + resource.getPath()); } this.resource = resource; } public GeometrixxMediaArticleBody(String body){ this.body = body; } public String getBody() { return body; } public String getBodyAsHtml() { return MarkdownUtils.markdownToHtml(body); } public String getBodyAsText() { // Markdown to HTML to plain text.
// Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/exceptions/SlingModelsException.java // public class SlingModelsException extends Exception { // // public SlingModelsException(String message) { // super(message); // } // // } // // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/util/HtmlUtils.java // public class HtmlUtils { // // /** // * Converts HTML to plain text. // * // * @param html // * @return Plain text on success and an empty string otherwise. // */ // public static String htmlToText(String html) { // // if (StringUtils.isBlank(html)) { // return ""; // } // // return Jsoup.parse(html).text(); // } // } // // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/util/MarkdownUtils.java // public class MarkdownUtils { // // /** // * Converts Markdown to HTML. // * // * @param markdown // * @return Markdown on success and an empty string otherwise. // */ // public static String markdownToHtml(String markdown) { // // if (StringUtils.isBlank(markdown)) { // return ""; // } // // MarkdownProcessor proc = new MarkdownProcessor(); // return proc.markdown(markdown); // } // } // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaArticleBody.java import com.day.cq.dam.api.Asset; import com.day.cq.dam.api.Rendition; import com.headwire.aemsolrsearch.geometrixxmedia.model.exceptions.SlingModelsException; import com.headwire.aemsolrsearch.geometrixxmedia.util.HtmlUtils; import com.headwire.aemsolrsearch.geometrixxmedia.util.MarkdownUtils; import org.apache.commons.io.IOUtils; import org.apache.sling.api.resource.Resource; import org.apache.sling.api.resource.ResourceUtil; import org.apache.sling.models.annotations.Default; import org.apache.sling.models.annotations.Model; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.annotation.PostConstruct; import java.io.IOException; import java.io.StringWriter; if (null == resource) { LOG.info("Resource is null"); throw new SlingModelsException("Resource is null"); } if (ResourceUtil.isNonExistingResource(resource)) { LOG.warn("Can't adapt non existent resource: '{}'", resource.getPath()); throw new SlingModelsException( "Can't adapt non existent resource." + resource.getPath()); } this.resource = resource; } public GeometrixxMediaArticleBody(String body){ this.body = body; } public String getBody() { return body; } public String getBodyAsHtml() { return MarkdownUtils.markdownToHtml(body); } public String getBodyAsText() { // Markdown to HTML to plain text.
return HtmlUtils.htmlToText(getBodyAsHtml());
headwirecom/aem-solr-search
aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaPage.java
// Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/exceptions/SlingModelsException.java // public class SlingModelsException extends Exception { // // public SlingModelsException(String message) { // super(message); // } // // }
import com.headwire.aemsolrsearch.geometrixxmedia.model.exceptions.SlingModelsException; import org.apache.sling.api.resource.Resource; import org.apache.sling.api.resource.ResourceUtil; import org.apache.sling.models.annotations.Model; import org.apache.solr.common.SolrInputDocument; import org.json.simple.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.annotation.PostConstruct; import javax.inject.Inject; import javax.inject.Named;
package com.headwire.aemsolrsearch.geometrixxmedia.model; /** * Sling model representing a Geometrixx Media Page. * */ @Model(adaptables = Resource.class, adapters = {GeometrixxMediaContentType.class, GeometrixxMediaPage.class}) public class GeometrixxMediaPage implements GeometrixxMediaContentType{ private static final Logger LOG = LoggerFactory.getLogger(GeometrixxMediaPage.class); private GeometrixxMediaPageContent pageContent; @Inject @Named("jcr:content") private Resource jcrResource; @PostConstruct
// Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/exceptions/SlingModelsException.java // public class SlingModelsException extends Exception { // // public SlingModelsException(String message) { // super(message); // } // // } // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaPage.java import com.headwire.aemsolrsearch.geometrixxmedia.model.exceptions.SlingModelsException; import org.apache.sling.api.resource.Resource; import org.apache.sling.api.resource.ResourceUtil; import org.apache.sling.models.annotations.Model; import org.apache.solr.common.SolrInputDocument; import org.json.simple.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.annotation.PostConstruct; import javax.inject.Inject; import javax.inject.Named; package com.headwire.aemsolrsearch.geometrixxmedia.model; /** * Sling model representing a Geometrixx Media Page. * */ @Model(adaptables = Resource.class, adapters = {GeometrixxMediaContentType.class, GeometrixxMediaPage.class}) public class GeometrixxMediaPage implements GeometrixxMediaContentType{ private static final Logger LOG = LoggerFactory.getLogger(GeometrixxMediaPage.class); private GeometrixxMediaPageContent pageContent; @Inject @Named("jcr:content") private Resource jcrResource; @PostConstruct
public void init() throws SlingModelsException {
headwirecom/aem-solr-search
aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaPageContent.java
// Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/exceptions/SlingModelsException.java // public class SlingModelsException extends Exception { // // public SlingModelsException(String message) { // super(message); // } // // } // // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/solr/SolrTimestamp.java // public class SolrTimestamp { // // // private SolrTimestamp() { // // Prevent instantiation // } // // /** // * Converts a date to the UTC DateField format that Solr expects. // * // * @param date // * @return // */ // public static String convertToUtc(Date date) { // // DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:00.00'Z'"); // formatter.setTimeZone(TimeZone.getTimeZone("UTC")); // return formatter.format(date); // } // // public static String convertToUtcAndUseNowIfNull(Date date) { // // return date != null ? convertToUtc(date) : convertToUtc(new Date()); // } // } // // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/solr/GeometrixxMediaSchema.java // public interface GeometrixxMediaSchema { // // public static final String AUTHOR = "author"; // public static final String BODY = "body"; // public static final String DESCRIPTION = "description"; // public static final String ID = "id"; // public static final String LAST_MODIFIED = "last_modified"; // public static final String PUBLISH_DATE = "publishDate"; // public static final String SLING_RESOUCE_TYPE = "sling_resource_type"; // public static final String TAGS = "tags"; // public static final String TITLE = "title"; // public static final String URL = "url"; // // }
import com.day.cq.tagging.Tag; import com.day.cq.tagging.TagManager; import com.day.cq.wcm.api.NameConstants; import com.headwire.aemsolrsearch.geometrixxmedia.model.exceptions.SlingModelsException; import com.headwire.aemsolrsearch.geometrixxmedia.solr.SolrTimestamp; import org.apache.sling.api.resource.Resource; import org.apache.sling.models.annotations.Default; import org.apache.sling.models.annotations.Model; import org.apache.sling.models.annotations.Optional; import org.apache.solr.common.SolrInputDocument; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.annotation.PostConstruct; import javax.inject.Inject; import javax.inject.Named; import java.util.Arrays; import java.util.Date; import static com.headwire.aemsolrsearch.geometrixxmedia.solr.GeometrixxMediaSchema.*;
package com.headwire.aemsolrsearch.geometrixxmedia.model; @Model(adaptables = Resource.class) public class GeometrixxMediaPageContent { private static final Logger LOG = LoggerFactory.getLogger(GeometrixxMediaPageContent.class); private GeometrixxMediaAuthorSummary author; private GeometrixxMediaArticleBody body; private String id; private String url; @Inject @Named("jcr:description") @Default private String description; @Inject @Named("sling:resourceType") private String slingResourceType; @Inject @Named("jcr:title") @Default private String title; @Inject @Named("author-summary/articleAuthor") @Default private String authorRef; @Inject @Named("article-content-par/article/fileReference") @Optional private GeometrixxMediaArticleBody articleBody; @Inject @Named(NameConstants.PN_PAGE_LAST_MOD) @Optional private Date lastUpdate; @Inject @Named("author-summary/publishedDate") @Optional private Date publishDate; private Tag[] tags; private Resource resource; @PostConstruct
// Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/exceptions/SlingModelsException.java // public class SlingModelsException extends Exception { // // public SlingModelsException(String message) { // super(message); // } // // } // // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/solr/SolrTimestamp.java // public class SolrTimestamp { // // // private SolrTimestamp() { // // Prevent instantiation // } // // /** // * Converts a date to the UTC DateField format that Solr expects. // * // * @param date // * @return // */ // public static String convertToUtc(Date date) { // // DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:00.00'Z'"); // formatter.setTimeZone(TimeZone.getTimeZone("UTC")); // return formatter.format(date); // } // // public static String convertToUtcAndUseNowIfNull(Date date) { // // return date != null ? convertToUtc(date) : convertToUtc(new Date()); // } // } // // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/solr/GeometrixxMediaSchema.java // public interface GeometrixxMediaSchema { // // public static final String AUTHOR = "author"; // public static final String BODY = "body"; // public static final String DESCRIPTION = "description"; // public static final String ID = "id"; // public static final String LAST_MODIFIED = "last_modified"; // public static final String PUBLISH_DATE = "publishDate"; // public static final String SLING_RESOUCE_TYPE = "sling_resource_type"; // public static final String TAGS = "tags"; // public static final String TITLE = "title"; // public static final String URL = "url"; // // } // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaPageContent.java import com.day.cq.tagging.Tag; import com.day.cq.tagging.TagManager; import com.day.cq.wcm.api.NameConstants; import com.headwire.aemsolrsearch.geometrixxmedia.model.exceptions.SlingModelsException; import com.headwire.aemsolrsearch.geometrixxmedia.solr.SolrTimestamp; import org.apache.sling.api.resource.Resource; import org.apache.sling.models.annotations.Default; import org.apache.sling.models.annotations.Model; import org.apache.sling.models.annotations.Optional; import org.apache.solr.common.SolrInputDocument; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.annotation.PostConstruct; import javax.inject.Inject; import javax.inject.Named; import java.util.Arrays; import java.util.Date; import static com.headwire.aemsolrsearch.geometrixxmedia.solr.GeometrixxMediaSchema.*; package com.headwire.aemsolrsearch.geometrixxmedia.model; @Model(adaptables = Resource.class) public class GeometrixxMediaPageContent { private static final Logger LOG = LoggerFactory.getLogger(GeometrixxMediaPageContent.class); private GeometrixxMediaAuthorSummary author; private GeometrixxMediaArticleBody body; private String id; private String url; @Inject @Named("jcr:description") @Default private String description; @Inject @Named("sling:resourceType") private String slingResourceType; @Inject @Named("jcr:title") @Default private String title; @Inject @Named("author-summary/articleAuthor") @Default private String authorRef; @Inject @Named("article-content-par/article/fileReference") @Optional private GeometrixxMediaArticleBody articleBody; @Inject @Named(NameConstants.PN_PAGE_LAST_MOD) @Optional private Date lastUpdate; @Inject @Named("author-summary/publishedDate") @Optional private Date publishDate; private Tag[] tags; private Resource resource; @PostConstruct
public void init() throws SlingModelsException {
headwirecom/aem-solr-search
aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaPageContent.java
// Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/exceptions/SlingModelsException.java // public class SlingModelsException extends Exception { // // public SlingModelsException(String message) { // super(message); // } // // } // // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/solr/SolrTimestamp.java // public class SolrTimestamp { // // // private SolrTimestamp() { // // Prevent instantiation // } // // /** // * Converts a date to the UTC DateField format that Solr expects. // * // * @param date // * @return // */ // public static String convertToUtc(Date date) { // // DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:00.00'Z'"); // formatter.setTimeZone(TimeZone.getTimeZone("UTC")); // return formatter.format(date); // } // // public static String convertToUtcAndUseNowIfNull(Date date) { // // return date != null ? convertToUtc(date) : convertToUtc(new Date()); // } // } // // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/solr/GeometrixxMediaSchema.java // public interface GeometrixxMediaSchema { // // public static final String AUTHOR = "author"; // public static final String BODY = "body"; // public static final String DESCRIPTION = "description"; // public static final String ID = "id"; // public static final String LAST_MODIFIED = "last_modified"; // public static final String PUBLISH_DATE = "publishDate"; // public static final String SLING_RESOUCE_TYPE = "sling_resource_type"; // public static final String TAGS = "tags"; // public static final String TITLE = "title"; // public static final String URL = "url"; // // }
import com.day.cq.tagging.Tag; import com.day.cq.tagging.TagManager; import com.day.cq.wcm.api.NameConstants; import com.headwire.aemsolrsearch.geometrixxmedia.model.exceptions.SlingModelsException; import com.headwire.aemsolrsearch.geometrixxmedia.solr.SolrTimestamp; import org.apache.sling.api.resource.Resource; import org.apache.sling.models.annotations.Default; import org.apache.sling.models.annotations.Model; import org.apache.sling.models.annotations.Optional; import org.apache.solr.common.SolrInputDocument; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.annotation.PostConstruct; import javax.inject.Inject; import javax.inject.Named; import java.util.Arrays; import java.util.Date; import static com.headwire.aemsolrsearch.geometrixxmedia.solr.GeometrixxMediaSchema.*;
return publishDate; } public Tag[] getTags() { return tags; } public String toString() { final StringBuilder sb = new StringBuilder(""); sb.append("author=").append(author); sb.append(", body=").append(body); sb.append(", description='").append(description).append('\''); sb.append(", id='").append(id).append('\''); sb.append(", title='").append(title).append('\''); sb.append(", url='").append(url).append('\''); sb.append(", slingResourceType='").append(slingResourceType).append('\''); sb.append(", lastUpdate=").append(lastUpdate); sb.append(", publishDate=").append(publishDate); sb.append(", tags=").append(Arrays.toString(tags)); return sb.toString(); } protected JSONObject getJson() { JSONObject json = new JSONObject(); json.put(ID, getId()); json.put(TITLE, getTitle()); json.put(DESCRIPTION, getDescription()); json.put(BODY, getBody().getBodyAsText()); json.put(AUTHOR, getAuthor().displayName());
// Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/exceptions/SlingModelsException.java // public class SlingModelsException extends Exception { // // public SlingModelsException(String message) { // super(message); // } // // } // // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/solr/SolrTimestamp.java // public class SolrTimestamp { // // // private SolrTimestamp() { // // Prevent instantiation // } // // /** // * Converts a date to the UTC DateField format that Solr expects. // * // * @param date // * @return // */ // public static String convertToUtc(Date date) { // // DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:00.00'Z'"); // formatter.setTimeZone(TimeZone.getTimeZone("UTC")); // return formatter.format(date); // } // // public static String convertToUtcAndUseNowIfNull(Date date) { // // return date != null ? convertToUtc(date) : convertToUtc(new Date()); // } // } // // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/solr/GeometrixxMediaSchema.java // public interface GeometrixxMediaSchema { // // public static final String AUTHOR = "author"; // public static final String BODY = "body"; // public static final String DESCRIPTION = "description"; // public static final String ID = "id"; // public static final String LAST_MODIFIED = "last_modified"; // public static final String PUBLISH_DATE = "publishDate"; // public static final String SLING_RESOUCE_TYPE = "sling_resource_type"; // public static final String TAGS = "tags"; // public static final String TITLE = "title"; // public static final String URL = "url"; // // } // Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaPageContent.java import com.day.cq.tagging.Tag; import com.day.cq.tagging.TagManager; import com.day.cq.wcm.api.NameConstants; import com.headwire.aemsolrsearch.geometrixxmedia.model.exceptions.SlingModelsException; import com.headwire.aemsolrsearch.geometrixxmedia.solr.SolrTimestamp; import org.apache.sling.api.resource.Resource; import org.apache.sling.models.annotations.Default; import org.apache.sling.models.annotations.Model; import org.apache.sling.models.annotations.Optional; import org.apache.solr.common.SolrInputDocument; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.annotation.PostConstruct; import javax.inject.Inject; import javax.inject.Named; import java.util.Arrays; import java.util.Date; import static com.headwire.aemsolrsearch.geometrixxmedia.solr.GeometrixxMediaSchema.*; return publishDate; } public Tag[] getTags() { return tags; } public String toString() { final StringBuilder sb = new StringBuilder(""); sb.append("author=").append(author); sb.append(", body=").append(body); sb.append(", description='").append(description).append('\''); sb.append(", id='").append(id).append('\''); sb.append(", title='").append(title).append('\''); sb.append(", url='").append(url).append('\''); sb.append(", slingResourceType='").append(slingResourceType).append('\''); sb.append(", lastUpdate=").append(lastUpdate); sb.append(", publishDate=").append(publishDate); sb.append(", tags=").append(Arrays.toString(tags)); return sb.toString(); } protected JSONObject getJson() { JSONObject json = new JSONObject(); json.put(ID, getId()); json.put(TITLE, getTitle()); json.put(DESCRIPTION, getDescription()); json.put(BODY, getBody().getBodyAsText()); json.put(AUTHOR, getAuthor().displayName());
json.put(LAST_MODIFIED, SolrTimestamp.convertToUtcAndUseNowIfNull(getLastUpdate()));
CyclopsMC/ColossalChests
src/main/java/org/cyclops/colossalchests/tileentity/TileUncolossalChestConfig.java
// Path: src/main/java/org/cyclops/colossalchests/ColossalChests.java // @Mod(Reference.MOD_ID) // public class ColossalChests extends ModBaseVersionable<ColossalChests> { // // /** // * The unique instance of this mod. // */ // public static ColossalChests _instance; // // public ColossalChests() { // super(Reference.MOD_ID, (instance) -> _instance = instance); // } // // @Override // protected void loadModCompats(ModCompatLoader modCompatLoader) { // modCompatLoader.addModCompat(new IronChestModCompat()); // modCompatLoader.addModCompat(new CommonCapabilitiesModCompat()); // } // // @Override // protected void setup(FMLCommonSetupEvent event) { // super.setup(event); // Advancements.load(); // } // // @Override // @OnlyIn(Dist.CLIENT) // protected IClientProxy constructClientProxy() { // return new ClientProxy(); // } // // @Override // protected ICommonProxy constructCommonProxy() { // return new CommonProxy(); // } // // @Override // public ItemGroup constructDefaultItemGroup() { // return new ItemGroupMod(this, () -> RegistryEntries.ITEM_CHEST); // } // // @Override // protected void onConfigsRegister(ConfigHandler configHandler) { // super.onConfigsRegister(configHandler); // // configHandler.addConfigurable(new GeneralConfig()); // // for (ChestMaterial material : ChestMaterial.VALUES) { // configHandler.addConfigurable(new ChestWallConfig(material)); // configHandler.addConfigurable(new ColossalChestConfig(material)); // configHandler.addConfigurable(new InterfaceConfig(material)); // } // // configHandler.addConfigurable(new UncolossalChestConfig()); // configHandler.addConfigurable(new ItemUpgradeToolConfig(true)); // configHandler.addConfigurable(new ItemUpgradeToolConfig(false)); // // configHandler.addConfigurable(new TileColossalChestConfig()); // configHandler.addConfigurable(new TileInterfaceConfig()); // configHandler.addConfigurable(new TileUncolossalChestConfig()); // // configHandler.addConfigurable(new ContainerColossalChestConfig()); // configHandler.addConfigurable(new ContainerUncolossalChestConfig()); // // configHandler.addConfigurable(new RecipeConditionMetalVariantsSettingConfig()); // } // // /** // * Log a new info message for this mod. // * @param message The message to show. // */ // public static void clog(String message) { // clog(Level.INFO, message); // } // // /** // * Log a new message of the given level for this mod. // * @param level The level in which the message must be shown. // * @param message The message to show. // */ // public static void clog(Level level, String message) { // ColossalChests._instance.getLoggerHelper().log(level, message); // } // // } // // Path: src/main/java/org/cyclops/colossalchests/RegistryEntries.java // public class RegistryEntries { // // @ObjectHolder("minecraft:chest") // public static final Item ITEM_CHEST = null; // // @ObjectHolder("colossalchests:uncolossal_chest") // public static final Block BLOCK_UNCOLOSSAL_CHEST = null; // // @ObjectHolder("colossalchests:colossal_chest") // public static final TileEntityType<TileColossalChest> TILE_ENTITY_COLOSSAL_CHEST = null; // @ObjectHolder("colossalchests:interface") // public static final TileEntityType<TileInterface> TILE_ENTITY_INTERFACE = null; // @ObjectHolder("colossalchests:uncolossal_chest") // public static final TileEntityType<TileColossalChest> TILE_ENTITY_UNCOLOSSAL_CHEST = null; // // @ObjectHolder("colossalchests:colossal_chest") // public static final ContainerType<ContainerColossalChest> CONTAINER_COLOSSAL_CHEST = null; // @ObjectHolder("colossalchests:uncolossal_chest") // public static final ContainerType<ContainerUncolossalChest> CONTAINER_UNCOLOSSAL_CHEST = null; // // } // // Path: src/main/java/org/cyclops/colossalchests/client/render/tileentity/RenderTileEntityUncolossalChest.java // @OnlyIn(Dist.CLIENT) // public class RenderTileEntityUncolossalChest extends RenderTileEntityChestBase<TileUncolossalChest> { // // public RenderTileEntityUncolossalChest(TileEntityRendererDispatcher tileEntityRendererDispatcher) { // super(tileEntityRendererDispatcher); // } // // @Override // protected Direction getDirection(TileUncolossalChest tile) { // return tile.getRotation(); // } // // @Override // public void render(TileUncolossalChest tile, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer renderTypeBuffer, int combinedLightIn, int combinedOverlayIn) { // matrixStack.push(); // matrixStack.translate(0.325F, 0F, 0.325F); // float size = 0.3F * 1.125F; // matrixStack.scale(size, size, size); // super.render(tile, partialTicks, matrixStack, renderTypeBuffer, combinedLightIn, combinedOverlayIn); // matrixStack.pop(); // } // // }
import com.google.common.collect.Sets; import net.minecraft.tileentity.TileEntityType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import org.cyclops.colossalchests.ColossalChests; import org.cyclops.colossalchests.RegistryEntries; import org.cyclops.colossalchests.client.render.tileentity.RenderTileEntityUncolossalChest; import org.cyclops.cyclopscore.config.extendedconfig.TileEntityConfig;
package org.cyclops.colossalchests.tileentity; /** * Config for the {@link TileUncolossalChest}. * @author rubensworks * */ public class TileUncolossalChestConfig extends TileEntityConfig<TileUncolossalChest> { public TileUncolossalChestConfig() { super(
// Path: src/main/java/org/cyclops/colossalchests/ColossalChests.java // @Mod(Reference.MOD_ID) // public class ColossalChests extends ModBaseVersionable<ColossalChests> { // // /** // * The unique instance of this mod. // */ // public static ColossalChests _instance; // // public ColossalChests() { // super(Reference.MOD_ID, (instance) -> _instance = instance); // } // // @Override // protected void loadModCompats(ModCompatLoader modCompatLoader) { // modCompatLoader.addModCompat(new IronChestModCompat()); // modCompatLoader.addModCompat(new CommonCapabilitiesModCompat()); // } // // @Override // protected void setup(FMLCommonSetupEvent event) { // super.setup(event); // Advancements.load(); // } // // @Override // @OnlyIn(Dist.CLIENT) // protected IClientProxy constructClientProxy() { // return new ClientProxy(); // } // // @Override // protected ICommonProxy constructCommonProxy() { // return new CommonProxy(); // } // // @Override // public ItemGroup constructDefaultItemGroup() { // return new ItemGroupMod(this, () -> RegistryEntries.ITEM_CHEST); // } // // @Override // protected void onConfigsRegister(ConfigHandler configHandler) { // super.onConfigsRegister(configHandler); // // configHandler.addConfigurable(new GeneralConfig()); // // for (ChestMaterial material : ChestMaterial.VALUES) { // configHandler.addConfigurable(new ChestWallConfig(material)); // configHandler.addConfigurable(new ColossalChestConfig(material)); // configHandler.addConfigurable(new InterfaceConfig(material)); // } // // configHandler.addConfigurable(new UncolossalChestConfig()); // configHandler.addConfigurable(new ItemUpgradeToolConfig(true)); // configHandler.addConfigurable(new ItemUpgradeToolConfig(false)); // // configHandler.addConfigurable(new TileColossalChestConfig()); // configHandler.addConfigurable(new TileInterfaceConfig()); // configHandler.addConfigurable(new TileUncolossalChestConfig()); // // configHandler.addConfigurable(new ContainerColossalChestConfig()); // configHandler.addConfigurable(new ContainerUncolossalChestConfig()); // // configHandler.addConfigurable(new RecipeConditionMetalVariantsSettingConfig()); // } // // /** // * Log a new info message for this mod. // * @param message The message to show. // */ // public static void clog(String message) { // clog(Level.INFO, message); // } // // /** // * Log a new message of the given level for this mod. // * @param level The level in which the message must be shown. // * @param message The message to show. // */ // public static void clog(Level level, String message) { // ColossalChests._instance.getLoggerHelper().log(level, message); // } // // } // // Path: src/main/java/org/cyclops/colossalchests/RegistryEntries.java // public class RegistryEntries { // // @ObjectHolder("minecraft:chest") // public static final Item ITEM_CHEST = null; // // @ObjectHolder("colossalchests:uncolossal_chest") // public static final Block BLOCK_UNCOLOSSAL_CHEST = null; // // @ObjectHolder("colossalchests:colossal_chest") // public static final TileEntityType<TileColossalChest> TILE_ENTITY_COLOSSAL_CHEST = null; // @ObjectHolder("colossalchests:interface") // public static final TileEntityType<TileInterface> TILE_ENTITY_INTERFACE = null; // @ObjectHolder("colossalchests:uncolossal_chest") // public static final TileEntityType<TileColossalChest> TILE_ENTITY_UNCOLOSSAL_CHEST = null; // // @ObjectHolder("colossalchests:colossal_chest") // public static final ContainerType<ContainerColossalChest> CONTAINER_COLOSSAL_CHEST = null; // @ObjectHolder("colossalchests:uncolossal_chest") // public static final ContainerType<ContainerUncolossalChest> CONTAINER_UNCOLOSSAL_CHEST = null; // // } // // Path: src/main/java/org/cyclops/colossalchests/client/render/tileentity/RenderTileEntityUncolossalChest.java // @OnlyIn(Dist.CLIENT) // public class RenderTileEntityUncolossalChest extends RenderTileEntityChestBase<TileUncolossalChest> { // // public RenderTileEntityUncolossalChest(TileEntityRendererDispatcher tileEntityRendererDispatcher) { // super(tileEntityRendererDispatcher); // } // // @Override // protected Direction getDirection(TileUncolossalChest tile) { // return tile.getRotation(); // } // // @Override // public void render(TileUncolossalChest tile, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer renderTypeBuffer, int combinedLightIn, int combinedOverlayIn) { // matrixStack.push(); // matrixStack.translate(0.325F, 0F, 0.325F); // float size = 0.3F * 1.125F; // matrixStack.scale(size, size, size); // super.render(tile, partialTicks, matrixStack, renderTypeBuffer, combinedLightIn, combinedOverlayIn); // matrixStack.pop(); // } // // } // Path: src/main/java/org/cyclops/colossalchests/tileentity/TileUncolossalChestConfig.java import com.google.common.collect.Sets; import net.minecraft.tileentity.TileEntityType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import org.cyclops.colossalchests.ColossalChests; import org.cyclops.colossalchests.RegistryEntries; import org.cyclops.colossalchests.client.render.tileentity.RenderTileEntityUncolossalChest; import org.cyclops.cyclopscore.config.extendedconfig.TileEntityConfig; package org.cyclops.colossalchests.tileentity; /** * Config for the {@link TileUncolossalChest}. * @author rubensworks * */ public class TileUncolossalChestConfig extends TileEntityConfig<TileUncolossalChest> { public TileUncolossalChestConfig() { super(
ColossalChests._instance,
CyclopsMC/ColossalChests
src/main/java/org/cyclops/colossalchests/tileentity/TileUncolossalChestConfig.java
// Path: src/main/java/org/cyclops/colossalchests/ColossalChests.java // @Mod(Reference.MOD_ID) // public class ColossalChests extends ModBaseVersionable<ColossalChests> { // // /** // * The unique instance of this mod. // */ // public static ColossalChests _instance; // // public ColossalChests() { // super(Reference.MOD_ID, (instance) -> _instance = instance); // } // // @Override // protected void loadModCompats(ModCompatLoader modCompatLoader) { // modCompatLoader.addModCompat(new IronChestModCompat()); // modCompatLoader.addModCompat(new CommonCapabilitiesModCompat()); // } // // @Override // protected void setup(FMLCommonSetupEvent event) { // super.setup(event); // Advancements.load(); // } // // @Override // @OnlyIn(Dist.CLIENT) // protected IClientProxy constructClientProxy() { // return new ClientProxy(); // } // // @Override // protected ICommonProxy constructCommonProxy() { // return new CommonProxy(); // } // // @Override // public ItemGroup constructDefaultItemGroup() { // return new ItemGroupMod(this, () -> RegistryEntries.ITEM_CHEST); // } // // @Override // protected void onConfigsRegister(ConfigHandler configHandler) { // super.onConfigsRegister(configHandler); // // configHandler.addConfigurable(new GeneralConfig()); // // for (ChestMaterial material : ChestMaterial.VALUES) { // configHandler.addConfigurable(new ChestWallConfig(material)); // configHandler.addConfigurable(new ColossalChestConfig(material)); // configHandler.addConfigurable(new InterfaceConfig(material)); // } // // configHandler.addConfigurable(new UncolossalChestConfig()); // configHandler.addConfigurable(new ItemUpgradeToolConfig(true)); // configHandler.addConfigurable(new ItemUpgradeToolConfig(false)); // // configHandler.addConfigurable(new TileColossalChestConfig()); // configHandler.addConfigurable(new TileInterfaceConfig()); // configHandler.addConfigurable(new TileUncolossalChestConfig()); // // configHandler.addConfigurable(new ContainerColossalChestConfig()); // configHandler.addConfigurable(new ContainerUncolossalChestConfig()); // // configHandler.addConfigurable(new RecipeConditionMetalVariantsSettingConfig()); // } // // /** // * Log a new info message for this mod. // * @param message The message to show. // */ // public static void clog(String message) { // clog(Level.INFO, message); // } // // /** // * Log a new message of the given level for this mod. // * @param level The level in which the message must be shown. // * @param message The message to show. // */ // public static void clog(Level level, String message) { // ColossalChests._instance.getLoggerHelper().log(level, message); // } // // } // // Path: src/main/java/org/cyclops/colossalchests/RegistryEntries.java // public class RegistryEntries { // // @ObjectHolder("minecraft:chest") // public static final Item ITEM_CHEST = null; // // @ObjectHolder("colossalchests:uncolossal_chest") // public static final Block BLOCK_UNCOLOSSAL_CHEST = null; // // @ObjectHolder("colossalchests:colossal_chest") // public static final TileEntityType<TileColossalChest> TILE_ENTITY_COLOSSAL_CHEST = null; // @ObjectHolder("colossalchests:interface") // public static final TileEntityType<TileInterface> TILE_ENTITY_INTERFACE = null; // @ObjectHolder("colossalchests:uncolossal_chest") // public static final TileEntityType<TileColossalChest> TILE_ENTITY_UNCOLOSSAL_CHEST = null; // // @ObjectHolder("colossalchests:colossal_chest") // public static final ContainerType<ContainerColossalChest> CONTAINER_COLOSSAL_CHEST = null; // @ObjectHolder("colossalchests:uncolossal_chest") // public static final ContainerType<ContainerUncolossalChest> CONTAINER_UNCOLOSSAL_CHEST = null; // // } // // Path: src/main/java/org/cyclops/colossalchests/client/render/tileentity/RenderTileEntityUncolossalChest.java // @OnlyIn(Dist.CLIENT) // public class RenderTileEntityUncolossalChest extends RenderTileEntityChestBase<TileUncolossalChest> { // // public RenderTileEntityUncolossalChest(TileEntityRendererDispatcher tileEntityRendererDispatcher) { // super(tileEntityRendererDispatcher); // } // // @Override // protected Direction getDirection(TileUncolossalChest tile) { // return tile.getRotation(); // } // // @Override // public void render(TileUncolossalChest tile, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer renderTypeBuffer, int combinedLightIn, int combinedOverlayIn) { // matrixStack.push(); // matrixStack.translate(0.325F, 0F, 0.325F); // float size = 0.3F * 1.125F; // matrixStack.scale(size, size, size); // super.render(tile, partialTicks, matrixStack, renderTypeBuffer, combinedLightIn, combinedOverlayIn); // matrixStack.pop(); // } // // }
import com.google.common.collect.Sets; import net.minecraft.tileentity.TileEntityType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import org.cyclops.colossalchests.ColossalChests; import org.cyclops.colossalchests.RegistryEntries; import org.cyclops.colossalchests.client.render.tileentity.RenderTileEntityUncolossalChest; import org.cyclops.cyclopscore.config.extendedconfig.TileEntityConfig;
package org.cyclops.colossalchests.tileentity; /** * Config for the {@link TileUncolossalChest}. * @author rubensworks * */ public class TileUncolossalChestConfig extends TileEntityConfig<TileUncolossalChest> { public TileUncolossalChestConfig() { super( ColossalChests._instance, "uncolossal_chest", (eConfig) -> new TileEntityType<>(TileUncolossalChest::new,
// Path: src/main/java/org/cyclops/colossalchests/ColossalChests.java // @Mod(Reference.MOD_ID) // public class ColossalChests extends ModBaseVersionable<ColossalChests> { // // /** // * The unique instance of this mod. // */ // public static ColossalChests _instance; // // public ColossalChests() { // super(Reference.MOD_ID, (instance) -> _instance = instance); // } // // @Override // protected void loadModCompats(ModCompatLoader modCompatLoader) { // modCompatLoader.addModCompat(new IronChestModCompat()); // modCompatLoader.addModCompat(new CommonCapabilitiesModCompat()); // } // // @Override // protected void setup(FMLCommonSetupEvent event) { // super.setup(event); // Advancements.load(); // } // // @Override // @OnlyIn(Dist.CLIENT) // protected IClientProxy constructClientProxy() { // return new ClientProxy(); // } // // @Override // protected ICommonProxy constructCommonProxy() { // return new CommonProxy(); // } // // @Override // public ItemGroup constructDefaultItemGroup() { // return new ItemGroupMod(this, () -> RegistryEntries.ITEM_CHEST); // } // // @Override // protected void onConfigsRegister(ConfigHandler configHandler) { // super.onConfigsRegister(configHandler); // // configHandler.addConfigurable(new GeneralConfig()); // // for (ChestMaterial material : ChestMaterial.VALUES) { // configHandler.addConfigurable(new ChestWallConfig(material)); // configHandler.addConfigurable(new ColossalChestConfig(material)); // configHandler.addConfigurable(new InterfaceConfig(material)); // } // // configHandler.addConfigurable(new UncolossalChestConfig()); // configHandler.addConfigurable(new ItemUpgradeToolConfig(true)); // configHandler.addConfigurable(new ItemUpgradeToolConfig(false)); // // configHandler.addConfigurable(new TileColossalChestConfig()); // configHandler.addConfigurable(new TileInterfaceConfig()); // configHandler.addConfigurable(new TileUncolossalChestConfig()); // // configHandler.addConfigurable(new ContainerColossalChestConfig()); // configHandler.addConfigurable(new ContainerUncolossalChestConfig()); // // configHandler.addConfigurable(new RecipeConditionMetalVariantsSettingConfig()); // } // // /** // * Log a new info message for this mod. // * @param message The message to show. // */ // public static void clog(String message) { // clog(Level.INFO, message); // } // // /** // * Log a new message of the given level for this mod. // * @param level The level in which the message must be shown. // * @param message The message to show. // */ // public static void clog(Level level, String message) { // ColossalChests._instance.getLoggerHelper().log(level, message); // } // // } // // Path: src/main/java/org/cyclops/colossalchests/RegistryEntries.java // public class RegistryEntries { // // @ObjectHolder("minecraft:chest") // public static final Item ITEM_CHEST = null; // // @ObjectHolder("colossalchests:uncolossal_chest") // public static final Block BLOCK_UNCOLOSSAL_CHEST = null; // // @ObjectHolder("colossalchests:colossal_chest") // public static final TileEntityType<TileColossalChest> TILE_ENTITY_COLOSSAL_CHEST = null; // @ObjectHolder("colossalchests:interface") // public static final TileEntityType<TileInterface> TILE_ENTITY_INTERFACE = null; // @ObjectHolder("colossalchests:uncolossal_chest") // public static final TileEntityType<TileColossalChest> TILE_ENTITY_UNCOLOSSAL_CHEST = null; // // @ObjectHolder("colossalchests:colossal_chest") // public static final ContainerType<ContainerColossalChest> CONTAINER_COLOSSAL_CHEST = null; // @ObjectHolder("colossalchests:uncolossal_chest") // public static final ContainerType<ContainerUncolossalChest> CONTAINER_UNCOLOSSAL_CHEST = null; // // } // // Path: src/main/java/org/cyclops/colossalchests/client/render/tileentity/RenderTileEntityUncolossalChest.java // @OnlyIn(Dist.CLIENT) // public class RenderTileEntityUncolossalChest extends RenderTileEntityChestBase<TileUncolossalChest> { // // public RenderTileEntityUncolossalChest(TileEntityRendererDispatcher tileEntityRendererDispatcher) { // super(tileEntityRendererDispatcher); // } // // @Override // protected Direction getDirection(TileUncolossalChest tile) { // return tile.getRotation(); // } // // @Override // public void render(TileUncolossalChest tile, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer renderTypeBuffer, int combinedLightIn, int combinedOverlayIn) { // matrixStack.push(); // matrixStack.translate(0.325F, 0F, 0.325F); // float size = 0.3F * 1.125F; // matrixStack.scale(size, size, size); // super.render(tile, partialTicks, matrixStack, renderTypeBuffer, combinedLightIn, combinedOverlayIn); // matrixStack.pop(); // } // // } // Path: src/main/java/org/cyclops/colossalchests/tileentity/TileUncolossalChestConfig.java import com.google.common.collect.Sets; import net.minecraft.tileentity.TileEntityType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import org.cyclops.colossalchests.ColossalChests; import org.cyclops.colossalchests.RegistryEntries; import org.cyclops.colossalchests.client.render.tileentity.RenderTileEntityUncolossalChest; import org.cyclops.cyclopscore.config.extendedconfig.TileEntityConfig; package org.cyclops.colossalchests.tileentity; /** * Config for the {@link TileUncolossalChest}. * @author rubensworks * */ public class TileUncolossalChestConfig extends TileEntityConfig<TileUncolossalChest> { public TileUncolossalChestConfig() { super( ColossalChests._instance, "uncolossal_chest", (eConfig) -> new TileEntityType<>(TileUncolossalChest::new,
Sets.newHashSet(RegistryEntries.BLOCK_UNCOLOSSAL_CHEST), null)
CyclopsMC/ColossalChests
src/main/java/org/cyclops/colossalchests/tileentity/TileUncolossalChestConfig.java
// Path: src/main/java/org/cyclops/colossalchests/ColossalChests.java // @Mod(Reference.MOD_ID) // public class ColossalChests extends ModBaseVersionable<ColossalChests> { // // /** // * The unique instance of this mod. // */ // public static ColossalChests _instance; // // public ColossalChests() { // super(Reference.MOD_ID, (instance) -> _instance = instance); // } // // @Override // protected void loadModCompats(ModCompatLoader modCompatLoader) { // modCompatLoader.addModCompat(new IronChestModCompat()); // modCompatLoader.addModCompat(new CommonCapabilitiesModCompat()); // } // // @Override // protected void setup(FMLCommonSetupEvent event) { // super.setup(event); // Advancements.load(); // } // // @Override // @OnlyIn(Dist.CLIENT) // protected IClientProxy constructClientProxy() { // return new ClientProxy(); // } // // @Override // protected ICommonProxy constructCommonProxy() { // return new CommonProxy(); // } // // @Override // public ItemGroup constructDefaultItemGroup() { // return new ItemGroupMod(this, () -> RegistryEntries.ITEM_CHEST); // } // // @Override // protected void onConfigsRegister(ConfigHandler configHandler) { // super.onConfigsRegister(configHandler); // // configHandler.addConfigurable(new GeneralConfig()); // // for (ChestMaterial material : ChestMaterial.VALUES) { // configHandler.addConfigurable(new ChestWallConfig(material)); // configHandler.addConfigurable(new ColossalChestConfig(material)); // configHandler.addConfigurable(new InterfaceConfig(material)); // } // // configHandler.addConfigurable(new UncolossalChestConfig()); // configHandler.addConfigurable(new ItemUpgradeToolConfig(true)); // configHandler.addConfigurable(new ItemUpgradeToolConfig(false)); // // configHandler.addConfigurable(new TileColossalChestConfig()); // configHandler.addConfigurable(new TileInterfaceConfig()); // configHandler.addConfigurable(new TileUncolossalChestConfig()); // // configHandler.addConfigurable(new ContainerColossalChestConfig()); // configHandler.addConfigurable(new ContainerUncolossalChestConfig()); // // configHandler.addConfigurable(new RecipeConditionMetalVariantsSettingConfig()); // } // // /** // * Log a new info message for this mod. // * @param message The message to show. // */ // public static void clog(String message) { // clog(Level.INFO, message); // } // // /** // * Log a new message of the given level for this mod. // * @param level The level in which the message must be shown. // * @param message The message to show. // */ // public static void clog(Level level, String message) { // ColossalChests._instance.getLoggerHelper().log(level, message); // } // // } // // Path: src/main/java/org/cyclops/colossalchests/RegistryEntries.java // public class RegistryEntries { // // @ObjectHolder("minecraft:chest") // public static final Item ITEM_CHEST = null; // // @ObjectHolder("colossalchests:uncolossal_chest") // public static final Block BLOCK_UNCOLOSSAL_CHEST = null; // // @ObjectHolder("colossalchests:colossal_chest") // public static final TileEntityType<TileColossalChest> TILE_ENTITY_COLOSSAL_CHEST = null; // @ObjectHolder("colossalchests:interface") // public static final TileEntityType<TileInterface> TILE_ENTITY_INTERFACE = null; // @ObjectHolder("colossalchests:uncolossal_chest") // public static final TileEntityType<TileColossalChest> TILE_ENTITY_UNCOLOSSAL_CHEST = null; // // @ObjectHolder("colossalchests:colossal_chest") // public static final ContainerType<ContainerColossalChest> CONTAINER_COLOSSAL_CHEST = null; // @ObjectHolder("colossalchests:uncolossal_chest") // public static final ContainerType<ContainerUncolossalChest> CONTAINER_UNCOLOSSAL_CHEST = null; // // } // // Path: src/main/java/org/cyclops/colossalchests/client/render/tileentity/RenderTileEntityUncolossalChest.java // @OnlyIn(Dist.CLIENT) // public class RenderTileEntityUncolossalChest extends RenderTileEntityChestBase<TileUncolossalChest> { // // public RenderTileEntityUncolossalChest(TileEntityRendererDispatcher tileEntityRendererDispatcher) { // super(tileEntityRendererDispatcher); // } // // @Override // protected Direction getDirection(TileUncolossalChest tile) { // return tile.getRotation(); // } // // @Override // public void render(TileUncolossalChest tile, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer renderTypeBuffer, int combinedLightIn, int combinedOverlayIn) { // matrixStack.push(); // matrixStack.translate(0.325F, 0F, 0.325F); // float size = 0.3F * 1.125F; // matrixStack.scale(size, size, size); // super.render(tile, partialTicks, matrixStack, renderTypeBuffer, combinedLightIn, combinedOverlayIn); // matrixStack.pop(); // } // // }
import com.google.common.collect.Sets; import net.minecraft.tileentity.TileEntityType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import org.cyclops.colossalchests.ColossalChests; import org.cyclops.colossalchests.RegistryEntries; import org.cyclops.colossalchests.client.render.tileentity.RenderTileEntityUncolossalChest; import org.cyclops.cyclopscore.config.extendedconfig.TileEntityConfig;
package org.cyclops.colossalchests.tileentity; /** * Config for the {@link TileUncolossalChest}. * @author rubensworks * */ public class TileUncolossalChestConfig extends TileEntityConfig<TileUncolossalChest> { public TileUncolossalChestConfig() { super( ColossalChests._instance, "uncolossal_chest", (eConfig) -> new TileEntityType<>(TileUncolossalChest::new, Sets.newHashSet(RegistryEntries.BLOCK_UNCOLOSSAL_CHEST), null) ); } @Override @OnlyIn(Dist.CLIENT) public void onRegistered() { super.onRegistered();
// Path: src/main/java/org/cyclops/colossalchests/ColossalChests.java // @Mod(Reference.MOD_ID) // public class ColossalChests extends ModBaseVersionable<ColossalChests> { // // /** // * The unique instance of this mod. // */ // public static ColossalChests _instance; // // public ColossalChests() { // super(Reference.MOD_ID, (instance) -> _instance = instance); // } // // @Override // protected void loadModCompats(ModCompatLoader modCompatLoader) { // modCompatLoader.addModCompat(new IronChestModCompat()); // modCompatLoader.addModCompat(new CommonCapabilitiesModCompat()); // } // // @Override // protected void setup(FMLCommonSetupEvent event) { // super.setup(event); // Advancements.load(); // } // // @Override // @OnlyIn(Dist.CLIENT) // protected IClientProxy constructClientProxy() { // return new ClientProxy(); // } // // @Override // protected ICommonProxy constructCommonProxy() { // return new CommonProxy(); // } // // @Override // public ItemGroup constructDefaultItemGroup() { // return new ItemGroupMod(this, () -> RegistryEntries.ITEM_CHEST); // } // // @Override // protected void onConfigsRegister(ConfigHandler configHandler) { // super.onConfigsRegister(configHandler); // // configHandler.addConfigurable(new GeneralConfig()); // // for (ChestMaterial material : ChestMaterial.VALUES) { // configHandler.addConfigurable(new ChestWallConfig(material)); // configHandler.addConfigurable(new ColossalChestConfig(material)); // configHandler.addConfigurable(new InterfaceConfig(material)); // } // // configHandler.addConfigurable(new UncolossalChestConfig()); // configHandler.addConfigurable(new ItemUpgradeToolConfig(true)); // configHandler.addConfigurable(new ItemUpgradeToolConfig(false)); // // configHandler.addConfigurable(new TileColossalChestConfig()); // configHandler.addConfigurable(new TileInterfaceConfig()); // configHandler.addConfigurable(new TileUncolossalChestConfig()); // // configHandler.addConfigurable(new ContainerColossalChestConfig()); // configHandler.addConfigurable(new ContainerUncolossalChestConfig()); // // configHandler.addConfigurable(new RecipeConditionMetalVariantsSettingConfig()); // } // // /** // * Log a new info message for this mod. // * @param message The message to show. // */ // public static void clog(String message) { // clog(Level.INFO, message); // } // // /** // * Log a new message of the given level for this mod. // * @param level The level in which the message must be shown. // * @param message The message to show. // */ // public static void clog(Level level, String message) { // ColossalChests._instance.getLoggerHelper().log(level, message); // } // // } // // Path: src/main/java/org/cyclops/colossalchests/RegistryEntries.java // public class RegistryEntries { // // @ObjectHolder("minecraft:chest") // public static final Item ITEM_CHEST = null; // // @ObjectHolder("colossalchests:uncolossal_chest") // public static final Block BLOCK_UNCOLOSSAL_CHEST = null; // // @ObjectHolder("colossalchests:colossal_chest") // public static final TileEntityType<TileColossalChest> TILE_ENTITY_COLOSSAL_CHEST = null; // @ObjectHolder("colossalchests:interface") // public static final TileEntityType<TileInterface> TILE_ENTITY_INTERFACE = null; // @ObjectHolder("colossalchests:uncolossal_chest") // public static final TileEntityType<TileColossalChest> TILE_ENTITY_UNCOLOSSAL_CHEST = null; // // @ObjectHolder("colossalchests:colossal_chest") // public static final ContainerType<ContainerColossalChest> CONTAINER_COLOSSAL_CHEST = null; // @ObjectHolder("colossalchests:uncolossal_chest") // public static final ContainerType<ContainerUncolossalChest> CONTAINER_UNCOLOSSAL_CHEST = null; // // } // // Path: src/main/java/org/cyclops/colossalchests/client/render/tileentity/RenderTileEntityUncolossalChest.java // @OnlyIn(Dist.CLIENT) // public class RenderTileEntityUncolossalChest extends RenderTileEntityChestBase<TileUncolossalChest> { // // public RenderTileEntityUncolossalChest(TileEntityRendererDispatcher tileEntityRendererDispatcher) { // super(tileEntityRendererDispatcher); // } // // @Override // protected Direction getDirection(TileUncolossalChest tile) { // return tile.getRotation(); // } // // @Override // public void render(TileUncolossalChest tile, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer renderTypeBuffer, int combinedLightIn, int combinedOverlayIn) { // matrixStack.push(); // matrixStack.translate(0.325F, 0F, 0.325F); // float size = 0.3F * 1.125F; // matrixStack.scale(size, size, size); // super.render(tile, partialTicks, matrixStack, renderTypeBuffer, combinedLightIn, combinedOverlayIn); // matrixStack.pop(); // } // // } // Path: src/main/java/org/cyclops/colossalchests/tileentity/TileUncolossalChestConfig.java import com.google.common.collect.Sets; import net.minecraft.tileentity.TileEntityType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import org.cyclops.colossalchests.ColossalChests; import org.cyclops.colossalchests.RegistryEntries; import org.cyclops.colossalchests.client.render.tileentity.RenderTileEntityUncolossalChest; import org.cyclops.cyclopscore.config.extendedconfig.TileEntityConfig; package org.cyclops.colossalchests.tileentity; /** * Config for the {@link TileUncolossalChest}. * @author rubensworks * */ public class TileUncolossalChestConfig extends TileEntityConfig<TileUncolossalChest> { public TileUncolossalChestConfig() { super( ColossalChests._instance, "uncolossal_chest", (eConfig) -> new TileEntityType<>(TileUncolossalChest::new, Sets.newHashSet(RegistryEntries.BLOCK_UNCOLOSSAL_CHEST), null) ); } @Override @OnlyIn(Dist.CLIENT) public void onRegistered() { super.onRegistered();
ColossalChests._instance.getProxy().registerRenderer(getInstance(), RenderTileEntityUncolossalChest::new);
CyclopsMC/ColossalChests
src/main/java/org/cyclops/colossalchests/block/InterfaceConfig.java
// Path: src/main/java/org/cyclops/colossalchests/ColossalChests.java // @Mod(Reference.MOD_ID) // public class ColossalChests extends ModBaseVersionable<ColossalChests> { // // /** // * The unique instance of this mod. // */ // public static ColossalChests _instance; // // public ColossalChests() { // super(Reference.MOD_ID, (instance) -> _instance = instance); // } // // @Override // protected void loadModCompats(ModCompatLoader modCompatLoader) { // modCompatLoader.addModCompat(new IronChestModCompat()); // modCompatLoader.addModCompat(new CommonCapabilitiesModCompat()); // } // // @Override // protected void setup(FMLCommonSetupEvent event) { // super.setup(event); // Advancements.load(); // } // // @Override // @OnlyIn(Dist.CLIENT) // protected IClientProxy constructClientProxy() { // return new ClientProxy(); // } // // @Override // protected ICommonProxy constructCommonProxy() { // return new CommonProxy(); // } // // @Override // public ItemGroup constructDefaultItemGroup() { // return new ItemGroupMod(this, () -> RegistryEntries.ITEM_CHEST); // } // // @Override // protected void onConfigsRegister(ConfigHandler configHandler) { // super.onConfigsRegister(configHandler); // // configHandler.addConfigurable(new GeneralConfig()); // // for (ChestMaterial material : ChestMaterial.VALUES) { // configHandler.addConfigurable(new ChestWallConfig(material)); // configHandler.addConfigurable(new ColossalChestConfig(material)); // configHandler.addConfigurable(new InterfaceConfig(material)); // } // // configHandler.addConfigurable(new UncolossalChestConfig()); // configHandler.addConfigurable(new ItemUpgradeToolConfig(true)); // configHandler.addConfigurable(new ItemUpgradeToolConfig(false)); // // configHandler.addConfigurable(new TileColossalChestConfig()); // configHandler.addConfigurable(new TileInterfaceConfig()); // configHandler.addConfigurable(new TileUncolossalChestConfig()); // // configHandler.addConfigurable(new ContainerColossalChestConfig()); // configHandler.addConfigurable(new ContainerUncolossalChestConfig()); // // configHandler.addConfigurable(new RecipeConditionMetalVariantsSettingConfig()); // } // // /** // * Log a new info message for this mod. // * @param message The message to show. // */ // public static void clog(String message) { // clog(Level.INFO, message); // } // // /** // * Log a new message of the given level for this mod. // * @param level The level in which the message must be shown. // * @param message The message to show. // */ // public static void clog(Level level, String message) { // ColossalChests._instance.getLoggerHelper().log(level, message); // } // // } // // Path: src/main/java/org/cyclops/colossalchests/item/ItemBlockMaterial.java // public class ItemBlockMaterial extends BlockItem { // // private final ChestMaterial material; // // public ItemBlockMaterial(Block block, Properties builder, ChestMaterial material) { // super(block, builder); // this.material = material; // } // // @Override // public void addInformation(ItemStack itemStack, World world, List<ITextComponent> list, ITooltipFlag flag) { // list.add(new TranslationTextComponent(material.getUnlocalizedName()).mergeStyle(TextFormatting.BLUE)); // super.addInformation(itemStack, world, list, flag); // // } // }
import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.item.Item; import org.cyclops.colossalchests.ColossalChests; import org.cyclops.colossalchests.item.ItemBlockMaterial; import org.cyclops.cyclopscore.config.extendedconfig.BlockConfig;
package org.cyclops.colossalchests.block; /** * Config for the {@link Interface}. * @author rubensworks * */ public class InterfaceConfig extends BlockConfig { public InterfaceConfig(ChestMaterial material) { super(
// Path: src/main/java/org/cyclops/colossalchests/ColossalChests.java // @Mod(Reference.MOD_ID) // public class ColossalChests extends ModBaseVersionable<ColossalChests> { // // /** // * The unique instance of this mod. // */ // public static ColossalChests _instance; // // public ColossalChests() { // super(Reference.MOD_ID, (instance) -> _instance = instance); // } // // @Override // protected void loadModCompats(ModCompatLoader modCompatLoader) { // modCompatLoader.addModCompat(new IronChestModCompat()); // modCompatLoader.addModCompat(new CommonCapabilitiesModCompat()); // } // // @Override // protected void setup(FMLCommonSetupEvent event) { // super.setup(event); // Advancements.load(); // } // // @Override // @OnlyIn(Dist.CLIENT) // protected IClientProxy constructClientProxy() { // return new ClientProxy(); // } // // @Override // protected ICommonProxy constructCommonProxy() { // return new CommonProxy(); // } // // @Override // public ItemGroup constructDefaultItemGroup() { // return new ItemGroupMod(this, () -> RegistryEntries.ITEM_CHEST); // } // // @Override // protected void onConfigsRegister(ConfigHandler configHandler) { // super.onConfigsRegister(configHandler); // // configHandler.addConfigurable(new GeneralConfig()); // // for (ChestMaterial material : ChestMaterial.VALUES) { // configHandler.addConfigurable(new ChestWallConfig(material)); // configHandler.addConfigurable(new ColossalChestConfig(material)); // configHandler.addConfigurable(new InterfaceConfig(material)); // } // // configHandler.addConfigurable(new UncolossalChestConfig()); // configHandler.addConfigurable(new ItemUpgradeToolConfig(true)); // configHandler.addConfigurable(new ItemUpgradeToolConfig(false)); // // configHandler.addConfigurable(new TileColossalChestConfig()); // configHandler.addConfigurable(new TileInterfaceConfig()); // configHandler.addConfigurable(new TileUncolossalChestConfig()); // // configHandler.addConfigurable(new ContainerColossalChestConfig()); // configHandler.addConfigurable(new ContainerUncolossalChestConfig()); // // configHandler.addConfigurable(new RecipeConditionMetalVariantsSettingConfig()); // } // // /** // * Log a new info message for this mod. // * @param message The message to show. // */ // public static void clog(String message) { // clog(Level.INFO, message); // } // // /** // * Log a new message of the given level for this mod. // * @param level The level in which the message must be shown. // * @param message The message to show. // */ // public static void clog(Level level, String message) { // ColossalChests._instance.getLoggerHelper().log(level, message); // } // // } // // Path: src/main/java/org/cyclops/colossalchests/item/ItemBlockMaterial.java // public class ItemBlockMaterial extends BlockItem { // // private final ChestMaterial material; // // public ItemBlockMaterial(Block block, Properties builder, ChestMaterial material) { // super(block, builder); // this.material = material; // } // // @Override // public void addInformation(ItemStack itemStack, World world, List<ITextComponent> list, ITooltipFlag flag) { // list.add(new TranslationTextComponent(material.getUnlocalizedName()).mergeStyle(TextFormatting.BLUE)); // super.addInformation(itemStack, world, list, flag); // // } // } // Path: src/main/java/org/cyclops/colossalchests/block/InterfaceConfig.java import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.item.Item; import org.cyclops.colossalchests.ColossalChests; import org.cyclops.colossalchests.item.ItemBlockMaterial; import org.cyclops.cyclopscore.config.extendedconfig.BlockConfig; package org.cyclops.colossalchests.block; /** * Config for the {@link Interface}. * @author rubensworks * */ public class InterfaceConfig extends BlockConfig { public InterfaceConfig(ChestMaterial material) { super(
ColossalChests._instance,
CyclopsMC/ColossalChests
src/main/java/org/cyclops/colossalchests/block/InterfaceConfig.java
// Path: src/main/java/org/cyclops/colossalchests/ColossalChests.java // @Mod(Reference.MOD_ID) // public class ColossalChests extends ModBaseVersionable<ColossalChests> { // // /** // * The unique instance of this mod. // */ // public static ColossalChests _instance; // // public ColossalChests() { // super(Reference.MOD_ID, (instance) -> _instance = instance); // } // // @Override // protected void loadModCompats(ModCompatLoader modCompatLoader) { // modCompatLoader.addModCompat(new IronChestModCompat()); // modCompatLoader.addModCompat(new CommonCapabilitiesModCompat()); // } // // @Override // protected void setup(FMLCommonSetupEvent event) { // super.setup(event); // Advancements.load(); // } // // @Override // @OnlyIn(Dist.CLIENT) // protected IClientProxy constructClientProxy() { // return new ClientProxy(); // } // // @Override // protected ICommonProxy constructCommonProxy() { // return new CommonProxy(); // } // // @Override // public ItemGroup constructDefaultItemGroup() { // return new ItemGroupMod(this, () -> RegistryEntries.ITEM_CHEST); // } // // @Override // protected void onConfigsRegister(ConfigHandler configHandler) { // super.onConfigsRegister(configHandler); // // configHandler.addConfigurable(new GeneralConfig()); // // for (ChestMaterial material : ChestMaterial.VALUES) { // configHandler.addConfigurable(new ChestWallConfig(material)); // configHandler.addConfigurable(new ColossalChestConfig(material)); // configHandler.addConfigurable(new InterfaceConfig(material)); // } // // configHandler.addConfigurable(new UncolossalChestConfig()); // configHandler.addConfigurable(new ItemUpgradeToolConfig(true)); // configHandler.addConfigurable(new ItemUpgradeToolConfig(false)); // // configHandler.addConfigurable(new TileColossalChestConfig()); // configHandler.addConfigurable(new TileInterfaceConfig()); // configHandler.addConfigurable(new TileUncolossalChestConfig()); // // configHandler.addConfigurable(new ContainerColossalChestConfig()); // configHandler.addConfigurable(new ContainerUncolossalChestConfig()); // // configHandler.addConfigurable(new RecipeConditionMetalVariantsSettingConfig()); // } // // /** // * Log a new info message for this mod. // * @param message The message to show. // */ // public static void clog(String message) { // clog(Level.INFO, message); // } // // /** // * Log a new message of the given level for this mod. // * @param level The level in which the message must be shown. // * @param message The message to show. // */ // public static void clog(Level level, String message) { // ColossalChests._instance.getLoggerHelper().log(level, message); // } // // } // // Path: src/main/java/org/cyclops/colossalchests/item/ItemBlockMaterial.java // public class ItemBlockMaterial extends BlockItem { // // private final ChestMaterial material; // // public ItemBlockMaterial(Block block, Properties builder, ChestMaterial material) { // super(block, builder); // this.material = material; // } // // @Override // public void addInformation(ItemStack itemStack, World world, List<ITextComponent> list, ITooltipFlag flag) { // list.add(new TranslationTextComponent(material.getUnlocalizedName()).mergeStyle(TextFormatting.BLUE)); // super.addInformation(itemStack, world, list, flag); // // } // }
import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.item.Item; import org.cyclops.colossalchests.ColossalChests; import org.cyclops.colossalchests.item.ItemBlockMaterial; import org.cyclops.cyclopscore.config.extendedconfig.BlockConfig;
package org.cyclops.colossalchests.block; /** * Config for the {@link Interface}. * @author rubensworks * */ public class InterfaceConfig extends BlockConfig { public InterfaceConfig(ChestMaterial material) { super( ColossalChests._instance, "interface_" + material.getName(), eConfig -> new Interface(Block.Properties.create(Material.ROCK) .hardnessAndResistance(5.0F) .sound(SoundType.WOOD) .harvestLevel(0) // Wood tier .notSolid(), material),
// Path: src/main/java/org/cyclops/colossalchests/ColossalChests.java // @Mod(Reference.MOD_ID) // public class ColossalChests extends ModBaseVersionable<ColossalChests> { // // /** // * The unique instance of this mod. // */ // public static ColossalChests _instance; // // public ColossalChests() { // super(Reference.MOD_ID, (instance) -> _instance = instance); // } // // @Override // protected void loadModCompats(ModCompatLoader modCompatLoader) { // modCompatLoader.addModCompat(new IronChestModCompat()); // modCompatLoader.addModCompat(new CommonCapabilitiesModCompat()); // } // // @Override // protected void setup(FMLCommonSetupEvent event) { // super.setup(event); // Advancements.load(); // } // // @Override // @OnlyIn(Dist.CLIENT) // protected IClientProxy constructClientProxy() { // return new ClientProxy(); // } // // @Override // protected ICommonProxy constructCommonProxy() { // return new CommonProxy(); // } // // @Override // public ItemGroup constructDefaultItemGroup() { // return new ItemGroupMod(this, () -> RegistryEntries.ITEM_CHEST); // } // // @Override // protected void onConfigsRegister(ConfigHandler configHandler) { // super.onConfigsRegister(configHandler); // // configHandler.addConfigurable(new GeneralConfig()); // // for (ChestMaterial material : ChestMaterial.VALUES) { // configHandler.addConfigurable(new ChestWallConfig(material)); // configHandler.addConfigurable(new ColossalChestConfig(material)); // configHandler.addConfigurable(new InterfaceConfig(material)); // } // // configHandler.addConfigurable(new UncolossalChestConfig()); // configHandler.addConfigurable(new ItemUpgradeToolConfig(true)); // configHandler.addConfigurable(new ItemUpgradeToolConfig(false)); // // configHandler.addConfigurable(new TileColossalChestConfig()); // configHandler.addConfigurable(new TileInterfaceConfig()); // configHandler.addConfigurable(new TileUncolossalChestConfig()); // // configHandler.addConfigurable(new ContainerColossalChestConfig()); // configHandler.addConfigurable(new ContainerUncolossalChestConfig()); // // configHandler.addConfigurable(new RecipeConditionMetalVariantsSettingConfig()); // } // // /** // * Log a new info message for this mod. // * @param message The message to show. // */ // public static void clog(String message) { // clog(Level.INFO, message); // } // // /** // * Log a new message of the given level for this mod. // * @param level The level in which the message must be shown. // * @param message The message to show. // */ // public static void clog(Level level, String message) { // ColossalChests._instance.getLoggerHelper().log(level, message); // } // // } // // Path: src/main/java/org/cyclops/colossalchests/item/ItemBlockMaterial.java // public class ItemBlockMaterial extends BlockItem { // // private final ChestMaterial material; // // public ItemBlockMaterial(Block block, Properties builder, ChestMaterial material) { // super(block, builder); // this.material = material; // } // // @Override // public void addInformation(ItemStack itemStack, World world, List<ITextComponent> list, ITooltipFlag flag) { // list.add(new TranslationTextComponent(material.getUnlocalizedName()).mergeStyle(TextFormatting.BLUE)); // super.addInformation(itemStack, world, list, flag); // // } // } // Path: src/main/java/org/cyclops/colossalchests/block/InterfaceConfig.java import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.item.Item; import org.cyclops.colossalchests.ColossalChests; import org.cyclops.colossalchests.item.ItemBlockMaterial; import org.cyclops.cyclopscore.config.extendedconfig.BlockConfig; package org.cyclops.colossalchests.block; /** * Config for the {@link Interface}. * @author rubensworks * */ public class InterfaceConfig extends BlockConfig { public InterfaceConfig(ChestMaterial material) { super( ColossalChests._instance, "interface_" + material.getName(), eConfig -> new Interface(Block.Properties.create(Material.ROCK) .hardnessAndResistance(5.0F) .sound(SoundType.WOOD) .harvestLevel(0) // Wood tier .notSolid(), material),
(eConfig, block) -> new ItemBlockMaterial(block, new Item.Properties()
CyclopsMC/ColossalChests
src/main/java/org/cyclops/colossalchests/block/ColossalChestConfig.java
// Path: src/main/java/org/cyclops/colossalchests/ColossalChests.java // @Mod(Reference.MOD_ID) // public class ColossalChests extends ModBaseVersionable<ColossalChests> { // // /** // * The unique instance of this mod. // */ // public static ColossalChests _instance; // // public ColossalChests() { // super(Reference.MOD_ID, (instance) -> _instance = instance); // } // // @Override // protected void loadModCompats(ModCompatLoader modCompatLoader) { // modCompatLoader.addModCompat(new IronChestModCompat()); // modCompatLoader.addModCompat(new CommonCapabilitiesModCompat()); // } // // @Override // protected void setup(FMLCommonSetupEvent event) { // super.setup(event); // Advancements.load(); // } // // @Override // @OnlyIn(Dist.CLIENT) // protected IClientProxy constructClientProxy() { // return new ClientProxy(); // } // // @Override // protected ICommonProxy constructCommonProxy() { // return new CommonProxy(); // } // // @Override // public ItemGroup constructDefaultItemGroup() { // return new ItemGroupMod(this, () -> RegistryEntries.ITEM_CHEST); // } // // @Override // protected void onConfigsRegister(ConfigHandler configHandler) { // super.onConfigsRegister(configHandler); // // configHandler.addConfigurable(new GeneralConfig()); // // for (ChestMaterial material : ChestMaterial.VALUES) { // configHandler.addConfigurable(new ChestWallConfig(material)); // configHandler.addConfigurable(new ColossalChestConfig(material)); // configHandler.addConfigurable(new InterfaceConfig(material)); // } // // configHandler.addConfigurable(new UncolossalChestConfig()); // configHandler.addConfigurable(new ItemUpgradeToolConfig(true)); // configHandler.addConfigurable(new ItemUpgradeToolConfig(false)); // // configHandler.addConfigurable(new TileColossalChestConfig()); // configHandler.addConfigurable(new TileInterfaceConfig()); // configHandler.addConfigurable(new TileUncolossalChestConfig()); // // configHandler.addConfigurable(new ContainerColossalChestConfig()); // configHandler.addConfigurable(new ContainerUncolossalChestConfig()); // // configHandler.addConfigurable(new RecipeConditionMetalVariantsSettingConfig()); // } // // /** // * Log a new info message for this mod. // * @param message The message to show. // */ // public static void clog(String message) { // clog(Level.INFO, message); // } // // /** // * Log a new message of the given level for this mod. // * @param level The level in which the message must be shown. // * @param message The message to show. // */ // public static void clog(Level level, String message) { // ColossalChests._instance.getLoggerHelper().log(level, message); // } // // } // // Path: src/main/java/org/cyclops/colossalchests/item/ItemBlockMaterial.java // public class ItemBlockMaterial extends BlockItem { // // private final ChestMaterial material; // // public ItemBlockMaterial(Block block, Properties builder, ChestMaterial material) { // super(block, builder); // this.material = material; // } // // @Override // public void addInformation(ItemStack itemStack, World world, List<ITextComponent> list, ITooltipFlag flag) { // list.add(new TranslationTextComponent(material.getUnlocalizedName()).mergeStyle(TextFormatting.BLUE)); // super.addInformation(itemStack, world, list, flag); // // } // }
import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.item.Item; import net.minecraftforge.fml.config.ModConfig; import org.cyclops.colossalchests.ColossalChests; import org.cyclops.colossalchests.item.ItemBlockMaterial; import org.cyclops.cyclopscore.config.ConfigurableProperty; import org.cyclops.cyclopscore.config.extendedconfig.BlockConfig;
package org.cyclops.colossalchests.block; /** * Config for the {@link ColossalChest}. * @author rubensworks * */ public class ColossalChestConfig extends BlockConfig { @ConfigurableProperty(namedId="colossal_chest", category = "machine", comment = "The maximum size a colossal chest can have.", isCommandable = true, configLocation = ModConfig.Type.SERVER) public static int maxSize = 20; @ConfigurableProperty(namedId="colossal_chest", category = "general", comment = "If the chest should visually open when someone uses it.", isCommandable = true, configLocation = ModConfig.Type.CLIENT) public static boolean chestAnimation = true; public ColossalChestConfig(ChestMaterial material) { super(
// Path: src/main/java/org/cyclops/colossalchests/ColossalChests.java // @Mod(Reference.MOD_ID) // public class ColossalChests extends ModBaseVersionable<ColossalChests> { // // /** // * The unique instance of this mod. // */ // public static ColossalChests _instance; // // public ColossalChests() { // super(Reference.MOD_ID, (instance) -> _instance = instance); // } // // @Override // protected void loadModCompats(ModCompatLoader modCompatLoader) { // modCompatLoader.addModCompat(new IronChestModCompat()); // modCompatLoader.addModCompat(new CommonCapabilitiesModCompat()); // } // // @Override // protected void setup(FMLCommonSetupEvent event) { // super.setup(event); // Advancements.load(); // } // // @Override // @OnlyIn(Dist.CLIENT) // protected IClientProxy constructClientProxy() { // return new ClientProxy(); // } // // @Override // protected ICommonProxy constructCommonProxy() { // return new CommonProxy(); // } // // @Override // public ItemGroup constructDefaultItemGroup() { // return new ItemGroupMod(this, () -> RegistryEntries.ITEM_CHEST); // } // // @Override // protected void onConfigsRegister(ConfigHandler configHandler) { // super.onConfigsRegister(configHandler); // // configHandler.addConfigurable(new GeneralConfig()); // // for (ChestMaterial material : ChestMaterial.VALUES) { // configHandler.addConfigurable(new ChestWallConfig(material)); // configHandler.addConfigurable(new ColossalChestConfig(material)); // configHandler.addConfigurable(new InterfaceConfig(material)); // } // // configHandler.addConfigurable(new UncolossalChestConfig()); // configHandler.addConfigurable(new ItemUpgradeToolConfig(true)); // configHandler.addConfigurable(new ItemUpgradeToolConfig(false)); // // configHandler.addConfigurable(new TileColossalChestConfig()); // configHandler.addConfigurable(new TileInterfaceConfig()); // configHandler.addConfigurable(new TileUncolossalChestConfig()); // // configHandler.addConfigurable(new ContainerColossalChestConfig()); // configHandler.addConfigurable(new ContainerUncolossalChestConfig()); // // configHandler.addConfigurable(new RecipeConditionMetalVariantsSettingConfig()); // } // // /** // * Log a new info message for this mod. // * @param message The message to show. // */ // public static void clog(String message) { // clog(Level.INFO, message); // } // // /** // * Log a new message of the given level for this mod. // * @param level The level in which the message must be shown. // * @param message The message to show. // */ // public static void clog(Level level, String message) { // ColossalChests._instance.getLoggerHelper().log(level, message); // } // // } // // Path: src/main/java/org/cyclops/colossalchests/item/ItemBlockMaterial.java // public class ItemBlockMaterial extends BlockItem { // // private final ChestMaterial material; // // public ItemBlockMaterial(Block block, Properties builder, ChestMaterial material) { // super(block, builder); // this.material = material; // } // // @Override // public void addInformation(ItemStack itemStack, World world, List<ITextComponent> list, ITooltipFlag flag) { // list.add(new TranslationTextComponent(material.getUnlocalizedName()).mergeStyle(TextFormatting.BLUE)); // super.addInformation(itemStack, world, list, flag); // // } // } // Path: src/main/java/org/cyclops/colossalchests/block/ColossalChestConfig.java import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.item.Item; import net.minecraftforge.fml.config.ModConfig; import org.cyclops.colossalchests.ColossalChests; import org.cyclops.colossalchests.item.ItemBlockMaterial; import org.cyclops.cyclopscore.config.ConfigurableProperty; import org.cyclops.cyclopscore.config.extendedconfig.BlockConfig; package org.cyclops.colossalchests.block; /** * Config for the {@link ColossalChest}. * @author rubensworks * */ public class ColossalChestConfig extends BlockConfig { @ConfigurableProperty(namedId="colossal_chest", category = "machine", comment = "The maximum size a colossal chest can have.", isCommandable = true, configLocation = ModConfig.Type.SERVER) public static int maxSize = 20; @ConfigurableProperty(namedId="colossal_chest", category = "general", comment = "If the chest should visually open when someone uses it.", isCommandable = true, configLocation = ModConfig.Type.CLIENT) public static boolean chestAnimation = true; public ColossalChestConfig(ChestMaterial material) { super(
ColossalChests._instance,
CyclopsMC/ColossalChests
src/main/java/org/cyclops/colossalchests/block/ColossalChestConfig.java
// Path: src/main/java/org/cyclops/colossalchests/ColossalChests.java // @Mod(Reference.MOD_ID) // public class ColossalChests extends ModBaseVersionable<ColossalChests> { // // /** // * The unique instance of this mod. // */ // public static ColossalChests _instance; // // public ColossalChests() { // super(Reference.MOD_ID, (instance) -> _instance = instance); // } // // @Override // protected void loadModCompats(ModCompatLoader modCompatLoader) { // modCompatLoader.addModCompat(new IronChestModCompat()); // modCompatLoader.addModCompat(new CommonCapabilitiesModCompat()); // } // // @Override // protected void setup(FMLCommonSetupEvent event) { // super.setup(event); // Advancements.load(); // } // // @Override // @OnlyIn(Dist.CLIENT) // protected IClientProxy constructClientProxy() { // return new ClientProxy(); // } // // @Override // protected ICommonProxy constructCommonProxy() { // return new CommonProxy(); // } // // @Override // public ItemGroup constructDefaultItemGroup() { // return new ItemGroupMod(this, () -> RegistryEntries.ITEM_CHEST); // } // // @Override // protected void onConfigsRegister(ConfigHandler configHandler) { // super.onConfigsRegister(configHandler); // // configHandler.addConfigurable(new GeneralConfig()); // // for (ChestMaterial material : ChestMaterial.VALUES) { // configHandler.addConfigurable(new ChestWallConfig(material)); // configHandler.addConfigurable(new ColossalChestConfig(material)); // configHandler.addConfigurable(new InterfaceConfig(material)); // } // // configHandler.addConfigurable(new UncolossalChestConfig()); // configHandler.addConfigurable(new ItemUpgradeToolConfig(true)); // configHandler.addConfigurable(new ItemUpgradeToolConfig(false)); // // configHandler.addConfigurable(new TileColossalChestConfig()); // configHandler.addConfigurable(new TileInterfaceConfig()); // configHandler.addConfigurable(new TileUncolossalChestConfig()); // // configHandler.addConfigurable(new ContainerColossalChestConfig()); // configHandler.addConfigurable(new ContainerUncolossalChestConfig()); // // configHandler.addConfigurable(new RecipeConditionMetalVariantsSettingConfig()); // } // // /** // * Log a new info message for this mod. // * @param message The message to show. // */ // public static void clog(String message) { // clog(Level.INFO, message); // } // // /** // * Log a new message of the given level for this mod. // * @param level The level in which the message must be shown. // * @param message The message to show. // */ // public static void clog(Level level, String message) { // ColossalChests._instance.getLoggerHelper().log(level, message); // } // // } // // Path: src/main/java/org/cyclops/colossalchests/item/ItemBlockMaterial.java // public class ItemBlockMaterial extends BlockItem { // // private final ChestMaterial material; // // public ItemBlockMaterial(Block block, Properties builder, ChestMaterial material) { // super(block, builder); // this.material = material; // } // // @Override // public void addInformation(ItemStack itemStack, World world, List<ITextComponent> list, ITooltipFlag flag) { // list.add(new TranslationTextComponent(material.getUnlocalizedName()).mergeStyle(TextFormatting.BLUE)); // super.addInformation(itemStack, world, list, flag); // // } // }
import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.item.Item; import net.minecraftforge.fml.config.ModConfig; import org.cyclops.colossalchests.ColossalChests; import org.cyclops.colossalchests.item.ItemBlockMaterial; import org.cyclops.cyclopscore.config.ConfigurableProperty; import org.cyclops.cyclopscore.config.extendedconfig.BlockConfig;
package org.cyclops.colossalchests.block; /** * Config for the {@link ColossalChest}. * @author rubensworks * */ public class ColossalChestConfig extends BlockConfig { @ConfigurableProperty(namedId="colossal_chest", category = "machine", comment = "The maximum size a colossal chest can have.", isCommandable = true, configLocation = ModConfig.Type.SERVER) public static int maxSize = 20; @ConfigurableProperty(namedId="colossal_chest", category = "general", comment = "If the chest should visually open when someone uses it.", isCommandable = true, configLocation = ModConfig.Type.CLIENT) public static boolean chestAnimation = true; public ColossalChestConfig(ChestMaterial material) { super( ColossalChests._instance, "colossal_chest_" + material.getName(), eConfig -> new ColossalChest(Block.Properties.create(Material.ROCK) .hardnessAndResistance(5.0F) .sound(SoundType.WOOD) .harvestLevel(0) // Wood tier .notSolid(), material),
// Path: src/main/java/org/cyclops/colossalchests/ColossalChests.java // @Mod(Reference.MOD_ID) // public class ColossalChests extends ModBaseVersionable<ColossalChests> { // // /** // * The unique instance of this mod. // */ // public static ColossalChests _instance; // // public ColossalChests() { // super(Reference.MOD_ID, (instance) -> _instance = instance); // } // // @Override // protected void loadModCompats(ModCompatLoader modCompatLoader) { // modCompatLoader.addModCompat(new IronChestModCompat()); // modCompatLoader.addModCompat(new CommonCapabilitiesModCompat()); // } // // @Override // protected void setup(FMLCommonSetupEvent event) { // super.setup(event); // Advancements.load(); // } // // @Override // @OnlyIn(Dist.CLIENT) // protected IClientProxy constructClientProxy() { // return new ClientProxy(); // } // // @Override // protected ICommonProxy constructCommonProxy() { // return new CommonProxy(); // } // // @Override // public ItemGroup constructDefaultItemGroup() { // return new ItemGroupMod(this, () -> RegistryEntries.ITEM_CHEST); // } // // @Override // protected void onConfigsRegister(ConfigHandler configHandler) { // super.onConfigsRegister(configHandler); // // configHandler.addConfigurable(new GeneralConfig()); // // for (ChestMaterial material : ChestMaterial.VALUES) { // configHandler.addConfigurable(new ChestWallConfig(material)); // configHandler.addConfigurable(new ColossalChestConfig(material)); // configHandler.addConfigurable(new InterfaceConfig(material)); // } // // configHandler.addConfigurable(new UncolossalChestConfig()); // configHandler.addConfigurable(new ItemUpgradeToolConfig(true)); // configHandler.addConfigurable(new ItemUpgradeToolConfig(false)); // // configHandler.addConfigurable(new TileColossalChestConfig()); // configHandler.addConfigurable(new TileInterfaceConfig()); // configHandler.addConfigurable(new TileUncolossalChestConfig()); // // configHandler.addConfigurable(new ContainerColossalChestConfig()); // configHandler.addConfigurable(new ContainerUncolossalChestConfig()); // // configHandler.addConfigurable(new RecipeConditionMetalVariantsSettingConfig()); // } // // /** // * Log a new info message for this mod. // * @param message The message to show. // */ // public static void clog(String message) { // clog(Level.INFO, message); // } // // /** // * Log a new message of the given level for this mod. // * @param level The level in which the message must be shown. // * @param message The message to show. // */ // public static void clog(Level level, String message) { // ColossalChests._instance.getLoggerHelper().log(level, message); // } // // } // // Path: src/main/java/org/cyclops/colossalchests/item/ItemBlockMaterial.java // public class ItemBlockMaterial extends BlockItem { // // private final ChestMaterial material; // // public ItemBlockMaterial(Block block, Properties builder, ChestMaterial material) { // super(block, builder); // this.material = material; // } // // @Override // public void addInformation(ItemStack itemStack, World world, List<ITextComponent> list, ITooltipFlag flag) { // list.add(new TranslationTextComponent(material.getUnlocalizedName()).mergeStyle(TextFormatting.BLUE)); // super.addInformation(itemStack, world, list, flag); // // } // } // Path: src/main/java/org/cyclops/colossalchests/block/ColossalChestConfig.java import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.item.Item; import net.minecraftforge.fml.config.ModConfig; import org.cyclops.colossalchests.ColossalChests; import org.cyclops.colossalchests.item.ItemBlockMaterial; import org.cyclops.cyclopscore.config.ConfigurableProperty; import org.cyclops.cyclopscore.config.extendedconfig.BlockConfig; package org.cyclops.colossalchests.block; /** * Config for the {@link ColossalChest}. * @author rubensworks * */ public class ColossalChestConfig extends BlockConfig { @ConfigurableProperty(namedId="colossal_chest", category = "machine", comment = "The maximum size a colossal chest can have.", isCommandable = true, configLocation = ModConfig.Type.SERVER) public static int maxSize = 20; @ConfigurableProperty(namedId="colossal_chest", category = "general", comment = "If the chest should visually open when someone uses it.", isCommandable = true, configLocation = ModConfig.Type.CLIENT) public static boolean chestAnimation = true; public ColossalChestConfig(ChestMaterial material) { super( ColossalChests._instance, "colossal_chest_" + material.getName(), eConfig -> new ColossalChest(Block.Properties.create(Material.ROCK) .hardnessAndResistance(5.0F) .sound(SoundType.WOOD) .harvestLevel(0) // Wood tier .notSolid(), material),
(eConfig, block) -> new ItemBlockMaterial(block, new Item.Properties()
CyclopsMC/ColossalChests
src/main/java/org/cyclops/colossalchests/proxy/ClientProxy.java
// Path: src/main/java/org/cyclops/colossalchests/ColossalChests.java // @Mod(Reference.MOD_ID) // public class ColossalChests extends ModBaseVersionable<ColossalChests> { // // /** // * The unique instance of this mod. // */ // public static ColossalChests _instance; // // public ColossalChests() { // super(Reference.MOD_ID, (instance) -> _instance = instance); // } // // @Override // protected void loadModCompats(ModCompatLoader modCompatLoader) { // modCompatLoader.addModCompat(new IronChestModCompat()); // modCompatLoader.addModCompat(new CommonCapabilitiesModCompat()); // } // // @Override // protected void setup(FMLCommonSetupEvent event) { // super.setup(event); // Advancements.load(); // } // // @Override // @OnlyIn(Dist.CLIENT) // protected IClientProxy constructClientProxy() { // return new ClientProxy(); // } // // @Override // protected ICommonProxy constructCommonProxy() { // return new CommonProxy(); // } // // @Override // public ItemGroup constructDefaultItemGroup() { // return new ItemGroupMod(this, () -> RegistryEntries.ITEM_CHEST); // } // // @Override // protected void onConfigsRegister(ConfigHandler configHandler) { // super.onConfigsRegister(configHandler); // // configHandler.addConfigurable(new GeneralConfig()); // // for (ChestMaterial material : ChestMaterial.VALUES) { // configHandler.addConfigurable(new ChestWallConfig(material)); // configHandler.addConfigurable(new ColossalChestConfig(material)); // configHandler.addConfigurable(new InterfaceConfig(material)); // } // // configHandler.addConfigurable(new UncolossalChestConfig()); // configHandler.addConfigurable(new ItemUpgradeToolConfig(true)); // configHandler.addConfigurable(new ItemUpgradeToolConfig(false)); // // configHandler.addConfigurable(new TileColossalChestConfig()); // configHandler.addConfigurable(new TileInterfaceConfig()); // configHandler.addConfigurable(new TileUncolossalChestConfig()); // // configHandler.addConfigurable(new ContainerColossalChestConfig()); // configHandler.addConfigurable(new ContainerUncolossalChestConfig()); // // configHandler.addConfigurable(new RecipeConditionMetalVariantsSettingConfig()); // } // // /** // * Log a new info message for this mod. // * @param message The message to show. // */ // public static void clog(String message) { // clog(Level.INFO, message); // } // // /** // * Log a new message of the given level for this mod. // * @param level The level in which the message must be shown. // * @param message The message to show. // */ // public static void clog(Level level, String message) { // ColossalChests._instance.getLoggerHelper().log(level, message); // } // // }
import org.cyclops.colossalchests.ColossalChests; import org.cyclops.cyclopscore.init.ModBase; import org.cyclops.cyclopscore.proxy.ClientProxyComponent;
package org.cyclops.colossalchests.proxy; /** * Proxy for the client side. * * @author rubensworks * */ public class ClientProxy extends ClientProxyComponent { public ClientProxy() { super(new CommonProxy()); } @Override public ModBase getMod() {
// Path: src/main/java/org/cyclops/colossalchests/ColossalChests.java // @Mod(Reference.MOD_ID) // public class ColossalChests extends ModBaseVersionable<ColossalChests> { // // /** // * The unique instance of this mod. // */ // public static ColossalChests _instance; // // public ColossalChests() { // super(Reference.MOD_ID, (instance) -> _instance = instance); // } // // @Override // protected void loadModCompats(ModCompatLoader modCompatLoader) { // modCompatLoader.addModCompat(new IronChestModCompat()); // modCompatLoader.addModCompat(new CommonCapabilitiesModCompat()); // } // // @Override // protected void setup(FMLCommonSetupEvent event) { // super.setup(event); // Advancements.load(); // } // // @Override // @OnlyIn(Dist.CLIENT) // protected IClientProxy constructClientProxy() { // return new ClientProxy(); // } // // @Override // protected ICommonProxy constructCommonProxy() { // return new CommonProxy(); // } // // @Override // public ItemGroup constructDefaultItemGroup() { // return new ItemGroupMod(this, () -> RegistryEntries.ITEM_CHEST); // } // // @Override // protected void onConfigsRegister(ConfigHandler configHandler) { // super.onConfigsRegister(configHandler); // // configHandler.addConfigurable(new GeneralConfig()); // // for (ChestMaterial material : ChestMaterial.VALUES) { // configHandler.addConfigurable(new ChestWallConfig(material)); // configHandler.addConfigurable(new ColossalChestConfig(material)); // configHandler.addConfigurable(new InterfaceConfig(material)); // } // // configHandler.addConfigurable(new UncolossalChestConfig()); // configHandler.addConfigurable(new ItemUpgradeToolConfig(true)); // configHandler.addConfigurable(new ItemUpgradeToolConfig(false)); // // configHandler.addConfigurable(new TileColossalChestConfig()); // configHandler.addConfigurable(new TileInterfaceConfig()); // configHandler.addConfigurable(new TileUncolossalChestConfig()); // // configHandler.addConfigurable(new ContainerColossalChestConfig()); // configHandler.addConfigurable(new ContainerUncolossalChestConfig()); // // configHandler.addConfigurable(new RecipeConditionMetalVariantsSettingConfig()); // } // // /** // * Log a new info message for this mod. // * @param message The message to show. // */ // public static void clog(String message) { // clog(Level.INFO, message); // } // // /** // * Log a new message of the given level for this mod. // * @param level The level in which the message must be shown. // * @param message The message to show. // */ // public static void clog(Level level, String message) { // ColossalChests._instance.getLoggerHelper().log(level, message); // } // // } // Path: src/main/java/org/cyclops/colossalchests/proxy/ClientProxy.java import org.cyclops.colossalchests.ColossalChests; import org.cyclops.cyclopscore.init.ModBase; import org.cyclops.cyclopscore.proxy.ClientProxyComponent; package org.cyclops.colossalchests.proxy; /** * Proxy for the client side. * * @author rubensworks * */ public class ClientProxy extends ClientProxyComponent { public ClientProxy() { super(new CommonProxy()); } @Override public ModBase getMod() {
return ColossalChests._instance;
CyclopsMC/ColossalChests
src/main/java/org/cyclops/colossalchests/tileentity/TileInterface.java
// Path: src/main/java/org/cyclops/colossalchests/RegistryEntries.java // public class RegistryEntries { // // @ObjectHolder("minecraft:chest") // public static final Item ITEM_CHEST = null; // // @ObjectHolder("colossalchests:uncolossal_chest") // public static final Block BLOCK_UNCOLOSSAL_CHEST = null; // // @ObjectHolder("colossalchests:colossal_chest") // public static final TileEntityType<TileColossalChest> TILE_ENTITY_COLOSSAL_CHEST = null; // @ObjectHolder("colossalchests:interface") // public static final TileEntityType<TileInterface> TILE_ENTITY_INTERFACE = null; // @ObjectHolder("colossalchests:uncolossal_chest") // public static final TileEntityType<TileColossalChest> TILE_ENTITY_UNCOLOSSAL_CHEST = null; // // @ObjectHolder("colossalchests:colossal_chest") // public static final ContainerType<ContainerColossalChest> CONTAINER_COLOSSAL_CHEST = null; // @ObjectHolder("colossalchests:uncolossal_chest") // public static final ContainerType<ContainerUncolossalChest> CONTAINER_UNCOLOSSAL_CHEST = null; // // }
import lombok.Getter; import lombok.experimental.Delegate; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.vector.Vector3i; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; import org.cyclops.colossalchests.RegistryEntries; import org.cyclops.cyclopscore.helper.TileHelpers; import org.cyclops.cyclopscore.persist.nbt.NBTPersist; import org.cyclops.cyclopscore.tileentity.CyclopsTileEntity; import javax.annotation.Nonnull; import java.lang.ref.WeakReference;
package org.cyclops.colossalchests.tileentity; /** * A machine that can infuse things with blood. * @author rubensworks * */ public class TileInterface extends CyclopsTileEntity { @Delegate private final ITickingTile tickingTileComponent = new TickingTileComponent(this); @NBTPersist @Getter private Vector3i corePosition = null; private WeakReference<TileColossalChest> coreReference = new WeakReference<TileColossalChest>(null); public TileInterface() {
// Path: src/main/java/org/cyclops/colossalchests/RegistryEntries.java // public class RegistryEntries { // // @ObjectHolder("minecraft:chest") // public static final Item ITEM_CHEST = null; // // @ObjectHolder("colossalchests:uncolossal_chest") // public static final Block BLOCK_UNCOLOSSAL_CHEST = null; // // @ObjectHolder("colossalchests:colossal_chest") // public static final TileEntityType<TileColossalChest> TILE_ENTITY_COLOSSAL_CHEST = null; // @ObjectHolder("colossalchests:interface") // public static final TileEntityType<TileInterface> TILE_ENTITY_INTERFACE = null; // @ObjectHolder("colossalchests:uncolossal_chest") // public static final TileEntityType<TileColossalChest> TILE_ENTITY_UNCOLOSSAL_CHEST = null; // // @ObjectHolder("colossalchests:colossal_chest") // public static final ContainerType<ContainerColossalChest> CONTAINER_COLOSSAL_CHEST = null; // @ObjectHolder("colossalchests:uncolossal_chest") // public static final ContainerType<ContainerUncolossalChest> CONTAINER_UNCOLOSSAL_CHEST = null; // // } // Path: src/main/java/org/cyclops/colossalchests/tileentity/TileInterface.java import lombok.Getter; import lombok.experimental.Delegate; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.vector.Vector3i; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; import org.cyclops.colossalchests.RegistryEntries; import org.cyclops.cyclopscore.helper.TileHelpers; import org.cyclops.cyclopscore.persist.nbt.NBTPersist; import org.cyclops.cyclopscore.tileentity.CyclopsTileEntity; import javax.annotation.Nonnull; import java.lang.ref.WeakReference; package org.cyclops.colossalchests.tileentity; /** * A machine that can infuse things with blood. * @author rubensworks * */ public class TileInterface extends CyclopsTileEntity { @Delegate private final ITickingTile tickingTileComponent = new TickingTileComponent(this); @NBTPersist @Getter private Vector3i corePosition = null; private WeakReference<TileColossalChest> coreReference = new WeakReference<TileColossalChest>(null); public TileInterface() {
super(RegistryEntries.TILE_ENTITY_INTERFACE);
CyclopsMC/ColossalChests
src/main/java/org/cyclops/colossalchests/inventory/container/ContainerUncolossalChest.java
// Path: src/main/java/org/cyclops/colossalchests/RegistryEntries.java // public class RegistryEntries { // // @ObjectHolder("minecraft:chest") // public static final Item ITEM_CHEST = null; // // @ObjectHolder("colossalchests:uncolossal_chest") // public static final Block BLOCK_UNCOLOSSAL_CHEST = null; // // @ObjectHolder("colossalchests:colossal_chest") // public static final TileEntityType<TileColossalChest> TILE_ENTITY_COLOSSAL_CHEST = null; // @ObjectHolder("colossalchests:interface") // public static final TileEntityType<TileInterface> TILE_ENTITY_INTERFACE = null; // @ObjectHolder("colossalchests:uncolossal_chest") // public static final TileEntityType<TileColossalChest> TILE_ENTITY_UNCOLOSSAL_CHEST = null; // // @ObjectHolder("colossalchests:colossal_chest") // public static final ContainerType<ContainerColossalChest> CONTAINER_COLOSSAL_CHEST = null; // @ObjectHolder("colossalchests:uncolossal_chest") // public static final ContainerType<ContainerUncolossalChest> CONTAINER_UNCOLOSSAL_CHEST = null; // // }
import com.google.common.collect.Lists; import com.google.common.collect.Maps; import invtweaks.api.container.ChestContainer; import invtweaks.api.container.ContainerSection; import invtweaks.api.container.ContainerSectionCallback; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Inventory; import net.minecraft.inventory.container.Slot; import org.cyclops.colossalchests.RegistryEntries; import org.cyclops.cyclopscore.inventory.container.InventoryContainer; import java.util.List; import java.util.Map;
package org.cyclops.colossalchests.inventory.container; /** * @author rubensworks */ @ChestContainer(rowSize = 5) public class ContainerUncolossalChest extends InventoryContainer { public ContainerUncolossalChest(int id, PlayerInventory playerInventory) { this(id, playerInventory, new Inventory(5)); } public ContainerUncolossalChest(int id, PlayerInventory playerInventory, IInventory inventory) {
// Path: src/main/java/org/cyclops/colossalchests/RegistryEntries.java // public class RegistryEntries { // // @ObjectHolder("minecraft:chest") // public static final Item ITEM_CHEST = null; // // @ObjectHolder("colossalchests:uncolossal_chest") // public static final Block BLOCK_UNCOLOSSAL_CHEST = null; // // @ObjectHolder("colossalchests:colossal_chest") // public static final TileEntityType<TileColossalChest> TILE_ENTITY_COLOSSAL_CHEST = null; // @ObjectHolder("colossalchests:interface") // public static final TileEntityType<TileInterface> TILE_ENTITY_INTERFACE = null; // @ObjectHolder("colossalchests:uncolossal_chest") // public static final TileEntityType<TileColossalChest> TILE_ENTITY_UNCOLOSSAL_CHEST = null; // // @ObjectHolder("colossalchests:colossal_chest") // public static final ContainerType<ContainerColossalChest> CONTAINER_COLOSSAL_CHEST = null; // @ObjectHolder("colossalchests:uncolossal_chest") // public static final ContainerType<ContainerUncolossalChest> CONTAINER_UNCOLOSSAL_CHEST = null; // // } // Path: src/main/java/org/cyclops/colossalchests/inventory/container/ContainerUncolossalChest.java import com.google.common.collect.Lists; import com.google.common.collect.Maps; import invtweaks.api.container.ChestContainer; import invtweaks.api.container.ContainerSection; import invtweaks.api.container.ContainerSectionCallback; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Inventory; import net.minecraft.inventory.container.Slot; import org.cyclops.colossalchests.RegistryEntries; import org.cyclops.cyclopscore.inventory.container.InventoryContainer; import java.util.List; import java.util.Map; package org.cyclops.colossalchests.inventory.container; /** * @author rubensworks */ @ChestContainer(rowSize = 5) public class ContainerUncolossalChest extends InventoryContainer { public ContainerUncolossalChest(int id, PlayerInventory playerInventory) { this(id, playerInventory, new Inventory(5)); } public ContainerUncolossalChest(int id, PlayerInventory playerInventory, IInventory inventory) {
super(RegistryEntries.CONTAINER_UNCOLOSSAL_CHEST, id, playerInventory, inventory);
CyclopsMC/ColossalChests
src/main/java/org/cyclops/colossalchests/item/ItemUpgradeToolConfig.java
// Path: src/main/java/org/cyclops/colossalchests/ColossalChests.java // @Mod(Reference.MOD_ID) // public class ColossalChests extends ModBaseVersionable<ColossalChests> { // // /** // * The unique instance of this mod. // */ // public static ColossalChests _instance; // // public ColossalChests() { // super(Reference.MOD_ID, (instance) -> _instance = instance); // } // // @Override // protected void loadModCompats(ModCompatLoader modCompatLoader) { // modCompatLoader.addModCompat(new IronChestModCompat()); // modCompatLoader.addModCompat(new CommonCapabilitiesModCompat()); // } // // @Override // protected void setup(FMLCommonSetupEvent event) { // super.setup(event); // Advancements.load(); // } // // @Override // @OnlyIn(Dist.CLIENT) // protected IClientProxy constructClientProxy() { // return new ClientProxy(); // } // // @Override // protected ICommonProxy constructCommonProxy() { // return new CommonProxy(); // } // // @Override // public ItemGroup constructDefaultItemGroup() { // return new ItemGroupMod(this, () -> RegistryEntries.ITEM_CHEST); // } // // @Override // protected void onConfigsRegister(ConfigHandler configHandler) { // super.onConfigsRegister(configHandler); // // configHandler.addConfigurable(new GeneralConfig()); // // for (ChestMaterial material : ChestMaterial.VALUES) { // configHandler.addConfigurable(new ChestWallConfig(material)); // configHandler.addConfigurable(new ColossalChestConfig(material)); // configHandler.addConfigurable(new InterfaceConfig(material)); // } // // configHandler.addConfigurable(new UncolossalChestConfig()); // configHandler.addConfigurable(new ItemUpgradeToolConfig(true)); // configHandler.addConfigurable(new ItemUpgradeToolConfig(false)); // // configHandler.addConfigurable(new TileColossalChestConfig()); // configHandler.addConfigurable(new TileInterfaceConfig()); // configHandler.addConfigurable(new TileUncolossalChestConfig()); // // configHandler.addConfigurable(new ContainerColossalChestConfig()); // configHandler.addConfigurable(new ContainerUncolossalChestConfig()); // // configHandler.addConfigurable(new RecipeConditionMetalVariantsSettingConfig()); // } // // /** // * Log a new info message for this mod. // * @param message The message to show. // */ // public static void clog(String message) { // clog(Level.INFO, message); // } // // /** // * Log a new message of the given level for this mod. // * @param level The level in which the message must be shown. // * @param message The message to show. // */ // public static void clog(Level level, String message) { // ColossalChests._instance.getLoggerHelper().log(level, message); // } // // }
import net.minecraft.item.Item; import org.cyclops.colossalchests.ColossalChests; import org.cyclops.cyclopscore.config.extendedconfig.ItemConfig;
package org.cyclops.colossalchests.item; /** * Config for the facade. * @author rubensworks */ public class ItemUpgradeToolConfig extends ItemConfig { public ItemUpgradeToolConfig(boolean upgrade) { super(
// Path: src/main/java/org/cyclops/colossalchests/ColossalChests.java // @Mod(Reference.MOD_ID) // public class ColossalChests extends ModBaseVersionable<ColossalChests> { // // /** // * The unique instance of this mod. // */ // public static ColossalChests _instance; // // public ColossalChests() { // super(Reference.MOD_ID, (instance) -> _instance = instance); // } // // @Override // protected void loadModCompats(ModCompatLoader modCompatLoader) { // modCompatLoader.addModCompat(new IronChestModCompat()); // modCompatLoader.addModCompat(new CommonCapabilitiesModCompat()); // } // // @Override // protected void setup(FMLCommonSetupEvent event) { // super.setup(event); // Advancements.load(); // } // // @Override // @OnlyIn(Dist.CLIENT) // protected IClientProxy constructClientProxy() { // return new ClientProxy(); // } // // @Override // protected ICommonProxy constructCommonProxy() { // return new CommonProxy(); // } // // @Override // public ItemGroup constructDefaultItemGroup() { // return new ItemGroupMod(this, () -> RegistryEntries.ITEM_CHEST); // } // // @Override // protected void onConfigsRegister(ConfigHandler configHandler) { // super.onConfigsRegister(configHandler); // // configHandler.addConfigurable(new GeneralConfig()); // // for (ChestMaterial material : ChestMaterial.VALUES) { // configHandler.addConfigurable(new ChestWallConfig(material)); // configHandler.addConfigurable(new ColossalChestConfig(material)); // configHandler.addConfigurable(new InterfaceConfig(material)); // } // // configHandler.addConfigurable(new UncolossalChestConfig()); // configHandler.addConfigurable(new ItemUpgradeToolConfig(true)); // configHandler.addConfigurable(new ItemUpgradeToolConfig(false)); // // configHandler.addConfigurable(new TileColossalChestConfig()); // configHandler.addConfigurable(new TileInterfaceConfig()); // configHandler.addConfigurable(new TileUncolossalChestConfig()); // // configHandler.addConfigurable(new ContainerColossalChestConfig()); // configHandler.addConfigurable(new ContainerUncolossalChestConfig()); // // configHandler.addConfigurable(new RecipeConditionMetalVariantsSettingConfig()); // } // // /** // * Log a new info message for this mod. // * @param message The message to show. // */ // public static void clog(String message) { // clog(Level.INFO, message); // } // // /** // * Log a new message of the given level for this mod. // * @param level The level in which the message must be shown. // * @param message The message to show. // */ // public static void clog(Level level, String message) { // ColossalChests._instance.getLoggerHelper().log(level, message); // } // // } // Path: src/main/java/org/cyclops/colossalchests/item/ItemUpgradeToolConfig.java import net.minecraft.item.Item; import org.cyclops.colossalchests.ColossalChests; import org.cyclops.cyclopscore.config.extendedconfig.ItemConfig; package org.cyclops.colossalchests.item; /** * Config for the facade. * @author rubensworks */ public class ItemUpgradeToolConfig extends ItemConfig { public ItemUpgradeToolConfig(boolean upgrade) { super(
ColossalChests._instance,
CyclopsMC/ColossalChests
src/main/java/org/cyclops/colossalchests/block/UncolossalChestConfig.java
// Path: src/main/java/org/cyclops/colossalchests/ColossalChests.java // @Mod(Reference.MOD_ID) // public class ColossalChests extends ModBaseVersionable<ColossalChests> { // // /** // * The unique instance of this mod. // */ // public static ColossalChests _instance; // // public ColossalChests() { // super(Reference.MOD_ID, (instance) -> _instance = instance); // } // // @Override // protected void loadModCompats(ModCompatLoader modCompatLoader) { // modCompatLoader.addModCompat(new IronChestModCompat()); // modCompatLoader.addModCompat(new CommonCapabilitiesModCompat()); // } // // @Override // protected void setup(FMLCommonSetupEvent event) { // super.setup(event); // Advancements.load(); // } // // @Override // @OnlyIn(Dist.CLIENT) // protected IClientProxy constructClientProxy() { // return new ClientProxy(); // } // // @Override // protected ICommonProxy constructCommonProxy() { // return new CommonProxy(); // } // // @Override // public ItemGroup constructDefaultItemGroup() { // return new ItemGroupMod(this, () -> RegistryEntries.ITEM_CHEST); // } // // @Override // protected void onConfigsRegister(ConfigHandler configHandler) { // super.onConfigsRegister(configHandler); // // configHandler.addConfigurable(new GeneralConfig()); // // for (ChestMaterial material : ChestMaterial.VALUES) { // configHandler.addConfigurable(new ChestWallConfig(material)); // configHandler.addConfigurable(new ColossalChestConfig(material)); // configHandler.addConfigurable(new InterfaceConfig(material)); // } // // configHandler.addConfigurable(new UncolossalChestConfig()); // configHandler.addConfigurable(new ItemUpgradeToolConfig(true)); // configHandler.addConfigurable(new ItemUpgradeToolConfig(false)); // // configHandler.addConfigurable(new TileColossalChestConfig()); // configHandler.addConfigurable(new TileInterfaceConfig()); // configHandler.addConfigurable(new TileUncolossalChestConfig()); // // configHandler.addConfigurable(new ContainerColossalChestConfig()); // configHandler.addConfigurable(new ContainerUncolossalChestConfig()); // // configHandler.addConfigurable(new RecipeConditionMetalVariantsSettingConfig()); // } // // /** // * Log a new info message for this mod. // * @param message The message to show. // */ // public static void clog(String message) { // clog(Level.INFO, message); // } // // /** // * Log a new message of the given level for this mod. // * @param level The level in which the message must be shown. // * @param message The message to show. // */ // public static void clog(Level level, String message) { // ColossalChests._instance.getLoggerHelper().log(level, message); // } // // } // // Path: src/main/java/org/cyclops/colossalchests/client/render/tileentity/ItemStackTileEntityUncolossalChestRender.java // @OnlyIn(Dist.CLIENT) // public class ItemStackTileEntityUncolossalChestRender extends ItemStackTileEntityRendererBase { // // public ItemStackTileEntityUncolossalChestRender() { // super(TileUncolossalChest::new); // } // // }
import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import org.cyclops.colossalchests.ColossalChests; import org.cyclops.colossalchests.client.render.tileentity.ItemStackTileEntityUncolossalChestRender; import org.cyclops.cyclopscore.config.extendedconfig.BlockConfig;
package org.cyclops.colossalchests.block; /** * Config for the {@link ColossalChest}. * @author rubensworks * */ public class UncolossalChestConfig extends BlockConfig { public UncolossalChestConfig() { super(
// Path: src/main/java/org/cyclops/colossalchests/ColossalChests.java // @Mod(Reference.MOD_ID) // public class ColossalChests extends ModBaseVersionable<ColossalChests> { // // /** // * The unique instance of this mod. // */ // public static ColossalChests _instance; // // public ColossalChests() { // super(Reference.MOD_ID, (instance) -> _instance = instance); // } // // @Override // protected void loadModCompats(ModCompatLoader modCompatLoader) { // modCompatLoader.addModCompat(new IronChestModCompat()); // modCompatLoader.addModCompat(new CommonCapabilitiesModCompat()); // } // // @Override // protected void setup(FMLCommonSetupEvent event) { // super.setup(event); // Advancements.load(); // } // // @Override // @OnlyIn(Dist.CLIENT) // protected IClientProxy constructClientProxy() { // return new ClientProxy(); // } // // @Override // protected ICommonProxy constructCommonProxy() { // return new CommonProxy(); // } // // @Override // public ItemGroup constructDefaultItemGroup() { // return new ItemGroupMod(this, () -> RegistryEntries.ITEM_CHEST); // } // // @Override // protected void onConfigsRegister(ConfigHandler configHandler) { // super.onConfigsRegister(configHandler); // // configHandler.addConfigurable(new GeneralConfig()); // // for (ChestMaterial material : ChestMaterial.VALUES) { // configHandler.addConfigurable(new ChestWallConfig(material)); // configHandler.addConfigurable(new ColossalChestConfig(material)); // configHandler.addConfigurable(new InterfaceConfig(material)); // } // // configHandler.addConfigurable(new UncolossalChestConfig()); // configHandler.addConfigurable(new ItemUpgradeToolConfig(true)); // configHandler.addConfigurable(new ItemUpgradeToolConfig(false)); // // configHandler.addConfigurable(new TileColossalChestConfig()); // configHandler.addConfigurable(new TileInterfaceConfig()); // configHandler.addConfigurable(new TileUncolossalChestConfig()); // // configHandler.addConfigurable(new ContainerColossalChestConfig()); // configHandler.addConfigurable(new ContainerUncolossalChestConfig()); // // configHandler.addConfigurable(new RecipeConditionMetalVariantsSettingConfig()); // } // // /** // * Log a new info message for this mod. // * @param message The message to show. // */ // public static void clog(String message) { // clog(Level.INFO, message); // } // // /** // * Log a new message of the given level for this mod. // * @param level The level in which the message must be shown. // * @param message The message to show. // */ // public static void clog(Level level, String message) { // ColossalChests._instance.getLoggerHelper().log(level, message); // } // // } // // Path: src/main/java/org/cyclops/colossalchests/client/render/tileentity/ItemStackTileEntityUncolossalChestRender.java // @OnlyIn(Dist.CLIENT) // public class ItemStackTileEntityUncolossalChestRender extends ItemStackTileEntityRendererBase { // // public ItemStackTileEntityUncolossalChestRender() { // super(TileUncolossalChest::new); // } // // } // Path: src/main/java/org/cyclops/colossalchests/block/UncolossalChestConfig.java import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import org.cyclops.colossalchests.ColossalChests; import org.cyclops.colossalchests.client.render.tileentity.ItemStackTileEntityUncolossalChestRender; import org.cyclops.cyclopscore.config.extendedconfig.BlockConfig; package org.cyclops.colossalchests.block; /** * Config for the {@link ColossalChest}. * @author rubensworks * */ public class UncolossalChestConfig extends BlockConfig { public UncolossalChestConfig() { super(
ColossalChests._instance,
CyclopsMC/ColossalChests
src/main/java/org/cyclops/colossalchests/block/UncolossalChestConfig.java
// Path: src/main/java/org/cyclops/colossalchests/ColossalChests.java // @Mod(Reference.MOD_ID) // public class ColossalChests extends ModBaseVersionable<ColossalChests> { // // /** // * The unique instance of this mod. // */ // public static ColossalChests _instance; // // public ColossalChests() { // super(Reference.MOD_ID, (instance) -> _instance = instance); // } // // @Override // protected void loadModCompats(ModCompatLoader modCompatLoader) { // modCompatLoader.addModCompat(new IronChestModCompat()); // modCompatLoader.addModCompat(new CommonCapabilitiesModCompat()); // } // // @Override // protected void setup(FMLCommonSetupEvent event) { // super.setup(event); // Advancements.load(); // } // // @Override // @OnlyIn(Dist.CLIENT) // protected IClientProxy constructClientProxy() { // return new ClientProxy(); // } // // @Override // protected ICommonProxy constructCommonProxy() { // return new CommonProxy(); // } // // @Override // public ItemGroup constructDefaultItemGroup() { // return new ItemGroupMod(this, () -> RegistryEntries.ITEM_CHEST); // } // // @Override // protected void onConfigsRegister(ConfigHandler configHandler) { // super.onConfigsRegister(configHandler); // // configHandler.addConfigurable(new GeneralConfig()); // // for (ChestMaterial material : ChestMaterial.VALUES) { // configHandler.addConfigurable(new ChestWallConfig(material)); // configHandler.addConfigurable(new ColossalChestConfig(material)); // configHandler.addConfigurable(new InterfaceConfig(material)); // } // // configHandler.addConfigurable(new UncolossalChestConfig()); // configHandler.addConfigurable(new ItemUpgradeToolConfig(true)); // configHandler.addConfigurable(new ItemUpgradeToolConfig(false)); // // configHandler.addConfigurable(new TileColossalChestConfig()); // configHandler.addConfigurable(new TileInterfaceConfig()); // configHandler.addConfigurable(new TileUncolossalChestConfig()); // // configHandler.addConfigurable(new ContainerColossalChestConfig()); // configHandler.addConfigurable(new ContainerUncolossalChestConfig()); // // configHandler.addConfigurable(new RecipeConditionMetalVariantsSettingConfig()); // } // // /** // * Log a new info message for this mod. // * @param message The message to show. // */ // public static void clog(String message) { // clog(Level.INFO, message); // } // // /** // * Log a new message of the given level for this mod. // * @param level The level in which the message must be shown. // * @param message The message to show. // */ // public static void clog(Level level, String message) { // ColossalChests._instance.getLoggerHelper().log(level, message); // } // // } // // Path: src/main/java/org/cyclops/colossalchests/client/render/tileentity/ItemStackTileEntityUncolossalChestRender.java // @OnlyIn(Dist.CLIENT) // public class ItemStackTileEntityUncolossalChestRender extends ItemStackTileEntityRendererBase { // // public ItemStackTileEntityUncolossalChestRender() { // super(TileUncolossalChest::new); // } // // }
import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import org.cyclops.colossalchests.ColossalChests; import org.cyclops.colossalchests.client.render.tileentity.ItemStackTileEntityUncolossalChestRender; import org.cyclops.cyclopscore.config.extendedconfig.BlockConfig;
package org.cyclops.colossalchests.block; /** * Config for the {@link ColossalChest}. * @author rubensworks * */ public class UncolossalChestConfig extends BlockConfig { public UncolossalChestConfig() { super( ColossalChests._instance, "uncolossal_chest", eConfig -> new UncolossalChest(Block.Properties.create(Material.ROCK) .hardnessAndResistance(5.0F) .sound(SoundType.WOOD) .harvestLevel(0)),
// Path: src/main/java/org/cyclops/colossalchests/ColossalChests.java // @Mod(Reference.MOD_ID) // public class ColossalChests extends ModBaseVersionable<ColossalChests> { // // /** // * The unique instance of this mod. // */ // public static ColossalChests _instance; // // public ColossalChests() { // super(Reference.MOD_ID, (instance) -> _instance = instance); // } // // @Override // protected void loadModCompats(ModCompatLoader modCompatLoader) { // modCompatLoader.addModCompat(new IronChestModCompat()); // modCompatLoader.addModCompat(new CommonCapabilitiesModCompat()); // } // // @Override // protected void setup(FMLCommonSetupEvent event) { // super.setup(event); // Advancements.load(); // } // // @Override // @OnlyIn(Dist.CLIENT) // protected IClientProxy constructClientProxy() { // return new ClientProxy(); // } // // @Override // protected ICommonProxy constructCommonProxy() { // return new CommonProxy(); // } // // @Override // public ItemGroup constructDefaultItemGroup() { // return new ItemGroupMod(this, () -> RegistryEntries.ITEM_CHEST); // } // // @Override // protected void onConfigsRegister(ConfigHandler configHandler) { // super.onConfigsRegister(configHandler); // // configHandler.addConfigurable(new GeneralConfig()); // // for (ChestMaterial material : ChestMaterial.VALUES) { // configHandler.addConfigurable(new ChestWallConfig(material)); // configHandler.addConfigurable(new ColossalChestConfig(material)); // configHandler.addConfigurable(new InterfaceConfig(material)); // } // // configHandler.addConfigurable(new UncolossalChestConfig()); // configHandler.addConfigurable(new ItemUpgradeToolConfig(true)); // configHandler.addConfigurable(new ItemUpgradeToolConfig(false)); // // configHandler.addConfigurable(new TileColossalChestConfig()); // configHandler.addConfigurable(new TileInterfaceConfig()); // configHandler.addConfigurable(new TileUncolossalChestConfig()); // // configHandler.addConfigurable(new ContainerColossalChestConfig()); // configHandler.addConfigurable(new ContainerUncolossalChestConfig()); // // configHandler.addConfigurable(new RecipeConditionMetalVariantsSettingConfig()); // } // // /** // * Log a new info message for this mod. // * @param message The message to show. // */ // public static void clog(String message) { // clog(Level.INFO, message); // } // // /** // * Log a new message of the given level for this mod. // * @param level The level in which the message must be shown. // * @param message The message to show. // */ // public static void clog(Level level, String message) { // ColossalChests._instance.getLoggerHelper().log(level, message); // } // // } // // Path: src/main/java/org/cyclops/colossalchests/client/render/tileentity/ItemStackTileEntityUncolossalChestRender.java // @OnlyIn(Dist.CLIENT) // public class ItemStackTileEntityUncolossalChestRender extends ItemStackTileEntityRendererBase { // // public ItemStackTileEntityUncolossalChestRender() { // super(TileUncolossalChest::new); // } // // } // Path: src/main/java/org/cyclops/colossalchests/block/UncolossalChestConfig.java import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import org.cyclops.colossalchests.ColossalChests; import org.cyclops.colossalchests.client.render.tileentity.ItemStackTileEntityUncolossalChestRender; import org.cyclops.cyclopscore.config.extendedconfig.BlockConfig; package org.cyclops.colossalchests.block; /** * Config for the {@link ColossalChest}. * @author rubensworks * */ public class UncolossalChestConfig extends BlockConfig { public UncolossalChestConfig() { super( ColossalChests._instance, "uncolossal_chest", eConfig -> new UncolossalChest(Block.Properties.create(Material.ROCK) .hardnessAndResistance(5.0F) .sound(SoundType.WOOD) .harvestLevel(0)),
getDefaultItemConstructor(ColossalChests._instance, (itemProperties) -> itemProperties.setISTER(() -> ItemStackTileEntityUncolossalChestRender::new))
CyclopsMC/ColossalChests
src/main/java/org/cyclops/colossalchests/recipe/condition/RecipeConditionMetalVariantsSettingConfig.java
// Path: src/main/java/org/cyclops/colossalchests/ColossalChests.java // @Mod(Reference.MOD_ID) // public class ColossalChests extends ModBaseVersionable<ColossalChests> { // // /** // * The unique instance of this mod. // */ // public static ColossalChests _instance; // // public ColossalChests() { // super(Reference.MOD_ID, (instance) -> _instance = instance); // } // // @Override // protected void loadModCompats(ModCompatLoader modCompatLoader) { // modCompatLoader.addModCompat(new IronChestModCompat()); // modCompatLoader.addModCompat(new CommonCapabilitiesModCompat()); // } // // @Override // protected void setup(FMLCommonSetupEvent event) { // super.setup(event); // Advancements.load(); // } // // @Override // @OnlyIn(Dist.CLIENT) // protected IClientProxy constructClientProxy() { // return new ClientProxy(); // } // // @Override // protected ICommonProxy constructCommonProxy() { // return new CommonProxy(); // } // // @Override // public ItemGroup constructDefaultItemGroup() { // return new ItemGroupMod(this, () -> RegistryEntries.ITEM_CHEST); // } // // @Override // protected void onConfigsRegister(ConfigHandler configHandler) { // super.onConfigsRegister(configHandler); // // configHandler.addConfigurable(new GeneralConfig()); // // for (ChestMaterial material : ChestMaterial.VALUES) { // configHandler.addConfigurable(new ChestWallConfig(material)); // configHandler.addConfigurable(new ColossalChestConfig(material)); // configHandler.addConfigurable(new InterfaceConfig(material)); // } // // configHandler.addConfigurable(new UncolossalChestConfig()); // configHandler.addConfigurable(new ItemUpgradeToolConfig(true)); // configHandler.addConfigurable(new ItemUpgradeToolConfig(false)); // // configHandler.addConfigurable(new TileColossalChestConfig()); // configHandler.addConfigurable(new TileInterfaceConfig()); // configHandler.addConfigurable(new TileUncolossalChestConfig()); // // configHandler.addConfigurable(new ContainerColossalChestConfig()); // configHandler.addConfigurable(new ContainerUncolossalChestConfig()); // // configHandler.addConfigurable(new RecipeConditionMetalVariantsSettingConfig()); // } // // /** // * Log a new info message for this mod. // * @param message The message to show. // */ // public static void clog(String message) { // clog(Level.INFO, message); // } // // /** // * Log a new message of the given level for this mod. // * @param level The level in which the message must be shown. // * @param message The message to show. // */ // public static void clog(Level level, String message) { // ColossalChests._instance.getLoggerHelper().log(level, message); // } // // }
import org.cyclops.colossalchests.ColossalChests; import org.cyclops.cyclopscore.config.extendedconfig.RecipeConditionConfig;
package org.cyclops.colossalchests.recipe.condition; /** * Config for the metal variants setting recipe condition. * @author rubensworks */ public class RecipeConditionMetalVariantsSettingConfig extends RecipeConditionConfig<RecipeConditionMetalVariantsSetting> { public RecipeConditionMetalVariantsSettingConfig() { super(
// Path: src/main/java/org/cyclops/colossalchests/ColossalChests.java // @Mod(Reference.MOD_ID) // public class ColossalChests extends ModBaseVersionable<ColossalChests> { // // /** // * The unique instance of this mod. // */ // public static ColossalChests _instance; // // public ColossalChests() { // super(Reference.MOD_ID, (instance) -> _instance = instance); // } // // @Override // protected void loadModCompats(ModCompatLoader modCompatLoader) { // modCompatLoader.addModCompat(new IronChestModCompat()); // modCompatLoader.addModCompat(new CommonCapabilitiesModCompat()); // } // // @Override // protected void setup(FMLCommonSetupEvent event) { // super.setup(event); // Advancements.load(); // } // // @Override // @OnlyIn(Dist.CLIENT) // protected IClientProxy constructClientProxy() { // return new ClientProxy(); // } // // @Override // protected ICommonProxy constructCommonProxy() { // return new CommonProxy(); // } // // @Override // public ItemGroup constructDefaultItemGroup() { // return new ItemGroupMod(this, () -> RegistryEntries.ITEM_CHEST); // } // // @Override // protected void onConfigsRegister(ConfigHandler configHandler) { // super.onConfigsRegister(configHandler); // // configHandler.addConfigurable(new GeneralConfig()); // // for (ChestMaterial material : ChestMaterial.VALUES) { // configHandler.addConfigurable(new ChestWallConfig(material)); // configHandler.addConfigurable(new ColossalChestConfig(material)); // configHandler.addConfigurable(new InterfaceConfig(material)); // } // // configHandler.addConfigurable(new UncolossalChestConfig()); // configHandler.addConfigurable(new ItemUpgradeToolConfig(true)); // configHandler.addConfigurable(new ItemUpgradeToolConfig(false)); // // configHandler.addConfigurable(new TileColossalChestConfig()); // configHandler.addConfigurable(new TileInterfaceConfig()); // configHandler.addConfigurable(new TileUncolossalChestConfig()); // // configHandler.addConfigurable(new ContainerColossalChestConfig()); // configHandler.addConfigurable(new ContainerUncolossalChestConfig()); // // configHandler.addConfigurable(new RecipeConditionMetalVariantsSettingConfig()); // } // // /** // * Log a new info message for this mod. // * @param message The message to show. // */ // public static void clog(String message) { // clog(Level.INFO, message); // } // // /** // * Log a new message of the given level for this mod. // * @param level The level in which the message must be shown. // * @param message The message to show. // */ // public static void clog(Level level, String message) { // ColossalChests._instance.getLoggerHelper().log(level, message); // } // // } // Path: src/main/java/org/cyclops/colossalchests/recipe/condition/RecipeConditionMetalVariantsSettingConfig.java import org.cyclops.colossalchests.ColossalChests; import org.cyclops.cyclopscore.config.extendedconfig.RecipeConditionConfig; package org.cyclops.colossalchests.recipe.condition; /** * Config for the metal variants setting recipe condition. * @author rubensworks */ public class RecipeConditionMetalVariantsSettingConfig extends RecipeConditionConfig<RecipeConditionMetalVariantsSetting> { public RecipeConditionMetalVariantsSettingConfig() { super(
ColossalChests._instance,
CyclopsMC/ColossalChests
src/main/java/org/cyclops/colossalchests/recipe/condition/RecipeConditionMetalVariantsSetting.java
// Path: src/main/java/org/cyclops/colossalchests/GeneralConfig.java // public class GeneralConfig extends DummyConfig { // // @ConfigurableProperty(category = "core", comment = "If the recipe loader should crash when finding invalid recipes.", requiresMcRestart = true, configLocation = ModConfig.Type.SERVER) // public static boolean crashOnInvalidRecipe = false; // // @ConfigurableProperty(category = "core", comment = "If mod compatibility loader should crash hard if errors occur in that process.", requiresMcRestart = true, configLocation = ModConfig.Type.SERVER) // public static boolean crashOnModCompatCrash = false; // // @ConfigurableProperty(category = "core", comment = "If an anonymous mod startup analytics request may be sent to our analytics service.") // public static boolean analytics = true; // // @ConfigurableProperty(category = "core", comment = "If the version checker should be enabled.") // public static boolean versionChecker = true; // // @ConfigurableProperty(category = "general", comment = "If items should be ejected from the chests if one of the structure blocks are removed.", configLocation = ModConfig.Type.SERVER) // public static boolean ejectItemsOnDestroy = false; // // @ConfigurableProperty(category = "general", comment = "If the higher tier metal variants (including diamond and obsidian) can be crafted.", configLocation = ModConfig.Type.SERVER) // public static boolean metalVariants = true; // // @ConfigurableProperty(category = "core", comment = "Maximum buffer byte size for adaptive inventory slots fragmentation.") // public static int maxPacketBufferSize = 20000; // // @ConfigurableProperty(category = "general", comment = "If the interface input overlay should always be rendered on chests.", isCommandable = true, configLocation = ModConfig.Type.CLIENT) // public static boolean alwaysShowInterfaceOverlay = true; // // @ConfigurableProperty(category = "general", comment = "Always create full creative-mode chests when formed. Should not be used in survival worlds!", isCommandable = true, configLocation = ModConfig.Type.SERVER) // public static boolean creativeChests = false; // // public GeneralConfig() { // super(ColossalChests._instance, "general"); // } // // @Override // public void onRegistered() { // getMod().putGenericReference(ModBase.REFKEY_CRASH_ON_INVALID_RECIPE, GeneralConfig.crashOnInvalidRecipe); // getMod().putGenericReference(ModBase.REFKEY_CRASH_ON_MODCOMPAT_CRASH, GeneralConfig.crashOnModCompatCrash); // // if(analytics) { // Analytics.registerMod(getMod(), Reference.GA_TRACKING_ID); // } // if(versionChecker) { // Versions.registerMod(getMod(), ColossalChests._instance, Reference.VERSION_URL); // } // } // // } // // Path: src/main/java/org/cyclops/colossalchests/Reference.java // @SuppressWarnings("javadoc") // public class Reference { // // // Mod info // public static final String MOD_ID = "colossalchests"; // public static final String GA_TRACKING_ID = "UA-65307010-5"; // public static final String VERSION_URL = "https://raw.githubusercontent.com/CyclopsMC/Versions/master/" + MinecraftHelpers.getMinecraftVersionMajorMinor() + "/ColossalChests.txt"; // // // Paths // public static final String TEXTURE_PATH_GUI = "textures/gui/"; // public static final String TEXTURE_PATH_SKINS = "textures/skins/"; // public static final String TEXTURE_PATH_MODELS = "textures/models/"; // public static final String TEXTURE_PATH_ENTITIES = "textures/entities/"; // public static final String TEXTURE_PATH_GUIBACKGROUNDS = "textures/gui/title/background/"; // public static final String TEXTURE_PATH_ITEMS = "textures/items/"; // public static final String TEXTURE_PATH_PARTICLES = "textures/particles/"; // public static final String MODEL_PATH = "models/"; // // // MOD ID's // public static final String MOD_IRONCHEST = "ironchest"; // public static final String MOD_COMMONCAPABILITIES = "commoncapabilities"; // }
import com.google.gson.JsonObject; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.crafting.conditions.ICondition; import net.minecraftforge.common.crafting.conditions.IConditionSerializer; import org.cyclops.colossalchests.GeneralConfig; import org.cyclops.colossalchests.Reference;
package org.cyclops.colossalchests.recipe.condition; /** * A recipe condition for checking if the {@link GeneralConfig#metalVariants} setting is enabled. * @author rubensworks */ public class RecipeConditionMetalVariantsSetting implements ICondition { private static final ResourceLocation NAME = new ResourceLocation(Reference.MOD_ID, "metal_variants_enabled"); @Override public ResourceLocation getID() { return NAME; } @Override public boolean test() {
// Path: src/main/java/org/cyclops/colossalchests/GeneralConfig.java // public class GeneralConfig extends DummyConfig { // // @ConfigurableProperty(category = "core", comment = "If the recipe loader should crash when finding invalid recipes.", requiresMcRestart = true, configLocation = ModConfig.Type.SERVER) // public static boolean crashOnInvalidRecipe = false; // // @ConfigurableProperty(category = "core", comment = "If mod compatibility loader should crash hard if errors occur in that process.", requiresMcRestart = true, configLocation = ModConfig.Type.SERVER) // public static boolean crashOnModCompatCrash = false; // // @ConfigurableProperty(category = "core", comment = "If an anonymous mod startup analytics request may be sent to our analytics service.") // public static boolean analytics = true; // // @ConfigurableProperty(category = "core", comment = "If the version checker should be enabled.") // public static boolean versionChecker = true; // // @ConfigurableProperty(category = "general", comment = "If items should be ejected from the chests if one of the structure blocks are removed.", configLocation = ModConfig.Type.SERVER) // public static boolean ejectItemsOnDestroy = false; // // @ConfigurableProperty(category = "general", comment = "If the higher tier metal variants (including diamond and obsidian) can be crafted.", configLocation = ModConfig.Type.SERVER) // public static boolean metalVariants = true; // // @ConfigurableProperty(category = "core", comment = "Maximum buffer byte size for adaptive inventory slots fragmentation.") // public static int maxPacketBufferSize = 20000; // // @ConfigurableProperty(category = "general", comment = "If the interface input overlay should always be rendered on chests.", isCommandable = true, configLocation = ModConfig.Type.CLIENT) // public static boolean alwaysShowInterfaceOverlay = true; // // @ConfigurableProperty(category = "general", comment = "Always create full creative-mode chests when formed. Should not be used in survival worlds!", isCommandable = true, configLocation = ModConfig.Type.SERVER) // public static boolean creativeChests = false; // // public GeneralConfig() { // super(ColossalChests._instance, "general"); // } // // @Override // public void onRegistered() { // getMod().putGenericReference(ModBase.REFKEY_CRASH_ON_INVALID_RECIPE, GeneralConfig.crashOnInvalidRecipe); // getMod().putGenericReference(ModBase.REFKEY_CRASH_ON_MODCOMPAT_CRASH, GeneralConfig.crashOnModCompatCrash); // // if(analytics) { // Analytics.registerMod(getMod(), Reference.GA_TRACKING_ID); // } // if(versionChecker) { // Versions.registerMod(getMod(), ColossalChests._instance, Reference.VERSION_URL); // } // } // // } // // Path: src/main/java/org/cyclops/colossalchests/Reference.java // @SuppressWarnings("javadoc") // public class Reference { // // // Mod info // public static final String MOD_ID = "colossalchests"; // public static final String GA_TRACKING_ID = "UA-65307010-5"; // public static final String VERSION_URL = "https://raw.githubusercontent.com/CyclopsMC/Versions/master/" + MinecraftHelpers.getMinecraftVersionMajorMinor() + "/ColossalChests.txt"; // // // Paths // public static final String TEXTURE_PATH_GUI = "textures/gui/"; // public static final String TEXTURE_PATH_SKINS = "textures/skins/"; // public static final String TEXTURE_PATH_MODELS = "textures/models/"; // public static final String TEXTURE_PATH_ENTITIES = "textures/entities/"; // public static final String TEXTURE_PATH_GUIBACKGROUNDS = "textures/gui/title/background/"; // public static final String TEXTURE_PATH_ITEMS = "textures/items/"; // public static final String TEXTURE_PATH_PARTICLES = "textures/particles/"; // public static final String MODEL_PATH = "models/"; // // // MOD ID's // public static final String MOD_IRONCHEST = "ironchest"; // public static final String MOD_COMMONCAPABILITIES = "commoncapabilities"; // } // Path: src/main/java/org/cyclops/colossalchests/recipe/condition/RecipeConditionMetalVariantsSetting.java import com.google.gson.JsonObject; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.crafting.conditions.ICondition; import net.minecraftforge.common.crafting.conditions.IConditionSerializer; import org.cyclops.colossalchests.GeneralConfig; import org.cyclops.colossalchests.Reference; package org.cyclops.colossalchests.recipe.condition; /** * A recipe condition for checking if the {@link GeneralConfig#metalVariants} setting is enabled. * @author rubensworks */ public class RecipeConditionMetalVariantsSetting implements ICondition { private static final ResourceLocation NAME = new ResourceLocation(Reference.MOD_ID, "metal_variants_enabled"); @Override public ResourceLocation getID() { return NAME; } @Override public boolean test() {
return GeneralConfig.metalVariants;
CyclopsMC/ColossalChests
src/main/java/org/cyclops/colossalchests/block/ChestWallConfig.java
// Path: src/main/java/org/cyclops/colossalchests/ColossalChests.java // @Mod(Reference.MOD_ID) // public class ColossalChests extends ModBaseVersionable<ColossalChests> { // // /** // * The unique instance of this mod. // */ // public static ColossalChests _instance; // // public ColossalChests() { // super(Reference.MOD_ID, (instance) -> _instance = instance); // } // // @Override // protected void loadModCompats(ModCompatLoader modCompatLoader) { // modCompatLoader.addModCompat(new IronChestModCompat()); // modCompatLoader.addModCompat(new CommonCapabilitiesModCompat()); // } // // @Override // protected void setup(FMLCommonSetupEvent event) { // super.setup(event); // Advancements.load(); // } // // @Override // @OnlyIn(Dist.CLIENT) // protected IClientProxy constructClientProxy() { // return new ClientProxy(); // } // // @Override // protected ICommonProxy constructCommonProxy() { // return new CommonProxy(); // } // // @Override // public ItemGroup constructDefaultItemGroup() { // return new ItemGroupMod(this, () -> RegistryEntries.ITEM_CHEST); // } // // @Override // protected void onConfigsRegister(ConfigHandler configHandler) { // super.onConfigsRegister(configHandler); // // configHandler.addConfigurable(new GeneralConfig()); // // for (ChestMaterial material : ChestMaterial.VALUES) { // configHandler.addConfigurable(new ChestWallConfig(material)); // configHandler.addConfigurable(new ColossalChestConfig(material)); // configHandler.addConfigurable(new InterfaceConfig(material)); // } // // configHandler.addConfigurable(new UncolossalChestConfig()); // configHandler.addConfigurable(new ItemUpgradeToolConfig(true)); // configHandler.addConfigurable(new ItemUpgradeToolConfig(false)); // // configHandler.addConfigurable(new TileColossalChestConfig()); // configHandler.addConfigurable(new TileInterfaceConfig()); // configHandler.addConfigurable(new TileUncolossalChestConfig()); // // configHandler.addConfigurable(new ContainerColossalChestConfig()); // configHandler.addConfigurable(new ContainerUncolossalChestConfig()); // // configHandler.addConfigurable(new RecipeConditionMetalVariantsSettingConfig()); // } // // /** // * Log a new info message for this mod. // * @param message The message to show. // */ // public static void clog(String message) { // clog(Level.INFO, message); // } // // /** // * Log a new message of the given level for this mod. // * @param level The level in which the message must be shown. // * @param message The message to show. // */ // public static void clog(Level level, String message) { // ColossalChests._instance.getLoggerHelper().log(level, message); // } // // } // // Path: src/main/java/org/cyclops/colossalchests/item/ItemBlockMaterial.java // public class ItemBlockMaterial extends BlockItem { // // private final ChestMaterial material; // // public ItemBlockMaterial(Block block, Properties builder, ChestMaterial material) { // super(block, builder); // this.material = material; // } // // @Override // public void addInformation(ItemStack itemStack, World world, List<ITextComponent> list, ITooltipFlag flag) { // list.add(new TranslationTextComponent(material.getUnlocalizedName()).mergeStyle(TextFormatting.BLUE)); // super.addInformation(itemStack, world, list, flag); // // } // }
import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import org.cyclops.colossalchests.ColossalChests; import org.cyclops.colossalchests.item.ItemBlockMaterial; import org.cyclops.cyclopscore.config.extendedconfig.BlockConfig;
package org.cyclops.colossalchests.block; /** * Config for the {@link ChestWall}. * @author rubensworks * */ public class ChestWallConfig extends BlockConfig { public ChestWallConfig(ChestMaterial material) { super(
// Path: src/main/java/org/cyclops/colossalchests/ColossalChests.java // @Mod(Reference.MOD_ID) // public class ColossalChests extends ModBaseVersionable<ColossalChests> { // // /** // * The unique instance of this mod. // */ // public static ColossalChests _instance; // // public ColossalChests() { // super(Reference.MOD_ID, (instance) -> _instance = instance); // } // // @Override // protected void loadModCompats(ModCompatLoader modCompatLoader) { // modCompatLoader.addModCompat(new IronChestModCompat()); // modCompatLoader.addModCompat(new CommonCapabilitiesModCompat()); // } // // @Override // protected void setup(FMLCommonSetupEvent event) { // super.setup(event); // Advancements.load(); // } // // @Override // @OnlyIn(Dist.CLIENT) // protected IClientProxy constructClientProxy() { // return new ClientProxy(); // } // // @Override // protected ICommonProxy constructCommonProxy() { // return new CommonProxy(); // } // // @Override // public ItemGroup constructDefaultItemGroup() { // return new ItemGroupMod(this, () -> RegistryEntries.ITEM_CHEST); // } // // @Override // protected void onConfigsRegister(ConfigHandler configHandler) { // super.onConfigsRegister(configHandler); // // configHandler.addConfigurable(new GeneralConfig()); // // for (ChestMaterial material : ChestMaterial.VALUES) { // configHandler.addConfigurable(new ChestWallConfig(material)); // configHandler.addConfigurable(new ColossalChestConfig(material)); // configHandler.addConfigurable(new InterfaceConfig(material)); // } // // configHandler.addConfigurable(new UncolossalChestConfig()); // configHandler.addConfigurable(new ItemUpgradeToolConfig(true)); // configHandler.addConfigurable(new ItemUpgradeToolConfig(false)); // // configHandler.addConfigurable(new TileColossalChestConfig()); // configHandler.addConfigurable(new TileInterfaceConfig()); // configHandler.addConfigurable(new TileUncolossalChestConfig()); // // configHandler.addConfigurable(new ContainerColossalChestConfig()); // configHandler.addConfigurable(new ContainerUncolossalChestConfig()); // // configHandler.addConfigurable(new RecipeConditionMetalVariantsSettingConfig()); // } // // /** // * Log a new info message for this mod. // * @param message The message to show. // */ // public static void clog(String message) { // clog(Level.INFO, message); // } // // /** // * Log a new message of the given level for this mod. // * @param level The level in which the message must be shown. // * @param message The message to show. // */ // public static void clog(Level level, String message) { // ColossalChests._instance.getLoggerHelper().log(level, message); // } // // } // // Path: src/main/java/org/cyclops/colossalchests/item/ItemBlockMaterial.java // public class ItemBlockMaterial extends BlockItem { // // private final ChestMaterial material; // // public ItemBlockMaterial(Block block, Properties builder, ChestMaterial material) { // super(block, builder); // this.material = material; // } // // @Override // public void addInformation(ItemStack itemStack, World world, List<ITextComponent> list, ITooltipFlag flag) { // list.add(new TranslationTextComponent(material.getUnlocalizedName()).mergeStyle(TextFormatting.BLUE)); // super.addInformation(itemStack, world, list, flag); // // } // } // Path: src/main/java/org/cyclops/colossalchests/block/ChestWallConfig.java import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import org.cyclops.colossalchests.ColossalChests; import org.cyclops.colossalchests.item.ItemBlockMaterial; import org.cyclops.cyclopscore.config.extendedconfig.BlockConfig; package org.cyclops.colossalchests.block; /** * Config for the {@link ChestWall}. * @author rubensworks * */ public class ChestWallConfig extends BlockConfig { public ChestWallConfig(ChestMaterial material) { super(
ColossalChests._instance,
CyclopsMC/ColossalChests
src/main/java/org/cyclops/colossalchests/block/ChestWallConfig.java
// Path: src/main/java/org/cyclops/colossalchests/ColossalChests.java // @Mod(Reference.MOD_ID) // public class ColossalChests extends ModBaseVersionable<ColossalChests> { // // /** // * The unique instance of this mod. // */ // public static ColossalChests _instance; // // public ColossalChests() { // super(Reference.MOD_ID, (instance) -> _instance = instance); // } // // @Override // protected void loadModCompats(ModCompatLoader modCompatLoader) { // modCompatLoader.addModCompat(new IronChestModCompat()); // modCompatLoader.addModCompat(new CommonCapabilitiesModCompat()); // } // // @Override // protected void setup(FMLCommonSetupEvent event) { // super.setup(event); // Advancements.load(); // } // // @Override // @OnlyIn(Dist.CLIENT) // protected IClientProxy constructClientProxy() { // return new ClientProxy(); // } // // @Override // protected ICommonProxy constructCommonProxy() { // return new CommonProxy(); // } // // @Override // public ItemGroup constructDefaultItemGroup() { // return new ItemGroupMod(this, () -> RegistryEntries.ITEM_CHEST); // } // // @Override // protected void onConfigsRegister(ConfigHandler configHandler) { // super.onConfigsRegister(configHandler); // // configHandler.addConfigurable(new GeneralConfig()); // // for (ChestMaterial material : ChestMaterial.VALUES) { // configHandler.addConfigurable(new ChestWallConfig(material)); // configHandler.addConfigurable(new ColossalChestConfig(material)); // configHandler.addConfigurable(new InterfaceConfig(material)); // } // // configHandler.addConfigurable(new UncolossalChestConfig()); // configHandler.addConfigurable(new ItemUpgradeToolConfig(true)); // configHandler.addConfigurable(new ItemUpgradeToolConfig(false)); // // configHandler.addConfigurable(new TileColossalChestConfig()); // configHandler.addConfigurable(new TileInterfaceConfig()); // configHandler.addConfigurable(new TileUncolossalChestConfig()); // // configHandler.addConfigurable(new ContainerColossalChestConfig()); // configHandler.addConfigurable(new ContainerUncolossalChestConfig()); // // configHandler.addConfigurable(new RecipeConditionMetalVariantsSettingConfig()); // } // // /** // * Log a new info message for this mod. // * @param message The message to show. // */ // public static void clog(String message) { // clog(Level.INFO, message); // } // // /** // * Log a new message of the given level for this mod. // * @param level The level in which the message must be shown. // * @param message The message to show. // */ // public static void clog(Level level, String message) { // ColossalChests._instance.getLoggerHelper().log(level, message); // } // // } // // Path: src/main/java/org/cyclops/colossalchests/item/ItemBlockMaterial.java // public class ItemBlockMaterial extends BlockItem { // // private final ChestMaterial material; // // public ItemBlockMaterial(Block block, Properties builder, ChestMaterial material) { // super(block, builder); // this.material = material; // } // // @Override // public void addInformation(ItemStack itemStack, World world, List<ITextComponent> list, ITooltipFlag flag) { // list.add(new TranslationTextComponent(material.getUnlocalizedName()).mergeStyle(TextFormatting.BLUE)); // super.addInformation(itemStack, world, list, flag); // // } // }
import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import org.cyclops.colossalchests.ColossalChests; import org.cyclops.colossalchests.item.ItemBlockMaterial; import org.cyclops.cyclopscore.config.extendedconfig.BlockConfig;
package org.cyclops.colossalchests.block; /** * Config for the {@link ChestWall}. * @author rubensworks * */ public class ChestWallConfig extends BlockConfig { public ChestWallConfig(ChestMaterial material) { super( ColossalChests._instance, "chest_wall_" + material.getName(), eConfig -> new ChestWall(Block.Properties.create(Material.ROCK) .hardnessAndResistance(5.0F) .sound(SoundType.WOOD) .harvestLevel(0) // Wood tier .notSolid(), material),
// Path: src/main/java/org/cyclops/colossalchests/ColossalChests.java // @Mod(Reference.MOD_ID) // public class ColossalChests extends ModBaseVersionable<ColossalChests> { // // /** // * The unique instance of this mod. // */ // public static ColossalChests _instance; // // public ColossalChests() { // super(Reference.MOD_ID, (instance) -> _instance = instance); // } // // @Override // protected void loadModCompats(ModCompatLoader modCompatLoader) { // modCompatLoader.addModCompat(new IronChestModCompat()); // modCompatLoader.addModCompat(new CommonCapabilitiesModCompat()); // } // // @Override // protected void setup(FMLCommonSetupEvent event) { // super.setup(event); // Advancements.load(); // } // // @Override // @OnlyIn(Dist.CLIENT) // protected IClientProxy constructClientProxy() { // return new ClientProxy(); // } // // @Override // protected ICommonProxy constructCommonProxy() { // return new CommonProxy(); // } // // @Override // public ItemGroup constructDefaultItemGroup() { // return new ItemGroupMod(this, () -> RegistryEntries.ITEM_CHEST); // } // // @Override // protected void onConfigsRegister(ConfigHandler configHandler) { // super.onConfigsRegister(configHandler); // // configHandler.addConfigurable(new GeneralConfig()); // // for (ChestMaterial material : ChestMaterial.VALUES) { // configHandler.addConfigurable(new ChestWallConfig(material)); // configHandler.addConfigurable(new ColossalChestConfig(material)); // configHandler.addConfigurable(new InterfaceConfig(material)); // } // // configHandler.addConfigurable(new UncolossalChestConfig()); // configHandler.addConfigurable(new ItemUpgradeToolConfig(true)); // configHandler.addConfigurable(new ItemUpgradeToolConfig(false)); // // configHandler.addConfigurable(new TileColossalChestConfig()); // configHandler.addConfigurable(new TileInterfaceConfig()); // configHandler.addConfigurable(new TileUncolossalChestConfig()); // // configHandler.addConfigurable(new ContainerColossalChestConfig()); // configHandler.addConfigurable(new ContainerUncolossalChestConfig()); // // configHandler.addConfigurable(new RecipeConditionMetalVariantsSettingConfig()); // } // // /** // * Log a new info message for this mod. // * @param message The message to show. // */ // public static void clog(String message) { // clog(Level.INFO, message); // } // // /** // * Log a new message of the given level for this mod. // * @param level The level in which the message must be shown. // * @param message The message to show. // */ // public static void clog(Level level, String message) { // ColossalChests._instance.getLoggerHelper().log(level, message); // } // // } // // Path: src/main/java/org/cyclops/colossalchests/item/ItemBlockMaterial.java // public class ItemBlockMaterial extends BlockItem { // // private final ChestMaterial material; // // public ItemBlockMaterial(Block block, Properties builder, ChestMaterial material) { // super(block, builder); // this.material = material; // } // // @Override // public void addInformation(ItemStack itemStack, World world, List<ITextComponent> list, ITooltipFlag flag) { // list.add(new TranslationTextComponent(material.getUnlocalizedName()).mergeStyle(TextFormatting.BLUE)); // super.addInformation(itemStack, world, list, flag); // // } // } // Path: src/main/java/org/cyclops/colossalchests/block/ChestWallConfig.java import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import org.cyclops.colossalchests.ColossalChests; import org.cyclops.colossalchests.item.ItemBlockMaterial; import org.cyclops.cyclopscore.config.extendedconfig.BlockConfig; package org.cyclops.colossalchests.block; /** * Config for the {@link ChestWall}. * @author rubensworks * */ public class ChestWallConfig extends BlockConfig { public ChestWallConfig(ChestMaterial material) { super( ColossalChests._instance, "chest_wall_" + material.getName(), eConfig -> new ChestWall(Block.Properties.create(Material.ROCK) .hardnessAndResistance(5.0F) .sound(SoundType.WOOD) .harvestLevel(0) // Wood tier .notSolid(), material),
(eConfig, block) -> new ItemBlockMaterial(block, new Item.Properties()
CyclopsMC/ColossalChests
src/main/java/org/cyclops/colossalchests/inventory/container/ContainerUncolossalChestConfig.java
// Path: src/main/java/org/cyclops/colossalchests/ColossalChests.java // @Mod(Reference.MOD_ID) // public class ColossalChests extends ModBaseVersionable<ColossalChests> { // // /** // * The unique instance of this mod. // */ // public static ColossalChests _instance; // // public ColossalChests() { // super(Reference.MOD_ID, (instance) -> _instance = instance); // } // // @Override // protected void loadModCompats(ModCompatLoader modCompatLoader) { // modCompatLoader.addModCompat(new IronChestModCompat()); // modCompatLoader.addModCompat(new CommonCapabilitiesModCompat()); // } // // @Override // protected void setup(FMLCommonSetupEvent event) { // super.setup(event); // Advancements.load(); // } // // @Override // @OnlyIn(Dist.CLIENT) // protected IClientProxy constructClientProxy() { // return new ClientProxy(); // } // // @Override // protected ICommonProxy constructCommonProxy() { // return new CommonProxy(); // } // // @Override // public ItemGroup constructDefaultItemGroup() { // return new ItemGroupMod(this, () -> RegistryEntries.ITEM_CHEST); // } // // @Override // protected void onConfigsRegister(ConfigHandler configHandler) { // super.onConfigsRegister(configHandler); // // configHandler.addConfigurable(new GeneralConfig()); // // for (ChestMaterial material : ChestMaterial.VALUES) { // configHandler.addConfigurable(new ChestWallConfig(material)); // configHandler.addConfigurable(new ColossalChestConfig(material)); // configHandler.addConfigurable(new InterfaceConfig(material)); // } // // configHandler.addConfigurable(new UncolossalChestConfig()); // configHandler.addConfigurable(new ItemUpgradeToolConfig(true)); // configHandler.addConfigurable(new ItemUpgradeToolConfig(false)); // // configHandler.addConfigurable(new TileColossalChestConfig()); // configHandler.addConfigurable(new TileInterfaceConfig()); // configHandler.addConfigurable(new TileUncolossalChestConfig()); // // configHandler.addConfigurable(new ContainerColossalChestConfig()); // configHandler.addConfigurable(new ContainerUncolossalChestConfig()); // // configHandler.addConfigurable(new RecipeConditionMetalVariantsSettingConfig()); // } // // /** // * Log a new info message for this mod. // * @param message The message to show. // */ // public static void clog(String message) { // clog(Level.INFO, message); // } // // /** // * Log a new message of the given level for this mod. // * @param level The level in which the message must be shown. // * @param message The message to show. // */ // public static void clog(Level level, String message) { // ColossalChests._instance.getLoggerHelper().log(level, message); // } // // } // // Path: src/main/java/org/cyclops/colossalchests/client/gui/container/ContainerScreenUncolossalChest.java // public class ContainerScreenUncolossalChest extends ContainerScreenExtended<ContainerUncolossalChest> { // public ContainerScreenUncolossalChest(ContainerUncolossalChest container, PlayerInventory inventory, ITextComponent title) { // super(container, inventory, title); // } // // @Override // protected void drawGuiContainerForegroundLayer(MatrixStack matrixStack, int p_146979_1_, int p_146979_2_) { // //super.drawGuiContainerForegroundLayer(matrixStack, p_146979_1_, p_146979_2_); // font.drawString(matrixStack, getTitle().getString(), 8 + offsetX, 6 + offsetY, 4210752); // } // // @Override // protected ResourceLocation constructGuiTexture() { // return new ResourceLocation("textures/gui/container/hopper.png"); // } // }
import net.minecraft.client.gui.IHasContainer; import net.minecraft.client.gui.ScreenManager; import net.minecraft.client.gui.screen.Screen; import net.minecraft.inventory.container.ContainerType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import org.cyclops.colossalchests.ColossalChests; import org.cyclops.colossalchests.client.gui.container.ContainerScreenUncolossalChest; import org.cyclops.cyclopscore.client.gui.ScreenFactorySafe; import org.cyclops.cyclopscore.config.extendedconfig.GuiConfig;
package org.cyclops.colossalchests.inventory.container; /** * Config for {@link ContainerUncolossalChest}. * @author rubensworks */ public class ContainerUncolossalChestConfig extends GuiConfig<ContainerUncolossalChest> { public ContainerUncolossalChestConfig() {
// Path: src/main/java/org/cyclops/colossalchests/ColossalChests.java // @Mod(Reference.MOD_ID) // public class ColossalChests extends ModBaseVersionable<ColossalChests> { // // /** // * The unique instance of this mod. // */ // public static ColossalChests _instance; // // public ColossalChests() { // super(Reference.MOD_ID, (instance) -> _instance = instance); // } // // @Override // protected void loadModCompats(ModCompatLoader modCompatLoader) { // modCompatLoader.addModCompat(new IronChestModCompat()); // modCompatLoader.addModCompat(new CommonCapabilitiesModCompat()); // } // // @Override // protected void setup(FMLCommonSetupEvent event) { // super.setup(event); // Advancements.load(); // } // // @Override // @OnlyIn(Dist.CLIENT) // protected IClientProxy constructClientProxy() { // return new ClientProxy(); // } // // @Override // protected ICommonProxy constructCommonProxy() { // return new CommonProxy(); // } // // @Override // public ItemGroup constructDefaultItemGroup() { // return new ItemGroupMod(this, () -> RegistryEntries.ITEM_CHEST); // } // // @Override // protected void onConfigsRegister(ConfigHandler configHandler) { // super.onConfigsRegister(configHandler); // // configHandler.addConfigurable(new GeneralConfig()); // // for (ChestMaterial material : ChestMaterial.VALUES) { // configHandler.addConfigurable(new ChestWallConfig(material)); // configHandler.addConfigurable(new ColossalChestConfig(material)); // configHandler.addConfigurable(new InterfaceConfig(material)); // } // // configHandler.addConfigurable(new UncolossalChestConfig()); // configHandler.addConfigurable(new ItemUpgradeToolConfig(true)); // configHandler.addConfigurable(new ItemUpgradeToolConfig(false)); // // configHandler.addConfigurable(new TileColossalChestConfig()); // configHandler.addConfigurable(new TileInterfaceConfig()); // configHandler.addConfigurable(new TileUncolossalChestConfig()); // // configHandler.addConfigurable(new ContainerColossalChestConfig()); // configHandler.addConfigurable(new ContainerUncolossalChestConfig()); // // configHandler.addConfigurable(new RecipeConditionMetalVariantsSettingConfig()); // } // // /** // * Log a new info message for this mod. // * @param message The message to show. // */ // public static void clog(String message) { // clog(Level.INFO, message); // } // // /** // * Log a new message of the given level for this mod. // * @param level The level in which the message must be shown. // * @param message The message to show. // */ // public static void clog(Level level, String message) { // ColossalChests._instance.getLoggerHelper().log(level, message); // } // // } // // Path: src/main/java/org/cyclops/colossalchests/client/gui/container/ContainerScreenUncolossalChest.java // public class ContainerScreenUncolossalChest extends ContainerScreenExtended<ContainerUncolossalChest> { // public ContainerScreenUncolossalChest(ContainerUncolossalChest container, PlayerInventory inventory, ITextComponent title) { // super(container, inventory, title); // } // // @Override // protected void drawGuiContainerForegroundLayer(MatrixStack matrixStack, int p_146979_1_, int p_146979_2_) { // //super.drawGuiContainerForegroundLayer(matrixStack, p_146979_1_, p_146979_2_); // font.drawString(matrixStack, getTitle().getString(), 8 + offsetX, 6 + offsetY, 4210752); // } // // @Override // protected ResourceLocation constructGuiTexture() { // return new ResourceLocation("textures/gui/container/hopper.png"); // } // } // Path: src/main/java/org/cyclops/colossalchests/inventory/container/ContainerUncolossalChestConfig.java import net.minecraft.client.gui.IHasContainer; import net.minecraft.client.gui.ScreenManager; import net.minecraft.client.gui.screen.Screen; import net.minecraft.inventory.container.ContainerType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import org.cyclops.colossalchests.ColossalChests; import org.cyclops.colossalchests.client.gui.container.ContainerScreenUncolossalChest; import org.cyclops.cyclopscore.client.gui.ScreenFactorySafe; import org.cyclops.cyclopscore.config.extendedconfig.GuiConfig; package org.cyclops.colossalchests.inventory.container; /** * Config for {@link ContainerUncolossalChest}. * @author rubensworks */ public class ContainerUncolossalChestConfig extends GuiConfig<ContainerUncolossalChest> { public ContainerUncolossalChestConfig() {
super(ColossalChests._instance,
CyclopsMC/ColossalChests
src/main/java/org/cyclops/colossalchests/inventory/container/ContainerUncolossalChestConfig.java
// Path: src/main/java/org/cyclops/colossalchests/ColossalChests.java // @Mod(Reference.MOD_ID) // public class ColossalChests extends ModBaseVersionable<ColossalChests> { // // /** // * The unique instance of this mod. // */ // public static ColossalChests _instance; // // public ColossalChests() { // super(Reference.MOD_ID, (instance) -> _instance = instance); // } // // @Override // protected void loadModCompats(ModCompatLoader modCompatLoader) { // modCompatLoader.addModCompat(new IronChestModCompat()); // modCompatLoader.addModCompat(new CommonCapabilitiesModCompat()); // } // // @Override // protected void setup(FMLCommonSetupEvent event) { // super.setup(event); // Advancements.load(); // } // // @Override // @OnlyIn(Dist.CLIENT) // protected IClientProxy constructClientProxy() { // return new ClientProxy(); // } // // @Override // protected ICommonProxy constructCommonProxy() { // return new CommonProxy(); // } // // @Override // public ItemGroup constructDefaultItemGroup() { // return new ItemGroupMod(this, () -> RegistryEntries.ITEM_CHEST); // } // // @Override // protected void onConfigsRegister(ConfigHandler configHandler) { // super.onConfigsRegister(configHandler); // // configHandler.addConfigurable(new GeneralConfig()); // // for (ChestMaterial material : ChestMaterial.VALUES) { // configHandler.addConfigurable(new ChestWallConfig(material)); // configHandler.addConfigurable(new ColossalChestConfig(material)); // configHandler.addConfigurable(new InterfaceConfig(material)); // } // // configHandler.addConfigurable(new UncolossalChestConfig()); // configHandler.addConfigurable(new ItemUpgradeToolConfig(true)); // configHandler.addConfigurable(new ItemUpgradeToolConfig(false)); // // configHandler.addConfigurable(new TileColossalChestConfig()); // configHandler.addConfigurable(new TileInterfaceConfig()); // configHandler.addConfigurable(new TileUncolossalChestConfig()); // // configHandler.addConfigurable(new ContainerColossalChestConfig()); // configHandler.addConfigurable(new ContainerUncolossalChestConfig()); // // configHandler.addConfigurable(new RecipeConditionMetalVariantsSettingConfig()); // } // // /** // * Log a new info message for this mod. // * @param message The message to show. // */ // public static void clog(String message) { // clog(Level.INFO, message); // } // // /** // * Log a new message of the given level for this mod. // * @param level The level in which the message must be shown. // * @param message The message to show. // */ // public static void clog(Level level, String message) { // ColossalChests._instance.getLoggerHelper().log(level, message); // } // // } // // Path: src/main/java/org/cyclops/colossalchests/client/gui/container/ContainerScreenUncolossalChest.java // public class ContainerScreenUncolossalChest extends ContainerScreenExtended<ContainerUncolossalChest> { // public ContainerScreenUncolossalChest(ContainerUncolossalChest container, PlayerInventory inventory, ITextComponent title) { // super(container, inventory, title); // } // // @Override // protected void drawGuiContainerForegroundLayer(MatrixStack matrixStack, int p_146979_1_, int p_146979_2_) { // //super.drawGuiContainerForegroundLayer(matrixStack, p_146979_1_, p_146979_2_); // font.drawString(matrixStack, getTitle().getString(), 8 + offsetX, 6 + offsetY, 4210752); // } // // @Override // protected ResourceLocation constructGuiTexture() { // return new ResourceLocation("textures/gui/container/hopper.png"); // } // }
import net.minecraft.client.gui.IHasContainer; import net.minecraft.client.gui.ScreenManager; import net.minecraft.client.gui.screen.Screen; import net.minecraft.inventory.container.ContainerType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import org.cyclops.colossalchests.ColossalChests; import org.cyclops.colossalchests.client.gui.container.ContainerScreenUncolossalChest; import org.cyclops.cyclopscore.client.gui.ScreenFactorySafe; import org.cyclops.cyclopscore.config.extendedconfig.GuiConfig;
package org.cyclops.colossalchests.inventory.container; /** * Config for {@link ContainerUncolossalChest}. * @author rubensworks */ public class ContainerUncolossalChestConfig extends GuiConfig<ContainerUncolossalChest> { public ContainerUncolossalChestConfig() { super(ColossalChests._instance, "uncolossal_chest", eConfig -> new ContainerType<>(ContainerUncolossalChest::new)); } @OnlyIn(Dist.CLIENT) @Override public <U extends Screen & IHasContainer<ContainerUncolossalChest>> ScreenManager.IScreenFactory<ContainerUncolossalChest, U> getScreenFactory() {
// Path: src/main/java/org/cyclops/colossalchests/ColossalChests.java // @Mod(Reference.MOD_ID) // public class ColossalChests extends ModBaseVersionable<ColossalChests> { // // /** // * The unique instance of this mod. // */ // public static ColossalChests _instance; // // public ColossalChests() { // super(Reference.MOD_ID, (instance) -> _instance = instance); // } // // @Override // protected void loadModCompats(ModCompatLoader modCompatLoader) { // modCompatLoader.addModCompat(new IronChestModCompat()); // modCompatLoader.addModCompat(new CommonCapabilitiesModCompat()); // } // // @Override // protected void setup(FMLCommonSetupEvent event) { // super.setup(event); // Advancements.load(); // } // // @Override // @OnlyIn(Dist.CLIENT) // protected IClientProxy constructClientProxy() { // return new ClientProxy(); // } // // @Override // protected ICommonProxy constructCommonProxy() { // return new CommonProxy(); // } // // @Override // public ItemGroup constructDefaultItemGroup() { // return new ItemGroupMod(this, () -> RegistryEntries.ITEM_CHEST); // } // // @Override // protected void onConfigsRegister(ConfigHandler configHandler) { // super.onConfigsRegister(configHandler); // // configHandler.addConfigurable(new GeneralConfig()); // // for (ChestMaterial material : ChestMaterial.VALUES) { // configHandler.addConfigurable(new ChestWallConfig(material)); // configHandler.addConfigurable(new ColossalChestConfig(material)); // configHandler.addConfigurable(new InterfaceConfig(material)); // } // // configHandler.addConfigurable(new UncolossalChestConfig()); // configHandler.addConfigurable(new ItemUpgradeToolConfig(true)); // configHandler.addConfigurable(new ItemUpgradeToolConfig(false)); // // configHandler.addConfigurable(new TileColossalChestConfig()); // configHandler.addConfigurable(new TileInterfaceConfig()); // configHandler.addConfigurable(new TileUncolossalChestConfig()); // // configHandler.addConfigurable(new ContainerColossalChestConfig()); // configHandler.addConfigurable(new ContainerUncolossalChestConfig()); // // configHandler.addConfigurable(new RecipeConditionMetalVariantsSettingConfig()); // } // // /** // * Log a new info message for this mod. // * @param message The message to show. // */ // public static void clog(String message) { // clog(Level.INFO, message); // } // // /** // * Log a new message of the given level for this mod. // * @param level The level in which the message must be shown. // * @param message The message to show. // */ // public static void clog(Level level, String message) { // ColossalChests._instance.getLoggerHelper().log(level, message); // } // // } // // Path: src/main/java/org/cyclops/colossalchests/client/gui/container/ContainerScreenUncolossalChest.java // public class ContainerScreenUncolossalChest extends ContainerScreenExtended<ContainerUncolossalChest> { // public ContainerScreenUncolossalChest(ContainerUncolossalChest container, PlayerInventory inventory, ITextComponent title) { // super(container, inventory, title); // } // // @Override // protected void drawGuiContainerForegroundLayer(MatrixStack matrixStack, int p_146979_1_, int p_146979_2_) { // //super.drawGuiContainerForegroundLayer(matrixStack, p_146979_1_, p_146979_2_); // font.drawString(matrixStack, getTitle().getString(), 8 + offsetX, 6 + offsetY, 4210752); // } // // @Override // protected ResourceLocation constructGuiTexture() { // return new ResourceLocation("textures/gui/container/hopper.png"); // } // } // Path: src/main/java/org/cyclops/colossalchests/inventory/container/ContainerUncolossalChestConfig.java import net.minecraft.client.gui.IHasContainer; import net.minecraft.client.gui.ScreenManager; import net.minecraft.client.gui.screen.Screen; import net.minecraft.inventory.container.ContainerType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import org.cyclops.colossalchests.ColossalChests; import org.cyclops.colossalchests.client.gui.container.ContainerScreenUncolossalChest; import org.cyclops.cyclopscore.client.gui.ScreenFactorySafe; import org.cyclops.cyclopscore.config.extendedconfig.GuiConfig; package org.cyclops.colossalchests.inventory.container; /** * Config for {@link ContainerUncolossalChest}. * @author rubensworks */ public class ContainerUncolossalChestConfig extends GuiConfig<ContainerUncolossalChest> { public ContainerUncolossalChestConfig() { super(ColossalChests._instance, "uncolossal_chest", eConfig -> new ContainerType<>(ContainerUncolossalChest::new)); } @OnlyIn(Dist.CLIENT) @Override public <U extends Screen & IHasContainer<ContainerUncolossalChest>> ScreenManager.IScreenFactory<ContainerUncolossalChest, U> getScreenFactory() {
return new ScreenFactorySafe<>(ContainerScreenUncolossalChest::new);
lucmoreau/OpenProvenanceModel
opm/src/test/java/org/openprovenance/model/Example9Test.java
// Path: opm/src/main/java/org/openprovenance/model/collections/CollectionFactory.java // public class CollectionFactory implements CollectionURIs { // // final private OPMFactory oFactory; // // public CollectionFactory(OPMFactory oFactory) { // this.oFactory=oFactory; // } // // // // public WasDerivedFrom newContained(String id, // // ArtifactRef aid1, // // ArtifactRef aid2, // // Collection<AccountRef> accounts) { // // return oFactory.newWasDerivedFrom(id,aid1,aid2,CONTAINED,accounts); // // } // // public WasDerivedFrom newContained(String id, // Artifact a1, // Artifact a2, // Collection<Account> accounts) { // return oFactory.newWasDerivedFrom(id,a1,a2,CONTAINED,accounts); // } // // // // public WasDerivedFrom newWasIdenticalTo(String id, // // ArtifactRef aid1, // // ArtifactRef aid2, // // Collection<AccountRef> accounts) { // // return oFactory.newWasDerivedFrom(id,aid1,aid2,WASIDENTICALTO,accounts); // // } // // public WasDerivedFrom newWasIdenticalTo(String id, // Artifact a1, // Artifact a2, // Collection<Account> accounts) { // return oFactory.newWasDerivedFrom(id,a1,a2,WASIDENTICALTO,accounts); // } // // // // // // }
import java.io.File; import java.io.StringWriter; import java.util.Collection; import java.util.Collections; import java.util.LinkedList; import java.util.List; import javax.xml.bind.JAXBException; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.openprovenance.model.collections.CollectionFactory;
package org.openprovenance.model; /** * Unit test for simple App. */ public class Example9Test extends TestCase { /** * Create the test case * * @param testName name of the test case */ public Example9Test( String testName ) { super( testName ); } /** * @return the suite of tests being tested */ static OPMGraph graph1; public void testCollectionProposal2() throws Exception { OPMFactory oFactory=new OPMFactory();
// Path: opm/src/main/java/org/openprovenance/model/collections/CollectionFactory.java // public class CollectionFactory implements CollectionURIs { // // final private OPMFactory oFactory; // // public CollectionFactory(OPMFactory oFactory) { // this.oFactory=oFactory; // } // // // // public WasDerivedFrom newContained(String id, // // ArtifactRef aid1, // // ArtifactRef aid2, // // Collection<AccountRef> accounts) { // // return oFactory.newWasDerivedFrom(id,aid1,aid2,CONTAINED,accounts); // // } // // public WasDerivedFrom newContained(String id, // Artifact a1, // Artifact a2, // Collection<Account> accounts) { // return oFactory.newWasDerivedFrom(id,a1,a2,CONTAINED,accounts); // } // // // // public WasDerivedFrom newWasIdenticalTo(String id, // // ArtifactRef aid1, // // ArtifactRef aid2, // // Collection<AccountRef> accounts) { // // return oFactory.newWasDerivedFrom(id,aid1,aid2,WASIDENTICALTO,accounts); // // } // // public WasDerivedFrom newWasIdenticalTo(String id, // Artifact a1, // Artifact a2, // Collection<Account> accounts) { // return oFactory.newWasDerivedFrom(id,a1,a2,WASIDENTICALTO,accounts); // } // // // // // // } // Path: opm/src/test/java/org/openprovenance/model/Example9Test.java import java.io.File; import java.io.StringWriter; import java.util.Collection; import java.util.Collections; import java.util.LinkedList; import java.util.List; import javax.xml.bind.JAXBException; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.openprovenance.model.collections.CollectionFactory; package org.openprovenance.model; /** * Unit test for simple App. */ public class Example9Test extends TestCase { /** * Create the test case * * @param testName name of the test case */ public Example9Test( String testName ) { super( testName ); } /** * @return the suite of tests being tested */ static OPMGraph graph1; public void testCollectionProposal2() throws Exception { OPMFactory oFactory=new OPMFactory();
CollectionFactory cFactory=new CollectionFactory(oFactory);
lucmoreau/OpenProvenanceModel
elmo/src/main/java/org/openprovenance/elmo/RdfPName.java
// Path: opm/src/main/java/org/openprovenance/model/Annotable.java // public interface Annotable extends Identifiable { // public List<JAXBElement<? extends EmbeddedAnnotation>> getAnnotation(); // } // // Path: opm/src/main/java/org/openprovenance/model/CommonURIs.java // public interface CommonURIs { // final String NEW_PROFILE_PROPERTY = "http://openprovenance.org/ontology#profile"; // final String NEW_VALUE_PROPERTY = "http://openprovenance.org/ontology#value"; // final String NEW_ENCODING_PROPERTY = "http://openprovenance.org/ontology#encoding"; // final String NEW_TYPE_PROPERTY = "http://openprovenance.org/ontology#type"; // final String NEW_LABEL_PROPERTY = "http://openprovenance.org/ontology#label"; // final String NEW_PNAME_PROPERTY = "http://openprovenance.org/ontology#pname"; // // // final String PROFILE_PROPERTY = "http://openprovenance.org/property/profile"; // final String VALUE_PROPERTY = "http://openprovenance.org/property/value"; // final String ENCODING_PROPERTY = "http://openprovenance.org/property/encoding"; // final String TYPE_PROPERTY = "http://openprovenance.org/property/type"; // final String LABEL_PROPERTY = "http://openprovenance.org/property/label"; // final String PNAME_PROPERTY = "http://openprovenance.org/property/pname"; // // }
import java.util.Set; import java.net.URI; import org.openprovenance.rdf.Account; import org.openprovenance.rdf.Node; import javax.xml.namespace.QName; import org.openrdf.elmo.ElmoManager; import org.openprovenance.model.Annotable; import org.openrdf.model.Statement; import org.openrdf.elmo.sesame.SesameManager; import org.openprovenance.model.CommonURIs;
package org.openprovenance.elmo; public class RdfPName extends org.openprovenance.model.PName implements CompactAnnotation, CommonURIs { ElmoManager manager; String prefix; QName qname; static int count=0; public RdfPName(ElmoManager manager, String prefix) { this.manager=manager; this.prefix=prefix; }
// Path: opm/src/main/java/org/openprovenance/model/Annotable.java // public interface Annotable extends Identifiable { // public List<JAXBElement<? extends EmbeddedAnnotation>> getAnnotation(); // } // // Path: opm/src/main/java/org/openprovenance/model/CommonURIs.java // public interface CommonURIs { // final String NEW_PROFILE_PROPERTY = "http://openprovenance.org/ontology#profile"; // final String NEW_VALUE_PROPERTY = "http://openprovenance.org/ontology#value"; // final String NEW_ENCODING_PROPERTY = "http://openprovenance.org/ontology#encoding"; // final String NEW_TYPE_PROPERTY = "http://openprovenance.org/ontology#type"; // final String NEW_LABEL_PROPERTY = "http://openprovenance.org/ontology#label"; // final String NEW_PNAME_PROPERTY = "http://openprovenance.org/ontology#pname"; // // // final String PROFILE_PROPERTY = "http://openprovenance.org/property/profile"; // final String VALUE_PROPERTY = "http://openprovenance.org/property/value"; // final String ENCODING_PROPERTY = "http://openprovenance.org/property/encoding"; // final String TYPE_PROPERTY = "http://openprovenance.org/property/type"; // final String LABEL_PROPERTY = "http://openprovenance.org/property/label"; // final String PNAME_PROPERTY = "http://openprovenance.org/property/pname"; // // } // Path: elmo/src/main/java/org/openprovenance/elmo/RdfPName.java import java.util.Set; import java.net.URI; import org.openprovenance.rdf.Account; import org.openprovenance.rdf.Node; import javax.xml.namespace.QName; import org.openrdf.elmo.ElmoManager; import org.openprovenance.model.Annotable; import org.openrdf.model.Statement; import org.openrdf.elmo.sesame.SesameManager; import org.openprovenance.model.CommonURIs; package org.openprovenance.elmo; public class RdfPName extends org.openprovenance.model.PName implements CompactAnnotation, CommonURIs { ElmoManager manager; String prefix; QName qname; static int count=0; public RdfPName(ElmoManager manager, String prefix) { this.manager=manager; this.prefix=prefix; }
public void toRdf(Annotable entity) throws org.openrdf.repository.RepositoryException {
lucmoreau/OpenProvenanceModel
opm/src/test/java/org/openprovenance/model/CycleTest.java
// Path: opm/src/main/java/org/openprovenance/model/collections/CollectionFactory.java // public class CollectionFactory implements CollectionURIs { // // final private OPMFactory oFactory; // // public CollectionFactory(OPMFactory oFactory) { // this.oFactory=oFactory; // } // // // // public WasDerivedFrom newContained(String id, // // ArtifactRef aid1, // // ArtifactRef aid2, // // Collection<AccountRef> accounts) { // // return oFactory.newWasDerivedFrom(id,aid1,aid2,CONTAINED,accounts); // // } // // public WasDerivedFrom newContained(String id, // Artifact a1, // Artifact a2, // Collection<Account> accounts) { // return oFactory.newWasDerivedFrom(id,a1,a2,CONTAINED,accounts); // } // // // // public WasDerivedFrom newWasIdenticalTo(String id, // // ArtifactRef aid1, // // ArtifactRef aid2, // // Collection<AccountRef> accounts) { // // return oFactory.newWasDerivedFrom(id,aid1,aid2,WASIDENTICALTO,accounts); // // } // // public WasDerivedFrom newWasIdenticalTo(String id, // Artifact a1, // Artifact a2, // Collection<Account> accounts) { // return oFactory.newWasDerivedFrom(id,a1,a2,WASIDENTICALTO,accounts); // } // // // // // // }
import java.io.File; import java.io.StringWriter; import java.util.Collection; import java.util.Collections; import java.util.LinkedList; import java.util.List; import javax.xml.bind.JAXBException; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.openprovenance.model.collections.CollectionFactory;
package org.openprovenance.model; /** * Unit test for simple App. */ public class CycleTest extends TestCase { /** * Create the test case * * @param testName name of the test case */ public CycleTest( String testName ) { super( testName ); } /** * @return the suite of tests being tested */ public static Test suite() { return new TestSuite( CycleTest.class ); } static OPMGraph graph1; static OPMGraph graph2; /** Creates and serialises an OPM graph. */ public void testCycle1() throws JAXBException, java.io.FileNotFoundException, java.io.IOException { OPMFactory oFactory=new OPMFactory();
// Path: opm/src/main/java/org/openprovenance/model/collections/CollectionFactory.java // public class CollectionFactory implements CollectionURIs { // // final private OPMFactory oFactory; // // public CollectionFactory(OPMFactory oFactory) { // this.oFactory=oFactory; // } // // // // public WasDerivedFrom newContained(String id, // // ArtifactRef aid1, // // ArtifactRef aid2, // // Collection<AccountRef> accounts) { // // return oFactory.newWasDerivedFrom(id,aid1,aid2,CONTAINED,accounts); // // } // // public WasDerivedFrom newContained(String id, // Artifact a1, // Artifact a2, // Collection<Account> accounts) { // return oFactory.newWasDerivedFrom(id,a1,a2,CONTAINED,accounts); // } // // // // public WasDerivedFrom newWasIdenticalTo(String id, // // ArtifactRef aid1, // // ArtifactRef aid2, // // Collection<AccountRef> accounts) { // // return oFactory.newWasDerivedFrom(id,aid1,aid2,WASIDENTICALTO,accounts); // // } // // public WasDerivedFrom newWasIdenticalTo(String id, // Artifact a1, // Artifact a2, // Collection<Account> accounts) { // return oFactory.newWasDerivedFrom(id,a1,a2,WASIDENTICALTO,accounts); // } // // // // // // } // Path: opm/src/test/java/org/openprovenance/model/CycleTest.java import java.io.File; import java.io.StringWriter; import java.util.Collection; import java.util.Collections; import java.util.LinkedList; import java.util.List; import javax.xml.bind.JAXBException; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.openprovenance.model.collections.CollectionFactory; package org.openprovenance.model; /** * Unit test for simple App. */ public class CycleTest extends TestCase { /** * Create the test case * * @param testName name of the test case */ public CycleTest( String testName ) { super( testName ); } /** * @return the suite of tests being tested */ public static Test suite() { return new TestSuite( CycleTest.class ); } static OPMGraph graph1; static OPMGraph graph2; /** Creates and serialises an OPM graph. */ public void testCycle1() throws JAXBException, java.io.FileNotFoundException, java.io.IOException { OPMFactory oFactory=new OPMFactory();
CollectionFactory cFactory=new CollectionFactory(oFactory);
lucmoreau/OpenProvenanceModel
elmo/src/main/java/org/openprovenance/elmo/RdfType.java
// Path: opm/src/main/java/org/openprovenance/model/Annotable.java // public interface Annotable extends Identifiable { // public List<JAXBElement<? extends EmbeddedAnnotation>> getAnnotation(); // } // // Path: opm/src/main/java/org/openprovenance/model/CommonURIs.java // public interface CommonURIs { // final String NEW_PROFILE_PROPERTY = "http://openprovenance.org/ontology#profile"; // final String NEW_VALUE_PROPERTY = "http://openprovenance.org/ontology#value"; // final String NEW_ENCODING_PROPERTY = "http://openprovenance.org/ontology#encoding"; // final String NEW_TYPE_PROPERTY = "http://openprovenance.org/ontology#type"; // final String NEW_LABEL_PROPERTY = "http://openprovenance.org/ontology#label"; // final String NEW_PNAME_PROPERTY = "http://openprovenance.org/ontology#pname"; // // // final String PROFILE_PROPERTY = "http://openprovenance.org/property/profile"; // final String VALUE_PROPERTY = "http://openprovenance.org/property/value"; // final String ENCODING_PROPERTY = "http://openprovenance.org/property/encoding"; // final String TYPE_PROPERTY = "http://openprovenance.org/property/type"; // final String LABEL_PROPERTY = "http://openprovenance.org/property/label"; // final String PNAME_PROPERTY = "http://openprovenance.org/property/pname"; // // }
import java.util.Set; import java.net.URI; import org.openprovenance.rdf.Account; import org.openprovenance.rdf.Node; import javax.xml.namespace.QName; import org.openrdf.elmo.ElmoManager; import org.openprovenance.model.Annotable; import org.openrdf.model.Statement; import org.openrdf.elmo.sesame.SesameManager; import org.openprovenance.model.CommonURIs;
package org.openprovenance.elmo; public class RdfType extends org.openprovenance.model.Type implements CompactAnnotation, CommonURIs { ElmoManager manager; String prefix; QName qname; static int count=0; public RdfType(ElmoManager manager, String prefix) { this.manager=manager; this.prefix=prefix; }
// Path: opm/src/main/java/org/openprovenance/model/Annotable.java // public interface Annotable extends Identifiable { // public List<JAXBElement<? extends EmbeddedAnnotation>> getAnnotation(); // } // // Path: opm/src/main/java/org/openprovenance/model/CommonURIs.java // public interface CommonURIs { // final String NEW_PROFILE_PROPERTY = "http://openprovenance.org/ontology#profile"; // final String NEW_VALUE_PROPERTY = "http://openprovenance.org/ontology#value"; // final String NEW_ENCODING_PROPERTY = "http://openprovenance.org/ontology#encoding"; // final String NEW_TYPE_PROPERTY = "http://openprovenance.org/ontology#type"; // final String NEW_LABEL_PROPERTY = "http://openprovenance.org/ontology#label"; // final String NEW_PNAME_PROPERTY = "http://openprovenance.org/ontology#pname"; // // // final String PROFILE_PROPERTY = "http://openprovenance.org/property/profile"; // final String VALUE_PROPERTY = "http://openprovenance.org/property/value"; // final String ENCODING_PROPERTY = "http://openprovenance.org/property/encoding"; // final String TYPE_PROPERTY = "http://openprovenance.org/property/type"; // final String LABEL_PROPERTY = "http://openprovenance.org/property/label"; // final String PNAME_PROPERTY = "http://openprovenance.org/property/pname"; // // } // Path: elmo/src/main/java/org/openprovenance/elmo/RdfType.java import java.util.Set; import java.net.URI; import org.openprovenance.rdf.Account; import org.openprovenance.rdf.Node; import javax.xml.namespace.QName; import org.openrdf.elmo.ElmoManager; import org.openprovenance.model.Annotable; import org.openrdf.model.Statement; import org.openrdf.elmo.sesame.SesameManager; import org.openprovenance.model.CommonURIs; package org.openprovenance.elmo; public class RdfType extends org.openprovenance.model.Type implements CompactAnnotation, CommonURIs { ElmoManager manager; String prefix; QName qname; static int count=0; public RdfType(ElmoManager manager, String prefix) { this.manager=manager; this.prefix=prefix; }
public void toRdf(Annotable entity) throws org.openrdf.repository.RepositoryException {
lucmoreau/OpenProvenanceModel
opm/src/test/java/org/openprovenance/model/Example8Test.java
// Path: opm/src/main/java/org/openprovenance/model/collections/CollectionFactory.java // public class CollectionFactory implements CollectionURIs { // // final private OPMFactory oFactory; // // public CollectionFactory(OPMFactory oFactory) { // this.oFactory=oFactory; // } // // // // public WasDerivedFrom newContained(String id, // // ArtifactRef aid1, // // ArtifactRef aid2, // // Collection<AccountRef> accounts) { // // return oFactory.newWasDerivedFrom(id,aid1,aid2,CONTAINED,accounts); // // } // // public WasDerivedFrom newContained(String id, // Artifact a1, // Artifact a2, // Collection<Account> accounts) { // return oFactory.newWasDerivedFrom(id,a1,a2,CONTAINED,accounts); // } // // // // public WasDerivedFrom newWasIdenticalTo(String id, // // ArtifactRef aid1, // // ArtifactRef aid2, // // Collection<AccountRef> accounts) { // // return oFactory.newWasDerivedFrom(id,aid1,aid2,WASIDENTICALTO,accounts); // // } // // public WasDerivedFrom newWasIdenticalTo(String id, // Artifact a1, // Artifact a2, // Collection<Account> accounts) { // return oFactory.newWasDerivedFrom(id,a1,a2,WASIDENTICALTO,accounts); // } // // // // // // }
import java.io.File; import java.io.StringWriter; import java.util.Collection; import java.util.Collections; import java.util.LinkedList; import java.util.List; import javax.xml.bind.JAXBException; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.openprovenance.model.collections.CollectionFactory;
package org.openprovenance.model; /** * Unit test for simple App. */ public class Example8Test extends TestCase { /** * Create the test case * * @param testName name of the test case */ public Example8Test( String testName ) { super( testName ); } /** * @return the suite of tests being tested */ static OPMGraph graph1; public void testCollectionProposal1() throws Exception { OPMFactory oFactory=new OPMFactory();
// Path: opm/src/main/java/org/openprovenance/model/collections/CollectionFactory.java // public class CollectionFactory implements CollectionURIs { // // final private OPMFactory oFactory; // // public CollectionFactory(OPMFactory oFactory) { // this.oFactory=oFactory; // } // // // // public WasDerivedFrom newContained(String id, // // ArtifactRef aid1, // // ArtifactRef aid2, // // Collection<AccountRef> accounts) { // // return oFactory.newWasDerivedFrom(id,aid1,aid2,CONTAINED,accounts); // // } // // public WasDerivedFrom newContained(String id, // Artifact a1, // Artifact a2, // Collection<Account> accounts) { // return oFactory.newWasDerivedFrom(id,a1,a2,CONTAINED,accounts); // } // // // // public WasDerivedFrom newWasIdenticalTo(String id, // // ArtifactRef aid1, // // ArtifactRef aid2, // // Collection<AccountRef> accounts) { // // return oFactory.newWasDerivedFrom(id,aid1,aid2,WASIDENTICALTO,accounts); // // } // // public WasDerivedFrom newWasIdenticalTo(String id, // Artifact a1, // Artifact a2, // Collection<Account> accounts) { // return oFactory.newWasDerivedFrom(id,a1,a2,WASIDENTICALTO,accounts); // } // // // // // // } // Path: opm/src/test/java/org/openprovenance/model/Example8Test.java import java.io.File; import java.io.StringWriter; import java.util.Collection; import java.util.Collections; import java.util.LinkedList; import java.util.List; import javax.xml.bind.JAXBException; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.openprovenance.model.collections.CollectionFactory; package org.openprovenance.model; /** * Unit test for simple App. */ public class Example8Test extends TestCase { /** * Create the test case * * @param testName name of the test case */ public Example8Test( String testName ) { super( testName ); } /** * @return the suite of tests being tested */ static OPMGraph graph1; public void testCollectionProposal1() throws Exception { OPMFactory oFactory=new OPMFactory();
CollectionFactory cFactory=new CollectionFactory(oFactory);
lucmoreau/OpenProvenanceModel
elmo/src/main/java/org/openprovenance/elmo/RdfProfile.java
// Path: opm/src/main/java/org/openprovenance/model/Annotable.java // public interface Annotable extends Identifiable { // public List<JAXBElement<? extends EmbeddedAnnotation>> getAnnotation(); // } // // Path: opm/src/main/java/org/openprovenance/model/CommonURIs.java // public interface CommonURIs { // final String NEW_PROFILE_PROPERTY = "http://openprovenance.org/ontology#profile"; // final String NEW_VALUE_PROPERTY = "http://openprovenance.org/ontology#value"; // final String NEW_ENCODING_PROPERTY = "http://openprovenance.org/ontology#encoding"; // final String NEW_TYPE_PROPERTY = "http://openprovenance.org/ontology#type"; // final String NEW_LABEL_PROPERTY = "http://openprovenance.org/ontology#label"; // final String NEW_PNAME_PROPERTY = "http://openprovenance.org/ontology#pname"; // // // final String PROFILE_PROPERTY = "http://openprovenance.org/property/profile"; // final String VALUE_PROPERTY = "http://openprovenance.org/property/value"; // final String ENCODING_PROPERTY = "http://openprovenance.org/property/encoding"; // final String TYPE_PROPERTY = "http://openprovenance.org/property/type"; // final String LABEL_PROPERTY = "http://openprovenance.org/property/label"; // final String PNAME_PROPERTY = "http://openprovenance.org/property/pname"; // // }
import java.util.Set; import org.openprovenance.rdf.Account; import org.openprovenance.rdf.Node; import javax.xml.namespace.QName; import org.openrdf.elmo.ElmoManager; import org.openprovenance.model.Annotable; import org.openrdf.model.Statement; import org.openrdf.elmo.sesame.SesameManager; import org.openprovenance.model.CommonURIs;
package org.openprovenance.elmo; public class RdfProfile extends org.openprovenance.model.Profile implements CompactAnnotation, CommonURIs { ElmoManager manager; String prefix; QName qname; static int count=0; public RdfProfile(ElmoManager manager, String prefix) { this.manager=manager; this.prefix=prefix; }
// Path: opm/src/main/java/org/openprovenance/model/Annotable.java // public interface Annotable extends Identifiable { // public List<JAXBElement<? extends EmbeddedAnnotation>> getAnnotation(); // } // // Path: opm/src/main/java/org/openprovenance/model/CommonURIs.java // public interface CommonURIs { // final String NEW_PROFILE_PROPERTY = "http://openprovenance.org/ontology#profile"; // final String NEW_VALUE_PROPERTY = "http://openprovenance.org/ontology#value"; // final String NEW_ENCODING_PROPERTY = "http://openprovenance.org/ontology#encoding"; // final String NEW_TYPE_PROPERTY = "http://openprovenance.org/ontology#type"; // final String NEW_LABEL_PROPERTY = "http://openprovenance.org/ontology#label"; // final String NEW_PNAME_PROPERTY = "http://openprovenance.org/ontology#pname"; // // // final String PROFILE_PROPERTY = "http://openprovenance.org/property/profile"; // final String VALUE_PROPERTY = "http://openprovenance.org/property/value"; // final String ENCODING_PROPERTY = "http://openprovenance.org/property/encoding"; // final String TYPE_PROPERTY = "http://openprovenance.org/property/type"; // final String LABEL_PROPERTY = "http://openprovenance.org/property/label"; // final String PNAME_PROPERTY = "http://openprovenance.org/property/pname"; // // } // Path: elmo/src/main/java/org/openprovenance/elmo/RdfProfile.java import java.util.Set; import org.openprovenance.rdf.Account; import org.openprovenance.rdf.Node; import javax.xml.namespace.QName; import org.openrdf.elmo.ElmoManager; import org.openprovenance.model.Annotable; import org.openrdf.model.Statement; import org.openrdf.elmo.sesame.SesameManager; import org.openprovenance.model.CommonURIs; package org.openprovenance.elmo; public class RdfProfile extends org.openprovenance.model.Profile implements CompactAnnotation, CommonURIs { ElmoManager manager; String prefix; QName qname; static int count=0; public RdfProfile(ElmoManager manager, String prefix) { this.manager=manager; this.prefix=prefix; }
public void toRdf(Annotable entity) throws org.openrdf.repository.RepositoryException {
lucmoreau/OpenProvenanceModel
jena/src/main/java/org/openprovenance/jena/Querier.java
// Path: jena/src/main/java/org/openprovenance/jena/TripleStore.java // public static String OPMO_NS="http://openprovenance.org/model/opmo#"; // // Path: jena/src/main/java/org/openprovenance/jena/TripleStore.java // public static String OPMV_NS="http://purl.org/net/opmv/ns#";
import com.hp.hpl.jena.ontology.OntClass; import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.query.Query; import com.hp.hpl.jena.query.QueryExecution; import com.hp.hpl.jena.query.QuerySolution; import com.hp.hpl.jena.query.QueryExecutionFactory; import com.hp.hpl.jena.query.QueryFactory; import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.query.ResultSetFormatter; import com.hp.hpl.jena.rdf.model.InfModel; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.Resource; import com.hp.hpl.jena.rdf.model.Literal; import com.hp.hpl.jena.reasoner.Reasoner; import com.hp.hpl.jena.reasoner.ValidityReport; import com.hp.hpl.jena.vocabulary.RDFS; import static org.openprovenance.jena.TripleStore.OPMO_NS; import static org.openprovenance.jena.TripleStore.OPMV_NS; import java.util.LinkedList; import java.util.List;
package org.openprovenance.jena; public class Querier { final Model model; public Querier(Model model) { this.model=model; } String queryString_used(String p) {
// Path: jena/src/main/java/org/openprovenance/jena/TripleStore.java // public static String OPMO_NS="http://openprovenance.org/model/opmo#"; // // Path: jena/src/main/java/org/openprovenance/jena/TripleStore.java // public static String OPMV_NS="http://purl.org/net/opmv/ns#"; // Path: jena/src/main/java/org/openprovenance/jena/Querier.java import com.hp.hpl.jena.ontology.OntClass; import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.query.Query; import com.hp.hpl.jena.query.QueryExecution; import com.hp.hpl.jena.query.QuerySolution; import com.hp.hpl.jena.query.QueryExecutionFactory; import com.hp.hpl.jena.query.QueryFactory; import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.query.ResultSetFormatter; import com.hp.hpl.jena.rdf.model.InfModel; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.Resource; import com.hp.hpl.jena.rdf.model.Literal; import com.hp.hpl.jena.reasoner.Reasoner; import com.hp.hpl.jena.reasoner.ValidityReport; import com.hp.hpl.jena.vocabulary.RDFS; import static org.openprovenance.jena.TripleStore.OPMO_NS; import static org.openprovenance.jena.TripleStore.OPMV_NS; import java.util.LinkedList; import java.util.List; package org.openprovenance.jena; public class Querier { final Model model; public Querier(Model model) { this.model=model; } String queryString_used(String p) {
return "PREFIX opmo: <" + OPMO_NS + "> " +
lucmoreau/OpenProvenanceModel
jena/src/main/java/org/openprovenance/jena/Querier.java
// Path: jena/src/main/java/org/openprovenance/jena/TripleStore.java // public static String OPMO_NS="http://openprovenance.org/model/opmo#"; // // Path: jena/src/main/java/org/openprovenance/jena/TripleStore.java // public static String OPMV_NS="http://purl.org/net/opmv/ns#";
import com.hp.hpl.jena.ontology.OntClass; import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.query.Query; import com.hp.hpl.jena.query.QueryExecution; import com.hp.hpl.jena.query.QuerySolution; import com.hp.hpl.jena.query.QueryExecutionFactory; import com.hp.hpl.jena.query.QueryFactory; import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.query.ResultSetFormatter; import com.hp.hpl.jena.rdf.model.InfModel; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.Resource; import com.hp.hpl.jena.rdf.model.Literal; import com.hp.hpl.jena.reasoner.Reasoner; import com.hp.hpl.jena.reasoner.ValidityReport; import com.hp.hpl.jena.vocabulary.RDFS; import static org.openprovenance.jena.TripleStore.OPMO_NS; import static org.openprovenance.jena.TripleStore.OPMV_NS; import java.util.LinkedList; import java.util.List;
package org.openprovenance.jena; public class Querier { final Model model; public Querier(Model model) { this.model=model; } String queryString_used(String p) { return "PREFIX opmo: <" + OPMO_NS + "> " +
// Path: jena/src/main/java/org/openprovenance/jena/TripleStore.java // public static String OPMO_NS="http://openprovenance.org/model/opmo#"; // // Path: jena/src/main/java/org/openprovenance/jena/TripleStore.java // public static String OPMV_NS="http://purl.org/net/opmv/ns#"; // Path: jena/src/main/java/org/openprovenance/jena/Querier.java import com.hp.hpl.jena.ontology.OntClass; import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.query.Query; import com.hp.hpl.jena.query.QueryExecution; import com.hp.hpl.jena.query.QuerySolution; import com.hp.hpl.jena.query.QueryExecutionFactory; import com.hp.hpl.jena.query.QueryFactory; import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.query.ResultSetFormatter; import com.hp.hpl.jena.rdf.model.InfModel; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.Resource; import com.hp.hpl.jena.rdf.model.Literal; import com.hp.hpl.jena.reasoner.Reasoner; import com.hp.hpl.jena.reasoner.ValidityReport; import com.hp.hpl.jena.vocabulary.RDFS; import static org.openprovenance.jena.TripleStore.OPMO_NS; import static org.openprovenance.jena.TripleStore.OPMV_NS; import java.util.LinkedList; import java.util.List; package org.openprovenance.jena; public class Querier { final Model model; public Querier(Model model) { this.model=model; } String queryString_used(String p) { return "PREFIX opmo: <" + OPMO_NS + "> " +
"PREFIX opmv: <" + OPMV_NS + "> " +
lucmoreau/OpenProvenanceModel
opm/src/test/java/org/openprovenance/model/List1Test.java
// Path: opm/src/main/java/org/openprovenance/model/collections/CollectionFactory.java // public class CollectionFactory implements CollectionURIs { // // final private OPMFactory oFactory; // // public CollectionFactory(OPMFactory oFactory) { // this.oFactory=oFactory; // } // // // // public WasDerivedFrom newContained(String id, // // ArtifactRef aid1, // // ArtifactRef aid2, // // Collection<AccountRef> accounts) { // // return oFactory.newWasDerivedFrom(id,aid1,aid2,CONTAINED,accounts); // // } // // public WasDerivedFrom newContained(String id, // Artifact a1, // Artifact a2, // Collection<Account> accounts) { // return oFactory.newWasDerivedFrom(id,a1,a2,CONTAINED,accounts); // } // // // // public WasDerivedFrom newWasIdenticalTo(String id, // // ArtifactRef aid1, // // ArtifactRef aid2, // // Collection<AccountRef> accounts) { // // return oFactory.newWasDerivedFrom(id,aid1,aid2,WASIDENTICALTO,accounts); // // } // // public WasDerivedFrom newWasIdenticalTo(String id, // Artifact a1, // Artifact a2, // Collection<Account> accounts) { // return oFactory.newWasDerivedFrom(id,a1,a2,WASIDENTICALTO,accounts); // } // // // // // // }
import java.io.File; import java.io.StringWriter; import java.util.Collection; import java.util.Collections; import java.util.LinkedList; import java.util.List; import javax.xml.bind.JAXBException; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.openprovenance.model.collections.CollectionFactory;
package org.openprovenance.model; /** * Unit test for simple App. */ public class List1Test extends TestCase { static public OPMFactory oFactory=new OPMFactory(); /** * Create the test case * * @param testName name of the test case */ public List1Test( String testName ) { super( testName ); } /** * @return the suite of tests being tested */ public static Test suite() { return new TestSuite( List1Test.class ); } static OPMGraph graph1; static OPMGraph graph2; /** Creates and serialises an OPM graph. */ public void testList1() throws JAXBException, java.io.FileNotFoundException, java.io.IOException { OPMGraph graph=makeList1Graph(oFactory); OPMSerialiser serial=OPMSerialiser.getThreadOPMSerialiser(); StringWriter sw=new StringWriter(); serial.serialiseOPMGraph(sw,graph,true); serial.serialiseOPMGraph(new File("target/list1.xml"),graph,true); graph1=graph; assertTrue( true ); OPMToDot toDot=new OPMToDot("src/test/resources/collectionConfig.xml"); toDot.convert(graph1,"target/list1.dot", "target/list1.pdf"); toDot=new OPMToDot("src/test/resources/collectionConfig1.xml"); toDot.convert(graph1,"target/list2.dot", "target/list2.pdf"); toDot=new OPMToDot("src/test/resources/collectionConfig2.xml"); toDot.convert(graph1,"target/list3.dot", "target/list3.pdf"); toDot=new OPMToDot("src/test/resources/collectionConfig3.xml"); toDot.convert(graph1,"target/list4.dot", "target/list4.pdf"); } public OPMGraph makeList1Graph(OPMFactory oFactory) throws JAXBException, java.io.FileNotFoundException, java.io.IOException {
// Path: opm/src/main/java/org/openprovenance/model/collections/CollectionFactory.java // public class CollectionFactory implements CollectionURIs { // // final private OPMFactory oFactory; // // public CollectionFactory(OPMFactory oFactory) { // this.oFactory=oFactory; // } // // // // public WasDerivedFrom newContained(String id, // // ArtifactRef aid1, // // ArtifactRef aid2, // // Collection<AccountRef> accounts) { // // return oFactory.newWasDerivedFrom(id,aid1,aid2,CONTAINED,accounts); // // } // // public WasDerivedFrom newContained(String id, // Artifact a1, // Artifact a2, // Collection<Account> accounts) { // return oFactory.newWasDerivedFrom(id,a1,a2,CONTAINED,accounts); // } // // // // public WasDerivedFrom newWasIdenticalTo(String id, // // ArtifactRef aid1, // // ArtifactRef aid2, // // Collection<AccountRef> accounts) { // // return oFactory.newWasDerivedFrom(id,aid1,aid2,WASIDENTICALTO,accounts); // // } // // public WasDerivedFrom newWasIdenticalTo(String id, // Artifact a1, // Artifact a2, // Collection<Account> accounts) { // return oFactory.newWasDerivedFrom(id,a1,a2,WASIDENTICALTO,accounts); // } // // // // // // } // Path: opm/src/test/java/org/openprovenance/model/List1Test.java import java.io.File; import java.io.StringWriter; import java.util.Collection; import java.util.Collections; import java.util.LinkedList; import java.util.List; import javax.xml.bind.JAXBException; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.openprovenance.model.collections.CollectionFactory; package org.openprovenance.model; /** * Unit test for simple App. */ public class List1Test extends TestCase { static public OPMFactory oFactory=new OPMFactory(); /** * Create the test case * * @param testName name of the test case */ public List1Test( String testName ) { super( testName ); } /** * @return the suite of tests being tested */ public static Test suite() { return new TestSuite( List1Test.class ); } static OPMGraph graph1; static OPMGraph graph2; /** Creates and serialises an OPM graph. */ public void testList1() throws JAXBException, java.io.FileNotFoundException, java.io.IOException { OPMGraph graph=makeList1Graph(oFactory); OPMSerialiser serial=OPMSerialiser.getThreadOPMSerialiser(); StringWriter sw=new StringWriter(); serial.serialiseOPMGraph(sw,graph,true); serial.serialiseOPMGraph(new File("target/list1.xml"),graph,true); graph1=graph; assertTrue( true ); OPMToDot toDot=new OPMToDot("src/test/resources/collectionConfig.xml"); toDot.convert(graph1,"target/list1.dot", "target/list1.pdf"); toDot=new OPMToDot("src/test/resources/collectionConfig1.xml"); toDot.convert(graph1,"target/list2.dot", "target/list2.pdf"); toDot=new OPMToDot("src/test/resources/collectionConfig2.xml"); toDot.convert(graph1,"target/list3.dot", "target/list3.pdf"); toDot=new OPMToDot("src/test/resources/collectionConfig3.xml"); toDot.convert(graph1,"target/list4.dot", "target/list4.pdf"); } public OPMGraph makeList1Graph(OPMFactory oFactory) throws JAXBException, java.io.FileNotFoundException, java.io.IOException {
CollectionFactory cFactory=new CollectionFactory(oFactory);
lucmoreau/OpenProvenanceModel
jena/src/test/java/org/openprovenance/jena/Jena1Test.java
// Path: jena/src/main/java/org/openprovenance/jena/TripleStore.java // public static String OPMO_NS="http://openprovenance.org/model/opmo#"; // // Path: jena/src/main/java/org/openprovenance/jena/TripleStore.java // public static String OPMV_NS="http://purl.org/net/opmv/ns#";
import static org.openprovenance.jena.TripleStore.OPMO_NS; import static org.openprovenance.jena.TripleStore.OPMV_NS; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import com.hp.hpl.jena.ontology.OntClass; import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.query.Query; import com.hp.hpl.jena.query.QueryExecution; import com.hp.hpl.jena.query.QueryExecutionFactory; import com.hp.hpl.jena.query.QueryFactory; import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.query.ResultSetFormatter; import com.hp.hpl.jena.rdf.model.InfModel; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.Resource; import com.hp.hpl.jena.reasoner.Reasoner; import com.hp.hpl.jena.reasoner.ValidityReport; import com.hp.hpl.jena.vocabulary.RDFS;
package org.openprovenance.jena; public class Jena1Test extends TestCase { public static String PC1_NS="http://www.ipaw.info/pc1/"; public Jena1Test (String testName) { super(testName); } public void testOPMV1() { TripleStore ts= new TripleStore(); ts.setUp(); ts.loadOPMVOntology(); // read the files ts.readFile( "file:src/test/resources/pc1-time.n3", "N3" ); // print validation report ValidityReport report = ts.validate(); ts.printIterator( report.getReports(), "Validation Results" ); Model model=ts.getModel(); // print superclasses
// Path: jena/src/main/java/org/openprovenance/jena/TripleStore.java // public static String OPMO_NS="http://openprovenance.org/model/opmo#"; // // Path: jena/src/main/java/org/openprovenance/jena/TripleStore.java // public static String OPMV_NS="http://purl.org/net/opmv/ns#"; // Path: jena/src/test/java/org/openprovenance/jena/Jena1Test.java import static org.openprovenance.jena.TripleStore.OPMO_NS; import static org.openprovenance.jena.TripleStore.OPMV_NS; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import com.hp.hpl.jena.ontology.OntClass; import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.query.Query; import com.hp.hpl.jena.query.QueryExecution; import com.hp.hpl.jena.query.QueryExecutionFactory; import com.hp.hpl.jena.query.QueryFactory; import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.query.ResultSetFormatter; import com.hp.hpl.jena.rdf.model.InfModel; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.Resource; import com.hp.hpl.jena.reasoner.Reasoner; import com.hp.hpl.jena.reasoner.ValidityReport; import com.hp.hpl.jena.vocabulary.RDFS; package org.openprovenance.jena; public class Jena1Test extends TestCase { public static String PC1_NS="http://www.ipaw.info/pc1/"; public Jena1Test (String testName) { super(testName); } public void testOPMV1() { TripleStore ts= new TripleStore(); ts.setUp(); ts.loadOPMVOntology(); // read the files ts.readFile( "file:src/test/resources/pc1-time.n3", "N3" ); // print validation report ValidityReport report = ts.validate(); ts.printIterator( report.getReports(), "Validation Results" ); Model model=ts.getModel(); // print superclasses
Resource c = model.getResource( OPMV_NS + "Artifact" );
lucmoreau/OpenProvenanceModel
elmo/src/main/java/org/openprovenance/elmo/RdfOPMFactory.java
// Path: elmo/src/main/java/org/openprovenance/elmo/XMLLiteral.java // public class XMLLiteral { // private static DocumentBuilder builder; // // private static Transformer transformer; // // private String xml; // // public XMLLiteral(String xml) { // this.xml = xml; // } // // public XMLLiteral(Document document) { // this.xml = serialize(document); // } // // public Document getDocument() { // return deserialize(xml); // } // // @Override // public String toString() { // return xml; // } // // private String serialize(Document object) { // Source source = new DOMSource(object); // CharArrayWriter writer = new CharArrayWriter(); // Result result = new StreamResult(writer); // try { // if (transformer == null) { // transformer = TransformerFactory.newInstance() // .newTransformer(); // } // transformer.transform(source, result); // } catch (Exception e) { // throw new ElmoConversionException(e); // } // return writer.toString(); // } // // private Document deserialize(String xml) { // try { // char[] charArray = xml.toCharArray(); // CharArrayReader reader = new CharArrayReader(charArray); // try { // if (builder == null) { // DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance(); // dbf.setNamespaceAware(true); // builder = dbf.newDocumentBuilder(); // } // return builder.parse(new InputSource(reader)); // } finally { // reader.close(); // } // } catch (Exception e) { // throw new ElmoConversionException(e); // } // } // // } // // Path: opm/src/main/java/org/openprovenance/model/Annotable.java // public interface Annotable extends Identifiable { // public List<JAXBElement<? extends EmbeddedAnnotation>> getAnnotation(); // } // // Path: opm/src/main/java/org/openprovenance/model/HasAccounts.java // public interface HasAccounts { // List<AccountRef> getAccount(); // } // // Path: opm/src/main/java/org/openprovenance/model/Identifiable.java // public interface Identifiable { // public void setId(String s); // public String getId(); // }
import java.net.URI; import java.util.Collection; import java.util.Set; import java.util.List; import java.util.LinkedList; import java.util.HashSet; import java.util.Hashtable; import javax.xml.bind.JAXBElement; import javax.xml.namespace.QName; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.openrdf.elmo.ElmoManager; import org.openprovenance.elmo.XMLLiteral; import org.openprovenance.model.Account; import org.openprovenance.model.AccountRef; import org.openprovenance.model.Agent; import org.openprovenance.model.Annotable; import org.openprovenance.model.Annotation; import org.openprovenance.model.Artifact; import org.openprovenance.model.EmbeddedAnnotation; import org.openprovenance.model.HasAccounts; import org.openprovenance.model.Identifiable; import org.openprovenance.model.Label; import org.openprovenance.model.OPMGraph; import org.openprovenance.model.Process; import org.openprovenance.model.Property; import org.openprovenance.model.Type; import org.openprovenance.model.Used; import org.openprovenance.model.Value; import org.openprovenance.model.WasControlledBy; import org.openprovenance.model.WasDerivedFrom; import org.openprovenance.model.WasGeneratedBy; import org.openprovenance.model.WasTriggeredBy; import org.openprovenance.rdf.AnnotationOrEdgeOrNode; import org.openrdf.elmo.Entity;
static int count=0; public String autoGenerateId(String prefix) { String id=prefix+count++; return id; } public String autoGenerateId(String prefix, String id) { if (id!=null) return id; id=prefix+count++; return id; } public void addProperty(EmbeddedAnnotation ann, Property p) { super.addProperty(ann,p); Object o=((HasFacade) ann).findMyFacade(); org.openprovenance.rdf.Annotation ann2=(org.openprovenance.rdf.Annotation) o; org.openprovenance.rdf.Property p2=(org.openprovenance.rdf.Property) ((HasFacade)p).findMyFacade(); ann2.getProperties().add(p2); } public void addProperty(Annotation ann, Property p) { super.addProperty(ann,p); Object o=((HasFacade) ann).findMyFacade(); org.openprovenance.rdf.Annotation ann2=(org.openprovenance.rdf.Annotation) o; org.openprovenance.rdf.Property p2=(org.openprovenance.rdf.Property) ((HasFacade)p).findMyFacade(); ann2.getProperties().add(p2); }
// Path: elmo/src/main/java/org/openprovenance/elmo/XMLLiteral.java // public class XMLLiteral { // private static DocumentBuilder builder; // // private static Transformer transformer; // // private String xml; // // public XMLLiteral(String xml) { // this.xml = xml; // } // // public XMLLiteral(Document document) { // this.xml = serialize(document); // } // // public Document getDocument() { // return deserialize(xml); // } // // @Override // public String toString() { // return xml; // } // // private String serialize(Document object) { // Source source = new DOMSource(object); // CharArrayWriter writer = new CharArrayWriter(); // Result result = new StreamResult(writer); // try { // if (transformer == null) { // transformer = TransformerFactory.newInstance() // .newTransformer(); // } // transformer.transform(source, result); // } catch (Exception e) { // throw new ElmoConversionException(e); // } // return writer.toString(); // } // // private Document deserialize(String xml) { // try { // char[] charArray = xml.toCharArray(); // CharArrayReader reader = new CharArrayReader(charArray); // try { // if (builder == null) { // DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance(); // dbf.setNamespaceAware(true); // builder = dbf.newDocumentBuilder(); // } // return builder.parse(new InputSource(reader)); // } finally { // reader.close(); // } // } catch (Exception e) { // throw new ElmoConversionException(e); // } // } // // } // // Path: opm/src/main/java/org/openprovenance/model/Annotable.java // public interface Annotable extends Identifiable { // public List<JAXBElement<? extends EmbeddedAnnotation>> getAnnotation(); // } // // Path: opm/src/main/java/org/openprovenance/model/HasAccounts.java // public interface HasAccounts { // List<AccountRef> getAccount(); // } // // Path: opm/src/main/java/org/openprovenance/model/Identifiable.java // public interface Identifiable { // public void setId(String s); // public String getId(); // } // Path: elmo/src/main/java/org/openprovenance/elmo/RdfOPMFactory.java import java.net.URI; import java.util.Collection; import java.util.Set; import java.util.List; import java.util.LinkedList; import java.util.HashSet; import java.util.Hashtable; import javax.xml.bind.JAXBElement; import javax.xml.namespace.QName; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.openrdf.elmo.ElmoManager; import org.openprovenance.elmo.XMLLiteral; import org.openprovenance.model.Account; import org.openprovenance.model.AccountRef; import org.openprovenance.model.Agent; import org.openprovenance.model.Annotable; import org.openprovenance.model.Annotation; import org.openprovenance.model.Artifact; import org.openprovenance.model.EmbeddedAnnotation; import org.openprovenance.model.HasAccounts; import org.openprovenance.model.Identifiable; import org.openprovenance.model.Label; import org.openprovenance.model.OPMGraph; import org.openprovenance.model.Process; import org.openprovenance.model.Property; import org.openprovenance.model.Type; import org.openprovenance.model.Used; import org.openprovenance.model.Value; import org.openprovenance.model.WasControlledBy; import org.openprovenance.model.WasDerivedFrom; import org.openprovenance.model.WasGeneratedBy; import org.openprovenance.model.WasTriggeredBy; import org.openprovenance.rdf.AnnotationOrEdgeOrNode; import org.openrdf.elmo.Entity; static int count=0; public String autoGenerateId(String prefix) { String id=prefix+count++; return id; } public String autoGenerateId(String prefix, String id) { if (id!=null) return id; id=prefix+count++; return id; } public void addProperty(EmbeddedAnnotation ann, Property p) { super.addProperty(ann,p); Object o=((HasFacade) ann).findMyFacade(); org.openprovenance.rdf.Annotation ann2=(org.openprovenance.rdf.Annotation) o; org.openprovenance.rdf.Property p2=(org.openprovenance.rdf.Property) ((HasFacade)p).findMyFacade(); ann2.getProperties().add(p2); } public void addProperty(Annotation ann, Property p) { super.addProperty(ann,p); Object o=((HasFacade) ann).findMyFacade(); org.openprovenance.rdf.Annotation ann2=(org.openprovenance.rdf.Annotation) o; org.openprovenance.rdf.Property p2=(org.openprovenance.rdf.Property) ((HasFacade)p).findMyFacade(); ann2.getProperties().add(p2); }
public void addAccounts(HasAccounts element, Collection<AccountRef> accounts) {
lucmoreau/OpenProvenanceModel
elmo/src/main/java/org/openprovenance/elmo/RdfOPMFactory.java
// Path: elmo/src/main/java/org/openprovenance/elmo/XMLLiteral.java // public class XMLLiteral { // private static DocumentBuilder builder; // // private static Transformer transformer; // // private String xml; // // public XMLLiteral(String xml) { // this.xml = xml; // } // // public XMLLiteral(Document document) { // this.xml = serialize(document); // } // // public Document getDocument() { // return deserialize(xml); // } // // @Override // public String toString() { // return xml; // } // // private String serialize(Document object) { // Source source = new DOMSource(object); // CharArrayWriter writer = new CharArrayWriter(); // Result result = new StreamResult(writer); // try { // if (transformer == null) { // transformer = TransformerFactory.newInstance() // .newTransformer(); // } // transformer.transform(source, result); // } catch (Exception e) { // throw new ElmoConversionException(e); // } // return writer.toString(); // } // // private Document deserialize(String xml) { // try { // char[] charArray = xml.toCharArray(); // CharArrayReader reader = new CharArrayReader(charArray); // try { // if (builder == null) { // DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance(); // dbf.setNamespaceAware(true); // builder = dbf.newDocumentBuilder(); // } // return builder.parse(new InputSource(reader)); // } finally { // reader.close(); // } // } catch (Exception e) { // throw new ElmoConversionException(e); // } // } // // } // // Path: opm/src/main/java/org/openprovenance/model/Annotable.java // public interface Annotable extends Identifiable { // public List<JAXBElement<? extends EmbeddedAnnotation>> getAnnotation(); // } // // Path: opm/src/main/java/org/openprovenance/model/HasAccounts.java // public interface HasAccounts { // List<AccountRef> getAccount(); // } // // Path: opm/src/main/java/org/openprovenance/model/Identifiable.java // public interface Identifiable { // public void setId(String s); // public String getId(); // }
import java.net.URI; import java.util.Collection; import java.util.Set; import java.util.List; import java.util.LinkedList; import java.util.HashSet; import java.util.Hashtable; import javax.xml.bind.JAXBElement; import javax.xml.namespace.QName; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.openrdf.elmo.ElmoManager; import org.openprovenance.elmo.XMLLiteral; import org.openprovenance.model.Account; import org.openprovenance.model.AccountRef; import org.openprovenance.model.Agent; import org.openprovenance.model.Annotable; import org.openprovenance.model.Annotation; import org.openprovenance.model.Artifact; import org.openprovenance.model.EmbeddedAnnotation; import org.openprovenance.model.HasAccounts; import org.openprovenance.model.Identifiable; import org.openprovenance.model.Label; import org.openprovenance.model.OPMGraph; import org.openprovenance.model.Process; import org.openprovenance.model.Property; import org.openprovenance.model.Type; import org.openprovenance.model.Used; import org.openprovenance.model.Value; import org.openprovenance.model.WasControlledBy; import org.openprovenance.model.WasDerivedFrom; import org.openprovenance.model.WasGeneratedBy; import org.openprovenance.model.WasTriggeredBy; import org.openprovenance.rdf.AnnotationOrEdgeOrNode; import org.openrdf.elmo.Entity;
Object o=((HasFacade) ann).findMyFacade(); org.openprovenance.rdf.Annotation ann2=(org.openprovenance.rdf.Annotation) o; org.openprovenance.rdf.Property p2=(org.openprovenance.rdf.Property) ((HasFacade)p).findMyFacade(); ann2.getProperties().add(p2); } public void addProperty(Annotation ann, Property p) { super.addProperty(ann,p); Object o=((HasFacade) ann).findMyFacade(); org.openprovenance.rdf.Annotation ann2=(org.openprovenance.rdf.Annotation) o; org.openprovenance.rdf.Property p2=(org.openprovenance.rdf.Property) ((HasFacade)p).findMyFacade(); ann2.getProperties().add(p2); } public void addAccounts(HasAccounts element, Collection<AccountRef> accounts) { super.addAccounts(element,accounts); if (element instanceof HasAccounts) { //Annotable HasFacade facade=(HasFacade) element; Object o=facade.findMyFacade(); AnnotationOrEdgeOrNode el=(AnnotationOrEdgeOrNode) o; Set set=new HashSet(); for (AccountRef accr: accounts) { set.add(((HasFacade)accr.getRef()).findMyFacade()); } el.getAccounts().addAll(set); //el.setAccounts(set); } }
// Path: elmo/src/main/java/org/openprovenance/elmo/XMLLiteral.java // public class XMLLiteral { // private static DocumentBuilder builder; // // private static Transformer transformer; // // private String xml; // // public XMLLiteral(String xml) { // this.xml = xml; // } // // public XMLLiteral(Document document) { // this.xml = serialize(document); // } // // public Document getDocument() { // return deserialize(xml); // } // // @Override // public String toString() { // return xml; // } // // private String serialize(Document object) { // Source source = new DOMSource(object); // CharArrayWriter writer = new CharArrayWriter(); // Result result = new StreamResult(writer); // try { // if (transformer == null) { // transformer = TransformerFactory.newInstance() // .newTransformer(); // } // transformer.transform(source, result); // } catch (Exception e) { // throw new ElmoConversionException(e); // } // return writer.toString(); // } // // private Document deserialize(String xml) { // try { // char[] charArray = xml.toCharArray(); // CharArrayReader reader = new CharArrayReader(charArray); // try { // if (builder == null) { // DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance(); // dbf.setNamespaceAware(true); // builder = dbf.newDocumentBuilder(); // } // return builder.parse(new InputSource(reader)); // } finally { // reader.close(); // } // } catch (Exception e) { // throw new ElmoConversionException(e); // } // } // // } // // Path: opm/src/main/java/org/openprovenance/model/Annotable.java // public interface Annotable extends Identifiable { // public List<JAXBElement<? extends EmbeddedAnnotation>> getAnnotation(); // } // // Path: opm/src/main/java/org/openprovenance/model/HasAccounts.java // public interface HasAccounts { // List<AccountRef> getAccount(); // } // // Path: opm/src/main/java/org/openprovenance/model/Identifiable.java // public interface Identifiable { // public void setId(String s); // public String getId(); // } // Path: elmo/src/main/java/org/openprovenance/elmo/RdfOPMFactory.java import java.net.URI; import java.util.Collection; import java.util.Set; import java.util.List; import java.util.LinkedList; import java.util.HashSet; import java.util.Hashtable; import javax.xml.bind.JAXBElement; import javax.xml.namespace.QName; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.openrdf.elmo.ElmoManager; import org.openprovenance.elmo.XMLLiteral; import org.openprovenance.model.Account; import org.openprovenance.model.AccountRef; import org.openprovenance.model.Agent; import org.openprovenance.model.Annotable; import org.openprovenance.model.Annotation; import org.openprovenance.model.Artifact; import org.openprovenance.model.EmbeddedAnnotation; import org.openprovenance.model.HasAccounts; import org.openprovenance.model.Identifiable; import org.openprovenance.model.Label; import org.openprovenance.model.OPMGraph; import org.openprovenance.model.Process; import org.openprovenance.model.Property; import org.openprovenance.model.Type; import org.openprovenance.model.Used; import org.openprovenance.model.Value; import org.openprovenance.model.WasControlledBy; import org.openprovenance.model.WasDerivedFrom; import org.openprovenance.model.WasGeneratedBy; import org.openprovenance.model.WasTriggeredBy; import org.openprovenance.rdf.AnnotationOrEdgeOrNode; import org.openrdf.elmo.Entity; Object o=((HasFacade) ann).findMyFacade(); org.openprovenance.rdf.Annotation ann2=(org.openprovenance.rdf.Annotation) o; org.openprovenance.rdf.Property p2=(org.openprovenance.rdf.Property) ((HasFacade)p).findMyFacade(); ann2.getProperties().add(p2); } public void addProperty(Annotation ann, Property p) { super.addProperty(ann,p); Object o=((HasFacade) ann).findMyFacade(); org.openprovenance.rdf.Annotation ann2=(org.openprovenance.rdf.Annotation) o; org.openprovenance.rdf.Property p2=(org.openprovenance.rdf.Property) ((HasFacade)p).findMyFacade(); ann2.getProperties().add(p2); } public void addAccounts(HasAccounts element, Collection<AccountRef> accounts) { super.addAccounts(element,accounts); if (element instanceof HasAccounts) { //Annotable HasFacade facade=(HasFacade) element; Object o=facade.findMyFacade(); AnnotationOrEdgeOrNode el=(AnnotationOrEdgeOrNode) o; Set set=new HashSet(); for (AccountRef accr: accounts) { set.add(((HasFacade)accr.getRef()).findMyFacade()); } el.getAccounts().addAll(set); //el.setAccounts(set); } }
public void addAnnotation(Annotable annotable,
lucmoreau/OpenProvenanceModel
elmo/src/main/java/org/openprovenance/elmo/RdfOPMFactory.java
// Path: elmo/src/main/java/org/openprovenance/elmo/XMLLiteral.java // public class XMLLiteral { // private static DocumentBuilder builder; // // private static Transformer transformer; // // private String xml; // // public XMLLiteral(String xml) { // this.xml = xml; // } // // public XMLLiteral(Document document) { // this.xml = serialize(document); // } // // public Document getDocument() { // return deserialize(xml); // } // // @Override // public String toString() { // return xml; // } // // private String serialize(Document object) { // Source source = new DOMSource(object); // CharArrayWriter writer = new CharArrayWriter(); // Result result = new StreamResult(writer); // try { // if (transformer == null) { // transformer = TransformerFactory.newInstance() // .newTransformer(); // } // transformer.transform(source, result); // } catch (Exception e) { // throw new ElmoConversionException(e); // } // return writer.toString(); // } // // private Document deserialize(String xml) { // try { // char[] charArray = xml.toCharArray(); // CharArrayReader reader = new CharArrayReader(charArray); // try { // if (builder == null) { // DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance(); // dbf.setNamespaceAware(true); // builder = dbf.newDocumentBuilder(); // } // return builder.parse(new InputSource(reader)); // } finally { // reader.close(); // } // } catch (Exception e) { // throw new ElmoConversionException(e); // } // } // // } // // Path: opm/src/main/java/org/openprovenance/model/Annotable.java // public interface Annotable extends Identifiable { // public List<JAXBElement<? extends EmbeddedAnnotation>> getAnnotation(); // } // // Path: opm/src/main/java/org/openprovenance/model/HasAccounts.java // public interface HasAccounts { // List<AccountRef> getAccount(); // } // // Path: opm/src/main/java/org/openprovenance/model/Identifiable.java // public interface Identifiable { // public void setId(String s); // public String getId(); // }
import java.net.URI; import java.util.Collection; import java.util.Set; import java.util.List; import java.util.LinkedList; import java.util.HashSet; import java.util.Hashtable; import javax.xml.bind.JAXBElement; import javax.xml.namespace.QName; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.openrdf.elmo.ElmoManager; import org.openprovenance.elmo.XMLLiteral; import org.openprovenance.model.Account; import org.openprovenance.model.AccountRef; import org.openprovenance.model.Agent; import org.openprovenance.model.Annotable; import org.openprovenance.model.Annotation; import org.openprovenance.model.Artifact; import org.openprovenance.model.EmbeddedAnnotation; import org.openprovenance.model.HasAccounts; import org.openprovenance.model.Identifiable; import org.openprovenance.model.Label; import org.openprovenance.model.OPMGraph; import org.openprovenance.model.Process; import org.openprovenance.model.Property; import org.openprovenance.model.Type; import org.openprovenance.model.Used; import org.openprovenance.model.Value; import org.openprovenance.model.WasControlledBy; import org.openprovenance.model.WasDerivedFrom; import org.openprovenance.model.WasGeneratedBy; import org.openprovenance.model.WasTriggeredBy; import org.openprovenance.rdf.AnnotationOrEdgeOrNode; import org.openrdf.elmo.Entity;
QName qname=((Entity)a).getQName(); RdfWasTriggeredBy wtb=new RdfWasTriggeredBy(manager,qname); org.openprovenance.rdf.Node cause=a.getCause(); org.openprovenance.rdf.Node effect=a.getEffect(); wtb.setNodes(newProcessRef(processRegister.get(((Entity)cause).getQName())), newProcessRef(processRegister.get(((Entity)effect).getQName()))); addAccounts((org.openprovenance.rdf.AnnotationOrEdgeOrNode)a,wtb.getAccount()); processAnnotations(a,wtb); return wtb; } public void processAnnotations(org.openprovenance.rdf.Annotable a, Annotable res) { for (org.openprovenance.rdf.Annotation ann: a.getAnnotations()) { addAnnotation(res,newEmbeddedAnnotation(ann)); } for (String label: a.getLabels()) { super.addAnnotation(res,newLabel(label)); } for (URI pname: a.getPnames()) { super.addAnnotation(res,newPName(pname.toString())); } for (String profile: a.getProfiles()) { super.addAnnotation(res,newProfile(profile)); } for (URI type: a.getTypes()) { super.addAnnotation(res,newType(type.toString())); } if (a instanceof org.openprovenance.rdf.Artifact) { org.openprovenance.rdf.Artifact aa=(org.openprovenance.rdf.Artifact) a; for (org.openprovenance.rdf.AValue av: aa.getAvalues()) {
// Path: elmo/src/main/java/org/openprovenance/elmo/XMLLiteral.java // public class XMLLiteral { // private static DocumentBuilder builder; // // private static Transformer transformer; // // private String xml; // // public XMLLiteral(String xml) { // this.xml = xml; // } // // public XMLLiteral(Document document) { // this.xml = serialize(document); // } // // public Document getDocument() { // return deserialize(xml); // } // // @Override // public String toString() { // return xml; // } // // private String serialize(Document object) { // Source source = new DOMSource(object); // CharArrayWriter writer = new CharArrayWriter(); // Result result = new StreamResult(writer); // try { // if (transformer == null) { // transformer = TransformerFactory.newInstance() // .newTransformer(); // } // transformer.transform(source, result); // } catch (Exception e) { // throw new ElmoConversionException(e); // } // return writer.toString(); // } // // private Document deserialize(String xml) { // try { // char[] charArray = xml.toCharArray(); // CharArrayReader reader = new CharArrayReader(charArray); // try { // if (builder == null) { // DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance(); // dbf.setNamespaceAware(true); // builder = dbf.newDocumentBuilder(); // } // return builder.parse(new InputSource(reader)); // } finally { // reader.close(); // } // } catch (Exception e) { // throw new ElmoConversionException(e); // } // } // // } // // Path: opm/src/main/java/org/openprovenance/model/Annotable.java // public interface Annotable extends Identifiable { // public List<JAXBElement<? extends EmbeddedAnnotation>> getAnnotation(); // } // // Path: opm/src/main/java/org/openprovenance/model/HasAccounts.java // public interface HasAccounts { // List<AccountRef> getAccount(); // } // // Path: opm/src/main/java/org/openprovenance/model/Identifiable.java // public interface Identifiable { // public void setId(String s); // public String getId(); // } // Path: elmo/src/main/java/org/openprovenance/elmo/RdfOPMFactory.java import java.net.URI; import java.util.Collection; import java.util.Set; import java.util.List; import java.util.LinkedList; import java.util.HashSet; import java.util.Hashtable; import javax.xml.bind.JAXBElement; import javax.xml.namespace.QName; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.openrdf.elmo.ElmoManager; import org.openprovenance.elmo.XMLLiteral; import org.openprovenance.model.Account; import org.openprovenance.model.AccountRef; import org.openprovenance.model.Agent; import org.openprovenance.model.Annotable; import org.openprovenance.model.Annotation; import org.openprovenance.model.Artifact; import org.openprovenance.model.EmbeddedAnnotation; import org.openprovenance.model.HasAccounts; import org.openprovenance.model.Identifiable; import org.openprovenance.model.Label; import org.openprovenance.model.OPMGraph; import org.openprovenance.model.Process; import org.openprovenance.model.Property; import org.openprovenance.model.Type; import org.openprovenance.model.Used; import org.openprovenance.model.Value; import org.openprovenance.model.WasControlledBy; import org.openprovenance.model.WasDerivedFrom; import org.openprovenance.model.WasGeneratedBy; import org.openprovenance.model.WasTriggeredBy; import org.openprovenance.rdf.AnnotationOrEdgeOrNode; import org.openrdf.elmo.Entity; QName qname=((Entity)a).getQName(); RdfWasTriggeredBy wtb=new RdfWasTriggeredBy(manager,qname); org.openprovenance.rdf.Node cause=a.getCause(); org.openprovenance.rdf.Node effect=a.getEffect(); wtb.setNodes(newProcessRef(processRegister.get(((Entity)cause).getQName())), newProcessRef(processRegister.get(((Entity)effect).getQName()))); addAccounts((org.openprovenance.rdf.AnnotationOrEdgeOrNode)a,wtb.getAccount()); processAnnotations(a,wtb); return wtb; } public void processAnnotations(org.openprovenance.rdf.Annotable a, Annotable res) { for (org.openprovenance.rdf.Annotation ann: a.getAnnotations()) { addAnnotation(res,newEmbeddedAnnotation(ann)); } for (String label: a.getLabels()) { super.addAnnotation(res,newLabel(label)); } for (URI pname: a.getPnames()) { super.addAnnotation(res,newPName(pname.toString())); } for (String profile: a.getProfiles()) { super.addAnnotation(res,newProfile(profile)); } for (URI type: a.getTypes()) { super.addAnnotation(res,newType(type.toString())); } if (a instanceof org.openprovenance.rdf.Artifact) { org.openprovenance.rdf.Artifact aa=(org.openprovenance.rdf.Artifact) a; for (org.openprovenance.rdf.AValue av: aa.getAvalues()) {
if (av.getContent() instanceof XMLLiteral) {
lucmoreau/OpenProvenanceModel
elmo/src/main/java/org/openprovenance/elmo/RdfOPMFactory.java
// Path: elmo/src/main/java/org/openprovenance/elmo/XMLLiteral.java // public class XMLLiteral { // private static DocumentBuilder builder; // // private static Transformer transformer; // // private String xml; // // public XMLLiteral(String xml) { // this.xml = xml; // } // // public XMLLiteral(Document document) { // this.xml = serialize(document); // } // // public Document getDocument() { // return deserialize(xml); // } // // @Override // public String toString() { // return xml; // } // // private String serialize(Document object) { // Source source = new DOMSource(object); // CharArrayWriter writer = new CharArrayWriter(); // Result result = new StreamResult(writer); // try { // if (transformer == null) { // transformer = TransformerFactory.newInstance() // .newTransformer(); // } // transformer.transform(source, result); // } catch (Exception e) { // throw new ElmoConversionException(e); // } // return writer.toString(); // } // // private Document deserialize(String xml) { // try { // char[] charArray = xml.toCharArray(); // CharArrayReader reader = new CharArrayReader(charArray); // try { // if (builder == null) { // DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance(); // dbf.setNamespaceAware(true); // builder = dbf.newDocumentBuilder(); // } // return builder.parse(new InputSource(reader)); // } finally { // reader.close(); // } // } catch (Exception e) { // throw new ElmoConversionException(e); // } // } // // } // // Path: opm/src/main/java/org/openprovenance/model/Annotable.java // public interface Annotable extends Identifiable { // public List<JAXBElement<? extends EmbeddedAnnotation>> getAnnotation(); // } // // Path: opm/src/main/java/org/openprovenance/model/HasAccounts.java // public interface HasAccounts { // List<AccountRef> getAccount(); // } // // Path: opm/src/main/java/org/openprovenance/model/Identifiable.java // public interface Identifiable { // public void setId(String s); // public String getId(); // }
import java.net.URI; import java.util.Collection; import java.util.Set; import java.util.List; import java.util.LinkedList; import java.util.HashSet; import java.util.Hashtable; import javax.xml.bind.JAXBElement; import javax.xml.namespace.QName; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.openrdf.elmo.ElmoManager; import org.openprovenance.elmo.XMLLiteral; import org.openprovenance.model.Account; import org.openprovenance.model.AccountRef; import org.openprovenance.model.Agent; import org.openprovenance.model.Annotable; import org.openprovenance.model.Annotation; import org.openprovenance.model.Artifact; import org.openprovenance.model.EmbeddedAnnotation; import org.openprovenance.model.HasAccounts; import org.openprovenance.model.Identifiable; import org.openprovenance.model.Label; import org.openprovenance.model.OPMGraph; import org.openprovenance.model.Process; import org.openprovenance.model.Property; import org.openprovenance.model.Type; import org.openprovenance.model.Used; import org.openprovenance.model.Value; import org.openprovenance.model.WasControlledBy; import org.openprovenance.model.WasDerivedFrom; import org.openprovenance.model.WasGeneratedBy; import org.openprovenance.model.WasTriggeredBy; import org.openprovenance.rdf.AnnotationOrEdgeOrNode; import org.openrdf.elmo.Entity;
newRole(d.getRole()), newProcessRef(processRegister2.get(((Process)d.getCause().getRef()).getId())), newAccounts(d.getAccount())); wgb.getAnnotation().addAll(d.getAnnotation()); if (d.getTime()!=null) wgb.setTime(newOTime(d.getTime())); return wgb; } public WasControlledBy newWasControlledBy(WasControlledBy d) { WasControlledBy wcb=newWasControlledBy(d.getId(), newProcessRef(processRegister2.get(((Process)d.getEffect().getRef()).getId())), newRole(d.getRole()), newAgentRef(agentRegister2.get(((Agent)d.getCause().getRef()).getId())), newAccounts(d.getAccount())); wcb.getAnnotation().addAll(d.getAnnotation()); if (d.getStartTime()!=null) wcb.setStartTime(newOTime(d.getStartTime())); if (d.getEndTime()!=null) wcb.setEndTime(newOTime(d.getEndTime())); return wcb; } public List<Property> newProperties(List<Property> props) { List<Property> res=new LinkedList(); for (Property prop: props) { res.add(newProperty(prop)); } return res; } public Annotation newAnnotation(Annotation ann) { Annotation res=newAnnotation(ann.getId(),
// Path: elmo/src/main/java/org/openprovenance/elmo/XMLLiteral.java // public class XMLLiteral { // private static DocumentBuilder builder; // // private static Transformer transformer; // // private String xml; // // public XMLLiteral(String xml) { // this.xml = xml; // } // // public XMLLiteral(Document document) { // this.xml = serialize(document); // } // // public Document getDocument() { // return deserialize(xml); // } // // @Override // public String toString() { // return xml; // } // // private String serialize(Document object) { // Source source = new DOMSource(object); // CharArrayWriter writer = new CharArrayWriter(); // Result result = new StreamResult(writer); // try { // if (transformer == null) { // transformer = TransformerFactory.newInstance() // .newTransformer(); // } // transformer.transform(source, result); // } catch (Exception e) { // throw new ElmoConversionException(e); // } // return writer.toString(); // } // // private Document deserialize(String xml) { // try { // char[] charArray = xml.toCharArray(); // CharArrayReader reader = new CharArrayReader(charArray); // try { // if (builder == null) { // DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance(); // dbf.setNamespaceAware(true); // builder = dbf.newDocumentBuilder(); // } // return builder.parse(new InputSource(reader)); // } finally { // reader.close(); // } // } catch (Exception e) { // throw new ElmoConversionException(e); // } // } // // } // // Path: opm/src/main/java/org/openprovenance/model/Annotable.java // public interface Annotable extends Identifiable { // public List<JAXBElement<? extends EmbeddedAnnotation>> getAnnotation(); // } // // Path: opm/src/main/java/org/openprovenance/model/HasAccounts.java // public interface HasAccounts { // List<AccountRef> getAccount(); // } // // Path: opm/src/main/java/org/openprovenance/model/Identifiable.java // public interface Identifiable { // public void setId(String s); // public String getId(); // } // Path: elmo/src/main/java/org/openprovenance/elmo/RdfOPMFactory.java import java.net.URI; import java.util.Collection; import java.util.Set; import java.util.List; import java.util.LinkedList; import java.util.HashSet; import java.util.Hashtable; import javax.xml.bind.JAXBElement; import javax.xml.namespace.QName; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.openrdf.elmo.ElmoManager; import org.openprovenance.elmo.XMLLiteral; import org.openprovenance.model.Account; import org.openprovenance.model.AccountRef; import org.openprovenance.model.Agent; import org.openprovenance.model.Annotable; import org.openprovenance.model.Annotation; import org.openprovenance.model.Artifact; import org.openprovenance.model.EmbeddedAnnotation; import org.openprovenance.model.HasAccounts; import org.openprovenance.model.Identifiable; import org.openprovenance.model.Label; import org.openprovenance.model.OPMGraph; import org.openprovenance.model.Process; import org.openprovenance.model.Property; import org.openprovenance.model.Type; import org.openprovenance.model.Used; import org.openprovenance.model.Value; import org.openprovenance.model.WasControlledBy; import org.openprovenance.model.WasDerivedFrom; import org.openprovenance.model.WasGeneratedBy; import org.openprovenance.model.WasTriggeredBy; import org.openprovenance.rdf.AnnotationOrEdgeOrNode; import org.openrdf.elmo.Entity; newRole(d.getRole()), newProcessRef(processRegister2.get(((Process)d.getCause().getRef()).getId())), newAccounts(d.getAccount())); wgb.getAnnotation().addAll(d.getAnnotation()); if (d.getTime()!=null) wgb.setTime(newOTime(d.getTime())); return wgb; } public WasControlledBy newWasControlledBy(WasControlledBy d) { WasControlledBy wcb=newWasControlledBy(d.getId(), newProcessRef(processRegister2.get(((Process)d.getEffect().getRef()).getId())), newRole(d.getRole()), newAgentRef(agentRegister2.get(((Agent)d.getCause().getRef()).getId())), newAccounts(d.getAccount())); wcb.getAnnotation().addAll(d.getAnnotation()); if (d.getStartTime()!=null) wcb.setStartTime(newOTime(d.getStartTime())); if (d.getEndTime()!=null) wcb.setEndTime(newOTime(d.getEndTime())); return wcb; } public List<Property> newProperties(List<Property> props) { List<Property> res=new LinkedList(); for (Property prop: props) { res.add(newProperty(prop)); } return res; } public Annotation newAnnotation(Annotation ann) { Annotation res=newAnnotation(ann.getId(),
getFromRegisters(((Identifiable)ann.getLocalSubject()).getId()),
lucmoreau/OpenProvenanceModel
elmo/src/main/java/org/openprovenance/elmo/RdfLabel.java
// Path: opm/src/main/java/org/openprovenance/model/Annotable.java // public interface Annotable extends Identifiable { // public List<JAXBElement<? extends EmbeddedAnnotation>> getAnnotation(); // } // // Path: opm/src/main/java/org/openprovenance/model/CommonURIs.java // public interface CommonURIs { // final String NEW_PROFILE_PROPERTY = "http://openprovenance.org/ontology#profile"; // final String NEW_VALUE_PROPERTY = "http://openprovenance.org/ontology#value"; // final String NEW_ENCODING_PROPERTY = "http://openprovenance.org/ontology#encoding"; // final String NEW_TYPE_PROPERTY = "http://openprovenance.org/ontology#type"; // final String NEW_LABEL_PROPERTY = "http://openprovenance.org/ontology#label"; // final String NEW_PNAME_PROPERTY = "http://openprovenance.org/ontology#pname"; // // // final String PROFILE_PROPERTY = "http://openprovenance.org/property/profile"; // final String VALUE_PROPERTY = "http://openprovenance.org/property/value"; // final String ENCODING_PROPERTY = "http://openprovenance.org/property/encoding"; // final String TYPE_PROPERTY = "http://openprovenance.org/property/type"; // final String LABEL_PROPERTY = "http://openprovenance.org/property/label"; // final String PNAME_PROPERTY = "http://openprovenance.org/property/pname"; // // }
import java.util.Set; import org.openprovenance.rdf.Account; import org.openprovenance.rdf.Node; import javax.xml.namespace.QName; import org.openrdf.elmo.ElmoManager; import org.openprovenance.model.Annotable; import org.openrdf.model.Statement; import org.openrdf.elmo.sesame.SesameManager; import org.openprovenance.model.CommonURIs;
package org.openprovenance.elmo; public class RdfLabel extends org.openprovenance.model.Label implements CompactAnnotation, CommonURIs { ElmoManager manager; String prefix; QName qname; static int count=0; public RdfLabel(ElmoManager manager, String prefix) { this.manager=manager; this.prefix=prefix; }
// Path: opm/src/main/java/org/openprovenance/model/Annotable.java // public interface Annotable extends Identifiable { // public List<JAXBElement<? extends EmbeddedAnnotation>> getAnnotation(); // } // // Path: opm/src/main/java/org/openprovenance/model/CommonURIs.java // public interface CommonURIs { // final String NEW_PROFILE_PROPERTY = "http://openprovenance.org/ontology#profile"; // final String NEW_VALUE_PROPERTY = "http://openprovenance.org/ontology#value"; // final String NEW_ENCODING_PROPERTY = "http://openprovenance.org/ontology#encoding"; // final String NEW_TYPE_PROPERTY = "http://openprovenance.org/ontology#type"; // final String NEW_LABEL_PROPERTY = "http://openprovenance.org/ontology#label"; // final String NEW_PNAME_PROPERTY = "http://openprovenance.org/ontology#pname"; // // // final String PROFILE_PROPERTY = "http://openprovenance.org/property/profile"; // final String VALUE_PROPERTY = "http://openprovenance.org/property/value"; // final String ENCODING_PROPERTY = "http://openprovenance.org/property/encoding"; // final String TYPE_PROPERTY = "http://openprovenance.org/property/type"; // final String LABEL_PROPERTY = "http://openprovenance.org/property/label"; // final String PNAME_PROPERTY = "http://openprovenance.org/property/pname"; // // } // Path: elmo/src/main/java/org/openprovenance/elmo/RdfLabel.java import java.util.Set; import org.openprovenance.rdf.Account; import org.openprovenance.rdf.Node; import javax.xml.namespace.QName; import org.openrdf.elmo.ElmoManager; import org.openprovenance.model.Annotable; import org.openrdf.model.Statement; import org.openrdf.elmo.sesame.SesameManager; import org.openprovenance.model.CommonURIs; package org.openprovenance.elmo; public class RdfLabel extends org.openprovenance.model.Label implements CompactAnnotation, CommonURIs { ElmoManager manager; String prefix; QName qname; static int count=0; public RdfLabel(ElmoManager manager, String prefix) { this.manager=manager; this.prefix=prefix; }
public void toRdf(Annotable entity) throws org.openrdf.repository.RepositoryException {
openstack/sahara-extra
hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/auth/AuthenticationResponseV3.java
// Path: hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/auth/entities/CatalogV3.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class CatalogV3 { // /** // * List of valid swift endpoints // */ // private List<EndpointV3> endpoints; // // /** // * Openstack REST service name. In our case name = "keystone" // */ // private String name; // // /** // * Type of REST service. In our case type = "identity" // */ // private String type; // // /** // * @return List of endpoints // */ // public List<EndpointV3> getEndpoints() { // return endpoints; // } // // /** // * @param endpoints list of endpoints // */ // public void setEndpoints(List<EndpointV3> endpoints) { // this.endpoints = endpoints; // } // // /** // * @return name of Openstack REST service // */ // public String getName() { // return name; // } // // /** // * @param name of Openstack REST service // */ // public void setName(String name) { // this.name = name; // } // // /** // * @return type of Openstack REST service // */ // public String getType() { // return type; // } // // /** // * @param type of REST service // */ // public void setType(String type) { // this.type = type; // } // }
import java.util.List; import org.apache.hadoop.fs.swift.auth.entities.CatalogV3; import org.apache.hadoop.fs.swift.auth.entities.Tenant; import org.codehaus.jackson.annotate.JsonIgnoreProperties;
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.hadoop.fs.swift.auth; /** * Response from KeyStone deserialized into AuthenticationResponse class. * THIS FILE IS MAPPED BY JACKSON TO AND FROM JSON. * DO NOT RENAME OR MODIFY FIELDS AND THEIR ACCESSORS. */ @JsonIgnoreProperties(ignoreUnknown = true) public class AuthenticationResponseV3 {
// Path: hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/auth/entities/CatalogV3.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class CatalogV3 { // /** // * List of valid swift endpoints // */ // private List<EndpointV3> endpoints; // // /** // * Openstack REST service name. In our case name = "keystone" // */ // private String name; // // /** // * Type of REST service. In our case type = "identity" // */ // private String type; // // /** // * @return List of endpoints // */ // public List<EndpointV3> getEndpoints() { // return endpoints; // } // // /** // * @param endpoints list of endpoints // */ // public void setEndpoints(List<EndpointV3> endpoints) { // this.endpoints = endpoints; // } // // /** // * @return name of Openstack REST service // */ // public String getName() { // return name; // } // // /** // * @param name of Openstack REST service // */ // public void setName(String name) { // this.name = name; // } // // /** // * @return type of Openstack REST service // */ // public String getType() { // return type; // } // // /** // * @param type of REST service // */ // public void setType(String type) { // this.type = type; // } // } // Path: hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/auth/AuthenticationResponseV3.java import java.util.List; import org.apache.hadoop.fs.swift.auth.entities.CatalogV3; import org.apache.hadoop.fs.swift.auth.entities.Tenant; import org.codehaus.jackson.annotate.JsonIgnoreProperties; /** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.hadoop.fs.swift.auth; /** * Response from KeyStone deserialized into AuthenticationResponse class. * THIS FILE IS MAPPED BY JACKSON TO AND FROM JSON. * DO NOT RENAME OR MODIFY FIELDS AND THEIR ACCESSORS. */ @JsonIgnoreProperties(ignoreUnknown = true) public class AuthenticationResponseV3 {
private List<CatalogV3> catalog;
openstack/sahara-extra
hadoop-swiftfs/src/test/java/org/apache/hadoop/fs/swift/TestSwiftFileSystemLsOperations.java
// Path: hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/util/SwiftTestUtils.java // public static void assertListStatusFinds(FileSystem fs, // Path dir, // Path subdir) throws IOException { // FileStatus[] stats = fs.listStatus(dir); // boolean found = false; // StringBuilder builder = new StringBuilder(); // for (FileStatus stat : stats) { // builder.append(stat.toString()).append('\n'); // if (stat.getPath().equals(subdir)) { // found = true; // } // } // assertTrue("Path " + subdir // + " not found in directory " + dir + ":" + builder, // found); // } // // Path: hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/util/SwiftTestUtils.java // public static void cleanup(String action, // FileSystem fileSystem, // String cleanupPath) { // noteAction(action); // try { // if (fileSystem != null) { // fileSystem.delete(new Path(cleanupPath).makeQualified(fileSystem), // true); // } // } catch (Exception e) { // LOG.error("Error deleting in "+ action + " - " + cleanupPath + ": " + e, e); // } // } // // Path: hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/util/SwiftTestUtils.java // public static String dumpStats(String pathname, FileStatus[] stats) { // return pathname + SwiftUtils.fileStatsToString(stats,"\n"); // } // // Path: hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/util/SwiftTestUtils.java // public static void touch(FileSystem fs, // Path path) throws IOException { // fs.delete(path, true); // writeTextFile(fs, path, null, false); // }
import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.Path; import org.junit.Test; import java.io.IOException; import static org.apache.hadoop.fs.swift.util.SwiftTestUtils.assertListStatusFinds; import static org.apache.hadoop.fs.swift.util.SwiftTestUtils.cleanup; import static org.apache.hadoop.fs.swift.util.SwiftTestUtils.dumpStats; import static org.apache.hadoop.fs.swift.util.SwiftTestUtils.touch;
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.hadoop.fs.swift; /** * Test the FileSystem#listStatus() operations */ public class TestSwiftFileSystemLsOperations extends SwiftFileSystemBaseTest { private Path[] testDirs; /** * Setup creates dirs under test/hadoop * * @throws Exception */ @Override public void setUp() throws Exception { super.setUp(); //delete the test directory Path test = path("/test"); fs.delete(test, true); mkdirs(test); } /** * Create subdirectories and files under test/ for those tests * that want them. Doing so adds overhead to setup and teardown, * so should only be done for those tests that need them. * @throws IOException on an IO problem */ private void createTestSubdirs() throws IOException { testDirs = new Path[]{ path("/test/hadoop/a"), path("/test/hadoop/b"), path("/test/hadoop/c/1"), }; assertPathDoesNotExist("test directory setup", testDirs[0]); for (Path path : testDirs) { mkdirs(path); } } @Test(timeout = SWIFT_TEST_TIMEOUT) public void testListLevelTest() throws Exception { createTestSubdirs(); FileStatus[] paths = fs.listStatus(path("/test"));
// Path: hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/util/SwiftTestUtils.java // public static void assertListStatusFinds(FileSystem fs, // Path dir, // Path subdir) throws IOException { // FileStatus[] stats = fs.listStatus(dir); // boolean found = false; // StringBuilder builder = new StringBuilder(); // for (FileStatus stat : stats) { // builder.append(stat.toString()).append('\n'); // if (stat.getPath().equals(subdir)) { // found = true; // } // } // assertTrue("Path " + subdir // + " not found in directory " + dir + ":" + builder, // found); // } // // Path: hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/util/SwiftTestUtils.java // public static void cleanup(String action, // FileSystem fileSystem, // String cleanupPath) { // noteAction(action); // try { // if (fileSystem != null) { // fileSystem.delete(new Path(cleanupPath).makeQualified(fileSystem), // true); // } // } catch (Exception e) { // LOG.error("Error deleting in "+ action + " - " + cleanupPath + ": " + e, e); // } // } // // Path: hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/util/SwiftTestUtils.java // public static String dumpStats(String pathname, FileStatus[] stats) { // return pathname + SwiftUtils.fileStatsToString(stats,"\n"); // } // // Path: hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/util/SwiftTestUtils.java // public static void touch(FileSystem fs, // Path path) throws IOException { // fs.delete(path, true); // writeTextFile(fs, path, null, false); // } // Path: hadoop-swiftfs/src/test/java/org/apache/hadoop/fs/swift/TestSwiftFileSystemLsOperations.java import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.Path; import org.junit.Test; import java.io.IOException; import static org.apache.hadoop.fs.swift.util.SwiftTestUtils.assertListStatusFinds; import static org.apache.hadoop.fs.swift.util.SwiftTestUtils.cleanup; import static org.apache.hadoop.fs.swift.util.SwiftTestUtils.dumpStats; import static org.apache.hadoop.fs.swift.util.SwiftTestUtils.touch; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.hadoop.fs.swift; /** * Test the FileSystem#listStatus() operations */ public class TestSwiftFileSystemLsOperations extends SwiftFileSystemBaseTest { private Path[] testDirs; /** * Setup creates dirs under test/hadoop * * @throws Exception */ @Override public void setUp() throws Exception { super.setUp(); //delete the test directory Path test = path("/test"); fs.delete(test, true); mkdirs(test); } /** * Create subdirectories and files under test/ for those tests * that want them. Doing so adds overhead to setup and teardown, * so should only be done for those tests that need them. * @throws IOException on an IO problem */ private void createTestSubdirs() throws IOException { testDirs = new Path[]{ path("/test/hadoop/a"), path("/test/hadoop/b"), path("/test/hadoop/c/1"), }; assertPathDoesNotExist("test directory setup", testDirs[0]); for (Path path : testDirs) { mkdirs(path); } } @Test(timeout = SWIFT_TEST_TIMEOUT) public void testListLevelTest() throws Exception { createTestSubdirs(); FileStatus[] paths = fs.listStatus(path("/test"));
assertEquals(dumpStats("/test", paths), 1, paths.length);
openstack/sahara-extra
hadoop-swiftfs/src/test/java/org/apache/hadoop/fs/swift/TestSwiftFileSystemLsOperations.java
// Path: hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/util/SwiftTestUtils.java // public static void assertListStatusFinds(FileSystem fs, // Path dir, // Path subdir) throws IOException { // FileStatus[] stats = fs.listStatus(dir); // boolean found = false; // StringBuilder builder = new StringBuilder(); // for (FileStatus stat : stats) { // builder.append(stat.toString()).append('\n'); // if (stat.getPath().equals(subdir)) { // found = true; // } // } // assertTrue("Path " + subdir // + " not found in directory " + dir + ":" + builder, // found); // } // // Path: hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/util/SwiftTestUtils.java // public static void cleanup(String action, // FileSystem fileSystem, // String cleanupPath) { // noteAction(action); // try { // if (fileSystem != null) { // fileSystem.delete(new Path(cleanupPath).makeQualified(fileSystem), // true); // } // } catch (Exception e) { // LOG.error("Error deleting in "+ action + " - " + cleanupPath + ": " + e, e); // } // } // // Path: hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/util/SwiftTestUtils.java // public static String dumpStats(String pathname, FileStatus[] stats) { // return pathname + SwiftUtils.fileStatsToString(stats,"\n"); // } // // Path: hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/util/SwiftTestUtils.java // public static void touch(FileSystem fs, // Path path) throws IOException { // fs.delete(path, true); // writeTextFile(fs, path, null, false); // }
import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.Path; import org.junit.Test; import java.io.IOException; import static org.apache.hadoop.fs.swift.util.SwiftTestUtils.assertListStatusFinds; import static org.apache.hadoop.fs.swift.util.SwiftTestUtils.cleanup; import static org.apache.hadoop.fs.swift.util.SwiftTestUtils.dumpStats; import static org.apache.hadoop.fs.swift.util.SwiftTestUtils.touch;
} @Test(timeout = SWIFT_TEST_TIMEOUT) public void testListStatusEmptyDirectory() throws Exception { createTestSubdirs(); FileStatus[] paths; paths = fs.listStatus(path("/test/hadoop/a")); assertEquals(dumpStats("/test/hadoop/a", paths), 0, paths.length); } @Test(timeout = SWIFT_TEST_TIMEOUT) public void testListStatusFile() throws Exception { describe("Create a single file under /test;" + " assert that listStatus(/test) finds it"); Path file = path("/test/filename"); createFile(file); FileStatus[] pathStats = fs.listStatus(file); assertEquals(dumpStats("/test/", pathStats), 1, pathStats.length); //and assert that the len of that ls'd path is the same as the original FileStatus lsStat = pathStats[0]; assertEquals("Wrong file len in listing of " + lsStat, data.length, lsStat.getLen()); } @Test(timeout = SWIFT_TEST_TIMEOUT) public void testListEmptyRoot() throws Throwable { describe("Empty the root dir and verify that an LS / returns {}");
// Path: hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/util/SwiftTestUtils.java // public static void assertListStatusFinds(FileSystem fs, // Path dir, // Path subdir) throws IOException { // FileStatus[] stats = fs.listStatus(dir); // boolean found = false; // StringBuilder builder = new StringBuilder(); // for (FileStatus stat : stats) { // builder.append(stat.toString()).append('\n'); // if (stat.getPath().equals(subdir)) { // found = true; // } // } // assertTrue("Path " + subdir // + " not found in directory " + dir + ":" + builder, // found); // } // // Path: hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/util/SwiftTestUtils.java // public static void cleanup(String action, // FileSystem fileSystem, // String cleanupPath) { // noteAction(action); // try { // if (fileSystem != null) { // fileSystem.delete(new Path(cleanupPath).makeQualified(fileSystem), // true); // } // } catch (Exception e) { // LOG.error("Error deleting in "+ action + " - " + cleanupPath + ": " + e, e); // } // } // // Path: hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/util/SwiftTestUtils.java // public static String dumpStats(String pathname, FileStatus[] stats) { // return pathname + SwiftUtils.fileStatsToString(stats,"\n"); // } // // Path: hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/util/SwiftTestUtils.java // public static void touch(FileSystem fs, // Path path) throws IOException { // fs.delete(path, true); // writeTextFile(fs, path, null, false); // } // Path: hadoop-swiftfs/src/test/java/org/apache/hadoop/fs/swift/TestSwiftFileSystemLsOperations.java import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.Path; import org.junit.Test; import java.io.IOException; import static org.apache.hadoop.fs.swift.util.SwiftTestUtils.assertListStatusFinds; import static org.apache.hadoop.fs.swift.util.SwiftTestUtils.cleanup; import static org.apache.hadoop.fs.swift.util.SwiftTestUtils.dumpStats; import static org.apache.hadoop.fs.swift.util.SwiftTestUtils.touch; } @Test(timeout = SWIFT_TEST_TIMEOUT) public void testListStatusEmptyDirectory() throws Exception { createTestSubdirs(); FileStatus[] paths; paths = fs.listStatus(path("/test/hadoop/a")); assertEquals(dumpStats("/test/hadoop/a", paths), 0, paths.length); } @Test(timeout = SWIFT_TEST_TIMEOUT) public void testListStatusFile() throws Exception { describe("Create a single file under /test;" + " assert that listStatus(/test) finds it"); Path file = path("/test/filename"); createFile(file); FileStatus[] pathStats = fs.listStatus(file); assertEquals(dumpStats("/test/", pathStats), 1, pathStats.length); //and assert that the len of that ls'd path is the same as the original FileStatus lsStat = pathStats[0]; assertEquals("Wrong file len in listing of " + lsStat, data.length, lsStat.getLen()); } @Test(timeout = SWIFT_TEST_TIMEOUT) public void testListEmptyRoot() throws Throwable { describe("Empty the root dir and verify that an LS / returns {}");
cleanup("testListEmptyRoot", fs, "/test");
openstack/sahara-extra
hadoop-swiftfs/src/test/java/org/apache/hadoop/fs/swift/TestSwiftFileSystemLsOperations.java
// Path: hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/util/SwiftTestUtils.java // public static void assertListStatusFinds(FileSystem fs, // Path dir, // Path subdir) throws IOException { // FileStatus[] stats = fs.listStatus(dir); // boolean found = false; // StringBuilder builder = new StringBuilder(); // for (FileStatus stat : stats) { // builder.append(stat.toString()).append('\n'); // if (stat.getPath().equals(subdir)) { // found = true; // } // } // assertTrue("Path " + subdir // + " not found in directory " + dir + ":" + builder, // found); // } // // Path: hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/util/SwiftTestUtils.java // public static void cleanup(String action, // FileSystem fileSystem, // String cleanupPath) { // noteAction(action); // try { // if (fileSystem != null) { // fileSystem.delete(new Path(cleanupPath).makeQualified(fileSystem), // true); // } // } catch (Exception e) { // LOG.error("Error deleting in "+ action + " - " + cleanupPath + ": " + e, e); // } // } // // Path: hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/util/SwiftTestUtils.java // public static String dumpStats(String pathname, FileStatus[] stats) { // return pathname + SwiftUtils.fileStatsToString(stats,"\n"); // } // // Path: hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/util/SwiftTestUtils.java // public static void touch(FileSystem fs, // Path path) throws IOException { // fs.delete(path, true); // writeTextFile(fs, path, null, false); // }
import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.Path; import org.junit.Test; import java.io.IOException; import static org.apache.hadoop.fs.swift.util.SwiftTestUtils.assertListStatusFinds; import static org.apache.hadoop.fs.swift.util.SwiftTestUtils.cleanup; import static org.apache.hadoop.fs.swift.util.SwiftTestUtils.dumpStats; import static org.apache.hadoop.fs.swift.util.SwiftTestUtils.touch;
} @Test(timeout = SWIFT_TEST_TIMEOUT) public void testListStatusFile() throws Exception { describe("Create a single file under /test;" + " assert that listStatus(/test) finds it"); Path file = path("/test/filename"); createFile(file); FileStatus[] pathStats = fs.listStatus(file); assertEquals(dumpStats("/test/", pathStats), 1, pathStats.length); //and assert that the len of that ls'd path is the same as the original FileStatus lsStat = pathStats[0]; assertEquals("Wrong file len in listing of " + lsStat, data.length, lsStat.getLen()); } @Test(timeout = SWIFT_TEST_TIMEOUT) public void testListEmptyRoot() throws Throwable { describe("Empty the root dir and verify that an LS / returns {}"); cleanup("testListEmptyRoot", fs, "/test"); cleanup("testListEmptyRoot", fs, "/user"); FileStatus[] fileStatuses = fs.listStatus(path("/")); assertEquals(0, fileStatuses.length); } @Test(timeout = SWIFT_TEST_TIMEOUT) public void testListNonEmptyRoot() throws Throwable { Path test = path("/test");
// Path: hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/util/SwiftTestUtils.java // public static void assertListStatusFinds(FileSystem fs, // Path dir, // Path subdir) throws IOException { // FileStatus[] stats = fs.listStatus(dir); // boolean found = false; // StringBuilder builder = new StringBuilder(); // for (FileStatus stat : stats) { // builder.append(stat.toString()).append('\n'); // if (stat.getPath().equals(subdir)) { // found = true; // } // } // assertTrue("Path " + subdir // + " not found in directory " + dir + ":" + builder, // found); // } // // Path: hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/util/SwiftTestUtils.java // public static void cleanup(String action, // FileSystem fileSystem, // String cleanupPath) { // noteAction(action); // try { // if (fileSystem != null) { // fileSystem.delete(new Path(cleanupPath).makeQualified(fileSystem), // true); // } // } catch (Exception e) { // LOG.error("Error deleting in "+ action + " - " + cleanupPath + ": " + e, e); // } // } // // Path: hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/util/SwiftTestUtils.java // public static String dumpStats(String pathname, FileStatus[] stats) { // return pathname + SwiftUtils.fileStatsToString(stats,"\n"); // } // // Path: hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/util/SwiftTestUtils.java // public static void touch(FileSystem fs, // Path path) throws IOException { // fs.delete(path, true); // writeTextFile(fs, path, null, false); // } // Path: hadoop-swiftfs/src/test/java/org/apache/hadoop/fs/swift/TestSwiftFileSystemLsOperations.java import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.Path; import org.junit.Test; import java.io.IOException; import static org.apache.hadoop.fs.swift.util.SwiftTestUtils.assertListStatusFinds; import static org.apache.hadoop.fs.swift.util.SwiftTestUtils.cleanup; import static org.apache.hadoop.fs.swift.util.SwiftTestUtils.dumpStats; import static org.apache.hadoop.fs.swift.util.SwiftTestUtils.touch; } @Test(timeout = SWIFT_TEST_TIMEOUT) public void testListStatusFile() throws Exception { describe("Create a single file under /test;" + " assert that listStatus(/test) finds it"); Path file = path("/test/filename"); createFile(file); FileStatus[] pathStats = fs.listStatus(file); assertEquals(dumpStats("/test/", pathStats), 1, pathStats.length); //and assert that the len of that ls'd path is the same as the original FileStatus lsStat = pathStats[0]; assertEquals("Wrong file len in listing of " + lsStat, data.length, lsStat.getLen()); } @Test(timeout = SWIFT_TEST_TIMEOUT) public void testListEmptyRoot() throws Throwable { describe("Empty the root dir and verify that an LS / returns {}"); cleanup("testListEmptyRoot", fs, "/test"); cleanup("testListEmptyRoot", fs, "/user"); FileStatus[] fileStatuses = fs.listStatus(path("/")); assertEquals(0, fileStatuses.length); } @Test(timeout = SWIFT_TEST_TIMEOUT) public void testListNonEmptyRoot() throws Throwable { Path test = path("/test");
touch(fs, test);
openstack/sahara-extra
hadoop-swiftfs/src/test/java/org/apache/hadoop/fs/swift/TestSwiftFileSystemLsOperations.java
// Path: hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/util/SwiftTestUtils.java // public static void assertListStatusFinds(FileSystem fs, // Path dir, // Path subdir) throws IOException { // FileStatus[] stats = fs.listStatus(dir); // boolean found = false; // StringBuilder builder = new StringBuilder(); // for (FileStatus stat : stats) { // builder.append(stat.toString()).append('\n'); // if (stat.getPath().equals(subdir)) { // found = true; // } // } // assertTrue("Path " + subdir // + " not found in directory " + dir + ":" + builder, // found); // } // // Path: hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/util/SwiftTestUtils.java // public static void cleanup(String action, // FileSystem fileSystem, // String cleanupPath) { // noteAction(action); // try { // if (fileSystem != null) { // fileSystem.delete(new Path(cleanupPath).makeQualified(fileSystem), // true); // } // } catch (Exception e) { // LOG.error("Error deleting in "+ action + " - " + cleanupPath + ": " + e, e); // } // } // // Path: hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/util/SwiftTestUtils.java // public static String dumpStats(String pathname, FileStatus[] stats) { // return pathname + SwiftUtils.fileStatsToString(stats,"\n"); // } // // Path: hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/util/SwiftTestUtils.java // public static void touch(FileSystem fs, // Path path) throws IOException { // fs.delete(path, true); // writeTextFile(fs, path, null, false); // }
import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.Path; import org.junit.Test; import java.io.IOException; import static org.apache.hadoop.fs.swift.util.SwiftTestUtils.assertListStatusFinds; import static org.apache.hadoop.fs.swift.util.SwiftTestUtils.cleanup; import static org.apache.hadoop.fs.swift.util.SwiftTestUtils.dumpStats; import static org.apache.hadoop.fs.swift.util.SwiftTestUtils.touch;
//and assert that the len of that ls'd path is the same as the original FileStatus lsStat = pathStats[0]; assertEquals("Wrong file len in listing of " + lsStat, data.length, lsStat.getLen()); } @Test(timeout = SWIFT_TEST_TIMEOUT) public void testListEmptyRoot() throws Throwable { describe("Empty the root dir and verify that an LS / returns {}"); cleanup("testListEmptyRoot", fs, "/test"); cleanup("testListEmptyRoot", fs, "/user"); FileStatus[] fileStatuses = fs.listStatus(path("/")); assertEquals(0, fileStatuses.length); } @Test(timeout = SWIFT_TEST_TIMEOUT) public void testListNonEmptyRoot() throws Throwable { Path test = path("/test"); touch(fs, test); FileStatus[] fileStatuses = fs.listStatus(path("/")); assertEquals(1, fileStatuses.length); FileStatus status = fileStatuses[0]; assertEquals(test, status.getPath()); } @Test(timeout = SWIFT_TEST_TIMEOUT) public void testListStatusRootDir() throws Throwable { Path dir = path("/"); Path child = path("/test"); touch(fs, child);
// Path: hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/util/SwiftTestUtils.java // public static void assertListStatusFinds(FileSystem fs, // Path dir, // Path subdir) throws IOException { // FileStatus[] stats = fs.listStatus(dir); // boolean found = false; // StringBuilder builder = new StringBuilder(); // for (FileStatus stat : stats) { // builder.append(stat.toString()).append('\n'); // if (stat.getPath().equals(subdir)) { // found = true; // } // } // assertTrue("Path " + subdir // + " not found in directory " + dir + ":" + builder, // found); // } // // Path: hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/util/SwiftTestUtils.java // public static void cleanup(String action, // FileSystem fileSystem, // String cleanupPath) { // noteAction(action); // try { // if (fileSystem != null) { // fileSystem.delete(new Path(cleanupPath).makeQualified(fileSystem), // true); // } // } catch (Exception e) { // LOG.error("Error deleting in "+ action + " - " + cleanupPath + ": " + e, e); // } // } // // Path: hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/util/SwiftTestUtils.java // public static String dumpStats(String pathname, FileStatus[] stats) { // return pathname + SwiftUtils.fileStatsToString(stats,"\n"); // } // // Path: hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/util/SwiftTestUtils.java // public static void touch(FileSystem fs, // Path path) throws IOException { // fs.delete(path, true); // writeTextFile(fs, path, null, false); // } // Path: hadoop-swiftfs/src/test/java/org/apache/hadoop/fs/swift/TestSwiftFileSystemLsOperations.java import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.Path; import org.junit.Test; import java.io.IOException; import static org.apache.hadoop.fs.swift.util.SwiftTestUtils.assertListStatusFinds; import static org.apache.hadoop.fs.swift.util.SwiftTestUtils.cleanup; import static org.apache.hadoop.fs.swift.util.SwiftTestUtils.dumpStats; import static org.apache.hadoop.fs.swift.util.SwiftTestUtils.touch; //and assert that the len of that ls'd path is the same as the original FileStatus lsStat = pathStats[0]; assertEquals("Wrong file len in listing of " + lsStat, data.length, lsStat.getLen()); } @Test(timeout = SWIFT_TEST_TIMEOUT) public void testListEmptyRoot() throws Throwable { describe("Empty the root dir and verify that an LS / returns {}"); cleanup("testListEmptyRoot", fs, "/test"); cleanup("testListEmptyRoot", fs, "/user"); FileStatus[] fileStatuses = fs.listStatus(path("/")); assertEquals(0, fileStatuses.length); } @Test(timeout = SWIFT_TEST_TIMEOUT) public void testListNonEmptyRoot() throws Throwable { Path test = path("/test"); touch(fs, test); FileStatus[] fileStatuses = fs.listStatus(path("/")); assertEquals(1, fileStatuses.length); FileStatus status = fileStatuses[0]; assertEquals(test, status.getPath()); } @Test(timeout = SWIFT_TEST_TIMEOUT) public void testListStatusRootDir() throws Throwable { Path dir = path("/"); Path child = path("/test"); touch(fs, child);
assertListStatusFinds(fs, dir, child);
ptitfred/magrit
server/core/src/main/java/org/kercoin/magrit/core/build/QueueService.java
// Path: server/core/src/main/java/org/kercoin/magrit/core/Pair.java // public class Pair<T, U> { // private T t; // private U u; // // public Pair(T t, U u) { // super(); // this.t = t; // this.u = u; // } // // public T getT() { // return t; // } // // public U getU() { // return u; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + ((t == null) ? 0 : t.hashCode()); // result = prime * result + ((u == null) ? 0 : u.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // @SuppressWarnings("unchecked") // Pair<T, U> other = (Pair<T, U>) obj; // if (t == null) { // if (other.t != null) // return false; // } else if (!t.equals(other.t)) // return false; // if (u == null) { // if (other.u != null) // return false; // } else if (!u.equals(other.u)) // return false; // return true; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/user/UserIdentity.java // public class UserIdentity { // private final String email; // private final String name; // private final String toString; // // public UserIdentity(String email, String name) { // super(); // this.email = email; // this.name = name; // this.toString = String.format("\"%s\" <%s>", name, email); // } // // public String getEmail() { // return email; // } // // public String getName() { // return name; // } // // @Override // public String toString() { // return toString; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result // + ((toString == null) ? 0 : toString.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // UserIdentity other = (UserIdentity) obj; // if (toString == null) { // if (other.toString != null) // return false; // } else if (!toString.equals(other.toString)) // return false; // return true; // } // // // }
import java.util.Collection; import java.util.concurrent.Future; import org.eclipse.jgit.lib.Repository; import org.kercoin.magrit.core.Pair; import org.kercoin.magrit.core.user.UserIdentity; import com.google.inject.ImplementedBy;
/* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.core.build; @ImplementedBy(QueueServiceImpl.class) public interface QueueService {
// Path: server/core/src/main/java/org/kercoin/magrit/core/Pair.java // public class Pair<T, U> { // private T t; // private U u; // // public Pair(T t, U u) { // super(); // this.t = t; // this.u = u; // } // // public T getT() { // return t; // } // // public U getU() { // return u; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + ((t == null) ? 0 : t.hashCode()); // result = prime * result + ((u == null) ? 0 : u.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // @SuppressWarnings("unchecked") // Pair<T, U> other = (Pair<T, U>) obj; // if (t == null) { // if (other.t != null) // return false; // } else if (!t.equals(other.t)) // return false; // if (u == null) { // if (other.u != null) // return false; // } else if (!u.equals(other.u)) // return false; // return true; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/user/UserIdentity.java // public class UserIdentity { // private final String email; // private final String name; // private final String toString; // // public UserIdentity(String email, String name) { // super(); // this.email = email; // this.name = name; // this.toString = String.format("\"%s\" <%s>", name, email); // } // // public String getEmail() { // return email; // } // // public String getName() { // return name; // } // // @Override // public String toString() { // return toString; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result // + ((toString == null) ? 0 : toString.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // UserIdentity other = (UserIdentity) obj; // if (toString == null) { // if (other.toString != null) // return false; // } else if (!toString.equals(other.toString)) // return false; // return true; // } // // // } // Path: server/core/src/main/java/org/kercoin/magrit/core/build/QueueService.java import java.util.Collection; import java.util.concurrent.Future; import org.eclipse.jgit.lib.Repository; import org.kercoin.magrit.core.Pair; import org.kercoin.magrit.core.user.UserIdentity; import com.google.inject.ImplementedBy; /* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.core.build; @ImplementedBy(QueueServiceImpl.class) public interface QueueService {
Future<BuildResult> enqueueBuild(UserIdentity committer, Repository repository,
ptitfred/magrit
server/core/src/main/java/org/kercoin/magrit/core/build/QueueService.java
// Path: server/core/src/main/java/org/kercoin/magrit/core/Pair.java // public class Pair<T, U> { // private T t; // private U u; // // public Pair(T t, U u) { // super(); // this.t = t; // this.u = u; // } // // public T getT() { // return t; // } // // public U getU() { // return u; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + ((t == null) ? 0 : t.hashCode()); // result = prime * result + ((u == null) ? 0 : u.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // @SuppressWarnings("unchecked") // Pair<T, U> other = (Pair<T, U>) obj; // if (t == null) { // if (other.t != null) // return false; // } else if (!t.equals(other.t)) // return false; // if (u == null) { // if (other.u != null) // return false; // } else if (!u.equals(other.u)) // return false; // return true; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/user/UserIdentity.java // public class UserIdentity { // private final String email; // private final String name; // private final String toString; // // public UserIdentity(String email, String name) { // super(); // this.email = email; // this.name = name; // this.toString = String.format("\"%s\" <%s>", name, email); // } // // public String getEmail() { // return email; // } // // public String getName() { // return name; // } // // @Override // public String toString() { // return toString; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result // + ((toString == null) ? 0 : toString.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // UserIdentity other = (UserIdentity) obj; // if (toString == null) { // if (other.toString != null) // return false; // } else if (!toString.equals(other.toString)) // return false; // return true; // } // // // }
import java.util.Collection; import java.util.concurrent.Future; import org.eclipse.jgit.lib.Repository; import org.kercoin.magrit.core.Pair; import org.kercoin.magrit.core.user.UserIdentity; import com.google.inject.ImplementedBy;
/* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.core.build; @ImplementedBy(QueueServiceImpl.class) public interface QueueService { Future<BuildResult> enqueueBuild(UserIdentity committer, Repository repository, String sha1, String command, boolean force) throws Exception; void addCallback(BuildLifeCycleListener callback); void removeCallback(BuildLifeCycleListener callback);
// Path: server/core/src/main/java/org/kercoin/magrit/core/Pair.java // public class Pair<T, U> { // private T t; // private U u; // // public Pair(T t, U u) { // super(); // this.t = t; // this.u = u; // } // // public T getT() { // return t; // } // // public U getU() { // return u; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + ((t == null) ? 0 : t.hashCode()); // result = prime * result + ((u == null) ? 0 : u.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // @SuppressWarnings("unchecked") // Pair<T, U> other = (Pair<T, U>) obj; // if (t == null) { // if (other.t != null) // return false; // } else if (!t.equals(other.t)) // return false; // if (u == null) { // if (other.u != null) // return false; // } else if (!u.equals(other.u)) // return false; // return true; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/user/UserIdentity.java // public class UserIdentity { // private final String email; // private final String name; // private final String toString; // // public UserIdentity(String email, String name) { // super(); // this.email = email; // this.name = name; // this.toString = String.format("\"%s\" <%s>", name, email); // } // // public String getEmail() { // return email; // } // // public String getName() { // return name; // } // // @Override // public String toString() { // return toString; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result // + ((toString == null) ? 0 : toString.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // UserIdentity other = (UserIdentity) obj; // if (toString == null) { // if (other.toString != null) // return false; // } else if (!toString.equals(other.toString)) // return false; // return true; // } // // // } // Path: server/core/src/main/java/org/kercoin/magrit/core/build/QueueService.java import java.util.Collection; import java.util.concurrent.Future; import org.eclipse.jgit.lib.Repository; import org.kercoin.magrit.core.Pair; import org.kercoin.magrit.core.user.UserIdentity; import com.google.inject.ImplementedBy; /* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.core.build; @ImplementedBy(QueueServiceImpl.class) public interface QueueService { Future<BuildResult> enqueueBuild(UserIdentity committer, Repository repository, String sha1, String command, boolean force) throws Exception; void addCallback(BuildLifeCycleListener callback); void removeCallback(BuildLifeCycleListener callback);
Collection<Pair<Repository, String>> getScheduledTasks();
ptitfred/magrit
server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/WaitForCommand.java
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/BuildLifeCycleListener.java // public interface BuildLifeCycleListener { // // void buildScheduled(Repository repo, String sha1); // // void buildStarted(Repository repo, String sha1); // // void buildEnded(Repository repo, String sha1, Status status); // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/QueueService.java // @ImplementedBy(QueueServiceImpl.class) // public interface QueueService { // Future<BuildResult> enqueueBuild(UserIdentity committer, Repository repository, // String sha1, String command, boolean force) throws Exception; // // void addCallback(BuildLifeCycleListener callback); // // void removeCallback(BuildLifeCycleListener callback); // // Collection<Pair<Repository, String>> getScheduledTasks(); // Collection<Pair<Repository, String>> getCurrentTasks(); // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/Status.java // public enum Status { // RUNNING('R'), // PENDING('P'), // ERROR('E'), // OK('O'), // INTERRUPTED('I'), // LOCAL('L'), // NEW('N'), // UNKNOWN('?'); // // private char code; // // private Status(char code) { this.code = code; } // // public char getCode() { // return code; // } // }
import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.inject.Inject; import java.io.IOException; import java.util.EnumSet; import java.util.HashSet; import java.util.Scanner; import java.util.Set; import org.eclipse.jgit.lib.Repository; import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.build.BuildLifeCycleListener; import org.kercoin.magrit.core.build.QueueService; import org.kercoin.magrit.core.build.Status;
/* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.sshd.commands; public class WaitForCommand extends AbstractCommand<WaitForCommand> implements BuildLifeCycleListener { private final Logger log = LoggerFactory.getLogger(getClass()); public static class WaitForCommandProvider implements CommandProvider<WaitForCommand>, org.kercoin.magrit.sshd.commands.AbstractCommand.EndCallback<WaitForCommand>{
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/BuildLifeCycleListener.java // public interface BuildLifeCycleListener { // // void buildScheduled(Repository repo, String sha1); // // void buildStarted(Repository repo, String sha1); // // void buildEnded(Repository repo, String sha1, Status status); // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/QueueService.java // @ImplementedBy(QueueServiceImpl.class) // public interface QueueService { // Future<BuildResult> enqueueBuild(UserIdentity committer, Repository repository, // String sha1, String command, boolean force) throws Exception; // // void addCallback(BuildLifeCycleListener callback); // // void removeCallback(BuildLifeCycleListener callback); // // Collection<Pair<Repository, String>> getScheduledTasks(); // Collection<Pair<Repository, String>> getCurrentTasks(); // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/Status.java // public enum Status { // RUNNING('R'), // PENDING('P'), // ERROR('E'), // OK('O'), // INTERRUPTED('I'), // LOCAL('L'), // NEW('N'), // UNKNOWN('?'); // // private char code; // // private Status(char code) { this.code = code; } // // public char getCode() { // return code; // } // } // Path: server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/WaitForCommand.java import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.inject.Inject; import java.io.IOException; import java.util.EnumSet; import java.util.HashSet; import java.util.Scanner; import java.util.Set; import org.eclipse.jgit.lib.Repository; import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.build.BuildLifeCycleListener; import org.kercoin.magrit.core.build.QueueService; import org.kercoin.magrit.core.build.Status; /* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.sshd.commands; public class WaitForCommand extends AbstractCommand<WaitForCommand> implements BuildLifeCycleListener { private final Logger log = LoggerFactory.getLogger(getClass()); public static class WaitForCommandProvider implements CommandProvider<WaitForCommand>, org.kercoin.magrit.sshd.commands.AbstractCommand.EndCallback<WaitForCommand>{
private final Context ctx;
ptitfred/magrit
server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/WaitForCommand.java
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/BuildLifeCycleListener.java // public interface BuildLifeCycleListener { // // void buildScheduled(Repository repo, String sha1); // // void buildStarted(Repository repo, String sha1); // // void buildEnded(Repository repo, String sha1, Status status); // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/QueueService.java // @ImplementedBy(QueueServiceImpl.class) // public interface QueueService { // Future<BuildResult> enqueueBuild(UserIdentity committer, Repository repository, // String sha1, String command, boolean force) throws Exception; // // void addCallback(BuildLifeCycleListener callback); // // void removeCallback(BuildLifeCycleListener callback); // // Collection<Pair<Repository, String>> getScheduledTasks(); // Collection<Pair<Repository, String>> getCurrentTasks(); // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/Status.java // public enum Status { // RUNNING('R'), // PENDING('P'), // ERROR('E'), // OK('O'), // INTERRUPTED('I'), // LOCAL('L'), // NEW('N'), // UNKNOWN('?'); // // private char code; // // private Status(char code) { this.code = code; } // // public char getCode() { // return code; // } // }
import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.inject.Inject; import java.io.IOException; import java.util.EnumSet; import java.util.HashSet; import java.util.Scanner; import java.util.Set; import org.eclipse.jgit.lib.Repository; import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.build.BuildLifeCycleListener; import org.kercoin.magrit.core.build.QueueService; import org.kercoin.magrit.core.build.Status;
/* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.sshd.commands; public class WaitForCommand extends AbstractCommand<WaitForCommand> implements BuildLifeCycleListener { private final Logger log = LoggerFactory.getLogger(getClass()); public static class WaitForCommandProvider implements CommandProvider<WaitForCommand>, org.kercoin.magrit.sshd.commands.AbstractCommand.EndCallback<WaitForCommand>{ private final Context ctx;
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/BuildLifeCycleListener.java // public interface BuildLifeCycleListener { // // void buildScheduled(Repository repo, String sha1); // // void buildStarted(Repository repo, String sha1); // // void buildEnded(Repository repo, String sha1, Status status); // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/QueueService.java // @ImplementedBy(QueueServiceImpl.class) // public interface QueueService { // Future<BuildResult> enqueueBuild(UserIdentity committer, Repository repository, // String sha1, String command, boolean force) throws Exception; // // void addCallback(BuildLifeCycleListener callback); // // void removeCallback(BuildLifeCycleListener callback); // // Collection<Pair<Repository, String>> getScheduledTasks(); // Collection<Pair<Repository, String>> getCurrentTasks(); // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/Status.java // public enum Status { // RUNNING('R'), // PENDING('P'), // ERROR('E'), // OK('O'), // INTERRUPTED('I'), // LOCAL('L'), // NEW('N'), // UNKNOWN('?'); // // private char code; // // private Status(char code) { this.code = code; } // // public char getCode() { // return code; // } // } // Path: server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/WaitForCommand.java import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.inject.Inject; import java.io.IOException; import java.util.EnumSet; import java.util.HashSet; import java.util.Scanner; import java.util.Set; import org.eclipse.jgit.lib.Repository; import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.build.BuildLifeCycleListener; import org.kercoin.magrit.core.build.QueueService; import org.kercoin.magrit.core.build.Status; /* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.sshd.commands; public class WaitForCommand extends AbstractCommand<WaitForCommand> implements BuildLifeCycleListener { private final Logger log = LoggerFactory.getLogger(getClass()); public static class WaitForCommandProvider implements CommandProvider<WaitForCommand>, org.kercoin.magrit.sshd.commands.AbstractCommand.EndCallback<WaitForCommand>{ private final Context ctx;
private final QueueService queueService;
ptitfred/magrit
server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/WaitForCommand.java
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/BuildLifeCycleListener.java // public interface BuildLifeCycleListener { // // void buildScheduled(Repository repo, String sha1); // // void buildStarted(Repository repo, String sha1); // // void buildEnded(Repository repo, String sha1, Status status); // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/QueueService.java // @ImplementedBy(QueueServiceImpl.class) // public interface QueueService { // Future<BuildResult> enqueueBuild(UserIdentity committer, Repository repository, // String sha1, String command, boolean force) throws Exception; // // void addCallback(BuildLifeCycleListener callback); // // void removeCallback(BuildLifeCycleListener callback); // // Collection<Pair<Repository, String>> getScheduledTasks(); // Collection<Pair<Repository, String>> getCurrentTasks(); // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/Status.java // public enum Status { // RUNNING('R'), // PENDING('P'), // ERROR('E'), // OK('O'), // INTERRUPTED('I'), // LOCAL('L'), // NEW('N'), // UNKNOWN('?'); // // private char code; // // private Status(char code) { this.code = code; } // // public char getCode() { // return code; // } // }
import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.inject.Inject; import java.io.IOException; import java.util.EnumSet; import java.util.HashSet; import java.util.Scanner; import java.util.Set; import org.eclipse.jgit.lib.Repository; import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.build.BuildLifeCycleListener; import org.kercoin.magrit.core.build.QueueService; import org.kercoin.magrit.core.build.Status;
} catch (InterruptedException e) { Thread.interrupted(); } } } } // else { // -- Nothing to do // -- Connection will be closed on event // } } @Override protected Class<WaitForCommand> getType() { return WaitForCommand.class; } Set<String> getSha1s() { return sha1s; } int getTimeout() { return timeout; } Set<Event> getEventMask() { return eventMask; } @Override
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/BuildLifeCycleListener.java // public interface BuildLifeCycleListener { // // void buildScheduled(Repository repo, String sha1); // // void buildStarted(Repository repo, String sha1); // // void buildEnded(Repository repo, String sha1, Status status); // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/QueueService.java // @ImplementedBy(QueueServiceImpl.class) // public interface QueueService { // Future<BuildResult> enqueueBuild(UserIdentity committer, Repository repository, // String sha1, String command, boolean force) throws Exception; // // void addCallback(BuildLifeCycleListener callback); // // void removeCallback(BuildLifeCycleListener callback); // // Collection<Pair<Repository, String>> getScheduledTasks(); // Collection<Pair<Repository, String>> getCurrentTasks(); // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/Status.java // public enum Status { // RUNNING('R'), // PENDING('P'), // ERROR('E'), // OK('O'), // INTERRUPTED('I'), // LOCAL('L'), // NEW('N'), // UNKNOWN('?'); // // private char code; // // private Status(char code) { this.code = code; } // // public char getCode() { // return code; // } // } // Path: server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/WaitForCommand.java import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.inject.Inject; import java.io.IOException; import java.util.EnumSet; import java.util.HashSet; import java.util.Scanner; import java.util.Set; import org.eclipse.jgit.lib.Repository; import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.build.BuildLifeCycleListener; import org.kercoin.magrit.core.build.QueueService; import org.kercoin.magrit.core.build.Status; } catch (InterruptedException e) { Thread.interrupted(); } } } } // else { // -- Nothing to do // -- Connection will be closed on event // } } @Override protected Class<WaitForCommand> getType() { return WaitForCommand.class; } Set<String> getSha1s() { return sha1s; } int getTimeout() { return timeout; } Set<Event> getEventMask() { return eventMask; } @Override
public void buildEnded(Repository repo, String sha1, Status status) {
ptitfred/magrit
server/core/src/main/java/org/kercoin/magrit/core/Context.java
// Path: server/core/src/main/java/org/kercoin/magrit/core/utils/GitUtils.java // @Singleton // public class GitUtils { // // private static final String REF_SPEC_PATTERN = "+refs/heads/*:refs/remotes/%s/*"; // // public void addRemote(Repository toConfigure, String name, Repository remoteRepo) throws IOException { // final String refSpec = String.format(REF_SPEC_PATTERN, name); // File dest = remoteRepo.getDirectory(); // if (!remoteRepo.isBare()) { // dest = dest.getParentFile(); // } // synchronized (toConfigure) { // toConfigure.getConfig().setString("remote", name, "fetch", refSpec ); // toConfigure.getConfig().setString("remote", name, "url", dest.getAbsolutePath()); // // write down configuration in .git/config // toConfigure.getConfig().save(); // } // } // // public void fetch(Repository repository, String remote) throws JGitInternalException, InvalidRemoteException { // Git.wrap(repository).fetch().setRemote(remote).call(); // } // // public RevCommit getCommit(Repository repo, String revstr) // throws MissingObjectException, IncorrectObjectTypeException, // AmbiguousObjectException, IOException { // ObjectId ref = repo.resolve(revstr); // if (ref==null) return null; // RevWalk walk = new RevWalk(repo); // try { // return walk.parseCommit(ref); // } finally { // walk.dispose(); // } // } // // public boolean containsCommit(Repository repository, String revstr) { // try { // return getCommit(repository, revstr) != null; // } catch (IOException e) { // return false; // } // } // // public byte[] showBytes(Repository repository, String revstr) throws AmbiguousObjectException, IOException { // ObjectId ref = repository.resolve(revstr); // if (ref == null) { // return null; // } // return repository.getObjectDatabase().newReader().open(ref).getBytes(); // } // // public String show(Repository repository, String revstr) throws AmbiguousObjectException, IOException { // byte[] bytes = showBytes(repository, revstr); // if (bytes == null) { // return null; // } // return new String(bytes, "UTF-8"); // } // // public boolean isSha1(String candidate) { // if (candidate.length()!=40) { // return false; // } // return Pattern.compile("[0-9a-f]{40}").matcher(candidate).matches(); // } // // public Repository createRepository(File fullPath) throws IOException { // RepositoryBuilder builder = new RepositoryBuilder(); // builder.setGitDir(fullPath); // return builder.build(); // } // // public String getTree(Repository repo, String commitSha1) { // try { // RevCommit commit = getCommit(repo, commitSha1); // if (commit == null) { // return null; // } // final RevTree tree = commit.getTree(); // if (tree == null) { // return null; // } // return tree.getName(); // } catch (IOException e) { // return null; // } // } // // public void checkoutAsBranch(Repository repository, String commitSha1, // String branchName) throws RefNotFoundException, // InvalidRefNameException { // try { // Git.wrap(repository).checkout().setCreateBranch(true) // .setName(branchName).setStartPoint(commitSha1).call(); // } catch (RefAlreadyExistsException e) { // // It's ok! // } // } // }
import java.util.concurrent.ExecutorService; import org.kercoin.magrit.core.utils.GitUtils; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Singleton; import com.google.inject.name.Named;
/* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.core; @Singleton public class Context { private final Configuration configuration = new Configuration(); private Injector injector;
// Path: server/core/src/main/java/org/kercoin/magrit/core/utils/GitUtils.java // @Singleton // public class GitUtils { // // private static final String REF_SPEC_PATTERN = "+refs/heads/*:refs/remotes/%s/*"; // // public void addRemote(Repository toConfigure, String name, Repository remoteRepo) throws IOException { // final String refSpec = String.format(REF_SPEC_PATTERN, name); // File dest = remoteRepo.getDirectory(); // if (!remoteRepo.isBare()) { // dest = dest.getParentFile(); // } // synchronized (toConfigure) { // toConfigure.getConfig().setString("remote", name, "fetch", refSpec ); // toConfigure.getConfig().setString("remote", name, "url", dest.getAbsolutePath()); // // write down configuration in .git/config // toConfigure.getConfig().save(); // } // } // // public void fetch(Repository repository, String remote) throws JGitInternalException, InvalidRemoteException { // Git.wrap(repository).fetch().setRemote(remote).call(); // } // // public RevCommit getCommit(Repository repo, String revstr) // throws MissingObjectException, IncorrectObjectTypeException, // AmbiguousObjectException, IOException { // ObjectId ref = repo.resolve(revstr); // if (ref==null) return null; // RevWalk walk = new RevWalk(repo); // try { // return walk.parseCommit(ref); // } finally { // walk.dispose(); // } // } // // public boolean containsCommit(Repository repository, String revstr) { // try { // return getCommit(repository, revstr) != null; // } catch (IOException e) { // return false; // } // } // // public byte[] showBytes(Repository repository, String revstr) throws AmbiguousObjectException, IOException { // ObjectId ref = repository.resolve(revstr); // if (ref == null) { // return null; // } // return repository.getObjectDatabase().newReader().open(ref).getBytes(); // } // // public String show(Repository repository, String revstr) throws AmbiguousObjectException, IOException { // byte[] bytes = showBytes(repository, revstr); // if (bytes == null) { // return null; // } // return new String(bytes, "UTF-8"); // } // // public boolean isSha1(String candidate) { // if (candidate.length()!=40) { // return false; // } // return Pattern.compile("[0-9a-f]{40}").matcher(candidate).matches(); // } // // public Repository createRepository(File fullPath) throws IOException { // RepositoryBuilder builder = new RepositoryBuilder(); // builder.setGitDir(fullPath); // return builder.build(); // } // // public String getTree(Repository repo, String commitSha1) { // try { // RevCommit commit = getCommit(repo, commitSha1); // if (commit == null) { // return null; // } // final RevTree tree = commit.getTree(); // if (tree == null) { // return null; // } // return tree.getName(); // } catch (IOException e) { // return null; // } // } // // public void checkoutAsBranch(Repository repository, String commitSha1, // String branchName) throws RefNotFoundException, // InvalidRefNameException { // try { // Git.wrap(repository).checkout().setCreateBranch(true) // .setName(branchName).setStartPoint(commitSha1).call(); // } catch (RefAlreadyExistsException e) { // // It's ok! // } // } // } // Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java import java.util.concurrent.ExecutorService; import org.kercoin.magrit.core.utils.GitUtils; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Singleton; import com.google.inject.name.Named; /* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.core; @Singleton public class Context { private final Configuration configuration = new Configuration(); private Injector injector;
private final GitUtils gitUtils;
ptitfred/magrit
server/core/src/main/java/org/kercoin/magrit/core/build/pipeline/PipelineImpl.java
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/BuildResult.java // public class BuildResult { // // private final String sha1; // // private boolean success; // // private byte[] log; // // private Date startDate; // private Date endDate; // // private int exitCode; // // public BuildResult(String sha1) { // this.sha1 = sha1; // success = false; // exitCode = -1; // } // // public void setSuccess(boolean success) { // this.success = success; // } // // public void setLog(byte[] log) { // this.log = log; // } // // public void setStartDate(Date startDate) { // this.startDate = startDate; // } // // public void setEndDate(Date endDate) { // this.endDate = endDate; // } // // public long getDuration() { // if (!endDate.after(startDate)) { // throw new IllegalArgumentException("End date is before start date > incoherent!"); // } // return endDate.getTime() - startDate.getTime(); // } // // public boolean isSuccess() { // return success; // } // // public byte[] getLog() { // return log; // } // // public Date getStartDate() { // return startDate; // } // // public Date getEndDate() { // return endDate; // } // // public void setExitCode(int exitCode) { // this.exitCode = exitCode; // } // // public int getExitCode() { // return exitCode; // } // // public String getCommitSha1() { // return sha1; // } // // }
import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.BlockingQueue; import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import java.util.concurrent.FutureTask; import java.util.concurrent.PriorityBlockingQueue; import java.util.concurrent.RunnableFuture; import java.util.concurrent.Semaphore; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantReadWriteLock; import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.build.BuildResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.inject.Inject; import com.google.inject.Singleton;
/* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.core.build.pipeline; @Singleton public class PipelineImpl implements Pipeline { private final Logger log = LoggerFactory.getLogger(getClass()); private final Semaphore slots; private AtomicInteger keyId = new AtomicInteger(0); private final ExecutorService dispatcher; private final Notifier notifier = new Notifier();
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/BuildResult.java // public class BuildResult { // // private final String sha1; // // private boolean success; // // private byte[] log; // // private Date startDate; // private Date endDate; // // private int exitCode; // // public BuildResult(String sha1) { // this.sha1 = sha1; // success = false; // exitCode = -1; // } // // public void setSuccess(boolean success) { // this.success = success; // } // // public void setLog(byte[] log) { // this.log = log; // } // // public void setStartDate(Date startDate) { // this.startDate = startDate; // } // // public void setEndDate(Date endDate) { // this.endDate = endDate; // } // // public long getDuration() { // if (!endDate.after(startDate)) { // throw new IllegalArgumentException("End date is before start date > incoherent!"); // } // return endDate.getTime() - startDate.getTime(); // } // // public boolean isSuccess() { // return success; // } // // public byte[] getLog() { // return log; // } // // public Date getStartDate() { // return startDate; // } // // public Date getEndDate() { // return endDate; // } // // public void setExitCode(int exitCode) { // this.exitCode = exitCode; // } // // public int getExitCode() { // return exitCode; // } // // public String getCommitSha1() { // return sha1; // } // // } // Path: server/core/src/main/java/org/kercoin/magrit/core/build/pipeline/PipelineImpl.java import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.BlockingQueue; import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import java.util.concurrent.FutureTask; import java.util.concurrent.PriorityBlockingQueue; import java.util.concurrent.RunnableFuture; import java.util.concurrent.Semaphore; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantReadWriteLock; import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.build.BuildResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.inject.Inject; import com.google.inject.Singleton; /* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.core.build.pipeline; @Singleton public class PipelineImpl implements Pipeline { private final Logger log = LoggerFactory.getLogger(getClass()); private final Semaphore slots; private AtomicInteger keyId = new AtomicInteger(0); private final ExecutorService dispatcher; private final Notifier notifier = new Notifier();
private volatile Map<Key, Future<BuildResult>> futures;
ptitfred/magrit
server/core/src/main/java/org/kercoin/magrit/core/build/pipeline/PipelineImpl.java
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/BuildResult.java // public class BuildResult { // // private final String sha1; // // private boolean success; // // private byte[] log; // // private Date startDate; // private Date endDate; // // private int exitCode; // // public BuildResult(String sha1) { // this.sha1 = sha1; // success = false; // exitCode = -1; // } // // public void setSuccess(boolean success) { // this.success = success; // } // // public void setLog(byte[] log) { // this.log = log; // } // // public void setStartDate(Date startDate) { // this.startDate = startDate; // } // // public void setEndDate(Date endDate) { // this.endDate = endDate; // } // // public long getDuration() { // if (!endDate.after(startDate)) { // throw new IllegalArgumentException("End date is before start date > incoherent!"); // } // return endDate.getTime() - startDate.getTime(); // } // // public boolean isSuccess() { // return success; // } // // public byte[] getLog() { // return log; // } // // public Date getStartDate() { // return startDate; // } // // public Date getEndDate() { // return endDate; // } // // public void setExitCode(int exitCode) { // this.exitCode = exitCode; // } // // public int getExitCode() { // return exitCode; // } // // public String getCommitSha1() { // return sha1; // } // // }
import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.BlockingQueue; import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import java.util.concurrent.FutureTask; import java.util.concurrent.PriorityBlockingQueue; import java.util.concurrent.RunnableFuture; import java.util.concurrent.Semaphore; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantReadWriteLock; import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.build.BuildResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.inject.Inject; import com.google.inject.Singleton;
/* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.core.build.pipeline; @Singleton public class PipelineImpl implements Pipeline { private final Logger log = LoggerFactory.getLogger(getClass()); private final Semaphore slots; private AtomicInteger keyId = new AtomicInteger(0); private final ExecutorService dispatcher; private final Notifier notifier = new Notifier(); private volatile Map<Key, Future<BuildResult>> futures; // @GuardedBy(main) private volatile Map<Key, Task<BuildResult>> tasks; private volatile Set<Key> workings; @Inject
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/BuildResult.java // public class BuildResult { // // private final String sha1; // // private boolean success; // // private byte[] log; // // private Date startDate; // private Date endDate; // // private int exitCode; // // public BuildResult(String sha1) { // this.sha1 = sha1; // success = false; // exitCode = -1; // } // // public void setSuccess(boolean success) { // this.success = success; // } // // public void setLog(byte[] log) { // this.log = log; // } // // public void setStartDate(Date startDate) { // this.startDate = startDate; // } // // public void setEndDate(Date endDate) { // this.endDate = endDate; // } // // public long getDuration() { // if (!endDate.after(startDate)) { // throw new IllegalArgumentException("End date is before start date > incoherent!"); // } // return endDate.getTime() - startDate.getTime(); // } // // public boolean isSuccess() { // return success; // } // // public byte[] getLog() { // return log; // } // // public Date getStartDate() { // return startDate; // } // // public Date getEndDate() { // return endDate; // } // // public void setExitCode(int exitCode) { // this.exitCode = exitCode; // } // // public int getExitCode() { // return exitCode; // } // // public String getCommitSha1() { // return sha1; // } // // } // Path: server/core/src/main/java/org/kercoin/magrit/core/build/pipeline/PipelineImpl.java import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.BlockingQueue; import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import java.util.concurrent.FutureTask; import java.util.concurrent.PriorityBlockingQueue; import java.util.concurrent.RunnableFuture; import java.util.concurrent.Semaphore; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantReadWriteLock; import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.build.BuildResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.inject.Inject; import com.google.inject.Singleton; /* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.core.build.pipeline; @Singleton public class PipelineImpl implements Pipeline { private final Logger log = LoggerFactory.getLogger(getClass()); private final Semaphore slots; private AtomicInteger keyId = new AtomicInteger(0); private final ExecutorService dispatcher; private final Notifier notifier = new Notifier(); private volatile Map<Key, Future<BuildResult>> futures; // @GuardedBy(main) private volatile Map<Key, Task<BuildResult>> tasks; private volatile Set<Key> workings; @Inject
public PipelineImpl(Context ctx) {
ptitfred/magrit
server/core/src/main/java/org/kercoin/magrit/core/build/RepositoryGuard.java
// Path: server/core/src/main/java/org/kercoin/magrit/core/build/pipeline/CriticalResource.java // public interface CriticalResource { // Lock getLock(); // }
import java.io.File; import java.util.HashMap; import java.util.Map; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import org.eclipse.jgit.lib.Repository; import org.kercoin.magrit.core.build.pipeline.CriticalResource; import com.google.inject.Singleton;
/* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.core.build; @Singleton public class RepositoryGuard {
// Path: server/core/src/main/java/org/kercoin/magrit/core/build/pipeline/CriticalResource.java // public interface CriticalResource { // Lock getLock(); // } // Path: server/core/src/main/java/org/kercoin/magrit/core/build/RepositoryGuard.java import java.io.File; import java.util.HashMap; import java.util.Map; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import org.eclipse.jgit.lib.Repository; import org.kercoin.magrit.core.build.pipeline.CriticalResource; import com.google.inject.Singleton; /* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.core.build; @Singleton public class RepositoryGuard {
Map<File, CriticalResource> locks = new HashMap<File, CriticalResource>();
ptitfred/magrit
server/core/src/main/java/org/kercoin/magrit/core/build/pipeline/Pipeline.java
// Path: server/core/src/main/java/org/kercoin/magrit/core/build/BuildResult.java // public class BuildResult { // // private final String sha1; // // private boolean success; // // private byte[] log; // // private Date startDate; // private Date endDate; // // private int exitCode; // // public BuildResult(String sha1) { // this.sha1 = sha1; // success = false; // exitCode = -1; // } // // public void setSuccess(boolean success) { // this.success = success; // } // // public void setLog(byte[] log) { // this.log = log; // } // // public void setStartDate(Date startDate) { // this.startDate = startDate; // } // // public void setEndDate(Date endDate) { // this.endDate = endDate; // } // // public long getDuration() { // if (!endDate.after(startDate)) { // throw new IllegalArgumentException("End date is before start date > incoherent!"); // } // return endDate.getTime() - startDate.getTime(); // } // // public boolean isSuccess() { // return success; // } // // public byte[] getLog() { // return log; // } // // public Date getStartDate() { // return startDate; // } // // public Date getEndDate() { // return endDate; // } // // public void setExitCode(int exitCode) { // this.exitCode = exitCode; // } // // public int getExitCode() { // return exitCode; // } // // public String getCommitSha1() { // return sha1; // } // // }
import java.io.InputStream; import java.util.List; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import org.kercoin.magrit.core.build.BuildResult; import com.google.inject.ImplementedBy;
/* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.core.build.pipeline; /** * Pipeline API */ @ImplementedBy(PipelineImpl.class) public interface Pipeline { /** * Submits tasks to the pipeline. If the tasks is accepted, the returned key will be valid. * @param task * @return */
// Path: server/core/src/main/java/org/kercoin/magrit/core/build/BuildResult.java // public class BuildResult { // // private final String sha1; // // private boolean success; // // private byte[] log; // // private Date startDate; // private Date endDate; // // private int exitCode; // // public BuildResult(String sha1) { // this.sha1 = sha1; // success = false; // exitCode = -1; // } // // public void setSuccess(boolean success) { // this.success = success; // } // // public void setLog(byte[] log) { // this.log = log; // } // // public void setStartDate(Date startDate) { // this.startDate = startDate; // } // // public void setEndDate(Date endDate) { // this.endDate = endDate; // } // // public long getDuration() { // if (!endDate.after(startDate)) { // throw new IllegalArgumentException("End date is before start date > incoherent!"); // } // return endDate.getTime() - startDate.getTime(); // } // // public boolean isSuccess() { // return success; // } // // public byte[] getLog() { // return log; // } // // public Date getStartDate() { // return startDate; // } // // public Date getEndDate() { // return endDate; // } // // public void setExitCode(int exitCode) { // this.exitCode = exitCode; // } // // public int getExitCode() { // return exitCode; // } // // public String getCommitSha1() { // return sha1; // } // // } // Path: server/core/src/main/java/org/kercoin/magrit/core/build/pipeline/Pipeline.java import java.io.InputStream; import java.util.List; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import org.kercoin.magrit.core.build.BuildResult; import com.google.inject.ImplementedBy; /* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.core.build.pipeline; /** * Pipeline API */ @ImplementedBy(PipelineImpl.class) public interface Pipeline { /** * Submits tasks to the pipeline. If the tasks is accepted, the returned key will be valid. * @param task * @return */
Key submit(Task<BuildResult> task);
ptitfred/magrit
server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/ReceivePackCommand.java
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // }
import java.io.IOException; import org.apache.sshd.server.Command; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.transport.ReceivePack; import org.kercoin.magrit.core.Context; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.inject.Inject; import com.google.inject.Singleton;
/* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.sshd.commands; /** * <p>Wraps a JGit {@link ReceivePack} as a Mina SSHD {@link Command}.</p> * @author ptitfred * @see ReceivePack */ public class ReceivePackCommand extends AbstractCommand<ReceivePackCommand> { protected final Logger log = LoggerFactory.getLogger(getClass()); @Singleton public static class ReceivePackCommandProvider implements CommandProvider<ReceivePackCommand> {
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // Path: server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/ReceivePackCommand.java import java.io.IOException; import org.apache.sshd.server.Command; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.transport.ReceivePack; import org.kercoin.magrit.core.Context; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.inject.Inject; import com.google.inject.Singleton; /* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.sshd.commands; /** * <p>Wraps a JGit {@link ReceivePack} as a Mina SSHD {@link Command}.</p> * @author ptitfred * @see ReceivePack */ public class ReceivePackCommand extends AbstractCommand<ReceivePackCommand> { protected final Logger log = LoggerFactory.getLogger(getClass()); @Singleton public static class ReceivePackCommandProvider implements CommandProvider<ReceivePackCommand> {
private final Context ctx;
ptitfred/magrit
server/core/src/test/java/tests/ConfigurationAssert.java
// Path: server/core/src/main/java/org/kercoin/magrit/core/Configuration.java // public class Configuration { // // private static final String DEFAULT_BASE_DIR = System.getProperty("java.io.tmpdir") + "/magrit"; // // private int sshPort = 2022; // // private File repositoriesHomeDir = new File(DEFAULT_BASE_DIR, "repos"); // // private File publickeysRepositoryDir = new File(DEFAULT_BASE_DIR, "keys"); // // private File workHomeDir = new File(DEFAULT_BASE_DIR, "builds"); // // private Authentication authentication = Authentication.SSH_PUBLIC_KEYS; // // private boolean remoteAllowed; // // public static enum Authentication { // SSH_PUBLIC_KEYS { public String external() { return "ssh-public-keys"; } }, // NONE { public String external() { return "none"; } }; // // public abstract String external(); // // /** // * @param authValue // * @return // */ // public static Authentication fromExternalValue(String authValue) { // for (Authentication auth : Authentication.values()) { // if (auth.external().equals(authValue)) { // return auth; // } // } // return Authentication.NONE; // } // } // // public int getSshPort() { // return sshPort; // } // // public void setSshPort(int sshPort) { // this.sshPort = sshPort; // } // // public Authentication getAuthentication() { // return authentication; // } // // public void setAuthentication(Authentication authentication) { // this.authentication = authentication; // } // // public File getRepositoriesHomeDir() { // return repositoriesHomeDir; // } // // public void setRepositoriesHomeDir(File repositoriesHomeDir) { // this.repositoriesHomeDir = repositoriesHomeDir; // } // // public File getWorkHomeDir() { // return workHomeDir; // } // // public void setWorkHomeDir(File workHomeDir) { // this.workHomeDir = workHomeDir; // } // // public File getPublickeyRepositoryDir() { // return publickeysRepositoryDir; // } // // public void setPublickeysRepositoryDir(File publickeysRepositoryDir) { // this.publickeysRepositoryDir = publickeysRepositoryDir; // } // // public void applyStandardLayout(String dir) { // repositoriesHomeDir = new File(dir, "bares"); // workHomeDir = new File(dir, "builds"); // publickeysRepositoryDir = new File(dir, "keys"); // } // // public boolean isRemoteAllowed() { // return remoteAllowed; // } // // public void setRemoteAllowed(boolean remoteAllowed) { // this.remoteAllowed = remoteAllowed; // } // // public int getSlots() { // return Runtime.getRuntime().availableProcessors(); // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/Configuration.java // public static enum Authentication { // SSH_PUBLIC_KEYS { public String external() { return "ssh-public-keys"; } }, // NONE { public String external() { return "none"; } }; // // public abstract String external(); // // /** // * @param authValue // * @return // */ // public static Authentication fromExternalValue(String authValue) { // for (Authentication auth : Authentication.values()) { // if (auth.external().equals(authValue)) { // return auth; // } // } // return Authentication.NONE; // } // }
import static org.fest.assertions.Assertions.assertThat; import java.io.File; import org.fest.assertions.GenericAssert; import org.kercoin.magrit.core.Configuration; import org.kercoin.magrit.core.Configuration.Authentication;
/* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package tests; public class ConfigurationAssert extends GenericAssert<ConfigurationAssert, Configuration> { ConfigurationAssert(Class<ConfigurationAssert> selfType, Configuration actual) { super(selfType, actual); } public ConfigurationAssert onPort(int expected) { assertThat(actual.getSshPort()).isEqualTo(expected); return this; } public ConfigurationAssert hasHomeDir(String absolutePath) { assertThat(actual.getRepositoriesHomeDir().getAbsolutePath()).isEqualTo(cleanPath(absolutePath)); return this; } public ConfigurationAssert hasWorkDir(String absolutePath) { assertThat(actual.getWorkHomeDir().getAbsolutePath()).isEqualTo(cleanPath(absolutePath)); return this; } public ConfigurationAssert hasPublickeyDir(String absolutePath) { assertThat(actual.getPublickeyRepositoryDir().getAbsolutePath()).isEqualTo(cleanPath(absolutePath)); return this; }
// Path: server/core/src/main/java/org/kercoin/magrit/core/Configuration.java // public class Configuration { // // private static final String DEFAULT_BASE_DIR = System.getProperty("java.io.tmpdir") + "/magrit"; // // private int sshPort = 2022; // // private File repositoriesHomeDir = new File(DEFAULT_BASE_DIR, "repos"); // // private File publickeysRepositoryDir = new File(DEFAULT_BASE_DIR, "keys"); // // private File workHomeDir = new File(DEFAULT_BASE_DIR, "builds"); // // private Authentication authentication = Authentication.SSH_PUBLIC_KEYS; // // private boolean remoteAllowed; // // public static enum Authentication { // SSH_PUBLIC_KEYS { public String external() { return "ssh-public-keys"; } }, // NONE { public String external() { return "none"; } }; // // public abstract String external(); // // /** // * @param authValue // * @return // */ // public static Authentication fromExternalValue(String authValue) { // for (Authentication auth : Authentication.values()) { // if (auth.external().equals(authValue)) { // return auth; // } // } // return Authentication.NONE; // } // } // // public int getSshPort() { // return sshPort; // } // // public void setSshPort(int sshPort) { // this.sshPort = sshPort; // } // // public Authentication getAuthentication() { // return authentication; // } // // public void setAuthentication(Authentication authentication) { // this.authentication = authentication; // } // // public File getRepositoriesHomeDir() { // return repositoriesHomeDir; // } // // public void setRepositoriesHomeDir(File repositoriesHomeDir) { // this.repositoriesHomeDir = repositoriesHomeDir; // } // // public File getWorkHomeDir() { // return workHomeDir; // } // // public void setWorkHomeDir(File workHomeDir) { // this.workHomeDir = workHomeDir; // } // // public File getPublickeyRepositoryDir() { // return publickeysRepositoryDir; // } // // public void setPublickeysRepositoryDir(File publickeysRepositoryDir) { // this.publickeysRepositoryDir = publickeysRepositoryDir; // } // // public void applyStandardLayout(String dir) { // repositoriesHomeDir = new File(dir, "bares"); // workHomeDir = new File(dir, "builds"); // publickeysRepositoryDir = new File(dir, "keys"); // } // // public boolean isRemoteAllowed() { // return remoteAllowed; // } // // public void setRemoteAllowed(boolean remoteAllowed) { // this.remoteAllowed = remoteAllowed; // } // // public int getSlots() { // return Runtime.getRuntime().availableProcessors(); // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/Configuration.java // public static enum Authentication { // SSH_PUBLIC_KEYS { public String external() { return "ssh-public-keys"; } }, // NONE { public String external() { return "none"; } }; // // public abstract String external(); // // /** // * @param authValue // * @return // */ // public static Authentication fromExternalValue(String authValue) { // for (Authentication auth : Authentication.values()) { // if (auth.external().equals(authValue)) { // return auth; // } // } // return Authentication.NONE; // } // } // Path: server/core/src/test/java/tests/ConfigurationAssert.java import static org.fest.assertions.Assertions.assertThat; import java.io.File; import org.fest.assertions.GenericAssert; import org.kercoin.magrit.core.Configuration; import org.kercoin.magrit.core.Configuration.Authentication; /* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package tests; public class ConfigurationAssert extends GenericAssert<ConfigurationAssert, Configuration> { ConfigurationAssert(Class<ConfigurationAssert> selfType, Configuration actual) { super(selfType, actual); } public ConfigurationAssert onPort(int expected) { assertThat(actual.getSshPort()).isEqualTo(expected); return this; } public ConfigurationAssert hasHomeDir(String absolutePath) { assertThat(actual.getRepositoriesHomeDir().getAbsolutePath()).isEqualTo(cleanPath(absolutePath)); return this; } public ConfigurationAssert hasWorkDir(String absolutePath) { assertThat(actual.getWorkHomeDir().getAbsolutePath()).isEqualTo(cleanPath(absolutePath)); return this; } public ConfigurationAssert hasPublickeyDir(String absolutePath) { assertThat(actual.getPublickeyRepositoryDir().getAbsolutePath()).isEqualTo(cleanPath(absolutePath)); return this; }
public ConfigurationAssert hasAuthentication(Authentication expected) {
ptitfred/magrit
server/core/src/main/java/org/kercoin/magrit/core/services/Service.java
// Path: server/core/src/main/java/org/kercoin/magrit/core/Configuration.java // public class Configuration { // // private static final String DEFAULT_BASE_DIR = System.getProperty("java.io.tmpdir") + "/magrit"; // // private int sshPort = 2022; // // private File repositoriesHomeDir = new File(DEFAULT_BASE_DIR, "repos"); // // private File publickeysRepositoryDir = new File(DEFAULT_BASE_DIR, "keys"); // // private File workHomeDir = new File(DEFAULT_BASE_DIR, "builds"); // // private Authentication authentication = Authentication.SSH_PUBLIC_KEYS; // // private boolean remoteAllowed; // // public static enum Authentication { // SSH_PUBLIC_KEYS { public String external() { return "ssh-public-keys"; } }, // NONE { public String external() { return "none"; } }; // // public abstract String external(); // // /** // * @param authValue // * @return // */ // public static Authentication fromExternalValue(String authValue) { // for (Authentication auth : Authentication.values()) { // if (auth.external().equals(authValue)) { // return auth; // } // } // return Authentication.NONE; // } // } // // public int getSshPort() { // return sshPort; // } // // public void setSshPort(int sshPort) { // this.sshPort = sshPort; // } // // public Authentication getAuthentication() { // return authentication; // } // // public void setAuthentication(Authentication authentication) { // this.authentication = authentication; // } // // public File getRepositoriesHomeDir() { // return repositoriesHomeDir; // } // // public void setRepositoriesHomeDir(File repositoriesHomeDir) { // this.repositoriesHomeDir = repositoriesHomeDir; // } // // public File getWorkHomeDir() { // return workHomeDir; // } // // public void setWorkHomeDir(File workHomeDir) { // this.workHomeDir = workHomeDir; // } // // public File getPublickeyRepositoryDir() { // return publickeysRepositoryDir; // } // // public void setPublickeysRepositoryDir(File publickeysRepositoryDir) { // this.publickeysRepositoryDir = publickeysRepositoryDir; // } // // public void applyStandardLayout(String dir) { // repositoriesHomeDir = new File(dir, "bares"); // workHomeDir = new File(dir, "builds"); // publickeysRepositoryDir = new File(dir, "keys"); // } // // public boolean isRemoteAllowed() { // return remoteAllowed; // } // // public void setRemoteAllowed(boolean remoteAllowed) { // this.remoteAllowed = remoteAllowed; // } // // public int getSlots() { // return Runtime.getRuntime().availableProcessors(); // } // // }
import org.kercoin.magrit.core.Configuration;
/* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.core.services; /** * @author ptitfred * */ public interface Service { String getName();
// Path: server/core/src/main/java/org/kercoin/magrit/core/Configuration.java // public class Configuration { // // private static final String DEFAULT_BASE_DIR = System.getProperty("java.io.tmpdir") + "/magrit"; // // private int sshPort = 2022; // // private File repositoriesHomeDir = new File(DEFAULT_BASE_DIR, "repos"); // // private File publickeysRepositoryDir = new File(DEFAULT_BASE_DIR, "keys"); // // private File workHomeDir = new File(DEFAULT_BASE_DIR, "builds"); // // private Authentication authentication = Authentication.SSH_PUBLIC_KEYS; // // private boolean remoteAllowed; // // public static enum Authentication { // SSH_PUBLIC_KEYS { public String external() { return "ssh-public-keys"; } }, // NONE { public String external() { return "none"; } }; // // public abstract String external(); // // /** // * @param authValue // * @return // */ // public static Authentication fromExternalValue(String authValue) { // for (Authentication auth : Authentication.values()) { // if (auth.external().equals(authValue)) { // return auth; // } // } // return Authentication.NONE; // } // } // // public int getSshPort() { // return sshPort; // } // // public void setSshPort(int sshPort) { // this.sshPort = sshPort; // } // // public Authentication getAuthentication() { // return authentication; // } // // public void setAuthentication(Authentication authentication) { // this.authentication = authentication; // } // // public File getRepositoriesHomeDir() { // return repositoriesHomeDir; // } // // public void setRepositoriesHomeDir(File repositoriesHomeDir) { // this.repositoriesHomeDir = repositoriesHomeDir; // } // // public File getWorkHomeDir() { // return workHomeDir; // } // // public void setWorkHomeDir(File workHomeDir) { // this.workHomeDir = workHomeDir; // } // // public File getPublickeyRepositoryDir() { // return publickeysRepositoryDir; // } // // public void setPublickeysRepositoryDir(File publickeysRepositoryDir) { // this.publickeysRepositoryDir = publickeysRepositoryDir; // } // // public void applyStandardLayout(String dir) { // repositoriesHomeDir = new File(dir, "bares"); // workHomeDir = new File(dir, "builds"); // publickeysRepositoryDir = new File(dir, "keys"); // } // // public boolean isRemoteAllowed() { // return remoteAllowed; // } // // public void setRemoteAllowed(boolean remoteAllowed) { // this.remoteAllowed = remoteAllowed; // } // // public int getSlots() { // return Runtime.getRuntime().availableProcessors(); // } // // } // Path: server/core/src/main/java/org/kercoin/magrit/core/services/Service.java import org.kercoin.magrit.core.Configuration; /* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.core.services; /** * @author ptitfred * */ public interface Service { String getName();
void logConfig(ConfigurationLogger log, Configuration cfg);
ptitfred/magrit
server/core/src/test/java/org/kercoin/magrit/core/build/pipeline/PipelineImplTest.java
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/BuildResult.java // public class BuildResult { // // private final String sha1; // // private boolean success; // // private byte[] log; // // private Date startDate; // private Date endDate; // // private int exitCode; // // public BuildResult(String sha1) { // this.sha1 = sha1; // success = false; // exitCode = -1; // } // // public void setSuccess(boolean success) { // this.success = success; // } // // public void setLog(byte[] log) { // this.log = log; // } // // public void setStartDate(Date startDate) { // this.startDate = startDate; // } // // public void setEndDate(Date endDate) { // this.endDate = endDate; // } // // public long getDuration() { // if (!endDate.after(startDate)) { // throw new IllegalArgumentException("End date is before start date > incoherent!"); // } // return endDate.getTime() - startDate.getTime(); // } // // public boolean isSuccess() { // return success; // } // // public byte[] getLog() { // return log; // } // // public Date getStartDate() { // return startDate; // } // // public Date getEndDate() { // return endDate; // } // // public void setExitCode(int exitCode) { // this.exitCode = exitCode; // } // // public int getExitCode() { // return exitCode; // } // // public String getCommitSha1() { // return sha1; // } // // }
import static org.fest.assertions.Assertions.assertThat; import static org.mockito.BDDMockito.given; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.build.BuildResult; import org.mockito.Answers; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner;
/* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.core.build.pipeline; @RunWith(MockitoJUnitRunner.class) public class PipelineImplTest { PipelineImpl pipeline; @Mock(answer=Answers.RETURNS_DEEP_STUBS)
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/BuildResult.java // public class BuildResult { // // private final String sha1; // // private boolean success; // // private byte[] log; // // private Date startDate; // private Date endDate; // // private int exitCode; // // public BuildResult(String sha1) { // this.sha1 = sha1; // success = false; // exitCode = -1; // } // // public void setSuccess(boolean success) { // this.success = success; // } // // public void setLog(byte[] log) { // this.log = log; // } // // public void setStartDate(Date startDate) { // this.startDate = startDate; // } // // public void setEndDate(Date endDate) { // this.endDate = endDate; // } // // public long getDuration() { // if (!endDate.after(startDate)) { // throw new IllegalArgumentException("End date is before start date > incoherent!"); // } // return endDate.getTime() - startDate.getTime(); // } // // public boolean isSuccess() { // return success; // } // // public byte[] getLog() { // return log; // } // // public Date getStartDate() { // return startDate; // } // // public Date getEndDate() { // return endDate; // } // // public void setExitCode(int exitCode) { // this.exitCode = exitCode; // } // // public int getExitCode() { // return exitCode; // } // // public String getCommitSha1() { // return sha1; // } // // } // Path: server/core/src/test/java/org/kercoin/magrit/core/build/pipeline/PipelineImplTest.java import static org.fest.assertions.Assertions.assertThat; import static org.mockito.BDDMockito.given; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.build.BuildResult; import org.mockito.Answers; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; /* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.core.build.pipeline; @RunWith(MockitoJUnitRunner.class) public class PipelineImplTest { PipelineImpl pipeline; @Mock(answer=Answers.RETURNS_DEEP_STUBS)
Context ctx;
ptitfred/magrit
server/core/src/test/java/org/kercoin/magrit/core/build/pipeline/PipelineImplTest.java
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/BuildResult.java // public class BuildResult { // // private final String sha1; // // private boolean success; // // private byte[] log; // // private Date startDate; // private Date endDate; // // private int exitCode; // // public BuildResult(String sha1) { // this.sha1 = sha1; // success = false; // exitCode = -1; // } // // public void setSuccess(boolean success) { // this.success = success; // } // // public void setLog(byte[] log) { // this.log = log; // } // // public void setStartDate(Date startDate) { // this.startDate = startDate; // } // // public void setEndDate(Date endDate) { // this.endDate = endDate; // } // // public long getDuration() { // if (!endDate.after(startDate)) { // throw new IllegalArgumentException("End date is before start date > incoherent!"); // } // return endDate.getTime() - startDate.getTime(); // } // // public boolean isSuccess() { // return success; // } // // public byte[] getLog() { // return log; // } // // public Date getStartDate() { // return startDate; // } // // public Date getEndDate() { // return endDate; // } // // public void setExitCode(int exitCode) { // this.exitCode = exitCode; // } // // public int getExitCode() { // return exitCode; // } // // public String getCommitSha1() { // return sha1; // } // // }
import static org.fest.assertions.Assertions.assertThat; import static org.mockito.BDDMockito.given; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.build.BuildResult; import org.mockito.Answers; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner;
} @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; CR other = (CR) obj; if (pseudoPath == null) { if (other.pseudoPath != null) return false; } else if (!pseudoPath.equals(other.pseudoPath)) return false; return true; } } Map<String, CriticalResource> locks = new HashMap<String, CriticalResource>(); private CriticalResource getLock(String repoPath) { if (locks.get(repoPath) == null) { locks.put(repoPath, new CR(repoPath)); } return locks.get(repoPath); }
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/BuildResult.java // public class BuildResult { // // private final String sha1; // // private boolean success; // // private byte[] log; // // private Date startDate; // private Date endDate; // // private int exitCode; // // public BuildResult(String sha1) { // this.sha1 = sha1; // success = false; // exitCode = -1; // } // // public void setSuccess(boolean success) { // this.success = success; // } // // public void setLog(byte[] log) { // this.log = log; // } // // public void setStartDate(Date startDate) { // this.startDate = startDate; // } // // public void setEndDate(Date endDate) { // this.endDate = endDate; // } // // public long getDuration() { // if (!endDate.after(startDate)) { // throw new IllegalArgumentException("End date is before start date > incoherent!"); // } // return endDate.getTime() - startDate.getTime(); // } // // public boolean isSuccess() { // return success; // } // // public byte[] getLog() { // return log; // } // // public Date getStartDate() { // return startDate; // } // // public Date getEndDate() { // return endDate; // } // // public void setExitCode(int exitCode) { // this.exitCode = exitCode; // } // // public int getExitCode() { // return exitCode; // } // // public String getCommitSha1() { // return sha1; // } // // } // Path: server/core/src/test/java/org/kercoin/magrit/core/build/pipeline/PipelineImplTest.java import static org.fest.assertions.Assertions.assertThat; import static org.mockito.BDDMockito.given; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.build.BuildResult; import org.mockito.Answers; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; CR other = (CR) obj; if (pseudoPath == null) { if (other.pseudoPath != null) return false; } else if (!pseudoPath.equals(other.pseudoPath)) return false; return true; } } Map<String, CriticalResource> locks = new HashMap<String, CriticalResource>(); private CriticalResource getLock(String repoPath) { if (locks.get(repoPath) == null) { locks.put(repoPath, new CR(repoPath)); } return locks.get(repoPath); }
class TestTask implements Task<BuildResult> {
ptitfred/magrit
server/core/src/test/java/org/kercoin/magrit/core/utils/SimpleTimeServiceTest.java
// Path: server/core/src/main/java/org/kercoin/magrit/core/Pair.java // public class Pair<T, U> { // private T t; // private U u; // // public Pair(T t, U u) { // super(); // this.t = t; // this.u = u; // } // // public T getT() { // return t; // } // // public U getU() { // return u; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + ((t == null) ? 0 : t.hashCode()); // result = prime * result + ((u == null) ? 0 : u.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // @SuppressWarnings("unchecked") // Pair<T, U> other = (Pair<T, U>) obj; // if (t == null) { // if (other.t != null) // return false; // } else if (!t.equals(other.t)) // return false; // if (u == null) { // if (other.u != null) // return false; // } else if (!u.equals(other.u)) // return false; // return true; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/utils/SimpleTimeService.java // public class SimpleTimeService implements TimeService { // // @Override // public Pair<Long, Integer> now() { // return now(Calendar.getInstance()); // } // // Pair<Long, Integer> now(Calendar when) { // TimeZone tz = when.getTimeZone(); // int offsetInMillis = tz.getOffset(when.getTimeInMillis()); // int offsetInMinutes = offsetInMillis / (1000 * 60); // return new Pair<Long, Integer>(when.getTimeInMillis(), offsetInMinutes); // } // // // public String offsetToString(int minutes) { // int offsetInHours = Math.abs(minutes) / 60; // int remainderInMinutes = Math.abs(minutes) % 60; // String offsetEncoded = Integer.toString(offsetInHours * 100 + remainderInMinutes); // StringBuilder sb = new StringBuilder(); // sb.append(minutes >= 0 ? '+' : '-'); // sb.append("0000".substring(offsetEncoded.length())); // sb.append(offsetEncoded); // return sb.toString(); // } // // }
import static org.fest.assertions.Assertions.assertThat; import java.util.Calendar; import java.util.TimeZone; import org.junit.Before; import org.junit.Test; import org.kercoin.magrit.core.Pair; import org.kercoin.magrit.core.utils.SimpleTimeService;
/* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.core.utils; public class SimpleTimeServiceTest { private static final long SECOND = 1000L; private static final long MINUTE = 60 * SECOND; private static final long HOUR = 60 * MINUTE; private static final long DAY = 24 * HOUR; private static final long WEEK = 7 * DAY;
// Path: server/core/src/main/java/org/kercoin/magrit/core/Pair.java // public class Pair<T, U> { // private T t; // private U u; // // public Pair(T t, U u) { // super(); // this.t = t; // this.u = u; // } // // public T getT() { // return t; // } // // public U getU() { // return u; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + ((t == null) ? 0 : t.hashCode()); // result = prime * result + ((u == null) ? 0 : u.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // @SuppressWarnings("unchecked") // Pair<T, U> other = (Pair<T, U>) obj; // if (t == null) { // if (other.t != null) // return false; // } else if (!t.equals(other.t)) // return false; // if (u == null) { // if (other.u != null) // return false; // } else if (!u.equals(other.u)) // return false; // return true; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/utils/SimpleTimeService.java // public class SimpleTimeService implements TimeService { // // @Override // public Pair<Long, Integer> now() { // return now(Calendar.getInstance()); // } // // Pair<Long, Integer> now(Calendar when) { // TimeZone tz = when.getTimeZone(); // int offsetInMillis = tz.getOffset(when.getTimeInMillis()); // int offsetInMinutes = offsetInMillis / (1000 * 60); // return new Pair<Long, Integer>(when.getTimeInMillis(), offsetInMinutes); // } // // // public String offsetToString(int minutes) { // int offsetInHours = Math.abs(minutes) / 60; // int remainderInMinutes = Math.abs(minutes) % 60; // String offsetEncoded = Integer.toString(offsetInHours * 100 + remainderInMinutes); // StringBuilder sb = new StringBuilder(); // sb.append(minutes >= 0 ? '+' : '-'); // sb.append("0000".substring(offsetEncoded.length())); // sb.append(offsetEncoded); // return sb.toString(); // } // // } // Path: server/core/src/test/java/org/kercoin/magrit/core/utils/SimpleTimeServiceTest.java import static org.fest.assertions.Assertions.assertThat; import java.util.Calendar; import java.util.TimeZone; import org.junit.Before; import org.junit.Test; import org.kercoin.magrit.core.Pair; import org.kercoin.magrit.core.utils.SimpleTimeService; /* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.core.utils; public class SimpleTimeServiceTest { private static final long SECOND = 1000L; private static final long MINUTE = 60 * SECOND; private static final long HOUR = 60 * MINUTE; private static final long DAY = 24 * HOUR; private static final long WEEK = 7 * DAY;
SimpleTimeService timeService;
ptitfred/magrit
server/core/src/test/java/org/kercoin/magrit/core/utils/SimpleTimeServiceTest.java
// Path: server/core/src/main/java/org/kercoin/magrit/core/Pair.java // public class Pair<T, U> { // private T t; // private U u; // // public Pair(T t, U u) { // super(); // this.t = t; // this.u = u; // } // // public T getT() { // return t; // } // // public U getU() { // return u; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + ((t == null) ? 0 : t.hashCode()); // result = prime * result + ((u == null) ? 0 : u.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // @SuppressWarnings("unchecked") // Pair<T, U> other = (Pair<T, U>) obj; // if (t == null) { // if (other.t != null) // return false; // } else if (!t.equals(other.t)) // return false; // if (u == null) { // if (other.u != null) // return false; // } else if (!u.equals(other.u)) // return false; // return true; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/utils/SimpleTimeService.java // public class SimpleTimeService implements TimeService { // // @Override // public Pair<Long, Integer> now() { // return now(Calendar.getInstance()); // } // // Pair<Long, Integer> now(Calendar when) { // TimeZone tz = when.getTimeZone(); // int offsetInMillis = tz.getOffset(when.getTimeInMillis()); // int offsetInMinutes = offsetInMillis / (1000 * 60); // return new Pair<Long, Integer>(when.getTimeInMillis(), offsetInMinutes); // } // // // public String offsetToString(int minutes) { // int offsetInHours = Math.abs(minutes) / 60; // int remainderInMinutes = Math.abs(minutes) % 60; // String offsetEncoded = Integer.toString(offsetInHours * 100 + remainderInMinutes); // StringBuilder sb = new StringBuilder(); // sb.append(minutes >= 0 ? '+' : '-'); // sb.append("0000".substring(offsetEncoded.length())); // sb.append(offsetEncoded); // return sb.toString(); // } // // }
import static org.fest.assertions.Assertions.assertThat; import java.util.Calendar; import java.util.TimeZone; import org.junit.Before; import org.junit.Test; import org.kercoin.magrit.core.Pair; import org.kercoin.magrit.core.utils.SimpleTimeService;
/* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.core.utils; public class SimpleTimeServiceTest { private static final long SECOND = 1000L; private static final long MINUTE = 60 * SECOND; private static final long HOUR = 60 * MINUTE; private static final long DAY = 24 * HOUR; private static final long WEEK = 7 * DAY; SimpleTimeService timeService; @Before public void setUp() { timeService = new SimpleTimeService(); } @Test public void testNow() { Calendar when = Calendar.getInstance(TimeZone.getTimeZone("CET")); // 1970.01.10 (yyyy.mm.dd) when.setTimeInMillis(1* WEEK + 3* DAY);
// Path: server/core/src/main/java/org/kercoin/magrit/core/Pair.java // public class Pair<T, U> { // private T t; // private U u; // // public Pair(T t, U u) { // super(); // this.t = t; // this.u = u; // } // // public T getT() { // return t; // } // // public U getU() { // return u; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + ((t == null) ? 0 : t.hashCode()); // result = prime * result + ((u == null) ? 0 : u.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // @SuppressWarnings("unchecked") // Pair<T, U> other = (Pair<T, U>) obj; // if (t == null) { // if (other.t != null) // return false; // } else if (!t.equals(other.t)) // return false; // if (u == null) { // if (other.u != null) // return false; // } else if (!u.equals(other.u)) // return false; // return true; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/utils/SimpleTimeService.java // public class SimpleTimeService implements TimeService { // // @Override // public Pair<Long, Integer> now() { // return now(Calendar.getInstance()); // } // // Pair<Long, Integer> now(Calendar when) { // TimeZone tz = when.getTimeZone(); // int offsetInMillis = tz.getOffset(when.getTimeInMillis()); // int offsetInMinutes = offsetInMillis / (1000 * 60); // return new Pair<Long, Integer>(when.getTimeInMillis(), offsetInMinutes); // } // // // public String offsetToString(int minutes) { // int offsetInHours = Math.abs(minutes) / 60; // int remainderInMinutes = Math.abs(minutes) % 60; // String offsetEncoded = Integer.toString(offsetInHours * 100 + remainderInMinutes); // StringBuilder sb = new StringBuilder(); // sb.append(minutes >= 0 ? '+' : '-'); // sb.append("0000".substring(offsetEncoded.length())); // sb.append(offsetEncoded); // return sb.toString(); // } // // } // Path: server/core/src/test/java/org/kercoin/magrit/core/utils/SimpleTimeServiceTest.java import static org.fest.assertions.Assertions.assertThat; import java.util.Calendar; import java.util.TimeZone; import org.junit.Before; import org.junit.Test; import org.kercoin.magrit.core.Pair; import org.kercoin.magrit.core.utils.SimpleTimeService; /* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.core.utils; public class SimpleTimeServiceTest { private static final long SECOND = 1000L; private static final long MINUTE = 60 * SECOND; private static final long HOUR = 60 * MINUTE; private static final long DAY = 24 * HOUR; private static final long WEEK = 7 * DAY; SimpleTimeService timeService; @Before public void setUp() { timeService = new SimpleTimeService(); } @Test public void testNow() { Calendar when = Calendar.getInstance(TimeZone.getTimeZone("CET")); // 1970.01.10 (yyyy.mm.dd) when.setTimeInMillis(1* WEEK + 3* DAY);
Pair<Long,Integer> time = timeService.now(when);
ptitfred/magrit
server/core/src/main/java/org/kercoin/magrit/core/utils/TimeService.java
// Path: server/core/src/main/java/org/kercoin/magrit/core/Pair.java // public class Pair<T, U> { // private T t; // private U u; // // public Pair(T t, U u) { // super(); // this.t = t; // this.u = u; // } // // public T getT() { // return t; // } // // public U getU() { // return u; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + ((t == null) ? 0 : t.hashCode()); // result = prime * result + ((u == null) ? 0 : u.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // @SuppressWarnings("unchecked") // Pair<T, U> other = (Pair<T, U>) obj; // if (t == null) { // if (other.t != null) // return false; // } else if (!t.equals(other.t)) // return false; // if (u == null) { // if (other.u != null) // return false; // } else if (!u.equals(other.u)) // return false; // return true; // } // // }
import org.kercoin.magrit.core.Pair; import com.google.inject.ImplementedBy;
/* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.core.utils; @ImplementedBy(SimpleTimeService.class) public interface TimeService {
// Path: server/core/src/main/java/org/kercoin/magrit/core/Pair.java // public class Pair<T, U> { // private T t; // private U u; // // public Pair(T t, U u) { // super(); // this.t = t; // this.u = u; // } // // public T getT() { // return t; // } // // public U getU() { // return u; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + ((t == null) ? 0 : t.hashCode()); // result = prime * result + ((u == null) ? 0 : u.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // @SuppressWarnings("unchecked") // Pair<T, U> other = (Pair<T, U>) obj; // if (t == null) { // if (other.t != null) // return false; // } else if (!t.equals(other.t)) // return false; // if (u == null) { // if (other.u != null) // return false; // } else if (!u.equals(other.u)) // return false; // return true; // } // // } // Path: server/core/src/main/java/org/kercoin/magrit/core/utils/TimeService.java import org.kercoin.magrit.core.Pair; import com.google.inject.ImplementedBy; /* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.core.utils; @ImplementedBy(SimpleTimeService.class) public interface TimeService {
Pair<Long, Integer> now();
ptitfred/magrit
server/sshd/src/main/java/org/kercoin/magrit/sshd/SshdModule.java
// Path: server/sshd/src/main/java/org/kercoin/magrit/sshd/auth/GitPublickeyAuthenticator.java // public class GitPublickeyAuthenticator implements PublickeyAuthenticator { // // private final Context context; // private final GitUtils gitUtils; // // private Repository datasource; // // @Inject // public GitPublickeyAuthenticator(Context context, GitUtils gitUtils) { // this.context = context; // this.gitUtils = gitUtils; // } // // private void open() throws IOException { // if (this.datasource == null) { // this.datasource = Git.open( // context.configuration().getPublickeyRepositoryDir() // ).getRepository(); // } // } // // @Override // public boolean authenticate(String username, PublicKey authKey, // ServerSession session) { // try { // open(); // PublicKey targetKey = readKeyFromRepository(username); // return targetKey != null && areEqual(targetKey, authKey); // } catch (Exception e) { // e.printStackTrace(); // return false; // } // } // // boolean areEqual(PublicKey ref, PublicKey candidate) { // return Arrays.areEqual(ref.getEncoded(), candidate.getEncoded()); // } // // private PublicKey readKeyFromRepository(String username) throws AmbiguousObjectException, Exception { // String revstr = String.format("HEAD:keys/%s.pub", username); // String encoded = gitUtils.show(datasource, revstr); // if (encoded == null) // return null; // // return new AuthorizedKeysDecoder().decodePublicKey(encoded); // } // // } // // Path: server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/MagritCommandFactory.java // @Singleton // public class MagritCommandFactory implements CommandFactory { // // private Iterable<AbstractCommand.CommandProvider<?>> commands; // // @Inject // public MagritCommandFactory(CommandsProvider commandsProvider) { // super(); // this.commands = commandsProvider.get(); // } // // @Override // public Command createCommand(String command) { // if (command == null || command.length() == 0) { // throw new IllegalArgumentException(); // } // try { // for (AbstractCommand.CommandProvider<?> cp : commands) { // if (cp.accept(command)) { // return cp.get().command(command); // } // } // } catch (Exception e) { // return new SyntaxErrorCommand(e); // } // return new SyntaxErrorCommand(new IllegalArgumentException("Unknown command " + command)); // } // // }
import org.apache.sshd.server.CommandFactory; import org.apache.sshd.server.PublickeyAuthenticator; import org.kercoin.magrit.sshd.auth.GitPublickeyAuthenticator; import org.kercoin.magrit.sshd.commands.MagritCommandFactory; import com.google.inject.AbstractModule;
/* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.sshd; /** * @author ptitfred * */ public class SshdModule extends AbstractModule { @Override protected void configure() {
// Path: server/sshd/src/main/java/org/kercoin/magrit/sshd/auth/GitPublickeyAuthenticator.java // public class GitPublickeyAuthenticator implements PublickeyAuthenticator { // // private final Context context; // private final GitUtils gitUtils; // // private Repository datasource; // // @Inject // public GitPublickeyAuthenticator(Context context, GitUtils gitUtils) { // this.context = context; // this.gitUtils = gitUtils; // } // // private void open() throws IOException { // if (this.datasource == null) { // this.datasource = Git.open( // context.configuration().getPublickeyRepositoryDir() // ).getRepository(); // } // } // // @Override // public boolean authenticate(String username, PublicKey authKey, // ServerSession session) { // try { // open(); // PublicKey targetKey = readKeyFromRepository(username); // return targetKey != null && areEqual(targetKey, authKey); // } catch (Exception e) { // e.printStackTrace(); // return false; // } // } // // boolean areEqual(PublicKey ref, PublicKey candidate) { // return Arrays.areEqual(ref.getEncoded(), candidate.getEncoded()); // } // // private PublicKey readKeyFromRepository(String username) throws AmbiguousObjectException, Exception { // String revstr = String.format("HEAD:keys/%s.pub", username); // String encoded = gitUtils.show(datasource, revstr); // if (encoded == null) // return null; // // return new AuthorizedKeysDecoder().decodePublicKey(encoded); // } // // } // // Path: server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/MagritCommandFactory.java // @Singleton // public class MagritCommandFactory implements CommandFactory { // // private Iterable<AbstractCommand.CommandProvider<?>> commands; // // @Inject // public MagritCommandFactory(CommandsProvider commandsProvider) { // super(); // this.commands = commandsProvider.get(); // } // // @Override // public Command createCommand(String command) { // if (command == null || command.length() == 0) { // throw new IllegalArgumentException(); // } // try { // for (AbstractCommand.CommandProvider<?> cp : commands) { // if (cp.accept(command)) { // return cp.get().command(command); // } // } // } catch (Exception e) { // return new SyntaxErrorCommand(e); // } // return new SyntaxErrorCommand(new IllegalArgumentException("Unknown command " + command)); // } // // } // Path: server/sshd/src/main/java/org/kercoin/magrit/sshd/SshdModule.java import org.apache.sshd.server.CommandFactory; import org.apache.sshd.server.PublickeyAuthenticator; import org.kercoin.magrit.sshd.auth.GitPublickeyAuthenticator; import org.kercoin.magrit.sshd.commands.MagritCommandFactory; import com.google.inject.AbstractModule; /* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.sshd; /** * @author ptitfred * */ public class SshdModule extends AbstractModule { @Override protected void configure() {
bind(PublickeyAuthenticator.class).to(GitPublickeyAuthenticator.class);
ptitfred/magrit
server/sshd/src/main/java/org/kercoin/magrit/sshd/SshdModule.java
// Path: server/sshd/src/main/java/org/kercoin/magrit/sshd/auth/GitPublickeyAuthenticator.java // public class GitPublickeyAuthenticator implements PublickeyAuthenticator { // // private final Context context; // private final GitUtils gitUtils; // // private Repository datasource; // // @Inject // public GitPublickeyAuthenticator(Context context, GitUtils gitUtils) { // this.context = context; // this.gitUtils = gitUtils; // } // // private void open() throws IOException { // if (this.datasource == null) { // this.datasource = Git.open( // context.configuration().getPublickeyRepositoryDir() // ).getRepository(); // } // } // // @Override // public boolean authenticate(String username, PublicKey authKey, // ServerSession session) { // try { // open(); // PublicKey targetKey = readKeyFromRepository(username); // return targetKey != null && areEqual(targetKey, authKey); // } catch (Exception e) { // e.printStackTrace(); // return false; // } // } // // boolean areEqual(PublicKey ref, PublicKey candidate) { // return Arrays.areEqual(ref.getEncoded(), candidate.getEncoded()); // } // // private PublicKey readKeyFromRepository(String username) throws AmbiguousObjectException, Exception { // String revstr = String.format("HEAD:keys/%s.pub", username); // String encoded = gitUtils.show(datasource, revstr); // if (encoded == null) // return null; // // return new AuthorizedKeysDecoder().decodePublicKey(encoded); // } // // } // // Path: server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/MagritCommandFactory.java // @Singleton // public class MagritCommandFactory implements CommandFactory { // // private Iterable<AbstractCommand.CommandProvider<?>> commands; // // @Inject // public MagritCommandFactory(CommandsProvider commandsProvider) { // super(); // this.commands = commandsProvider.get(); // } // // @Override // public Command createCommand(String command) { // if (command == null || command.length() == 0) { // throw new IllegalArgumentException(); // } // try { // for (AbstractCommand.CommandProvider<?> cp : commands) { // if (cp.accept(command)) { // return cp.get().command(command); // } // } // } catch (Exception e) { // return new SyntaxErrorCommand(e); // } // return new SyntaxErrorCommand(new IllegalArgumentException("Unknown command " + command)); // } // // }
import org.apache.sshd.server.CommandFactory; import org.apache.sshd.server.PublickeyAuthenticator; import org.kercoin.magrit.sshd.auth.GitPublickeyAuthenticator; import org.kercoin.magrit.sshd.commands.MagritCommandFactory; import com.google.inject.AbstractModule;
/* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.sshd; /** * @author ptitfred * */ public class SshdModule extends AbstractModule { @Override protected void configure() { bind(PublickeyAuthenticator.class).to(GitPublickeyAuthenticator.class);
// Path: server/sshd/src/main/java/org/kercoin/magrit/sshd/auth/GitPublickeyAuthenticator.java // public class GitPublickeyAuthenticator implements PublickeyAuthenticator { // // private final Context context; // private final GitUtils gitUtils; // // private Repository datasource; // // @Inject // public GitPublickeyAuthenticator(Context context, GitUtils gitUtils) { // this.context = context; // this.gitUtils = gitUtils; // } // // private void open() throws IOException { // if (this.datasource == null) { // this.datasource = Git.open( // context.configuration().getPublickeyRepositoryDir() // ).getRepository(); // } // } // // @Override // public boolean authenticate(String username, PublicKey authKey, // ServerSession session) { // try { // open(); // PublicKey targetKey = readKeyFromRepository(username); // return targetKey != null && areEqual(targetKey, authKey); // } catch (Exception e) { // e.printStackTrace(); // return false; // } // } // // boolean areEqual(PublicKey ref, PublicKey candidate) { // return Arrays.areEqual(ref.getEncoded(), candidate.getEncoded()); // } // // private PublicKey readKeyFromRepository(String username) throws AmbiguousObjectException, Exception { // String revstr = String.format("HEAD:keys/%s.pub", username); // String encoded = gitUtils.show(datasource, revstr); // if (encoded == null) // return null; // // return new AuthorizedKeysDecoder().decodePublicKey(encoded); // } // // } // // Path: server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/MagritCommandFactory.java // @Singleton // public class MagritCommandFactory implements CommandFactory { // // private Iterable<AbstractCommand.CommandProvider<?>> commands; // // @Inject // public MagritCommandFactory(CommandsProvider commandsProvider) { // super(); // this.commands = commandsProvider.get(); // } // // @Override // public Command createCommand(String command) { // if (command == null || command.length() == 0) { // throw new IllegalArgumentException(); // } // try { // for (AbstractCommand.CommandProvider<?> cp : commands) { // if (cp.accept(command)) { // return cp.get().command(command); // } // } // } catch (Exception e) { // return new SyntaxErrorCommand(e); // } // return new SyntaxErrorCommand(new IllegalArgumentException("Unknown command " + command)); // } // // } // Path: server/sshd/src/main/java/org/kercoin/magrit/sshd/SshdModule.java import org.apache.sshd.server.CommandFactory; import org.apache.sshd.server.PublickeyAuthenticator; import org.kercoin.magrit.sshd.auth.GitPublickeyAuthenticator; import org.kercoin.magrit.sshd.commands.MagritCommandFactory; import com.google.inject.AbstractModule; /* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.sshd; /** * @author ptitfred * */ public class SshdModule extends AbstractModule { @Override protected void configure() { bind(PublickeyAuthenticator.class).to(GitPublickeyAuthenticator.class);
bind(CommandFactory.class).to(MagritCommandFactory.class);
ptitfred/magrit
server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/CatBuildCommand.java
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/BuildResult.java // public class BuildResult { // // private final String sha1; // // private boolean success; // // private byte[] log; // // private Date startDate; // private Date endDate; // // private int exitCode; // // public BuildResult(String sha1) { // this.sha1 = sha1; // success = false; // exitCode = -1; // } // // public void setSuccess(boolean success) { // this.success = success; // } // // public void setLog(byte[] log) { // this.log = log; // } // // public void setStartDate(Date startDate) { // this.startDate = startDate; // } // // public void setEndDate(Date endDate) { // this.endDate = endDate; // } // // public long getDuration() { // if (!endDate.after(startDate)) { // throw new IllegalArgumentException("End date is before start date > incoherent!"); // } // return endDate.getTime() - startDate.getTime(); // } // // public boolean isSuccess() { // return success; // } // // public byte[] getLog() { // return log; // } // // public Date getStartDate() { // return startDate; // } // // public Date getEndDate() { // return endDate; // } // // public void setExitCode(int exitCode) { // this.exitCode = exitCode; // } // // public int getExitCode() { // return exitCode; // } // // public String getCommitSha1() { // return sha1; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/dao/BuildDAO.java // public interface BuildDAO { // void save(BuildResult buildResult, Repository repo, String userName, Pair<Long,Integer> when); // BuildResult getLast(Repository repo, String sha1); // List<BuildResult> getAll(Repository repo, String sha1); // }
import java.io.PrintStream; import java.util.Scanner; import org.eclipse.jgit.lib.Repository; import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.build.BuildResult; import org.kercoin.magrit.core.dao.BuildDAO; import com.google.inject.Inject; import com.google.inject.Singleton;
/* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.sshd.commands; public class CatBuildCommand extends AbstractCommand<CatBuildCommand> { @Singleton public static class CatBuildCommandProvider implements CommandProvider<CatBuildCommand> {
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/BuildResult.java // public class BuildResult { // // private final String sha1; // // private boolean success; // // private byte[] log; // // private Date startDate; // private Date endDate; // // private int exitCode; // // public BuildResult(String sha1) { // this.sha1 = sha1; // success = false; // exitCode = -1; // } // // public void setSuccess(boolean success) { // this.success = success; // } // // public void setLog(byte[] log) { // this.log = log; // } // // public void setStartDate(Date startDate) { // this.startDate = startDate; // } // // public void setEndDate(Date endDate) { // this.endDate = endDate; // } // // public long getDuration() { // if (!endDate.after(startDate)) { // throw new IllegalArgumentException("End date is before start date > incoherent!"); // } // return endDate.getTime() - startDate.getTime(); // } // // public boolean isSuccess() { // return success; // } // // public byte[] getLog() { // return log; // } // // public Date getStartDate() { // return startDate; // } // // public Date getEndDate() { // return endDate; // } // // public void setExitCode(int exitCode) { // this.exitCode = exitCode; // } // // public int getExitCode() { // return exitCode; // } // // public String getCommitSha1() { // return sha1; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/dao/BuildDAO.java // public interface BuildDAO { // void save(BuildResult buildResult, Repository repo, String userName, Pair<Long,Integer> when); // BuildResult getLast(Repository repo, String sha1); // List<BuildResult> getAll(Repository repo, String sha1); // } // Path: server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/CatBuildCommand.java import java.io.PrintStream; import java.util.Scanner; import org.eclipse.jgit.lib.Repository; import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.build.BuildResult; import org.kercoin.magrit.core.dao.BuildDAO; import com.google.inject.Inject; import com.google.inject.Singleton; /* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.sshd.commands; public class CatBuildCommand extends AbstractCommand<CatBuildCommand> { @Singleton public static class CatBuildCommandProvider implements CommandProvider<CatBuildCommand> {
private final Context ctx;
ptitfred/magrit
server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/CatBuildCommand.java
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/BuildResult.java // public class BuildResult { // // private final String sha1; // // private boolean success; // // private byte[] log; // // private Date startDate; // private Date endDate; // // private int exitCode; // // public BuildResult(String sha1) { // this.sha1 = sha1; // success = false; // exitCode = -1; // } // // public void setSuccess(boolean success) { // this.success = success; // } // // public void setLog(byte[] log) { // this.log = log; // } // // public void setStartDate(Date startDate) { // this.startDate = startDate; // } // // public void setEndDate(Date endDate) { // this.endDate = endDate; // } // // public long getDuration() { // if (!endDate.after(startDate)) { // throw new IllegalArgumentException("End date is before start date > incoherent!"); // } // return endDate.getTime() - startDate.getTime(); // } // // public boolean isSuccess() { // return success; // } // // public byte[] getLog() { // return log; // } // // public Date getStartDate() { // return startDate; // } // // public Date getEndDate() { // return endDate; // } // // public void setExitCode(int exitCode) { // this.exitCode = exitCode; // } // // public int getExitCode() { // return exitCode; // } // // public String getCommitSha1() { // return sha1; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/dao/BuildDAO.java // public interface BuildDAO { // void save(BuildResult buildResult, Repository repo, String userName, Pair<Long,Integer> when); // BuildResult getLast(Repository repo, String sha1); // List<BuildResult> getAll(Repository repo, String sha1); // }
import java.io.PrintStream; import java.util.Scanner; import org.eclipse.jgit.lib.Repository; import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.build.BuildResult; import org.kercoin.magrit.core.dao.BuildDAO; import com.google.inject.Inject; import com.google.inject.Singleton;
/* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.sshd.commands; public class CatBuildCommand extends AbstractCommand<CatBuildCommand> { @Singleton public static class CatBuildCommandProvider implements CommandProvider<CatBuildCommand> { private final Context ctx;
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/BuildResult.java // public class BuildResult { // // private final String sha1; // // private boolean success; // // private byte[] log; // // private Date startDate; // private Date endDate; // // private int exitCode; // // public BuildResult(String sha1) { // this.sha1 = sha1; // success = false; // exitCode = -1; // } // // public void setSuccess(boolean success) { // this.success = success; // } // // public void setLog(byte[] log) { // this.log = log; // } // // public void setStartDate(Date startDate) { // this.startDate = startDate; // } // // public void setEndDate(Date endDate) { // this.endDate = endDate; // } // // public long getDuration() { // if (!endDate.after(startDate)) { // throw new IllegalArgumentException("End date is before start date > incoherent!"); // } // return endDate.getTime() - startDate.getTime(); // } // // public boolean isSuccess() { // return success; // } // // public byte[] getLog() { // return log; // } // // public Date getStartDate() { // return startDate; // } // // public Date getEndDate() { // return endDate; // } // // public void setExitCode(int exitCode) { // this.exitCode = exitCode; // } // // public int getExitCode() { // return exitCode; // } // // public String getCommitSha1() { // return sha1; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/dao/BuildDAO.java // public interface BuildDAO { // void save(BuildResult buildResult, Repository repo, String userName, Pair<Long,Integer> when); // BuildResult getLast(Repository repo, String sha1); // List<BuildResult> getAll(Repository repo, String sha1); // } // Path: server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/CatBuildCommand.java import java.io.PrintStream; import java.util.Scanner; import org.eclipse.jgit.lib.Repository; import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.build.BuildResult; import org.kercoin.magrit.core.dao.BuildDAO; import com.google.inject.Inject; import com.google.inject.Singleton; /* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.sshd.commands; public class CatBuildCommand extends AbstractCommand<CatBuildCommand> { @Singleton public static class CatBuildCommandProvider implements CommandProvider<CatBuildCommand> { private final Context ctx;
private final BuildDAO dao;
ptitfred/magrit
server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/CatBuildCommand.java
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/BuildResult.java // public class BuildResult { // // private final String sha1; // // private boolean success; // // private byte[] log; // // private Date startDate; // private Date endDate; // // private int exitCode; // // public BuildResult(String sha1) { // this.sha1 = sha1; // success = false; // exitCode = -1; // } // // public void setSuccess(boolean success) { // this.success = success; // } // // public void setLog(byte[] log) { // this.log = log; // } // // public void setStartDate(Date startDate) { // this.startDate = startDate; // } // // public void setEndDate(Date endDate) { // this.endDate = endDate; // } // // public long getDuration() { // if (!endDate.after(startDate)) { // throw new IllegalArgumentException("End date is before start date > incoherent!"); // } // return endDate.getTime() - startDate.getTime(); // } // // public boolean isSuccess() { // return success; // } // // public byte[] getLog() { // return log; // } // // public Date getStartDate() { // return startDate; // } // // public Date getEndDate() { // return endDate; // } // // public void setExitCode(int exitCode) { // this.exitCode = exitCode; // } // // public int getExitCode() { // return exitCode; // } // // public String getCommitSha1() { // return sha1; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/dao/BuildDAO.java // public interface BuildDAO { // void save(BuildResult buildResult, Repository repo, String userName, Pair<Long,Integer> when); // BuildResult getLast(Repository repo, String sha1); // List<BuildResult> getAll(Repository repo, String sha1); // }
import java.io.PrintStream; import java.util.Scanner; import org.eclipse.jgit.lib.Repository; import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.build.BuildResult; import org.kercoin.magrit.core.dao.BuildDAO; import com.google.inject.Inject; import com.google.inject.Singleton;
@Override protected Class<CatBuildCommand> getType() { return CatBuildCommand.class; } String getSha1() { return sha1; } Repository getRepository() { return repository; } @Override public CatBuildCommand command(String command) throws Exception { // magrit cat-build SHA1 Scanner s = new Scanner(command); s.useDelimiter("\\s{1,}"); check(s.next(), "magrit"); check(s.next(), "cat-build"); check(command, s.hasNext()); this.repository = createRepository(s.next()); check(command, s.hasNext()); checkSha1(sha1 = s.next()); return this; } @Override public void run() { PrintStream pOut =null; try {
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/BuildResult.java // public class BuildResult { // // private final String sha1; // // private boolean success; // // private byte[] log; // // private Date startDate; // private Date endDate; // // private int exitCode; // // public BuildResult(String sha1) { // this.sha1 = sha1; // success = false; // exitCode = -1; // } // // public void setSuccess(boolean success) { // this.success = success; // } // // public void setLog(byte[] log) { // this.log = log; // } // // public void setStartDate(Date startDate) { // this.startDate = startDate; // } // // public void setEndDate(Date endDate) { // this.endDate = endDate; // } // // public long getDuration() { // if (!endDate.after(startDate)) { // throw new IllegalArgumentException("End date is before start date > incoherent!"); // } // return endDate.getTime() - startDate.getTime(); // } // // public boolean isSuccess() { // return success; // } // // public byte[] getLog() { // return log; // } // // public Date getStartDate() { // return startDate; // } // // public Date getEndDate() { // return endDate; // } // // public void setExitCode(int exitCode) { // this.exitCode = exitCode; // } // // public int getExitCode() { // return exitCode; // } // // public String getCommitSha1() { // return sha1; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/dao/BuildDAO.java // public interface BuildDAO { // void save(BuildResult buildResult, Repository repo, String userName, Pair<Long,Integer> when); // BuildResult getLast(Repository repo, String sha1); // List<BuildResult> getAll(Repository repo, String sha1); // } // Path: server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/CatBuildCommand.java import java.io.PrintStream; import java.util.Scanner; import org.eclipse.jgit.lib.Repository; import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.build.BuildResult; import org.kercoin.magrit.core.dao.BuildDAO; import com.google.inject.Inject; import com.google.inject.Singleton; @Override protected Class<CatBuildCommand> getType() { return CatBuildCommand.class; } String getSha1() { return sha1; } Repository getRepository() { return repository; } @Override public CatBuildCommand command(String command) throws Exception { // magrit cat-build SHA1 Scanner s = new Scanner(command); s.useDelimiter("\\s{1,}"); check(s.next(), "magrit"); check(s.next(), "cat-build"); check(command, s.hasNext()); this.repository = createRepository(s.next()); check(command, s.hasNext()); checkSha1(sha1 = s.next()); return this; } @Override public void run() { PrintStream pOut =null; try {
BuildResult last = dao.getLast(repository, sha1);
ptitfred/magrit
server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/SendBuildCommand.java
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/QueueService.java // @ImplementedBy(QueueServiceImpl.class) // public interface QueueService { // Future<BuildResult> enqueueBuild(UserIdentity committer, Repository repository, // String sha1, String command, boolean force) throws Exception; // // void addCallback(BuildLifeCycleListener callback); // // void removeCallback(BuildLifeCycleListener callback); // // Collection<Pair<Repository, String>> getScheduledTasks(); // Collection<Pair<Repository, String>> getCurrentTasks(); // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/user/UserIdentity.java // public class UserIdentity { // private final String email; // private final String name; // private final String toString; // // public UserIdentity(String email, String name) { // super(); // this.email = email; // this.name = name; // this.toString = String.format("\"%s\" <%s>", name, email); // } // // public String getEmail() { // return email; // } // // public String getName() { // return name; // } // // @Override // public String toString() { // return toString; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result // + ((toString == null) ? 0 : toString.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // UserIdentity other = (UserIdentity) obj; // if (toString == null) { // if (other.toString != null) // return false; // } else if (!toString.equals(other.toString)) // return false; // return true; // } // // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/user/UserIdentityService.java // @ImplementedBy(UserIdentityServiceImpl.class) // public interface UserIdentityService { // UserIdentity find(String login) throws AccessControlException; // }
import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.build.QueueService; import org.kercoin.magrit.core.user.UserIdentity; import org.kercoin.magrit.core.user.UserIdentityService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.security.AccessControlException; import java.util.Scanner; import org.apache.sshd.server.Environment; import org.eclipse.jgit.errors.AmbiguousObjectException; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Repository;
/* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.sshd.commands; public class SendBuildCommand extends AbstractCommand<SendBuildCommand> { protected final Logger log = LoggerFactory.getLogger(getClass()); @Singleton public static class SendBuildCommandProvider implements CommandProvider<SendBuildCommand> {
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/QueueService.java // @ImplementedBy(QueueServiceImpl.class) // public interface QueueService { // Future<BuildResult> enqueueBuild(UserIdentity committer, Repository repository, // String sha1, String command, boolean force) throws Exception; // // void addCallback(BuildLifeCycleListener callback); // // void removeCallback(BuildLifeCycleListener callback); // // Collection<Pair<Repository, String>> getScheduledTasks(); // Collection<Pair<Repository, String>> getCurrentTasks(); // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/user/UserIdentity.java // public class UserIdentity { // private final String email; // private final String name; // private final String toString; // // public UserIdentity(String email, String name) { // super(); // this.email = email; // this.name = name; // this.toString = String.format("\"%s\" <%s>", name, email); // } // // public String getEmail() { // return email; // } // // public String getName() { // return name; // } // // @Override // public String toString() { // return toString; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result // + ((toString == null) ? 0 : toString.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // UserIdentity other = (UserIdentity) obj; // if (toString == null) { // if (other.toString != null) // return false; // } else if (!toString.equals(other.toString)) // return false; // return true; // } // // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/user/UserIdentityService.java // @ImplementedBy(UserIdentityServiceImpl.class) // public interface UserIdentityService { // UserIdentity find(String login) throws AccessControlException; // } // Path: server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/SendBuildCommand.java import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.build.QueueService; import org.kercoin.magrit.core.user.UserIdentity; import org.kercoin.magrit.core.user.UserIdentityService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.security.AccessControlException; import java.util.Scanner; import org.apache.sshd.server.Environment; import org.eclipse.jgit.errors.AmbiguousObjectException; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Repository; /* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.sshd.commands; public class SendBuildCommand extends AbstractCommand<SendBuildCommand> { protected final Logger log = LoggerFactory.getLogger(getClass()); @Singleton public static class SendBuildCommandProvider implements CommandProvider<SendBuildCommand> {
private final Context ctx;
ptitfred/magrit
server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/SendBuildCommand.java
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/QueueService.java // @ImplementedBy(QueueServiceImpl.class) // public interface QueueService { // Future<BuildResult> enqueueBuild(UserIdentity committer, Repository repository, // String sha1, String command, boolean force) throws Exception; // // void addCallback(BuildLifeCycleListener callback); // // void removeCallback(BuildLifeCycleListener callback); // // Collection<Pair<Repository, String>> getScheduledTasks(); // Collection<Pair<Repository, String>> getCurrentTasks(); // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/user/UserIdentity.java // public class UserIdentity { // private final String email; // private final String name; // private final String toString; // // public UserIdentity(String email, String name) { // super(); // this.email = email; // this.name = name; // this.toString = String.format("\"%s\" <%s>", name, email); // } // // public String getEmail() { // return email; // } // // public String getName() { // return name; // } // // @Override // public String toString() { // return toString; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result // + ((toString == null) ? 0 : toString.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // UserIdentity other = (UserIdentity) obj; // if (toString == null) { // if (other.toString != null) // return false; // } else if (!toString.equals(other.toString)) // return false; // return true; // } // // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/user/UserIdentityService.java // @ImplementedBy(UserIdentityServiceImpl.class) // public interface UserIdentityService { // UserIdentity find(String login) throws AccessControlException; // }
import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.build.QueueService; import org.kercoin.magrit.core.user.UserIdentity; import org.kercoin.magrit.core.user.UserIdentityService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.security.AccessControlException; import java.util.Scanner; import org.apache.sshd.server.Environment; import org.eclipse.jgit.errors.AmbiguousObjectException; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Repository;
/* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.sshd.commands; public class SendBuildCommand extends AbstractCommand<SendBuildCommand> { protected final Logger log = LoggerFactory.getLogger(getClass()); @Singleton public static class SendBuildCommandProvider implements CommandProvider<SendBuildCommand> { private final Context ctx;
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/QueueService.java // @ImplementedBy(QueueServiceImpl.class) // public interface QueueService { // Future<BuildResult> enqueueBuild(UserIdentity committer, Repository repository, // String sha1, String command, boolean force) throws Exception; // // void addCallback(BuildLifeCycleListener callback); // // void removeCallback(BuildLifeCycleListener callback); // // Collection<Pair<Repository, String>> getScheduledTasks(); // Collection<Pair<Repository, String>> getCurrentTasks(); // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/user/UserIdentity.java // public class UserIdentity { // private final String email; // private final String name; // private final String toString; // // public UserIdentity(String email, String name) { // super(); // this.email = email; // this.name = name; // this.toString = String.format("\"%s\" <%s>", name, email); // } // // public String getEmail() { // return email; // } // // public String getName() { // return name; // } // // @Override // public String toString() { // return toString; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result // + ((toString == null) ? 0 : toString.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // UserIdentity other = (UserIdentity) obj; // if (toString == null) { // if (other.toString != null) // return false; // } else if (!toString.equals(other.toString)) // return false; // return true; // } // // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/user/UserIdentityService.java // @ImplementedBy(UserIdentityServiceImpl.class) // public interface UserIdentityService { // UserIdentity find(String login) throws AccessControlException; // } // Path: server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/SendBuildCommand.java import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.build.QueueService; import org.kercoin.magrit.core.user.UserIdentity; import org.kercoin.magrit.core.user.UserIdentityService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.security.AccessControlException; import java.util.Scanner; import org.apache.sshd.server.Environment; import org.eclipse.jgit.errors.AmbiguousObjectException; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Repository; /* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.sshd.commands; public class SendBuildCommand extends AbstractCommand<SendBuildCommand> { protected final Logger log = LoggerFactory.getLogger(getClass()); @Singleton public static class SendBuildCommandProvider implements CommandProvider<SendBuildCommand> { private final Context ctx;
private final QueueService buildQueueService;
ptitfred/magrit
server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/SendBuildCommand.java
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/QueueService.java // @ImplementedBy(QueueServiceImpl.class) // public interface QueueService { // Future<BuildResult> enqueueBuild(UserIdentity committer, Repository repository, // String sha1, String command, boolean force) throws Exception; // // void addCallback(BuildLifeCycleListener callback); // // void removeCallback(BuildLifeCycleListener callback); // // Collection<Pair<Repository, String>> getScheduledTasks(); // Collection<Pair<Repository, String>> getCurrentTasks(); // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/user/UserIdentity.java // public class UserIdentity { // private final String email; // private final String name; // private final String toString; // // public UserIdentity(String email, String name) { // super(); // this.email = email; // this.name = name; // this.toString = String.format("\"%s\" <%s>", name, email); // } // // public String getEmail() { // return email; // } // // public String getName() { // return name; // } // // @Override // public String toString() { // return toString; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result // + ((toString == null) ? 0 : toString.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // UserIdentity other = (UserIdentity) obj; // if (toString == null) { // if (other.toString != null) // return false; // } else if (!toString.equals(other.toString)) // return false; // return true; // } // // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/user/UserIdentityService.java // @ImplementedBy(UserIdentityServiceImpl.class) // public interface UserIdentityService { // UserIdentity find(String login) throws AccessControlException; // }
import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.build.QueueService; import org.kercoin.magrit.core.user.UserIdentity; import org.kercoin.magrit.core.user.UserIdentityService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.security.AccessControlException; import java.util.Scanner; import org.apache.sshd.server.Environment; import org.eclipse.jgit.errors.AmbiguousObjectException; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Repository;
/* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.sshd.commands; public class SendBuildCommand extends AbstractCommand<SendBuildCommand> { protected final Logger log = LoggerFactory.getLogger(getClass()); @Singleton public static class SendBuildCommandProvider implements CommandProvider<SendBuildCommand> { private final Context ctx; private final QueueService buildQueueService;
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/QueueService.java // @ImplementedBy(QueueServiceImpl.class) // public interface QueueService { // Future<BuildResult> enqueueBuild(UserIdentity committer, Repository repository, // String sha1, String command, boolean force) throws Exception; // // void addCallback(BuildLifeCycleListener callback); // // void removeCallback(BuildLifeCycleListener callback); // // Collection<Pair<Repository, String>> getScheduledTasks(); // Collection<Pair<Repository, String>> getCurrentTasks(); // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/user/UserIdentity.java // public class UserIdentity { // private final String email; // private final String name; // private final String toString; // // public UserIdentity(String email, String name) { // super(); // this.email = email; // this.name = name; // this.toString = String.format("\"%s\" <%s>", name, email); // } // // public String getEmail() { // return email; // } // // public String getName() { // return name; // } // // @Override // public String toString() { // return toString; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result // + ((toString == null) ? 0 : toString.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // UserIdentity other = (UserIdentity) obj; // if (toString == null) { // if (other.toString != null) // return false; // } else if (!toString.equals(other.toString)) // return false; // return true; // } // // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/user/UserIdentityService.java // @ImplementedBy(UserIdentityServiceImpl.class) // public interface UserIdentityService { // UserIdentity find(String login) throws AccessControlException; // } // Path: server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/SendBuildCommand.java import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.build.QueueService; import org.kercoin.magrit.core.user.UserIdentity; import org.kercoin.magrit.core.user.UserIdentityService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.security.AccessControlException; import java.util.Scanner; import org.apache.sshd.server.Environment; import org.eclipse.jgit.errors.AmbiguousObjectException; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Repository; /* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.sshd.commands; public class SendBuildCommand extends AbstractCommand<SendBuildCommand> { protected final Logger log = LoggerFactory.getLogger(getClass()); @Singleton public static class SendBuildCommandProvider implements CommandProvider<SendBuildCommand> { private final Context ctx; private final QueueService buildQueueService;
private final UserIdentityService userService;
ptitfred/magrit
server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/SendBuildCommand.java
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/QueueService.java // @ImplementedBy(QueueServiceImpl.class) // public interface QueueService { // Future<BuildResult> enqueueBuild(UserIdentity committer, Repository repository, // String sha1, String command, boolean force) throws Exception; // // void addCallback(BuildLifeCycleListener callback); // // void removeCallback(BuildLifeCycleListener callback); // // Collection<Pair<Repository, String>> getScheduledTasks(); // Collection<Pair<Repository, String>> getCurrentTasks(); // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/user/UserIdentity.java // public class UserIdentity { // private final String email; // private final String name; // private final String toString; // // public UserIdentity(String email, String name) { // super(); // this.email = email; // this.name = name; // this.toString = String.format("\"%s\" <%s>", name, email); // } // // public String getEmail() { // return email; // } // // public String getName() { // return name; // } // // @Override // public String toString() { // return toString; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result // + ((toString == null) ? 0 : toString.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // UserIdentity other = (UserIdentity) obj; // if (toString == null) { // if (other.toString != null) // return false; // } else if (!toString.equals(other.toString)) // return false; // return true; // } // // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/user/UserIdentityService.java // @ImplementedBy(UserIdentityServiceImpl.class) // public interface UserIdentityService { // UserIdentity find(String login) throws AccessControlException; // }
import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.build.QueueService; import org.kercoin.magrit.core.user.UserIdentity; import org.kercoin.magrit.core.user.UserIdentityService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.security.AccessControlException; import java.util.Scanner; import org.apache.sshd.server.Environment; import org.eclipse.jgit.errors.AmbiguousObjectException; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Repository;
/* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.sshd.commands; public class SendBuildCommand extends AbstractCommand<SendBuildCommand> { protected final Logger log = LoggerFactory.getLogger(getClass()); @Singleton public static class SendBuildCommandProvider implements CommandProvider<SendBuildCommand> { private final Context ctx; private final QueueService buildQueueService; private final UserIdentityService userService; @Inject public SendBuildCommandProvider(Context ctx, QueueService buildQueueService, UserIdentityService userService) { this.ctx = ctx; this.buildQueueService = buildQueueService; this.userService = userService; } @Override public SendBuildCommand get() { return new SendBuildCommand(ctx, buildQueueService, userService); } @Override public boolean accept(String command) { return command.startsWith("magrit send-build "); } } private final QueueService buildQueueService; private final UserIdentityService userService;
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/QueueService.java // @ImplementedBy(QueueServiceImpl.class) // public interface QueueService { // Future<BuildResult> enqueueBuild(UserIdentity committer, Repository repository, // String sha1, String command, boolean force) throws Exception; // // void addCallback(BuildLifeCycleListener callback); // // void removeCallback(BuildLifeCycleListener callback); // // Collection<Pair<Repository, String>> getScheduledTasks(); // Collection<Pair<Repository, String>> getCurrentTasks(); // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/user/UserIdentity.java // public class UserIdentity { // private final String email; // private final String name; // private final String toString; // // public UserIdentity(String email, String name) { // super(); // this.email = email; // this.name = name; // this.toString = String.format("\"%s\" <%s>", name, email); // } // // public String getEmail() { // return email; // } // // public String getName() { // return name; // } // // @Override // public String toString() { // return toString; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result // + ((toString == null) ? 0 : toString.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // UserIdentity other = (UserIdentity) obj; // if (toString == null) { // if (other.toString != null) // return false; // } else if (!toString.equals(other.toString)) // return false; // return true; // } // // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/user/UserIdentityService.java // @ImplementedBy(UserIdentityServiceImpl.class) // public interface UserIdentityService { // UserIdentity find(String login) throws AccessControlException; // } // Path: server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/SendBuildCommand.java import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.build.QueueService; import org.kercoin.magrit.core.user.UserIdentity; import org.kercoin.magrit.core.user.UserIdentityService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.security.AccessControlException; import java.util.Scanner; import org.apache.sshd.server.Environment; import org.eclipse.jgit.errors.AmbiguousObjectException; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Repository; /* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.sshd.commands; public class SendBuildCommand extends AbstractCommand<SendBuildCommand> { protected final Logger log = LoggerFactory.getLogger(getClass()); @Singleton public static class SendBuildCommandProvider implements CommandProvider<SendBuildCommand> { private final Context ctx; private final QueueService buildQueueService; private final UserIdentityService userService; @Inject public SendBuildCommandProvider(Context ctx, QueueService buildQueueService, UserIdentityService userService) { this.ctx = ctx; this.buildQueueService = buildQueueService; this.userService = userService; } @Override public SendBuildCommand get() { return new SendBuildCommand(ctx, buildQueueService, userService); } @Override public boolean accept(String command) { return command.startsWith("magrit send-build "); } } private final QueueService buildQueueService; private final UserIdentityService userService;
private UserIdentity committer;
ptitfred/magrit
server/sshd/src/test/java/org/kercoin/magrit/sshd/auth/AuthorizedKeysDecoderTest.java
// Path: server/sshd/src/main/java/org/kercoin/magrit/sshd/auth/AuthorizedKeysDecoder.java // public class AuthorizedKeysDecoder { // // private byte[] bytes; // private int pos; // // public PublicKey decodePublicKey(String keyLine) throws Exception { // bytes = null; // pos = 0; // // // look for the Base64 encoded part of the line to decode // // both ssh-rsa and ssh-dss begin with "AAAA" due to the length bytes // for (String part : keyLine.split(" ")) { // if (part.startsWith("AAAA")) { // bytes = Base64.decodeBase64(part); // break; // } // } // if (bytes == null) { // throw new IllegalArgumentException("no Base64 part to decode"); // } // // String type = decodeType(); // if (type.equals("ssh-rsa")) { // BigInteger e = decodeBigInt(); // BigInteger m = decodeBigInt(); // RSAPublicKeySpec spec = new RSAPublicKeySpec(m, e); // return KeyFactory.getInstance("RSA").generatePublic(spec); // } else if (type.equals("ssh-dss")) { // BigInteger p = decodeBigInt(); // BigInteger q = decodeBigInt(); // BigInteger g = decodeBigInt(); // BigInteger y = decodeBigInt(); // DSAPublicKeySpec spec = new DSAPublicKeySpec(y, p, q, g); // return KeyFactory.getInstance("DSA").generatePublic(spec); // } else { // throw new IllegalArgumentException("unknown type " + type); // } // } // // private String decodeType() { // int len = decodeInt(); // String type = new String(bytes, pos, len); // pos += len; // return type; // } // // private int decodeInt() { // return ((bytes[pos++] & 0xFF) << 24) | ((bytes[pos++] & 0xFF) << 16) // | ((bytes[pos++] & 0xFF) << 8) | (bytes[pos++] & 0xFF); // } // // private BigInteger decodeBigInt() { // int len = decodeInt(); // byte[] bigIntBytes = new byte[len]; // System.arraycopy(bytes, pos, bigIntBytes, 0, len); // pos += len; // return new BigInteger(bigIntBytes); // } // // } // // Path: server/core/src/test/java/tests/FilesUtils.java // public class FilesUtils { // // public static String tail(File file, int lines) { // String[] linesBuffer = new String[lines]; // int pos = 0; // BufferedReader br = null; // try { // br = new BufferedReader(new InputStreamReader(new FileInputStream(file))); // String buffer; // while ((buffer = br.readLine())!=null) { // linesBuffer[pos++] = buffer; // if (pos == lines) { // pos=0; // } // } // } catch (IOException e) { // e.printStackTrace(); // } finally { // if (br!=null) { // try { // br.close(); // } catch (IOException e) { // e.printStackTrace(); // } // } // } // StringBuffer accu = new StringBuffer(); // for (int i=pos; i<pos+lines; i++) { // accu.append(linesBuffer[i%lines]).append('\n'); // } // return accu.toString(); // } // // public static String readFile(File file) throws FileNotFoundException { // return readStream(new FileInputStream(file)); // } // // public static String readStream(InputStream in) { // StringBuffer sb = new StringBuffer(); // String buffer = null; // BufferedReader br = null; // try { // br = new BufferedReader(new InputStreamReader(in)); // while ((buffer = br.readLine())!=null) { // sb.append(buffer).append('\n'); // } // } catch (IOException e) { // return null; // } finally { // if (br != null) { // try { // br.close(); // } catch (IOException e) {} // } // } // return sb.toString(); // } // // public static void recursiveDelete(File path) { // try { // FileUtils.delete(path, FileUtils.RECURSIVE); // } catch (IOException e) { // e.printStackTrace(); // } // } // }
import static org.fest.assertions.Assertions.assertThat; import java.security.PublicKey; import org.junit.Before; import org.junit.Test; import org.kercoin.magrit.sshd.auth.AuthorizedKeysDecoder; import tests.FilesUtils;
/* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.sshd.auth; public class AuthorizedKeysDecoderTest { AuthorizedKeysDecoder decoder; @Before public void setUp() throws Exception { decoder = new AuthorizedKeysDecoder(); } @Test public void testDecodePublicKey_dsa() throws Exception { // given
// Path: server/sshd/src/main/java/org/kercoin/magrit/sshd/auth/AuthorizedKeysDecoder.java // public class AuthorizedKeysDecoder { // // private byte[] bytes; // private int pos; // // public PublicKey decodePublicKey(String keyLine) throws Exception { // bytes = null; // pos = 0; // // // look for the Base64 encoded part of the line to decode // // both ssh-rsa and ssh-dss begin with "AAAA" due to the length bytes // for (String part : keyLine.split(" ")) { // if (part.startsWith("AAAA")) { // bytes = Base64.decodeBase64(part); // break; // } // } // if (bytes == null) { // throw new IllegalArgumentException("no Base64 part to decode"); // } // // String type = decodeType(); // if (type.equals("ssh-rsa")) { // BigInteger e = decodeBigInt(); // BigInteger m = decodeBigInt(); // RSAPublicKeySpec spec = new RSAPublicKeySpec(m, e); // return KeyFactory.getInstance("RSA").generatePublic(spec); // } else if (type.equals("ssh-dss")) { // BigInteger p = decodeBigInt(); // BigInteger q = decodeBigInt(); // BigInteger g = decodeBigInt(); // BigInteger y = decodeBigInt(); // DSAPublicKeySpec spec = new DSAPublicKeySpec(y, p, q, g); // return KeyFactory.getInstance("DSA").generatePublic(spec); // } else { // throw new IllegalArgumentException("unknown type " + type); // } // } // // private String decodeType() { // int len = decodeInt(); // String type = new String(bytes, pos, len); // pos += len; // return type; // } // // private int decodeInt() { // return ((bytes[pos++] & 0xFF) << 24) | ((bytes[pos++] & 0xFF) << 16) // | ((bytes[pos++] & 0xFF) << 8) | (bytes[pos++] & 0xFF); // } // // private BigInteger decodeBigInt() { // int len = decodeInt(); // byte[] bigIntBytes = new byte[len]; // System.arraycopy(bytes, pos, bigIntBytes, 0, len); // pos += len; // return new BigInteger(bigIntBytes); // } // // } // // Path: server/core/src/test/java/tests/FilesUtils.java // public class FilesUtils { // // public static String tail(File file, int lines) { // String[] linesBuffer = new String[lines]; // int pos = 0; // BufferedReader br = null; // try { // br = new BufferedReader(new InputStreamReader(new FileInputStream(file))); // String buffer; // while ((buffer = br.readLine())!=null) { // linesBuffer[pos++] = buffer; // if (pos == lines) { // pos=0; // } // } // } catch (IOException e) { // e.printStackTrace(); // } finally { // if (br!=null) { // try { // br.close(); // } catch (IOException e) { // e.printStackTrace(); // } // } // } // StringBuffer accu = new StringBuffer(); // for (int i=pos; i<pos+lines; i++) { // accu.append(linesBuffer[i%lines]).append('\n'); // } // return accu.toString(); // } // // public static String readFile(File file) throws FileNotFoundException { // return readStream(new FileInputStream(file)); // } // // public static String readStream(InputStream in) { // StringBuffer sb = new StringBuffer(); // String buffer = null; // BufferedReader br = null; // try { // br = new BufferedReader(new InputStreamReader(in)); // while ((buffer = br.readLine())!=null) { // sb.append(buffer).append('\n'); // } // } catch (IOException e) { // return null; // } finally { // if (br != null) { // try { // br.close(); // } catch (IOException e) {} // } // } // return sb.toString(); // } // // public static void recursiveDelete(File path) { // try { // FileUtils.delete(path, FileUtils.RECURSIVE); // } catch (IOException e) { // e.printStackTrace(); // } // } // } // Path: server/sshd/src/test/java/org/kercoin/magrit/sshd/auth/AuthorizedKeysDecoderTest.java import static org.fest.assertions.Assertions.assertThat; import java.security.PublicKey; import org.junit.Before; import org.junit.Test; import org.kercoin.magrit.sshd.auth.AuthorizedKeysDecoder; import tests.FilesUtils; /* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.sshd.auth; public class AuthorizedKeysDecoderTest { AuthorizedKeysDecoder decoder; @Before public void setUp() throws Exception { decoder = new AuthorizedKeysDecoder(); } @Test public void testDecodePublicKey_dsa() throws Exception { // given
String encoded = FilesUtils.readStream(getClass().getClassLoader()
ptitfred/magrit
server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/PingCommand.java
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // }
import org.kercoin.magrit.core.Context; import com.google.inject.Inject;
/* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.sshd.commands; public class PingCommand extends AbstractCommand<PingCommand> { public static class PingCommandProvider implements CommandProvider<PingCommand> {
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // Path: server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/PingCommand.java import org.kercoin.magrit.core.Context; import com.google.inject.Inject; /* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.sshd.commands; public class PingCommand extends AbstractCommand<PingCommand> { public static class PingCommandProvider implements CommandProvider<PingCommand> {
private Context ctx;
ptitfred/magrit
server/core/src/test/java/org/kercoin/magrit/core/ContextTest.java
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/test/java/tests/GuiceModulesHolder.java // public class GuiceModulesHolder { // public static final Injector MAGRIT_MODULE; // static { // MAGRIT_MODULE = Guice.createInjector(new CoreModule()); // } // // }
import org.kercoin.magrit.core.Context; import tests.GuiceModulesHolder; import static org.fest.assertions.Assertions.assertThat; import org.junit.Test;
/* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.core; public class ContextTest { @Test public void testInjection() throws Exception { // when ----------------------------------
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/test/java/tests/GuiceModulesHolder.java // public class GuiceModulesHolder { // public static final Injector MAGRIT_MODULE; // static { // MAGRIT_MODULE = Guice.createInjector(new CoreModule()); // } // // } // Path: server/core/src/test/java/org/kercoin/magrit/core/ContextTest.java import org.kercoin.magrit.core.Context; import tests.GuiceModulesHolder; import static org.fest.assertions.Assertions.assertThat; import org.junit.Test; /* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.core; public class ContextTest { @Test public void testInjection() throws Exception { // when ----------------------------------
Context context = GuiceModulesHolder.MAGRIT_MODULE.getInstance(Context.class);
ptitfred/magrit
server/core/src/test/java/org/kercoin/magrit/core/ContextTest.java
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/test/java/tests/GuiceModulesHolder.java // public class GuiceModulesHolder { // public static final Injector MAGRIT_MODULE; // static { // MAGRIT_MODULE = Guice.createInjector(new CoreModule()); // } // // }
import org.kercoin.magrit.core.Context; import tests.GuiceModulesHolder; import static org.fest.assertions.Assertions.assertThat; import org.junit.Test;
/* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.core; public class ContextTest { @Test public void testInjection() throws Exception { // when ----------------------------------
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/test/java/tests/GuiceModulesHolder.java // public class GuiceModulesHolder { // public static final Injector MAGRIT_MODULE; // static { // MAGRIT_MODULE = Guice.createInjector(new CoreModule()); // } // // } // Path: server/core/src/test/java/org/kercoin/magrit/core/ContextTest.java import org.kercoin.magrit.core.Context; import tests.GuiceModulesHolder; import static org.fest.assertions.Assertions.assertThat; import org.junit.Test; /* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.core; public class ContextTest { @Test public void testInjection() throws Exception { // when ----------------------------------
Context context = GuiceModulesHolder.MAGRIT_MODULE.getInstance(Context.class);
ptitfred/magrit
server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/GetStatusCommand.java
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/Status.java // public enum Status { // RUNNING('R'), // PENDING('P'), // ERROR('E'), // OK('O'), // INTERRUPTED('I'), // LOCAL('L'), // NEW('N'), // UNKNOWN('?'); // // private char code; // // private Status(char code) { this.code = code; } // // public char getCode() { // return code; // } // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/StatusesService.java // @ImplementedBy(StatusesServiceImpl.class) // public interface StatusesService { // List<Status> getStatus(Repository repository, String sha1); // }
import org.slf4j.LoggerFactory; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.List; import org.eclipse.jgit.lib.Repository; import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.build.Status; import org.kercoin.magrit.core.build.StatusesService; import org.slf4j.Logger;
/* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.sshd.commands; public class GetStatusCommand extends AbstractCommand<GetStatusCommand> { protected final Logger log = LoggerFactory.getLogger(getClass()); @Singleton public static class GetStatusCommandProvider implements CommandProvider<GetStatusCommand> {
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/Status.java // public enum Status { // RUNNING('R'), // PENDING('P'), // ERROR('E'), // OK('O'), // INTERRUPTED('I'), // LOCAL('L'), // NEW('N'), // UNKNOWN('?'); // // private char code; // // private Status(char code) { this.code = code; } // // public char getCode() { // return code; // } // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/StatusesService.java // @ImplementedBy(StatusesServiceImpl.class) // public interface StatusesService { // List<Status> getStatus(Repository repository, String sha1); // } // Path: server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/GetStatusCommand.java import org.slf4j.LoggerFactory; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.List; import org.eclipse.jgit.lib.Repository; import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.build.Status; import org.kercoin.magrit.core.build.StatusesService; import org.slf4j.Logger; /* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.sshd.commands; public class GetStatusCommand extends AbstractCommand<GetStatusCommand> { protected final Logger log = LoggerFactory.getLogger(getClass()); @Singleton public static class GetStatusCommandProvider implements CommandProvider<GetStatusCommand> {
private Context ctx;
ptitfred/magrit
server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/GetStatusCommand.java
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/Status.java // public enum Status { // RUNNING('R'), // PENDING('P'), // ERROR('E'), // OK('O'), // INTERRUPTED('I'), // LOCAL('L'), // NEW('N'), // UNKNOWN('?'); // // private char code; // // private Status(char code) { this.code = code; } // // public char getCode() { // return code; // } // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/StatusesService.java // @ImplementedBy(StatusesServiceImpl.class) // public interface StatusesService { // List<Status> getStatus(Repository repository, String sha1); // }
import org.slf4j.LoggerFactory; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.List; import org.eclipse.jgit.lib.Repository; import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.build.Status; import org.kercoin.magrit.core.build.StatusesService; import org.slf4j.Logger;
/* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.sshd.commands; public class GetStatusCommand extends AbstractCommand<GetStatusCommand> { protected final Logger log = LoggerFactory.getLogger(getClass()); @Singleton public static class GetStatusCommandProvider implements CommandProvider<GetStatusCommand> { private Context ctx;
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/Status.java // public enum Status { // RUNNING('R'), // PENDING('P'), // ERROR('E'), // OK('O'), // INTERRUPTED('I'), // LOCAL('L'), // NEW('N'), // UNKNOWN('?'); // // private char code; // // private Status(char code) { this.code = code; } // // public char getCode() { // return code; // } // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/StatusesService.java // @ImplementedBy(StatusesServiceImpl.class) // public interface StatusesService { // List<Status> getStatus(Repository repository, String sha1); // } // Path: server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/GetStatusCommand.java import org.slf4j.LoggerFactory; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.List; import org.eclipse.jgit.lib.Repository; import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.build.Status; import org.kercoin.magrit.core.build.StatusesService; import org.slf4j.Logger; /* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.sshd.commands; public class GetStatusCommand extends AbstractCommand<GetStatusCommand> { protected final Logger log = LoggerFactory.getLogger(getClass()); @Singleton public static class GetStatusCommandProvider implements CommandProvider<GetStatusCommand> { private Context ctx;
private StatusesService buildStatusesService;
ptitfred/magrit
server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/GetStatusCommand.java
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/Status.java // public enum Status { // RUNNING('R'), // PENDING('P'), // ERROR('E'), // OK('O'), // INTERRUPTED('I'), // LOCAL('L'), // NEW('N'), // UNKNOWN('?'); // // private char code; // // private Status(char code) { this.code = code; } // // public char getCode() { // return code; // } // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/StatusesService.java // @ImplementedBy(StatusesServiceImpl.class) // public interface StatusesService { // List<Status> getStatus(Repository repository, String sha1); // }
import org.slf4j.LoggerFactory; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.List; import org.eclipse.jgit.lib.Repository; import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.build.Status; import org.kercoin.magrit.core.build.StatusesService; import org.slf4j.Logger;
} @Override public void setInputStream(InputStream in) { stdin = new BufferedReader(new InputStreamReader(in)); super.setInputStream(in); } @Override public void run() { try { if ("-".equals(sha1)) { String line = null; while ((line = stdin.readLine()) != null) { if ("--".equals(line)) { break; } handle(line); } } else { handle(sha1); } callback.onExit(0); } catch (IOException e) { e.printStackTrace(); callback.onExit(1); } } private void handle(String sha1) throws IOException {
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/Status.java // public enum Status { // RUNNING('R'), // PENDING('P'), // ERROR('E'), // OK('O'), // INTERRUPTED('I'), // LOCAL('L'), // NEW('N'), // UNKNOWN('?'); // // private char code; // // private Status(char code) { this.code = code; } // // public char getCode() { // return code; // } // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/StatusesService.java // @ImplementedBy(StatusesServiceImpl.class) // public interface StatusesService { // List<Status> getStatus(Repository repository, String sha1); // } // Path: server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/GetStatusCommand.java import org.slf4j.LoggerFactory; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.List; import org.eclipse.jgit.lib.Repository; import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.build.Status; import org.kercoin.magrit.core.build.StatusesService; import org.slf4j.Logger; } @Override public void setInputStream(InputStream in) { stdin = new BufferedReader(new InputStreamReader(in)); super.setInputStream(in); } @Override public void run() { try { if ("-".equals(sha1)) { String line = null; while ((line = stdin.readLine()) != null) { if ("--".equals(line)) { break; } handle(line); } } else { handle(sha1); } callback.onExit(0); } catch (IOException e) { e.printStackTrace(); callback.onExit(1); } } private void handle(String sha1) throws IOException {
List<Status> statuses = buildStatusesService.getStatus(repo, sha1);
ptitfred/magrit
server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/MonitorCommand.java
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/Pair.java // public class Pair<T, U> { // private T t; // private U u; // // public Pair(T t, U u) { // super(); // this.t = t; // this.u = u; // } // // public T getT() { // return t; // } // // public U getU() { // return u; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + ((t == null) ? 0 : t.hashCode()); // result = prime * result + ((u == null) ? 0 : u.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // @SuppressWarnings("unchecked") // Pair<T, U> other = (Pair<T, U>) obj; // if (t == null) { // if (other.t != null) // return false; // } else if (!t.equals(other.t)) // return false; // if (u == null) { // if (other.u != null) // return false; // } else if (!u.equals(other.u)) // return false; // return true; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/BuildLifeCycleListener.java // public interface BuildLifeCycleListener { // // void buildScheduled(Repository repo, String sha1); // // void buildStarted(Repository repo, String sha1); // // void buildEnded(Repository repo, String sha1, Status status); // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/QueueService.java // @ImplementedBy(QueueServiceImpl.class) // public interface QueueService { // Future<BuildResult> enqueueBuild(UserIdentity committer, Repository repository, // String sha1, String command, boolean force) throws Exception; // // void addCallback(BuildLifeCycleListener callback); // // void removeCallback(BuildLifeCycleListener callback); // // Collection<Pair<Repository, String>> getScheduledTasks(); // Collection<Pair<Repository, String>> getCurrentTasks(); // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/Status.java // public enum Status { // RUNNING('R'), // PENDING('P'), // ERROR('E'), // OK('O'), // INTERRUPTED('I'), // LOCAL('L'), // NEW('N'), // UNKNOWN('?'); // // private char code; // // private Status(char code) { this.code = code; } // // public char getCode() { // return code; // } // }
import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; import java.util.Date; import org.eclipse.jgit.lib.Repository; import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.Pair; import org.kercoin.magrit.core.build.BuildLifeCycleListener; import org.kercoin.magrit.core.build.QueueService; import org.kercoin.magrit.core.build.Status;
/* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.sshd.commands; public class MonitorCommand extends AbstractCommand<MonitorCommand> implements BuildLifeCycleListener { @Singleton public static class MonitorCommandProvider implements CommandProvider<MonitorCommand>, org.kercoin.magrit.sshd.commands.AbstractCommand.EndCallback<MonitorCommand> {
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/Pair.java // public class Pair<T, U> { // private T t; // private U u; // // public Pair(T t, U u) { // super(); // this.t = t; // this.u = u; // } // // public T getT() { // return t; // } // // public U getU() { // return u; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + ((t == null) ? 0 : t.hashCode()); // result = prime * result + ((u == null) ? 0 : u.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // @SuppressWarnings("unchecked") // Pair<T, U> other = (Pair<T, U>) obj; // if (t == null) { // if (other.t != null) // return false; // } else if (!t.equals(other.t)) // return false; // if (u == null) { // if (other.u != null) // return false; // } else if (!u.equals(other.u)) // return false; // return true; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/BuildLifeCycleListener.java // public interface BuildLifeCycleListener { // // void buildScheduled(Repository repo, String sha1); // // void buildStarted(Repository repo, String sha1); // // void buildEnded(Repository repo, String sha1, Status status); // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/QueueService.java // @ImplementedBy(QueueServiceImpl.class) // public interface QueueService { // Future<BuildResult> enqueueBuild(UserIdentity committer, Repository repository, // String sha1, String command, boolean force) throws Exception; // // void addCallback(BuildLifeCycleListener callback); // // void removeCallback(BuildLifeCycleListener callback); // // Collection<Pair<Repository, String>> getScheduledTasks(); // Collection<Pair<Repository, String>> getCurrentTasks(); // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/Status.java // public enum Status { // RUNNING('R'), // PENDING('P'), // ERROR('E'), // OK('O'), // INTERRUPTED('I'), // LOCAL('L'), // NEW('N'), // UNKNOWN('?'); // // private char code; // // private Status(char code) { this.code = code; } // // public char getCode() { // return code; // } // } // Path: server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/MonitorCommand.java import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; import java.util.Date; import org.eclipse.jgit.lib.Repository; import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.Pair; import org.kercoin.magrit.core.build.BuildLifeCycleListener; import org.kercoin.magrit.core.build.QueueService; import org.kercoin.magrit.core.build.Status; /* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.sshd.commands; public class MonitorCommand extends AbstractCommand<MonitorCommand> implements BuildLifeCycleListener { @Singleton public static class MonitorCommandProvider implements CommandProvider<MonitorCommand>, org.kercoin.magrit.sshd.commands.AbstractCommand.EndCallback<MonitorCommand> {
private Context ctx;
ptitfred/magrit
server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/MonitorCommand.java
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/Pair.java // public class Pair<T, U> { // private T t; // private U u; // // public Pair(T t, U u) { // super(); // this.t = t; // this.u = u; // } // // public T getT() { // return t; // } // // public U getU() { // return u; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + ((t == null) ? 0 : t.hashCode()); // result = prime * result + ((u == null) ? 0 : u.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // @SuppressWarnings("unchecked") // Pair<T, U> other = (Pair<T, U>) obj; // if (t == null) { // if (other.t != null) // return false; // } else if (!t.equals(other.t)) // return false; // if (u == null) { // if (other.u != null) // return false; // } else if (!u.equals(other.u)) // return false; // return true; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/BuildLifeCycleListener.java // public interface BuildLifeCycleListener { // // void buildScheduled(Repository repo, String sha1); // // void buildStarted(Repository repo, String sha1); // // void buildEnded(Repository repo, String sha1, Status status); // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/QueueService.java // @ImplementedBy(QueueServiceImpl.class) // public interface QueueService { // Future<BuildResult> enqueueBuild(UserIdentity committer, Repository repository, // String sha1, String command, boolean force) throws Exception; // // void addCallback(BuildLifeCycleListener callback); // // void removeCallback(BuildLifeCycleListener callback); // // Collection<Pair<Repository, String>> getScheduledTasks(); // Collection<Pair<Repository, String>> getCurrentTasks(); // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/Status.java // public enum Status { // RUNNING('R'), // PENDING('P'), // ERROR('E'), // OK('O'), // INTERRUPTED('I'), // LOCAL('L'), // NEW('N'), // UNKNOWN('?'); // // private char code; // // private Status(char code) { this.code = code; } // // public char getCode() { // return code; // } // }
import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; import java.util.Date; import org.eclipse.jgit.lib.Repository; import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.Pair; import org.kercoin.magrit.core.build.BuildLifeCycleListener; import org.kercoin.magrit.core.build.QueueService; import org.kercoin.magrit.core.build.Status;
/* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.sshd.commands; public class MonitorCommand extends AbstractCommand<MonitorCommand> implements BuildLifeCycleListener { @Singleton public static class MonitorCommandProvider implements CommandProvider<MonitorCommand>, org.kercoin.magrit.sshd.commands.AbstractCommand.EndCallback<MonitorCommand> { private Context ctx;
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java // @Singleton // public class Context { // // private final Configuration configuration = new Configuration(); // // private Injector injector; // // private final GitUtils gitUtils; // // private final ExecutorService commandRunnerPool; // // public Context() { // gitUtils = null; // commandRunnerPool = null; // } // // public Context(GitUtils gitUtils) { // this(gitUtils, null); // } // // @Inject // public Context(GitUtils gitUtils, // @Named("commandRunnerPool") ExecutorService commandRunnerPool) { // this.gitUtils = gitUtils; // this.commandRunnerPool = commandRunnerPool; // } // // public Configuration configuration() { // return configuration; // } // // public Injector getInjector() { // return injector; // } // // public ExecutorService getCommandRunnerPool() { // return commandRunnerPool; // } // // public void setInjector(Injector injector) { // this.injector = injector; // } // // public GitUtils getGitUtils() { // return gitUtils; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/Pair.java // public class Pair<T, U> { // private T t; // private U u; // // public Pair(T t, U u) { // super(); // this.t = t; // this.u = u; // } // // public T getT() { // return t; // } // // public U getU() { // return u; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + ((t == null) ? 0 : t.hashCode()); // result = prime * result + ((u == null) ? 0 : u.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // @SuppressWarnings("unchecked") // Pair<T, U> other = (Pair<T, U>) obj; // if (t == null) { // if (other.t != null) // return false; // } else if (!t.equals(other.t)) // return false; // if (u == null) { // if (other.u != null) // return false; // } else if (!u.equals(other.u)) // return false; // return true; // } // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/BuildLifeCycleListener.java // public interface BuildLifeCycleListener { // // void buildScheduled(Repository repo, String sha1); // // void buildStarted(Repository repo, String sha1); // // void buildEnded(Repository repo, String sha1, Status status); // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/QueueService.java // @ImplementedBy(QueueServiceImpl.class) // public interface QueueService { // Future<BuildResult> enqueueBuild(UserIdentity committer, Repository repository, // String sha1, String command, boolean force) throws Exception; // // void addCallback(BuildLifeCycleListener callback); // // void removeCallback(BuildLifeCycleListener callback); // // Collection<Pair<Repository, String>> getScheduledTasks(); // Collection<Pair<Repository, String>> getCurrentTasks(); // // } // // Path: server/core/src/main/java/org/kercoin/magrit/core/build/Status.java // public enum Status { // RUNNING('R'), // PENDING('P'), // ERROR('E'), // OK('O'), // INTERRUPTED('I'), // LOCAL('L'), // NEW('N'), // UNKNOWN('?'); // // private char code; // // private Status(char code) { this.code = code; } // // public char getCode() { // return code; // } // } // Path: server/sshd/src/main/java/org/kercoin/magrit/sshd/commands/MonitorCommand.java import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; import java.util.Date; import org.eclipse.jgit.lib.Repository; import org.kercoin.magrit.core.Context; import org.kercoin.magrit.core.Pair; import org.kercoin.magrit.core.build.BuildLifeCycleListener; import org.kercoin.magrit.core.build.QueueService; import org.kercoin.magrit.core.build.Status; /* Copyright 2011-2012 Frederic Menou and others referred in AUTHORS file. This file is part of Magrit. Magrit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Magrit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Magrit. If not, see <http://www.gnu.org/licenses/>. */ package org.kercoin.magrit.sshd.commands; public class MonitorCommand extends AbstractCommand<MonitorCommand> implements BuildLifeCycleListener { @Singleton public static class MonitorCommandProvider implements CommandProvider<MonitorCommand>, org.kercoin.magrit.sshd.commands.AbstractCommand.EndCallback<MonitorCommand> { private Context ctx;
private QueueService buildQueueService;